pyoceans / pocean-core

🐍 + 🌊 A python framework for working with met-ocean data
https://pyoceans.github.io/pocean-core/
MIT License
22 stars 16 forks source link

Dealing with multidimensional time series variables #5

Closed rsignell-usgs closed 5 years ago

rsignell-usgs commented 7 years ago

Sometimes observational time series contain multidimensional variables, like a light sensor with various channels, represented like the variable light_measurements in the example below:

$ ncdump -h 20161012.phsen.nc
netcdf \20161012.phsen {
dimensions:
        feature_type_instance = 8 ;
        time = 24 ;
        light = 92 ;
        refnc = 16 ;
variables:
        char feature_type_instance(feature_type_instance) ;
                feature_type_instance:cf_role = "timeseries_id" ;
                feature_type_instance:long_name = "Identifier for each feature type instance" ;
        double latitude ;
                latitude:units = "degrees_north" ;
                latitude:standard_name = "latitude" ;
                latitude:long_name = "sensor latitude" ;
                latitude:axis = "Y" ;
                latitude:valid_min = 44. ;
                latitude:valid_max = 44. ;
        double longitude ;
                longitude:units = "degrees_east" ;
                longitude:standard_name = "longitude" ;
                longitude:long_name = "sensor longitude" ;
                longitude:axis = "X" ;
                longitude:valid_min = -124. ;
                longitude:valid_max = -124. ;
        int crs ;
                crs:long_name = "http://www.opengis.net/def/crs/EPSG/0/4326" ;
                crs:grid_mapping_name = "latitude_longitude" ;
                crs:epsg_code = "EPSG:4326" ;
                crs:semi_major_axis = 6378137. ;
                crs:inverse_flattening = 298.257223563 ;
        int platform ;
                platform:definition = "http://mmisw.org/ont/ioos/definition/stationID" ;
                platform:short_name = "Seawater pH from PHSEN" ;
                platform:long_name = "Measures the seawater pH from the Sunburst Sensors SAMI2-pH " ;
                platform:ioos_code = "ce02shsm" ;
        double time(time) ;
                time:units = "seconds since 1970-01-01T00:00:00Z" ;
                time:standard_name = "time" ;
                time:long_name = "time of measurement" ;
                time:calendar = "gregorian" ;
                time:axis = "T" ;
        double z ;
                z:_FillValue = -9999.9 ;
                z:valid_min = 7. ;
                z:valid_max = 7. ;
                z:grid_mapping = "crs" ;
                z:long_name = "z of the sensor relative to the water surface" ;
                z:standard_name = "depth" ;
                z:positive = "down" ;
                z:units = "m" ;
                z:axis = "Z" ;
       double pH(time) ;
                pH:_FillValue = -999999999. ;
                pH:coordinates = "time z latitude longitude" ;
                pH:units = "1" ;
                pH:long_name = "Seawater pH" ;
                pH:standard_name = "seawater_ph" ;
                pH:missing_value = -999999999. ;
                pH:grid_mapping = "crs" ;
                pH:platform = "platform" ;
                pH:ancillary_variables = "platform" ;
                pH:coverage_content_type = "physicalMeasurement" ;
        int light_measurements(time, light) ;
                light_measurements:units = "counts" ;
                light_measurements:long_name = "Light Measurements Array" ;
                light_measurements:standard_name = "light_measurements" ;
                light_measurements:coordinates = "time z longitude latitude" ;

// global attributes:
                :project = "Ocean Observatories Initiative" ;
                :comment = "Mooring ID: CE02SHSM-00004" ;
                :references = "http://oceanobservatories.org" ;
                :creator_name = "Christopher Wingard" ;
                :title = "Seawater pH from PHSEN" ;
                :creator_email = "cwingard@coas.oregonstate.edu" ;
                :creator_url = "http://oceanobservatories.org" ;
                :acknowledgement = "National Science Foundation" ;
                :institution = "Coastal and Global Scales Nodes, (CGSN)" ;
                :summary = "Measures the seawater pH from the Sunburst Sensors SAMI2-pH Instrument)." ;
                :Conventions = "CF-1.6,ACDD-1.3" ;
                :featureType = "timeSeries" ;
                :ncei_template_version = "NCEI_NetCDF_TimeSeries_Orthogonal_Template_v2.0" ;
}

This is actually not a CF-Compliant DSG featureType=timeSeries file as indicated, and these multi-dimensional variables must be split out and represented as a different featureType, such as featureType=grid.

kwilcox commented 5 years ago

This is actually not a CF-Compliant DSG

This is key, we aren't trying to support datasets like this. You should use xarray, or wait for CF 2.0 and put the light_measurement variable into another group!