-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadBarometerObs.m
51 lines (48 loc) · 1.78 KB
/
readBarometerObs.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function data = readBarometerObs(station,instrument,type,code,level,year,month)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function data = readBarometerObs(station,instrument,type,code,level,year,month)
%
% Reads barometer observations from SOCIB THREDDS server
%
% Input arguments:
% station: string station name (i.e. 'ciutadella')
% instrument: string instrument name ('scb','pib', 'ime'...)
% type: barometer = string baro
% code: string number 007, 004, ...
% level: string QC level, 'L1' recommended i guess
% year: string yyyy year
% month: string mm month
%
% Output:
% data: matlab struct data
%
% Author: Matjaz Licer - NIB MBS / SOCIB
%
% Date of creation: Apr-2016
% Last modification: 12-Apr-2016
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('Reading IN SITU Barometer Observations...')
base_string = 'http://thredds.socib.es/thredds/dodsC/mooring/barometer/';
station_string = ['station_' station];
% construct filename:
fname = [base_string station_string '-' instrument '_' type code '/' level '/' year ...
'/dep0001_station-' station '_' instrument '-' type code '_' level '_' year '-' month '.nc'];
% try to download:
try
data.dataExists=true;
data.URL=fname;
time = ncread(fname,'time');
t0 = datenum('1970-01-01 00:00:00','yyyy-mm-dd HH:MM:SS');
dates = t0 + time/86400.;
data.time = dates;
data.LAT = double(ncread(fname,'LAT'));
data.LON = double(ncread(fname,'LON'));
data.AIR_PRE = double(ncread(fname,'AIR_PRE'));
data.QC_AIR_PRE = double(ncread(fname,'QC_AIR_PRE'));
catch
data.dataExists=false;
disp('>>>> readBarometerObs: CATCH WARNING: the file ')
disp(fname)
disp('could not be read.')
end