NCL Website header

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.
byte2flt_hdf Converts values of type byte to values of type float using the "scale" and "offset" attributes (if present).
charactertodouble Coerces values of type character to values of type double (deprecated; use todouble).
charactertofloat Coerces values of type character to values of type float (deprecated; use tofloat).
charactertointeger Coerces values of type character to values of type integer (deprecated; use tointeger).
charactertolong Coerces values of type character to values of NCL type long (deprecated; use tolong).
charactertoshort Coerces values of type character to values of type short (deprecated; use toshort).
charactertostring Coerces values of type character to values of type string (deprecated; use tostring).
chartodouble Coerces values of type character to values of type double (deprecated; use todouble).
chartofloat Coerces values of type character to values of type float (deprecated; use tofloat).
chartoint Coerces values of type character to values of type integer (deprecated; use toint).
chartointeger Coerces values of type character to values of type integer (deprecated; use tointeger).
chartolong Coerces values of type character to values of NCL type long (deprecated; use tolong).
chartoshort Coerces values of type character to values of type short (deprecated; use toshort).
chartostring Coerces values of type character to values of type string (deprecated; use tostring).
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 (deprecated; use tobyte).
doubletochar Coerces values of type double to values of type character (deprecated; use tochar).
doubletocharacter Coerces values of type double to values of type character (deprecated; use tochar).
doubletofloat Coerces values of type double to values of type float (deprecated; use tofloat).
doubletoint Coerces values of type double to values of type integer (deprecated; use toint).
doubletointeger Coerces values of type double to values of type integer (deprecated; use tointeger).
doubletolong Coerces values of type double to values of type long (deprecated; use tolong).
doubletoshort Coerces values of type double to values of type short (deprecated; use toshort).
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.
tobyte Converts values of any snumeric data type or string to values of type (NCL) byte (unsigned char).
tochar Converts values of any snumeric data type or string to values of type char.
todouble Converts values of any snumeric data type or string to values of type double.
tofloat Converts values of any snumeric data type or string to values of type float.
toint Converts values of any snumeric data type or string to values of type integer.
toint64 Converts values of any snumeric data type or string to values of type int64 (64 bit long, or long long).
tointeger Converts values of any snumeric data type or string to values of type integer.
tolong Converts values of any snumeric data type or string to values of type long.
toshort Converts values of any snumeric data type or string to values of type short.
tosigned Converts any kind of 8/16/32/64 integers to its corresponding signed integers.
tostring Converts values of any snumeric data type to values of type string.
tostring_with_format Converts values of any snumeric data type to values of type string, with specified format.
totype Converts values of any snumeric data type or string to values of the given type.
toubyte Converts values of any snumeric data type or string to values of type unsigned byte.
touint Converts values of any snumeric data type or string to values of type unsigned integer.
touint64 Converts values of any snumeric data type or string to values of type uint64 (unsigned 64 bit long, or unsigned long long).
toulong Converts values of any snumeric data type or string to values of type unsigned long.
tounsigned Converts any kind of 8/16/32/64 integers to its corresponding unsigned integers.
toushort Converts values of any snumeric data type or string to values of type unsigned short.
ushorttoint Coerces values of type unsigned short to values of type integer.