NOAA-PMEL / Ferret

The Ferret program from NOAA/PMEL
https://ferret.pmel.noaa.gov/Ferret/
The Unlicense
55 stars 20 forks source link

bug writing multiple vars with one SAVE when scaled #1512

Open karlmsmith opened 7 years ago

karlmsmith commented 7 years ago

Reported by @AnsleyManke on 6 Mar 2015 19:47 UTC When variables from a dataset have scale_factor and/or add_offset attributes, we re-scale them on writing to an output file. We also write them using the data type of the variable in the source data set.

When multiple variables are written together, the scaling is not done correctly.

This was reported by Ned Cokelet


yes? use my_subset.nc
yes? sh dat
     currently SET data sets:
    1> ./my_subset.nc  (default)
 name     title                             I         J         K         L         M         N
 LONGITUDE
          longitude                        1:11      1:11      ...       ...       ...       ...
 LATITUDE latitude                         1:11      1:11      ...       ...       ...       ...
 MELT_ONSET_DAY_SEAICE_CONC_CDR
          Day of Snow Melt Onset Over Sea  1:11      1:11      ...       1:1       ...       ...
 QA_OF_SEAICE_CONC_CDR
          Passive Microwave Daily Norther  1:11      1:11      ...       1:1       ...       ...
 GODDARD_MERGED_SEAICE_CONC
          Goddard Edited Climate Data Rec  1:11      1:11      ...       1:1       ...       ...

yes? sh att QA_OF_SEAICE_CONC_CDR
     attributes for dataset: ./my_subset.nc
 QA_OF_SEAICE_CONC_CDR.missing_value = 0
 QA_OF_SEAICE_CONC_CDR._FillValue = 0
 QA_OF_SEAICE_CONC_CDR.long_name = Passive Microwave Daily Northern Hemisphere Sea Ice Concentration QC flags 
 QA_OF_SEAICE_CONC_CDR.history = From seaice_conc_daily_nh_f17_20080101_v02r00 
yes? sh att GODDARD_MERGED_SEAICE_CONC
     attributes for dataset: ./my_subset.nc
 GODDARD_MERGED_SEAICE_CONC._FillValue = -1
 GODDARD_MERGED_SEAICE_CONC.long_name = Goddard Edited Climate Data Record of Passive Microwave Daily Northern Hemisphere Sea Ice Concentration, Goddard Edited 
 GODDARD_MERGED_SEAICE_CONC.units = 1 
 GODDARD_MERGED_SEAICE_CONC.scale_factor = 0.01
 GODDARD_MERGED_SEAICE_CONC.history = From seaice_conc_daily_nh_f17_20080101_v02r00 

yes? save/file=new.nc/clobber
yes? save/file=new.nc/clobber QA_OF_SEAICE_CONC_CDR, GODDARD_MERGED_SEAICE_CONC
 LISTing to file new.nc
NetCDF: Numeric conversion not representable (OPeNDAP/netCDF Error code -60)
 data in variable QA_OF_SEAICE_CONC_CDR not representable in output type NC_BYTE

The error message stems from the fact that the re-scaling factors for the variable GODDARD_MERGED_SEAICE_CONC was erroneously applied to QA_OF_SEAICE_CONC_CDR, making its values too large to write as BYTE.

Migrated-From: http://dunkel.pmel.noaa.gov/trac/ferret/ticket/2240

karlmsmith commented 7 years ago

Attachment from @AnsleyManke on 6 Mar 2015 19:48 UTC the file with scaled and BYTE type variables my_subset.nc.zip