[Thread Prev][Thread Next][Index]

Re: [ferret_users] different add_offset/scale_factor for different step files



Hi Seon,

This is correctly handled by PyFerret. The the add_offset and scale_factors from each step file are applied as the data are read from the file. This is noted in the documentation about descriptor files

I have attached a tar file with some simple example files, vary_scale.des which uses stepfiles varyscale_1.nc and varyscale_2.nc.  Here is what happens:

! First open each stepfile.  The variable tt has the same data values in both, but different scale and offset attributes:

yes? use varyscale_1.nc

yes? show attributes tt
     attributes for dataset: ./varyscale_1.nc
 TT.missing_value = -1.E+34
 TT._FillValue = -1.E+34
 TT.long_name = 1 + 0*T[GT=DAYT]
 TT.scale_factor = -1
 TT.add_offset = 0.5
yes? list tt
             VARIABLE : 1 + 0*T[GT=DAYT]
             FILENAME : varyscale_1.nc
             SUBSET   : 10 points (TIME)
 01-JAN-1990 00 /  1: -0.500
 02-JAN-1990 00 /  2: -1.500
 03-JAN-1990 00 /  3: -2.500
 04-JAN-1990 00 /  4: -3.500
 05-JAN-1990 00 /  5: -4.500
 06-JAN-1990 00 /  6: -5.500
 07-JAN-1990 00 /  7: -6.500
 08-JAN-1990 00 /  8: -7.500
 09-JAN-1990 00 /  9: -8.500
 10-JAN-1990 00 / 10: -9.500

yes? use varyscale_2.nc
yes? show attributes tt
     attributes for dataset: ./varyscale_2.nc
 TT.missing_value = -1.E+34
 TT._FillValue = -1.E+34
 TT.long_name = 1 + 0*T[GT=DAYT]
 TT.scale_factor = 2
 TT.add_offset = -0.02
yes? list tt
             VARIABLE : 1 + 0*T[GT=DAYT]
             FILENAME : varyscale_2.nc
             SUBSET   : 10 points (TIME)
 11-JAN-1990 00 /  1:   1.98
 12-JAN-1990 00 /  2:   3.98
 13-JAN-1990 00 /  3:   5.98
 14-JAN-1990 00 /  4:   7.98
 15-JAN-1990 00 /  5:   9.98
 16-JAN-1990 00 /  6:  11.98
 17-JAN-1990 00 /  7:  13.98
 18-JAN-1990 00 /  8:  15.98
 19-JAN-1990 00 /  9:  17.98
 20-JAN-1990 00 / 10:  19.98

! Now open the descriptor file and read the data. The scaling is
! applied for each step file.


yes? cancel data/all

yes? use vary_scale.des
yes? list tt
             VARIABLE : 1 + 0*T[GT=DAYT]
             DATA SET : Model Output, Daily Averages
             FILENAME : vary_scale.des
             SUBSET   : 20 points (TIME)
 01-JAN-1990 00 /  1:  -0.50
 02-JAN-1990 00 /  2:  -1.50
 03-JAN-1990 00 /  3:  -2.50
 04-JAN-1990 00 /  4:  -3.50
 05-JAN-1990 00 /  5:  -4.50
 06-JAN-1990 00 /  6:  -5.50
 07-JAN-1990 00 /  7:  -6.50
 08-JAN-1990 00 /  8:  -7.50
 09-JAN-1990 00 /  9:  -8.50
 10-JAN-1990 00 / 10:  -9.50
 11-JAN-1990 00 / 11:   1.98
 12-JAN-1990 00 / 12:   3.98
 13-JAN-1990 00 / 13:   5.98
 14-JAN-1990 00 / 14:   7.98
 15-JAN-1990 00 / 15:   9.98
 16-JAN-1990 00 / 16:  11.98
 17-JAN-1990 00 / 17:  13.98
 18-JAN-1990 00 / 18:  15.98
 19-JAN-1990 00 / 19:  17.98
 20-JAN-1990 00 / 20:  19.98

When looking at the descriptor file, If you ask for the values of the add_offset and scale_factor attributes, the values for the first file are shown, but when loading data, the attribute values from each file are applied. 


On 8/25/2022 4:36 AM, Seon Tae Kim wrote:
Dear ferreters 

When I tried to use a descriptor file to aggregate the multiple netcdf files, 
I realized that the add_offset and scale_factors in the first step file are to all step files in a multi-file set of a descriptor file.

I can not find any solution to this problem in the ferret e-mail archives. 

Best, 

Seon

Attachment: vary_scale_des.tar
Description: Unix tar archive


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement