NCL Website header
NCL Home > Documentation > Functions > Type converters

byte2flt_hdf

Converts values of type byte to values of type float using the "scale" and "offset" attributes (if present).

Prototype

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  ; This library is automatically loaded
                                                             ; from NCL V6.2.0 onward.
                                                             ; No need for user to explicitly load.

	function byte2flt_hdf (
		x  : byte   
	)

	return_val [dimsizes(x)] :  float

Arguments

x

An array of type byte of any dimensionality.

Return value

The results are returned in a float array of the same type dimensionality as x. Metadata is preserved.

Description

This function converts byte data to float using the "scale" and "offset" attributes (if present), and preserves metadata. It assumes that the "offset" is subtracted from the "scale" prior to application to the data.

             x_float = scale*(x_byte - offset)

Other attributes similar to "scale" and "offset" will be recognized:

offset:
"add_offset", "OFFSET", "Offset", "_offset", "Intercept", "intercept"
scale:
"SCALE", "Scale", "_scale", "scale_factor", "Scale_factor", "Slope" , "slope"
Note1: This function is slightly different than the built-in set of conversion functions (like floattointeger and shorttobyte), because it requires loading the "contributed.ncl" script and it preserves metadata. It has a slightly different naming style than the built-in functions, just to set it apart from these other functions.

Note2: A separate function, byte2flt, must be used if the following approach is to be applied:

             x_float = x_byte*scale + offset

See Also

short2flt, short2flt_hdf, dble2flt, flt2dble, byte2flt, typeof, getfilevartypes