The "units" attribute of a variable measuring ocean wave period is in "seconds". This is not a datetime field, but xarray is automatically ingesting this variable as timedelta64. Since the units are not "seconds since...", I would have assumed that xarray should treat this as a normal float32 data array, but apparently not so. Is there a way for me to tell xarray to ingest the wave period variables as float32 or to convert them from timedelta64 back to their original values after ingest? I still want it to convert the "time" variable to timedelta64, so I don't want to turn off translation for the entire dataset, just for specific variables (Tper, sper, wper).
Here is the base OPeNDAP URL that I am working with from a wave forecast in our TDS server:
Suggestions? Thanks!
You can see the "ncdump"-like output using the OPeNDAP page here:
Or you can run ncdump on the OPeNDAP URL like so:
This results in the following:
netcdf WaveWatch_III_Hawaii_Regional_Wave_Model_best {
dimensions:
lat = 101 ;
lon = 141 ;
time = 54453 ;
z = 1 ;
variables:
float lon(lon) ;
lon:units = "degrees_east" ;
lon:long_name = "longitude" ;
lon:standard_name = "longitude" ;
lon:short_name = "lon" ;
lon:axis = "x" ;
lon:_CoordinateAxisType = "Lon" ;
float lat(lat) ;
lat:units = "degrees_north" ;
lat:long_name = "latitude" ;
lat:standard_name = "latitude" ;
lat:short_name = "lat" ;
lat:axis = "y" ;
lat:_CoordinateAxisType = "Lat" ;
float z(z) ;
z:units = "meters" ;
z:long_name = "depth below mean sea level" ;
z:standard_name = "depth" ;
z:short_name = "depth" ;
z:axis = "z" ;
z:_CoordinateAxisType = "Height" ;
double time(time) ;
time:long_name = "Forecast time for ForecastModelRunCollection" ;
time:standard_name = "time" ;
time:calendar = "proleptic_gregorian" ;
time:units = "hours since 2011-06-21 00:00:00.000 UTC" ;
time:missing_value = NaN ;
time:_CoordinateAxisType = "Time" ;
double time_run(time) ;
time_run:long_name = "run times for coordinate = time" ;
time_run:standard_name = "forecast_reference_time" ;
time_run:calendar = "proleptic_gregorian" ;
time_run:units = "hours since 2011-06-21 00:00:00.000 UTC" ;
time_run:missing_value = NaN ;
time_run:_CoordinateAxisType = "RunTime" ;
double time_offset(time) ;
time_offset:long_name = "offset hour from start of run for coordinate = time" ;
time_offset:standard_name = "forecast_period" ;
time_offset:calendar = "proleptic_gregorian" ;
time_offset:units = "hours since 2011-06-21T00:00:00Z" ;
time_offset:missing_value = NaN ;
float Thgt(time, z, lat, lon) ;
Thgt:units = "meters" ;
Thgt:long_name = "significant wave height" ;
Thgt:standard_name = "sea_surface_wave_significant_height" ;
Thgt:short_name = "Thgt" ;
Thgt:valid_range = 0.f, 60.f ;
Thgt:_FillValue = NaNf ;
Thgt:coordinates = "time_run time z lat lon " ;
float Tper(time, z, lat, lon) ;
Tper:units = "seconds" ;
Tper:long_name = "peak wave period" ;
Tper:standard_name = "sea_surface_wave_period_at_variance_spectral_density_maximum" ;
Tper:short_name = "Tper" ;
Tper:valid_range = 0.f, 60.f ;
Tper:_FillValue = NaNf ;
Tper:coordinates = "time_run time z lat lon " ;
float Tdir(time, z, lat, lon) ;
Tdir:units = "degrees" ;
Tdir:long_name = "peak wave direction" ;
Tdir:standard_name = "sea_surface_wave_from_direction" ;
Tdir:short_name = "Tdir" ;
Tdir:valid_range = 0.f, 360.f ;
Tdir:_FillValue = NaNf ;
Tdir:coordinates = "time_run time z lat lon " ;
float shgt(time, z, lat, lon) ;
shgt:units = "meters" ;
shgt:long_name = "swell significant wave height" ;
shgt:standard_name = "sea_surface_swell_wave_significant_height" ;
shgt:short_name = "shgt" ;
shgt:valid_range = 0.f, 60.f ;
shgt:_FillValue = NaNf ;
shgt:coordinates = "time_run time z lat lon " ;
float sper(time, z, lat, lon) ;
sper:units = "seconds" ;
sper:long_name = "swell peak wave period" ;
sper:standard_name = "sea_surface_swell_wave_period" ;
sper:short_name = "sper" ;
sper:valid_range = 0.f, 60.f ;
sper:_FillValue = NaNf ;
sper:coordinates = "time_run time z lat lon " ;
float sdir(time, z, lat, lon) ;
sdir:units = "degrees" ;
sdir:long_name = "swell peak wave direction" ;
sdir:standard_name = "sea_surface_swell_wave_from_direction" ;
sdir:short_name = "sdir" ;
sdir:valid_range = 0.f, 360.f ;
sdir:_FillValue = NaNf ;
sdir:coordinates = "time_run time z lat lon " ;
float whgt(time, z, lat, lon) ;
whgt:units = "meters" ;
whgt:long_name = "wind significant wave height" ;
whgt:standard_name = "sea_surface_wind_wave_significant_height" ;
whgt:short_name = "whgt" ;
whgt:valid_range = 0.f, 60.f ;
whgt:_FillValue = NaNf ;
whgt:coordinates = "time_run time z lat lon " ;
float wper(time, z, lat, lon) ;
wper:units = "seconds" ;
wper:long_name = "wind peak wave period" ;
wper:standard_name = "sea_surface_wind_wave_period" ;
wper:short_name = "wper" ;
wper:valid_range = 0.f, 60.f ;
wper:_FillValue = NaNf ;
wper:coordinates = "time_run time z lat lon " ;
float wdir(time, z, lat, lon) ;
wdir:units = "degrees" ;
wdir:long_name = "wind peak wave direction" ;
wdir:standard_name = "sea_surface_wind_wave_from_direction" ;
wdir:short_name = "wdir" ;
wdir:valid_range = 0.f, 360.f ;
wdir:_FillValue = NaNf ;
wdir:coordinates = "time_run time z lat lon " ;
// global attributes:
:title = "WaveWatch III (WW3) Hawaii Regional Wave Model" ;
:_CoordSysBuilder = "ucar.nc2.dataset.conv.CF1Convention" ;
:Conventions = "CF-1.6, ACDD-1.3" ;
:cdm_data_type = "Grid" ;
:featureType = "GRID" ;
:location = "Proto fmrc:WaveWatch_III_Hawaii_Regional_Wave_Model" ;
:id = "ww3_hawaii" ;
:naming_authority = "org.pacioos" ;
:Metadata_Link = "http://pacioos.org/metadata/ww3_hawaii.html" ;
:ISO_Topic_Categories = "oceans" ;
:summary = "Through a collaborative effort with NOAA/NCEP and NWS Honolulu, the University of Hawaii has implemented a global-scale WaveWatch III (WW3) model, which in turn provides boundary conditions for this Hawaii regional WW3: a 7-day model with a 5-day hourly forecast at approximately 5-km or 0.05-deg resolution. The primary purpose of this regional model is to capture island effects such as island shadowing, refraction, and accurate modeling of local wind waves. Hawaii WW3 is forced with winds from the University of Hawaii Meteorology Department\'s operational mesoscale model, which has a more suitable spatial resolution than the global scale wind field. The Hawaii regional WW3 also provides boundary conditions for nearshore island-scale models via Simulating WAves Nearshore (SWAN). While considerable effort has been made to implement all model components in a thorough, correct, and accurate manner, numerous sources of error are possible. As such, please use these data with the caution appropriate for any ocean related activity." ;
:keywords = "Earth Science Services > Models > Ocean General Circulation Models (OGCM)/Regional Ocean Models, Earth Science Services > Models > Weather Research/Forecast Models, Earth Science > Oceans > Ocean Waves > Significant Wave Height, Earth Science > Oceans > Ocean Waves > Wave Period, Earth Science > Oceans > Ocean Waves > Wave Speed/Direction" ;
:keywords_vocabulary = "GCMD Science Keywords" ;
:platform = "Models/Analyses > > Operational Models" ;
:platform_vocabulary = "GCMD Platform Keywords" ;
:instrument = "Not Applicable > Not Applicable" ;
:instrument_vocabulary = "GCMD Instrument Keywords" ;
:locations = "Continent > North America > United States Of America > Hawaii, Ocean > Pacific Ocean > Central Pacific Ocean > Hawaiian Islands" ;
:locations_vocabulary = "GCMD Location Keywords" ;
:standard_name_vocabulary = "CF Standard Name Table v39" ;
:comment = "Model runs produced by Dr. Kwok Fai Cheung ([email protected])." ;
:geospatial_lat_min = 18. ;
:geospatial_lat_max = 23. ;
:geospatial_lon_min = 199. ;
:geospatial_lon_max = 206. ;
:geospatial_vertical_min = 0. ;
:geospatial_vertical_max = 0. ;
:geospatial_bounds = "POLYGON ((18 -161.0, 23 -161.0, 23 -154.0, 18 -154.0, 18 -161.0))" ;
:geospatial_bounds_crs = "EPSG:4326" ;
:time_coverage_start = "2011-06-21T21:00:00Z" ;
:geospatial_lat_units = "degrees_north" ;
:geospatial_lat_resolution = 0.05 ;
:geospatial_lon_units = "degrees_east" ;
:geospatial_lon_resolution = 0.05 ;
:geospatial_vertical_units = "meters" ;
:geospatial_vertical_positive = "up" ;
:geospatial_vertical_resolution = 0. ;
:time_coverage_resolution = "PT1H" ;
:creator_email = "[email protected]" ;
:creator_name = "Kwok Fai Cheung" ;
:creator_type = "person" ;
:creator_url = "http://www.ore.hawaii.edu/OE/cheung_research.htm" ;
:creator_institution = "University of Hawaii" ;
:date_created = "2011-06-22" ;
:date_issued = "2011-06-22" ;
:date_modified = "2014-06-23" ;
:date_metadata_modified = "2017-01-30" ;
:institution = "University of Hawaii" ;
:project = "Pacific Islands Ocean Observing System (PacIOOS)" ;
:program = "Pacific Islands Ocean Observing System (PacIOOS)" ;
:contributor_name = "Jim Potemra" ;
:contributor_role = "distributor" ;
:publisher_email = "[email protected]" ;
:publisher_name = "Pacific Islands Ocean Observing System (PacIOOS)" ;
:publisher_url = "http://pacioos.org" ;
:publisher_institution = "University of Hawaii" ;
:publisher_type = "group" ;
:license = "The data may be used and redistributed for free but is not intended for legal use, since it may contain inaccuracies. Neither the data Contributor, University of Hawaii, PacIOOS, NOAA, State of Hawaii nor the United States Government, nor any of their employees or contractors, makes any warranty, express or implied, including warranties of merchantability and fitness for a particular purpose, or assumes any legal liability for the accuracy, completeness, or usefulness, of this information." ;
:acknowledgement = "The Pacific Islands Ocean Observing System (PacIOOS) is funded through the National Oceanic and Atmospheric Administration (NOAA) as a Regional Association within the U.S. Integrated Ocean Observing System (IOOS). PacIOOS is coordinated by the University of Hawaii School of Ocean and Earth Science and Technology (SOEST)." ;
:source = "WaveWatch III (WW3) numerical wave model" ;
:references = "http://pacioos.org/waves/model-hawaii/, http://polar.ncep.noaa.gov/waves/wavewatch/" ;
:history = "FMRC Best Dataset" ;
Would you mind showing the output of
ncdump -h file.nc
if possible?I did a quick check of reading in some ocean wave period data of a WaveWatchIII experiment I ran and everything looked fine.
...
The only thing I remember doing differently is I changed L2374 in WW3v4.18/ftn/ww3_ounf.ftn from
Jday0=julday(1,1,1990)
toJday0=julday(1,1,1850)
and similar lines in WW3v4.18/ftn/ww3_ounp.ftn as i'm doing runs before 1990 and didn't want to get weird negative times.I also did a quick check on reading in some (climate model) data using OPeNDAP:
S: start date; M: ensemble member; X: lon; Y: lat; L: lead-time
In my case I should combine S and L to make a T (time) coordinate. Then append the T coord to the DataArray and drop the S and L coordinate. Unfortunately, I don't know how to do this part beyond this: