NCL Home > Documentation > Functions

Type converters

These functions convert between various NCL data types. The bulk of the functions convert between bytes, shorts, integers, floats, longs, doubles, characters, and strings in those cases where NCL does not provide automatic coercion. See the section on coercion of types for details on NCL's automatic type conversions.

Outside of the special attribute _FillValue, most of the conversion functions do not copy over metadata. The exceptions are the "contributed.ncl" functions:

byte2flt,
flt2dble,
short2flt,
dble2flt

The above functions do copy metadata, as well as (optionally) scale and offset the output.

byte2flt Converts values of type byte to values of type float.
charactertodouble Coerces values of type character to values of type double.
charactertofloat Coerces values of type character to values of type float.
charactertointeger Coerces values of type character to values of type integer.
charactertolong Coerces values of type character to values of NCL type long.
charactertoshort Coerces values of type character to values of type short.
charactertostring Coerces values of type character to values of type string.
chartodouble Coerces values of type character to values of type double.
chartofloat Coerces values of type character to values of type float.
chartoint Coerces values of type character to values of type integer.
chartointeger Coerces values of type character to values of type integer.
chartolong Coerces values of type character to values of NCL type long.
chartoshort Coerces values of type character to values of type short.
chartostring Coerces values of type character to values of type string.
cshstringtolist Converts a comma delimited string from csh and breaks it up into separate strings.
datatondc Converts data units into normalized device coordinates (NDCs).
dble2flt Converts values of type double to values of type float and preserves metadata.
doubletobyte Coerces values of type double to values of type byte.
doubletochar Coerces values of type double to values of type character.
doubletocharacter Coerces values of type double to values of type character.
doubletofloat Coerces values of type double to values of type float.
doubletoint Coerces values of type double to values of type integer.
doubletointeger Coerces values of type double to values of type integer.
doubletolong Coerces values of type double to values of type long.
doubletoshort Coerces values of type double to values of type short.
floattobyte Coerces values of type float to values of type byte.
floattochar Coerces values of type float to values of type character.
floattocharacter Coerces values of type float to values of type character.
floattoint Coerces values of type float to values of type integer.
floattointeger Coerces values of type float to values of type integer.
floattolong Coerces values of type float to values of type long.
floattoshort Coerces values of type float to values of type short.
flt2dble Converts values of type float to values of type double and preserves metadata.
flt2string Converts values of type float to values of type string.
int2dble Converts values of type integer to values of type float and preserves metadata.
int2flt Converts values of type integer to values of type float and preserves metadata.
integertobyte Coerces values of type integer to values of type byte.
integertochar Coerces values of type integer to values of type character.
integertocharacter Coerces values of type integer to values of type character.
integertoshort Coerces values of type integer to values of type short.
inttobyte Coerces values of type integer to values of type byte.
inttochar Coerces values of type integer to values of type character.
inttoshort Coerces values of type integer to values of type short.
longtobyte Coerces values of type long to values of type byte.
longtochar Coerces values of type long to values of type character.
longtocharacter Coerces values of type long to values of type character.
longtoint Coerces values of type long to values of type integer.
longtointeger Coerces values of type long to values of type integer.
longtoshort Coerces values of type long to values of type short.
ndctodata Converts normalized device coordinates (NDCs) into data coordinates.
NhlDataToNDC Converts data units into normalized device coordinates (NDCs).
NhlNDCToData Converts normalized device coordinates (NDCs) into data coordinates.
numeric2int Converts values of any numeric type to type integer.
pack_values Compress values of type float or double to values of type short or byte.
short2flt Converts values of type short to values of type float using the "scale" and "offset" attributes (if present).
short2flt_hdf Converts values of type short to values of type float using the "scale" and "offset" attributes (if present).
shorttobyte Coerces values of type short to values of type byte.
shorttochar Coerces values of type short to values of type character.
shorttocharacter Coerces values of type short to values of type character.
stringtochar Coerces values of type string to values of type character.
stringtocharacter Coerces values of type string to values of type character.
stringtodouble Coerces values of type string to values of type double.
stringtofloat Coerces values of type string to values of type float.
stringtoint Coerces values of type string to values of type integer.
stringtointeger Coerces values of type string to values of type integer.
stringtolong Coerces values of type string to values of type long.
stringtoshort Coerces values of type string to values of type short.
ushorttoint Coerces values of type unsigned short to values of type integer.