Unidata / netcdf-c

Official GitHub repository for netCDF-C libraries and utilities.
BSD 3-Clause "New" or "Revised" License
515 stars 262 forks source link

Potential error of data type between opendap access and fileserver access #175

Open lbesnard opened 8 years ago

lbesnard commented 8 years ago

G'Day

I may have found an error running a CF compliance checker (from IOOS) on a gridded file. I noticed that some byte types are "modified" to short if the netcdf file is being accessed via opendap rather than a filesystem/fileserver.

See this little bash script which shows the problem for the same file being accessed by the two different protocols : https://gist.github.com/lbesnard/3444799f58e7d75d18a4/revisions

Follows is the vimdiff output of the given script above. See line 106 difference ( -127s vs -127b) as well as line 16 :

   1 netcdf modified-20121101032000-ABOM-L3S_GHRSST-SSTskin-AVHRR_D-1d_day-v02.0-fv02.0 {                             |    1 netcdf tmp {                                                                                                    
    2 dimensions:                                                                                                      |    2 dimensions:
    3   lat = 4500 ;                                                                                                   |      ----------------------------------------------------------------------------------------------------------------
    4   lon = 6000 ;                                                                                                   |    3   lon = 6000 ;
      -----------------------------------------------------------------------------------------------------------------|    4   lat = 4500 ;                                                                                                  
    5   time = 1 ;                                                                                                     |    5   time = 1 ;
    6 variables:                                                                                                       |    6 variables:
    7   float lat(lat) ;                                                                                               |    7   float lat(lat) ;
    8     lat:_FillValue = 9.96921e+36f ;                                                                              |    8     lat:_FillValue = 9.96921e+36f ;
    9     lat:long_name = "latitude" ;                                                                                 |    9     lat:long_name = "latitude" ;
   10     lat:units = "degrees_north" ;                                                                                |   10     lat:units = "degrees_north" ;
   11     lat:valid_min = -90.f ;                                                                                      |   11     lat:valid_min = -90.f ;
   12     lat:valid_max = 90.f ;                                                                                       |   12     lat:valid_max = 90.f ;
   13     lat:axis = "Y" ;                                                                                             |   13     lat:axis = "Y" ;
   14     lat:comment = "Latitudes for locating data" ;                                                                |   14     lat:comment = "Latitudes for locating data" ;
   15     lat:standard_name = "latitude" ;                                                                             |   15     lat:standard_name = "latitude" ;
   16     lat:_ChunkSize = 4500 ;                                                                                      |      ----------------------------------------------------------------------------------------------------------------
   17   float lon(lon) ;                                                                                               |   16   float lon(lon) ;
..........

 97   byte wind_speed_dtime_from_sst(time, lat, lon) ;                                                               |   89   byte wind_speed_dtime_from_sst(time, lat, lon) ;                                                              
   98     wind_speed_dtime_from_sst:_FillValue = -128b ;                                                               |   90     wind_speed_dtime_from_sst:_FillValue = -128b ;                                                              
   99     wind_speed_dtime_from_sst:long_name = "time difference of wind speed measurement from sst measurement" ;     |   91     wind_speed_dtime_from_sst:long_name = "time difference of wind speed measurement from sst measurement" ;    
  100     wind_speed_dtime_from_sst:units = "hour" ;                                                                   |   92     wind_speed_dtime_from_sst:units = "hour" ;                                                                  
  101     wind_speed_dtime_from_sst:coordinates = "time lat lon" ;                                                     |   93     wind_speed_dtime_from_sst:coordinates = "time lat lon" ;                                                    
  102     wind_speed_dtime_from_sst:comment = "The hours between the wind speed measurement and the SST observation" ; |   94     wind_speed_dtime_from_sst:comment = "The hours between the wind speed measurement and the SST observation" ;
  103     wind_speed_dtime_from_sst:source = "ACCESSG-ABOM-Forecast-WSP" ;                                             |   95     wind_speed_dtime_from_sst:source = "ACCESSG-ABOM-Forecast-WSP" ;                                            
  104     wind_speed_dtime_from_sst:add_offset = -0.15251281298697 ;                                                   |   96     wind_speed_dtime_from_sst:add_offset = -0.15251281298697 ;                                                  
  105     wind_speed_dtime_from_sst:scale_factor = 0.0219329754148312 ;                                                |   97     wind_speed_dtime_from_sst:scale_factor = 0.0219329754148312 ;                                               
  106     wind_speed_dtime_from_sst:valid_min = -127s ;                                                                |   98     wind_speed_dtime_from_sst:valid_min = -127b ;                                                               
  107     wind_speed_dtime_from_sst:valid_max = 127b ;                                                                 |   99     wind_speed_dtime_from_sst:valid_max = 127b ;                                                                
  108     wind_speed_dtime_from_sst:_ChunkSize = 1, 2250, 3000 ;                                                       |      ----------------------------------------------------------------------------------------------------------------
  109   byte sea_ice_fraction(time, lat, lon) ;                                                                        |  100   byte sea_ice_fraction(time, lat, lon) ;                  

I also tried doing a similar thing using the netCDF4 python package, exactly the same thing.

Cheers

WardF commented 8 years ago

Thanks for the bug report on this; we will look into it and follow up as soon as we can (I've been traveling for a conference all week). As our resident DAP developer/expert, I wonder if @dmh has any insight into this.

DennisHeimbigner commented 8 years ago

I ran your test, and the results were identical using the latest netcdf-c on github.