You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By packing I mean taking a 32-bit or 64-bit float array, calculating a scale and offset, and storing values as short ints. In this way a 32 or 64 bit data type can be stored in 16 bits.
Of course people have been doing this for a long time, but we have no official way to do this in the netCDF library. I suggest we add one.
So lets say I can do:
/* Define a short var. */
nc_def_var(ncid, "data", NDIM3, dimid, NC_SHORT, &varid)
/* Tell library this var is a double, packed to a short, using offset and scale factor. */
nc_def_var_packing(ncid, varid, NC_DOUBLE, offset, scale_facror)
That defines a var that is a double, stored as a short. When I call nc_put_vara_double() for this var, it automatically packs the data and stores the shorts. When I call nc_get_vara_double(), it unpacks the data. (For calls to other types, it is treated as a double, not a short.)
Then we define some attribute names to store the scale and offset.
Easy-peasy, lemon squeezy, as the kids used to say. ;-)
By packing I mean taking a 32-bit or 64-bit float array, calculating a scale and offset, and storing values as short ints. In this way a 32 or 64 bit data type can be stored in 16 bits.
Of course people have been doing this for a long time, but we have no official way to do this in the netCDF library. I suggest we add one.
So lets say I can do:
That defines a var that is a double, stored as a short. When I call nc_put_vara_double() for this var, it automatically packs the data and stores the shorts. When I call nc_get_vara_double(), it unpacks the data. (For calls to other types, it is treated as a double, not a short.)
Then we define some attribute names to store the scale and offset.
Easy-peasy, lemon squeezy, as the kids used to say. ;-)
This is part of #1545
The text was updated successfully, but these errors were encountered: