Convert a Starlink NDF to an IDL array.


This IDL function will convert a Starlink NDF file of up to seven dimensions to an IDL array of an appropriate type and shape. Bad values in the NDF may be converted to specific values in the IDL array.

If NDF on-the-fly conversion has been activated, the given filename may refer to a file of a different data format which is to be converted.


Result = READ_NDF( Ndf_name[, Bad_value][,COMPONENT=Comp_name])


A string expression specifying name of the NDF to be read.
Optional - A value to replace in the IDL array any occurrence of the PRIMDAT bad value in the NDF component. The value must be the same type as the array.


Set this to a string expression specifying the NDF component to be read. It may be "DATA", "VARIANCE" or "QUALITY" and defaults to "DATA". The case of the string does not matter and it may be abbreviated to one or more characters.

Returned Value

  • Result An IDL array of a size and type corresponding with the NDF. The type correspondence is as follows:
    _REAL – > floating
    _DOUBLE – > double-precision
    _UBYTE – > byte
    _WORD – > integer
    _INTEGER – > longword integer
  • Examples:

    Assuming my_ndf.sdf is an NDF of type _REAL,
    IDL> data_array = read_ndf(’my_ndf’)
    creates an IDL floating array, data_array, with the same dimensions as the NDF and containing the values from its DATA component.
    IDL> data_array = read_ndf(’my_ndf’, !values.f_nan)
    As above except that any occurrence of a bad value (VAL__BADR as defined by the Starlink PRIMDAT package) in the NDF will be replaced by NaN in the IDL array.
    IDL> quality = read_ndf(’my_ndf’,comp=’q’)
    creates an IDL byte array from the QUALITY component of the same NDF. (The QUALITY component is always type _UBYTE.) Note that the keyword ’component’ and the value ’QUALITY’ are case-independent and can be abbreviated.


    No conversion of the given bad value to the appropriate type for the array will be attempted; instead an error will be reported.

    Related Applications

    Convert: WRITE_NDF.