The conversion routines can be used for writing values. This can be
useful for data compression -- e.g. converting internal floats to
byte values in the file, or converting internal shorts to bytes. When
doing this with normalization (to rescale bytes to the slice maximum,
for example) it is important to write the slice maximum and minimum in
MIimagemax
and MIimagemin
before writing the slice.
The other concern is that MIvalid_range
or MIvalid_max
and MIvalid_min
be written properly (especially if the defaults
are not correct). When writing floating point values,
MIvalid_range
should be set to the full range of values in the
variable. In this case, the attribute does not have to be set
correctly before writing the variable, but if it exists, the values
should be reasonable (maximum greater than minimum and values not
likely to cause overflow). These will be set automatically if the
routine micreate_std_variable
is used with
NC_FILL
mode on (the default).