swb2 icon indicating copy to clipboard operation
swb2 copied to clipboard

Missing data type in netcdf_support

Open smwesten-usgs opened this issue 8 months ago • 0 comments

Certain netCDF files found in the wild, perhaps written/munged by the Python xarray package, end up with time being encoded as a 64-bit integer. Not sure what the use case is for a 64-bit integer time value, but there you have it. SWB currently handles time encoded as short, int (int32), float (32-bit real), and double (64-bit real) values.

A recent encounter with CONUS404 data processed with xarray resulted in the following CDL:

netcdf ilrb_CONUS404_T2MIN_20200101_to_20200131__compressed { dimensions: time = 31 ; x = 487 ; y = 516 ; variables: int64 time(time) ; string time:units = "days since 1979-10-01" ; string time:calendar = "proleptic_gregorian" ; double x(x) ; x:_FillValue = NaN ; string x:_CoordinateAxisType = "GeoX" ; string x:long_name = "x coordinate of projection" ; x:resolution = 1000. ; string x:standard_name = "projection_x_coordinate" ; string x:units = "metre" ; string x:axis = "X" ; double y(y) ; y:_FillValue = NaN ; string y:_CoordinateAxisType = "GeoY" ; string y:long_name = "y coordinate of projection" ; y:resolution = 1000. ; string y:standard_name = "projection_y_coordinate" ; string y:units = "metre" ; string y:axis = "Y" ; int crs ; string crs:crs_wkt = "PROJCS[\"unknown\",GEOGCS[\"unknown\",DATUM[\"unknown\",SPHEROID[\"unknown\",6370000,0]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Lambert_Conformal_Conic_2SP\"],PARAMETER[\"latitude_of_origin\",40],PARAMETER[\"central_meridian\",-97],PARAMETER[\"standard_parallel_1\",30],PARAMETER[\"standard_parallel_2\",60],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]" ; crs:semi_major_axis = 6370000. ; crs:semi_minor_axis = 6370000. ; crs:inverse_flattening = 0. ; string crs:reference_ellipsoid_name = "unknown" ; crs:longitude_of_prime_meridian = 0. ; string crs:prime_meridian_name = "Greenwich" ; string crs:geographic_crs_name = "unknown" ; string crs:horizontal_datum_name = "unknown" ; string crs:projected_crs_name = "unknown" ; string crs:grid_mapping_name = "lambert_conformal_conic" ; crs:standard_parallel = 30., 60. ; crs:latitude_of_projection_origin = 40. ; crs:longitude_of_central_meridian = -97. ; crs:false_easting = 0. ; crs:false_northing = 0. ; string crs:spatial_ref = "PROJCS[\"unknown\",GEOGCS[\"unknown\",DATUM[\"unknown\",SPHEROID[\"unknown\",6370000,0]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Lambert_Conformal_Conic_2SP\"],PARAMETER[\"latitude_of_origin\",40],PARAMETER[\"central_meridian\",-97],PARAMETER[\"standard_parallel_1\",30],PARAMETER[\"standard_parallel_2\",60],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]" ; double T2MIN(time, y, x) ; T2MIN:_FillValue = NaN ; string T2MIN:cell_methods = "time: point" ; string T2MIN:grid_mapping = "crs" ; string T2MIN:long_name = "Daily minimum temperature at 2 meters" ; string T2MIN:standard_name = "air_temperature" ; string T2MIN:units = "K" ; string T2MIN:coordinates = "x y" ; }

Running SWB with this file results in a crash at about line 2892 owing to the fact that there is no code to handle a int64 variable in this manner.

smwesten-usgs avatar Jun 06 '24 21:06 smwesten-usgs