% netcdf_create -- create global attributes, dimensions, coordinate % and data variables % use of data_type 'met' or 'water' to determine what is saved in file since % separate files are created for SABSOON in-water and met packages. % set in calling routine % data_type %% GLOBALS % static info from nc_this or hard coded here nc.title = ['NCCOOS data for (' info.platform_name ') ' info.location_name]; nc.institution = 'Unversity of North Carolina at Chapel Hill (UNC-CH)'; nc.institution_url = 'http://nccoos.unc.edu'; nc.institution_dods_url = 'http://nccoos.unc.edu'; nc.metadata_url = 'TDB'; nc.references = 'http://nccoos.unc.edu'; nc.contact = 'Sara Haines (haines@email.unc.edu)'; nc.source = 'fixed-platform (tower) observation'; nc.history = ''; nc.comment = 'processed with MATLAB from monthly netCDF'; % conventions nc.Conventions = 'CF-1.0'; nc.format = 'SEA-COOS RT'; nc.seacoos_rt_version = '2.0'; % platform codes nc.platform_code = info.platform_name; nc.format_category_code = 'fixed-point'; nc.institution_code = 'nccoos'; % institution specific nc.project = 'North Carolina Coastal Ocean Observing System (NCCOOS)'; nc.project_url = 'http://nccoos.unc.edu'; % package info if strcmp(data_type, 'met') nc.data_type = 'met'; nc.instrument_code = 'met'; elseif strcmp(data_type, 'water') nc.data_type = 'CTD'; nc.instrument_code = 'CTD'; end nc.package_code = info.package_name; % timeframe of data nc.start_date = [datestr(dn(1), 'yyyy-mm-dd HH:MM:SS') ' UTC']; nc.end_date = [datestr(dn(end), 'yyyy-mm-dd HH:MM:SS') ' UTC']; nc.release_date = [datestr(info.current_time_dn, 'yyyy-mm-dd HH:MM:SS') ' UTC']; nc.creation_date = [datestr(info.current_time_dn, 'yyyy-mm-dd HH:MM:SS') ' UTC']; nc.modification_date = [datestr(info.current_time_dn, 'yyyy-mm-dd HH:MM:SS') ' UTC']; nc.process_level = 'raw data'; nc.FillValue_ = ncdouble(-99999); % %% DIMENSIONS nc('time') = length(dn); nc('lat') = 1; nc('lon') = 1; nc('z') = 2; 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 = 'seconds since 2025-1-1 00:00:00'; 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 2025-1-1 00:00:00'; 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'} = ncdouble('lat'); nc{'lat'}.long_name = 'Latitude'; 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'} = ncdouble('lon'); nc{'lon'}.long_name = 'Longitude'; nc{'lon'}.short_name = 'longitude'; nc{'lon'}.standard_name = 'longitude'; nc{'lon'}.units = 'degrees_east'; nc{'lon'}.valid_range = ncdouble([-180 180]); nc{'lon'}.axis = 'X'; nc{'z'} = ncdouble('z'); nc{'z'}.long_name = 'Height'; nc{'z'}.short_name = 'height'; nc{'z'}.standard_name = 'height'; nc{'z'}.units = 'm'; nc{'z'}.positive = 'up'; nc{'z'}.reference = 'zero at sea-surface'; 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'}(:) = [info.baro_ht info.wind_ht]; %% VARIABLES (data) if strcmp(data_type, 'met') nc{'wspd'} = ncdouble('time'); nc{'wspd'}.long_name = 'Wind Speed'; nc{'wspd'}.standard_name = 'wind_speed'; nc{'wspd'}.units = 'm s-1'; nc{'wspd'}.z = info.wind_ht; nc{'wspd'}.can_be_normalized = 'yes'; nc{'wspd'}(:) = awspd; 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 = info.wind_ht; nc{'wdir'}.can_be_normalized = 'yes'; nc{'wdir'}(:) = awdir; 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 = info.wind_ht; nc{'eastward_wind'}.can_be_normalized = 'yes'; nc{'eastward_wind'}(:) = WVE; 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 = info.wind_ht; nc{'northward_wind'}.can_be_normalized = 'yes'; nc{'northward_wind'}(:) = WVN; 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 = info.wind_ht; nc{'wind_gust'}.can_be_normalized = 'yes'; nc{'wind_gust'}(:) = wgust; nc{'atemp'} = ncdouble('time'); nc{'atemp'}.long_name = 'Air Temperature'; nc{'atemp'}.standard_name = 'air_temperature'; nc{'atemp'}.units = 'degrees Celsius'; nc{'atemp'}.z = info.atemp_ht; nc{'atemp'}(:) = atemp; nc{'dew_temp'} = ncdouble('time'); nc{'dew_temp'}.long_name = 'Dew Temperature'; nc{'dew_temp'}.standard_name = 'dew_temperature'; nc{'dew_temp'}.units = 'degrees Celsius'; nc{'dew_temp'}.z = info.atemp_ht; nc{'dew_temp'}(:) = adewp; nc{'air_pressure'} = ncdouble('time'); nc{'air_pressure'}.long_name = 'Air Pressure at Barometer Height'; nc{'air_pressure'}.standard_name = 'air_pressure'; nc{'air_pressure'}.units = 'hPa'; nc{'air_pressure'}.z = info.baro_ht; nc{'air_pressure'}(:) = abaro; % nc{'air_pressure_at_sealevel'} = ncdouble('time'); % nc{'air_pressure_at_sealevel'}.long_name = 'Air Pressure at Sealevel'; % nc{'air_pressure_at_sealevel'}.standard_name = 'air_pressure_at_sealevel'; % nc{'air_pressure_at_sealevel'}.units = 'hPa'; % nc{'air_pressure_at_sealevel'}.z = 0; % nc{'air_pressure_at_sealevel'}.z_units = 'm'; % nc{'air_pressure_at_sealevel'}(:) = abaro_sealevel; elseif strcmp(data_type, 'water') nc{'wtemp'} = ncdouble('time'); nc{'wtemp'}.long_name = 'Water Temperature'; nc{'wtemp'}.standard_name = 'water_temperature'; nc{'wtemp'}.units = 'degrees Celsius'; nc{'wtemp'}(:) = wtemp; end %