% netcdf_create -- create global attributes, dimensions, coordinate % and data variables %% GLOBALS % static info from nc_this or hard coded here nc.title = ['NOS Data for (' info.platform_name ') ' info.location_name]; nc.institution = 'National Ocean Service (NOS)'; nc.institution_url = 'http://nos.noaa.gov'; nc.institution_dods_url = 'http://nccoos.unc.edu'; nc.metadata_url = 'TDB'; nc.references = 'http://nos.noaa.gov/'; nc.contact = 'http://nos.noaa.gov/'; nc.source = 'coastal observation'; nc.history = 'processed data from NOS from tidesonline stations'; nc.comment = 'Wind obs parsed using perl. Not all fields included.'; % conventions nc.Conventions = 'CF-1.0'; nc.format = 'SEA-COOS RT'; nc.seacoos_rt_version = '2.0'; % platform info nc.platform_code = info.platform_name; nc.format_category_code = 'fixed-point'; nc.institution_code = 'nos'; % package info % nc.data_type = 'surface meteorlogical'; nc.data_type = 'met'; nc.instrument_code = 'met'; nc.package_code = info.package_name; % timeframe of data nc.start_date = datestr(dn(1), 'yyyy-mm-dd HH:MM:SS'); nc.end_date = datestr(dn(end), 'yyyy-mm-dd HH:MM:SS'); nc.release_date = datestr(info.current_time_dn, 'yyyy-mm-dd HH:MM:SS'); nc.creation_date = datestr(info.current_time_dn, 'yyyy-mm-dd HH:MM:SS'); nc.modification_date = datestr(info.current_time_dn, 'yyyy-mm-dd HH:MM:SS'); nc.process_level = 'processed data'; nc.FillValue_ = ncdouble(-9999); %% DIMENSIONS nc('time') = length(dn); nc('lat') = 1; nc('lon') = 1; nc('z') = 3; nc('ndate') = 19; %% VARIABLES (coordinate) nc{'time'} = nclong('time'); nc{'time'}.short_name = 'time'; nc{'time'}.long_name = 'time'; nc{'time'}.standard_name = 'time'; nc{'time'}.units = 'sec since 1970-1-1 00:00:00 -0'; nc{'time'}.axis = 'T'; nc{'source_time'} = ncdouble('time'); nc{'source_time'}.short_name = 'source_time'; nc{'source_time'}.long_name = 'Data Provider Time'; nc{'source_time'}.units = 'days since 0000-1-1 00:00:00 -0'; nc{'source_time'}.calendar = 'none'; nc{'date_time_string'} = ncchar('time', 'ndate'); nc{'date_time_string'}.units = 'string YYYY-MM-DD hh:mm:ss'; nc{'date_time_string'}.c_format = '%4d-%2d-%2d %2d:%2d:%2d'; nc{'lat'} = ncfloat('lat'); nc{'lat'}.long_name = 'latitude in decimal degrees'; nc{'lat'}.short_name = 'latitude'; nc{'lat'}.standard_name = 'latitude'; nc{'lat'}.reference = 'geographic coordinates'; nc{'lat'}.units = 'degrees_north'; nc{'lat'}.valid_range = [-90 90]; nc{'lat'}.axis = 'Y'; nc{'lon'} = ncfloat('lon'); nc{'lon'}.long_name = 'longitude in decimal degrees'; nc{'lon'}.short_name = 'longitude'; nc{'lon'}.standard_name = 'longitude'; nc{'lon'}.units = 'degrees_east'; nc{'lon'}.reference = 'geographical coordinates'; nc{'lon'}.valid_range = ncdouble([-180 180]); nc{'lon'}.axis = 'X'; nc{'lon'} = ncfloat('lon'); nc{'lon'}.long_name = 'longitude in decimal degrees'; nc{'lon'}.short_name = 'longitude'; nc{'lon'}.standard_name = 'longitude'; nc{'lon'}.units = 'degrees_east'; nc{'lon'}.reference = 'geographical coordinates'; nc{'lon'}.valid_range = ncdouble([-180 180]); nc{'lon'}.axis = 'X'; nc{'z'} = ncfloat('z'); nc{'z'}.long_name = 'Height'; nc{'z'}.short_name = 'z'; nc{'z'}.standard_name = 'height'; nc{'z'}.units = 'm'; nc{'z'}.positive = 'up'; nc{'z'}.reference = 'zero is sea-level'; nc{'z'}.axis = 'Z'; nc{'time'}(:) = seacoos_time_1970; nc{'source_time'}(:) = dn; nc{'date_time_string'}(:) = date_time_string; nc{'lat'}(:) = info.location_lat; nc{'lon'}(:) = info.location_lon; nc{'z'}(:) = [10 0 -2.5]; %% VARIABLES (data) if have_wind nc{'wspd'} = ncfloat('time'); nc{'wspd'}.long_name = 'wind speed'; nc{'wspd'}.standard_name = 'wind_speed'; nc{'wspd'}.units = 'm s-1'; nc{'wspd'}.z = 10; nc{'wspd'}(:) = wi_spd; nc{'wdir'} = ncdouble('time'); nc{'wdir'}.long_name = 'wind direction from'; nc{'wdir'}.standard_name = 'wind_from_direction'; nc{'wdir'}.units = 'degrees'; nc{'wdir'}.reference = 'clockwise from true north'; nc{'wdir'}.valid_range = [0 360]; nc{'wdir'}.z = 10; nc{'wdir'}(:) = wi_dir; nc{'eastward_wind'} = ncdouble('time'); nc{'eastward_wind'}.long_name = 'East/West Component of Wind'; nc{'eastward_wind'}.standard_name = 'eastward_wind'; nc{'eastward_wind'}.units = 'm s-1'; nc{'eastward_wind'}.z = 10; nc{'eastward_wind'}(:) = wi_u; nc{'northward_wind'} = ncdouble('time'); nc{'northward_wind'}.long_name = 'North/South Component of Wind'; nc{'northward_wind'}.standard_name = 'northward_wind'; nc{'northward_wind'}.units = 'm s-1'; nc{'northward_wind'}.z = 10; nc{'northward_wind'}(:) = wi_v; nc{'wind_gust'} = ncdouble('time'); nc{'wind_gust'}.long_name = 'Wind Gust'; nc{'wind_gust'}.standard_name = 'wind_gust'; nc{'wind_gust'}.units = 'm s-1'; nc{'wind_gust'}.z = 10; nc{'wind_gust'}(:) = wi_gst; nc{'press'} = ncdouble('time'); nc{'press'}.long_name = 'Air Pressure'; nc{'press'}.standard_name = 'air_pressure'; nc{'press'}.units = 'hPa'; nc{'press'}.z = 10; nc{'press'}(:) = baro; nc{'atemp'} = ncdouble('time'); nc{'atemp'}.long_name = 'Air Temperature'; nc{'atemp'}.standard_name = 'air_temperature'; nc{'atemp'}.units = 'degrees Celsius'; nc{'atemp'}(:) = atemp; end if have_sst nc{'sst'} = ncdouble('time'); nc{'sst'}.long_name = 'Water Temperature'; nc{'sst'}.standard_name = 'sea_surface_temperature'; nc{'sst'}.units = 'degree Celsius'; nc{'sst'}.z = -2.5; nc{'sst'}(:) = wtemp; end if have_wl nc{'wl'} = ncdouble('time'); nc{'wl'}.long_name = 'Water Level'; % % NEED SEACOOS or CF standard name nc{'wl'}.standard_name = 'water_level'; nc{'wl'}.units = 'm'; nc{'wl'}.reference = 'MLLW'; for k=1:length(info.datum) datum_str = char(info.datum(k)); eval(['nc{''wl''}.' datum_str ';']) end nc{'wl'}.z = 0; nc{'wl'}(:) = obs_wl; end