
NCL Home >
Documentation >
Functions >
Type converters
int2flt
Converts values of type integer to values of type float and preserves metadata.
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 int2flt ( x : integer ) return_val [dimsizes(x)] : float
Arguments
xAn array of any dimensionality and of type integer.
Return value
An array of the same size as x and of type float.
Description
This function converts values of type integer to values of type float and preserves metadata.
Note: 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.
See Also
Examples
Example 1
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" begin i = ispan(1,10,1) i@long_name = "sample" ; attribute i!0 = "foo" ; name dimension i&foo = ispan (35,350,35) ; create bogus coordinate array iFlt = int2flt( i ) print( iFlt ) endThe returned variable will be of type float and will retain all meta data.
Variable: iFlt Type: float Total Size: 40 bytes 10 values Number of Dimensions: 1 Dimensions and sizes: [foo | 10] <== retains dimension name Coordinates: foo: [35..350] <== retains coordinate information Number Of Attributes: 1 long_name : sample (0) 1 (1) 2 (2) 3 (3) 4 (4) 5 (5) 6 (6) 7 (7) 8 (8) 9 (9) 10