NL-SCIA-DC IDL reference

This page was created by the IDL library routine mk_html_help. For more information on this routine, refer to the IDL Online Help Navigator or type:

     ? mk_html_help

at the IDL command line prompt.

Last modified: Thu Feb 3 14:47:20 2011.


List of Routines


Routine Descriptions

CONVERT_TO_RUNS

[Next Routine] [List of Routines]
 NAME:
       CONVERT_TO_RUNS

 PURPOSE:
       converts a list of integers to sorted runs
       [1,3,5,7] -> [[1,1],[3,3],[5,5],[7,7]]
       [1,2,3,4] -> [[1,4]] (shortened!) (minimum of 'min_run' elements)

 TODO:
       optimise: use fixed size array instead of apppend operations

(See convert_to_runs.pro)


GET_LV0_MDS_COLLO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_LV0_MDS_COLLO

 PURPOSE:
       obtian index to MDS record given a julian date

 CATEGORY:
       SCIAMACHY level 0

 CALLING SEQUENCE:
       indx = GET_LV0_MDS_COLLO( jday, mds )

 INPUTS:
      jday :    modified (decimal) julian date for the year 2000 (array)

       mds :    an element or array of type structure
                MDS0_AUX/MDS0_DET/MDS0_PMD

 KEYWORD PARAMETERS:
    None

 OUTPUTS:
       array of structures:
           dt  :  (float) difference jday and collocated MDS records
           i   :  (long)  index to the closest collocation in time
           x   :  (long)  X-index (fastest) to the closest collocation
           y   :  (long)  Y-index to the closest collocation
           z   :  (long)  Z-index (slowest) to the closest collocation

 EXAMPLE:
          jdate = GET_LV0_MDS_TIME( det[100] )

 obtain index to closest AUX-record
          iindx = GET_LV0_MDS_COLLO( jdate, aux )
   --> AUX[iindx.z].DATA_SRC[iindx.y].BCP[iindx.x]

 obtain index to closest PMD-record
          iindx = GET_LV0_MDS_COLLO( jdate, aux )
   --> PMD[iindx.y].DATA_SRC.PACKET[iindx.x]

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), 16 April 2002
       Modified:  RvH, 19 September 2002
                    removed confusing Info-message
       Modified:  RvH, 19 September 2002
                    updated documentation (added examples)
       Modified:  RvH, 04 July 2005
                    accepts an array of jday
                    removed keyword dt_min (see output structure)
                    returns structure

(See get_lv0_mds_collo.pro)


GET_LV0_MDS_DATA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_LV0_MDS_DATA

 PURPOSE:
       This function extracts detector pixel readouts from a 
       level 0 Detector MDS

 CATEGORY:
       SCIAMACHY level 0

 CALLING SEQUENCE:
       data = GET_LV0_MDS_DATA( mds_det, ... )

 INPUTS:
   mds_det :    an element or array of type Structure MDS0_DET

 KEYWORD PARAMETERS:
  state_id :    a scalar of type integer specifying the ID of the
                state to be selected from the input MDS. The value of
                state_id can be set to -1 if all input MDS records
                hold data from the same state.

   channel :    a scalar of type integer specifying number of the
                channel to be extracted, valid range = [1:8]

   cluster :    a scalar of type integer specifying the number of the
                pixel data block (a cluster) to be extracted,
                starting at 1
                [this keyword is ignored in combination with "channel"]

    pixels :    lower and/or upper boundary of the pixel numbers to
                be extracted, valid range = [0:1023]
                 pixels=[p1:p2]    extract pixels between p1 and p2
                 pixels=-p1        extract pixels between 0 and p1
                 pixels=p2         extract pixels between p2 and 1023

     align :    if set to a non-zero value, the output array reflects
                the detector array layout, only in combination with
                keyword cluster or pixels

  do_coadd :    divide pixel counts by co-adding factor

      norm :    divide pixel counts by co-adding factor times pixel
                exposure time

    coaddf :    named variable holding co-adding factors of each pixel

      jday :    named variable holding julian dates of each pixel
                readout

       NaN :    if set to a non-zero value, NaN is used as fill value
                [implies that the return array is of type float]

    status :    returns named variable with error status (0 = ok)

 PROCEDURE:
       Each Detector MDS record holds science data of only those
       clusters which have finished their integration time. The
       purpose of this routine is to collect data from one or more
       MDS records and organize the data per science channel. The
       dimensions of the output array are (maximum 3):
        1) number of pixels, maximum 1024
        2) number of channels, zero or eight
        3) number of (selected) MDS records, maximum number of input
        MDS

 EXAMPLES:
       - extract all data from the second MDS.
            data_out = GET_LV0_MDS_DATA( mds_det[1] )

         (the returned array is an ULONG array of size [1024, num_chan])
       - extract all data with pixel numbers between [102,154]from
         the second MDS. 
            data_out = GET_LV0_MDS_DATA( mds_det[1], pixels=[102,154] )

         (the returned array is an ULONG array of size [53, num_chan])
       - extract all data of channel 4 from the second MDS.
            data_out = GET_LV0_MDS_DATA( mds_det[1], channel=4 )

         (the returned array is an ULONG array of size [1024])
       - extract all data of channel 4 & cluster 2 from the second MDS.
            data_out = GET_LV0_MDS_DATA( mds_det[1], channel=4,
                                         cluster=2 )
         (the returned array is an ULONG array of size [cluster_size])
       - extract all data of channel 4 & cluster 2 from the second MDS.
            data_out = GET_LV0_MDS_DATA( mds_d[2], channel=4,
                                         cluster=2, /align ) 
         (the returned array is an ULONG array of size [1024])
       - extract all data of channel 4 & pixel numbers between
         [102,154] from the second MDS.  
            data_out = GET_LV0_MDS_DATA( mds_det[1], channel=4,
                                         pixels=[102,154] ) 
         (the returned array is an ULONG array of size [53])

 REFERENCE:
       Measurement data definition and format description for
       SCIAMACHY, volume 14. PO-ID-DOR-SY-0032

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), Januari 2002
       Modified:  RvH, February 2002
                    Uses the new function GET_KEY_CHAN_HDR
       Modified:  RvH, March 2002
                    removed use of obsoleted function GET_KEY_CHAN_HDR
       Modified:  RvH, March 2002
                    added normalisation of data values both PET and coadding
       Modified:  RvH, 21 March 2002
                    set keywords to -1 results in no selection
       Modified:  RvH, 09 April 2002
                    updated documentation
       Modified:  RvH, 19 April 2002
                    now align also works in case of pixel selection
       Modified:  RvH, 21 April 2002
                    PET also works with virtual channels
       Modified:  RvH, 06 November 2002
                    more checks on data
                    added selection on state ID
       Modified:  RvH, 07 November 2002
                    bugfix for state_id checking
                    check on MDS input record type
                    added "PROCEDURE" to the documentation
       Modified:  RvH, 03 March 2004
                    fixed several bugs and did some code clean-ups
       Modified:  RvH, 30 November 2004
                    function can now return the coadding factors
       Modified:  RvH, 30 November 2004
                    Speeding-up this code!
       Modified:  RvH, 30 August 2005
                    Fixed several "brown paperbag" bugs
                    Added optional parameter: jday
       Modified:  RvH, 17 May 2007
                    Reduce output array to actual number of readouts
       Modified:  RvH, 15 January 2009
                    Fixed bugs (a.o. keyword CLUSTER) and code clean-up
       Modified:  RvH, 19 January 2009
                    added keyword DO_COADD to make a distinction
                    between applying co-adding factor and to return
                    the co-adding factors
       Modified:  RvH, 13 April 2010
                    adopted to modified mds_det_data_src.hdr structure

(See get_lv0_mds_data.pro)


GET_LV0_MDS_HK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_LV0_MDS_HK

 PURPOSE:
       obtain house keeping data from level 0 MDS records

 CATEGORY:
       SCIAMACHY level 0

 CALLING SEQUENCE:
       Result = GET_LV0_MDS_HK( mds [, posit=] [, status=] [, channel=] 
                                [, /pet] [, /ir_pet] [, virtual=]
                                [, /temp] [, /asm] [, /esm]
                                [, /rad] [, /az] [, /elv] [, /obm] )
 INPUTS:
       mds :    an element or array of type structure
                MDS0_AUX/MDS0_DET/MDS0_PMD 

 KEYWORD PARAMETERS:
     posit :    relative index or index-range [low,high] to MDS record(s)
    status :    returns named variable with error status (0 = ok)

     [MDS0_DET]
   channel :    a scalar of type integer specifying ID of the
                channel to be extracted, valid range = [1:8]
       pet :    return pixel exposure time
    ir_pet :    return pixel exposure time - chan 6-8 corrected
                ref. TN-SCIA-0000DO/19,10.03.1999
   virtual :    returns named variable indiacting the usage of
                virtual channels, virtual equals zero if no virtual
                channels are used. Only in combination with /pet and
                for channel 1 and 2. 
      temp :    return temperature of Detector block (K)

     [MDS0_PMD]
      temp :    return temperature of PMD electronics (K)

     [MDS0_AUX]
       asm :    return azimuth scan mirror position (degrees)
       esm :    return elevation scan mirror position (degrees)
  rad_temp :    return temperature near radiator (K)
   az_temp :    return temperature near AZ scanner (K)
  elv_temp :    return temperature near ELV scanner (K)
[obm_]temp :    return temperature of the optical bench (K),
                       (combination of AZ, ELV and RAD).

 EXAMPLES:
       - extract temperature for all eight detector arrays
            result = GET_LV0_MDS_HK( mds_det, /temp )

       - extract temperature of channel 1 detector array
            result = GET_LV0_MDS_HK( mds_det, /temp, channel=1 )

       - extract temperature of the PMD electronics
            result = GET_LV0_MDS_HK( mds_pmd, /temp )

       - extract temperature of the optical bench
            result = GET_LV0_MDS_HK( mds_aux, /temp )

       - extract azimuth scan mirror positions
            result = GET_LV0_MDS_HK( mds_aux, /asm )

 REFERENCE:
       Measurement data definition and format description for
       SCIAMACHY, volume 14. PO-ID-DOR-SY-0032

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), March 2002
       Modified:  RvH added optical bench temperature, March 2002
       Modified:  RvH, 19 March 2002
                    Handle uint to float conversion correctly (MDS0_AUX)
       Modified:  RvH, 19 March 2002
                    replaced confusing bench_obm with bench_rad
       Modified:  RvH, 19 March 2002
                    check return values of GET_LV0_DET_TEMP
       Modified:  RvH, 21 March 2002
                    set keywords to -1 results in no selection
       Modified:  RvH, 21 March 2002
                    added keywords "esm" and "asm"
       Modified:  RvH, 25 March 2002
                    keyword /obm for Auxiliaray MDS did not work.
       Modified:  RvH, 19 April 2002
                    implemented PET for virtual channels
       Modified:  RvH, 24 March 2003
                    check: 0 <= posit[0] <= posit[1] < array-size
       Modified:  RvH, 20 Januari 2004
                    changed the azimuth offset according to an update
                    of the PGS-ICD, dated 12.12.2001 
       Modified:  RvH, 12 Augustus 2004
                    apply correction to the PET of channel 6-8
                    The correct integration-time can be obtained by
                    using the corrected PET multiplied with the
                    coadding factor, only for option /ir_pet
                    ref. TN-SCIA-0000DO/19,10.03.1999
       Modified: RvH, 3 March 2010
                    fixed long standing bug: mixing radTemp & azTemp
                    fixed computation of OBM temperature

(See get_lv0_mds_hk.pro)


GET_LV0_MDS_STATE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_LV0_MDS_STATE

 PURPOSE:
	obtain SCIA level 0 info-records for given selection criteria

 CATEGORY:
	SCIA level 0 

 CALLING SEQUENCE:
	Result = GET_LV0_MDS_STATE( info, keywrd=keywrd, ... )

 INPUTS:
       info :    structure holding info about MDS records

 KEYWORD PARAMETERS:
    type_mds :  string to select MDS of type: 'DET', 'AUX', 'PMD'
                defaults to 'DET'
    category :  read only selected category of measurements (scalar or array)
                (default or -1: all categories)
    state_id :  read only selected states (scalar or array)
                (default or -1: all states)
      period :  read only MDS within a time-window (scalar or array)
                date must be given in decimal julian 2000 day
                (default or -1: all data)
 state_posit :  relative index/indices to the state record(s), this
                is last selection applied, only counting those MDS(s)
                which contain data (default or -1: all data)
  indx_state :  named variable which contains the indices to the
                original state records as defined in the level 1b/1c product
   num_state :  named variable which contains the number of selected states
      status :  named variable which contains the error status (0 = ok)

 OUTPUTS:
	selected SCIA level 0 info-records

 EXAMPLE:
	

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), March 2010

(See get_lv0_mds_state.pro)


GET_LV0_MDS_TIME

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_LV0_MDS_TIME

 PURPOSE:
       obtain decimal julian date for level 0 MDS records

 CATEGORY:
       SCIAMACHY level 0

 CALLING SEQUENCE:
       jday = GET_LV0_MDS_TIME( mds [, status=status] )

 INPUTS:
       mds :    an element or array of type structure
                MDS0_AUX/MDS0_DET/MDS0_PMD

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 OUTPUTS:
       modified (decimal) julian date for the year 2000.
       Detector MDS:  time when a packet was assembled
           T = T_ICU + bcps / 16.d               
       Auxiliary MDS: time when a BCP was assembled
           T[16,5] = T_ICU + bcps[16,5] / 16.d   
       PMD MDS:       time when a PMD data packet was assembled
           T[200] = T_ICU + bcps[200] / 16.d + (2/10^3 * delta_T-12.5)/10^3

        Note 1) that this routine does not return the time for each
        detector channel reading, NOR for each PMD measurement
        reading
        Note 2) the returned time is not corrected for the difference
        between the "ICU on-board time at start of measurement" and
        the BCPS counter reset (refered to as "RI").

 EXAMPLE:

 REFERENCE:
       Measurement data definition and format description for
       SCIAMACHY, volume 14. PO-ID-DOR-SY-0032


 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), 15 April 2002
       Modified:  RvH, 15 May 2002
                    removed bug calculating time for MDS_AUX
       Modified:  RvH, 4 October 2002
                    removed bug calculating time for MDS_DET
                    (now the BCPS of the channel data is used)
       Modified:  RvH, 4 December 2002
                    can also handle MDS0_INFO records   

(See get_lv0_mds_time.pro)


GET_LV0_STATE_TEMP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_LV0_STATE_TEMP

 PURPOSE:
       obtain house keeping data from level 0 MDS records

 CATEGORY:
       SCIAMACHY level 0

 CALLING SEQUENCE:
       GET_LV0_STATE_TEMP, info, temp_list, state_list=state_list

 INPUTS:
       info  :    structure holding info about MDS records
 OUTPUTS:
   temp_list :    temperatures (chan1..chan8,OBM,PMD) per state

 KEYWORD PARAMETERS:
  state_list :    listing of stateID in SCIA LV0 product

 EXAMPLES:

 REFERENCE:
       Measurement data definition and format description for
       SCIAMACHY, volume 14. PO-ID-DOR-SY-0032

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), May 2006

(See get_lv0_state_temp.pro)


GET_LV1_GOME_SPEC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_LV1_GOME_SPEC

 PURPOSE:
	combine GOME spectral band data into a spectrum

 CATEGORY:
       GOME level 1b

 CALLING SEQUENCE:
	Result = GET_LV1_GOME_SPEC( posit, fsr, fcd, pcd, status=status,
                                   calibration=calibration, wave=wave )

 INPUTS:
     posit :    scalar of type integer with the index of an PCD 
                record specifying the Spectral Band Record to be
                extracted, starting at zero
     fsr   :    structure with File Structure Record
     fcd   :    structure with Fixed Calibration Records
     pcd   :    structure with the Pixel Specific Calibration Records

 KEYWORD PARAMETERS:
     status :   returns named variable with error status (0 = ok)
 calibration:   string describing the calibration to be applied
     wave   :   set this keyword to a named variable that will
                contain the wavelength of the data points.

 OUTPUTS:
	This function returns the combined spectral band data of band
	1a, 1b, 2a, 2b, 3, and 4

 EXAMPLE:

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees, March 2003

(See get_lv1_gome_spec.pro)


GET_LV1_MDS_DATA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_LV1_MDS_DATA

 PURPOSE:
       This function extracts detector pixel readouts from a 
       level 1(c) MDS

 CATEGORY:
       SCIAMACHY level 1

 CALLING SEQUENCE:
       data = GET_LV1_MDS_DATA( mds, state_id )

 INPUTS:
       mds :    an array of type Structure MDS1_SCIA
  state_id :    a scalar of type integer specifying the ID of the
                state to be selected from the input MDS. The value of
                state_id can be set to -1 if all input MDS records
                hold data from the same state.

 KEYWORD PARAMETERS:
     posit :    a scalar of type integer specifying the index of the
                MDS record to be extracted, starting at zero.

   channel :    a scalar of type integer specifying number of the
                channel to be extracted, valid range = [1:8]

   cluster :    a scalar of type integer specifying the number of the
                pixel data block (a cluster) to be extracted,
                starting at 1
                [this keyword is ignored in combination with "channel"]

    pixels :    lower and/or upper boundary of the pixel numbers to
                be extracted, valid range = [0:1023]
                 pixels=[p1:p2]    extract pixels between p1 and p2
                 pixels=-p1        extract pixels between 0 and p1
                 pixels=p2         extract pixels between p2 and 1023

     align :    if set to a non-zero value, the output array reflects
                the detector array layout, only in combination with
                keyword cluster or pixels

     rebin :    if set to a non-zero value, the output array is
                resized to number of observations for the longest
                intergrations time (using nearest neighbor sampling)

     coadd :    divide pixel counts by coadding factor

      norm :    divide pixel counts by coadding factor times pixel
                exposure time

      jday :    named variable holding julian dates of each pixel
                readout

       NaN :    if set to a non-zero value, NaN is used as fill value

    errors :    set this keyword to a named variable that will
                contain the signal error values
      wave :    set this keyword to a named variable that will
                contain the wavelength of the data points.

    status :    returns named variable with error status (0 = ok)

 SIDE EFFECTS:
       1) wavelength calibration is not performed by this
       function. One should call SCIA_LV1_RD_MDS, or SciaL1C with
       the appropriate calibration options.
       2) ...

 PROCEDURE:
       Each MDS record holds science data from one cluster. The
       science data is defined by its state ID, cluster ID and
       channel ID. The purpose of this routine is to extract the
       science data from the complicated MDS record and organize the
       data per science channel.
       The dimensions of the output array (maximum of 4):
        1) number of pixels, maximum 1024
        2) number of observations:
                  state[].num_dsr * state[].Clcon[].n_read
        3) number of channels, maximum 8
        4) number of repeated MDS records of a requested state ID
       - Note than on output all dimensions of size 1 are removed
       - Note also that the number of observation (2) depends on the
       integration time, which is large for (a.o.) channel 1.
       Therefore, in case you not select a science channel, the gaps
       between data of channel 1 are large and filled with zero's or NaN's.

 EXAMPLES:
       - extract all data (from state_id = 6) with pixel numbers
         between [102,154], only the second record:
            data_out = GET_LV1_MDS_DATA( mds, 6, pixels=[102,154], posit=2 )

         (the returned array is an Float array of size [53,8])

       - extract all data of channel 4:
            data_out = GET_LV1_MDS_DATA( mds, 6, channel=4 )

         (the returned array is an Float array of size [1024,num_obs,num_mds])

       - extract all data of cluster 2, only the third record:
            data_out = GET_LV1_MDS_DATA( mds, 6, cluster=2, posit=3 )

         (the returned array is an Float array of size [cluster_size])

       - extract all data of cluster 2 as a 1024 array.
            data_out = GET_LV1_MDS_DATA( mds, 6, cluster=2, posit=3, /align ) 
         (the returned array is an Float array of size [1024])

       - extract all data of channel 4 & pixel numbers between
         [102,154], only the second record  
            data_out = GET_LV1_MDS_DATA( mds, 7, posit=2, channel=4, $
                                         pixels=[102,154] ) 
         (the returned array is an Float array of size [53])

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
       Input/Output Data Definition
       Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), 28 June 2002
       Modified:  RvH, 26 July 2002
                    improved the given eamples examples
       Modified:  RvH, 26 July 2002
                    added keyword state_id, and wave
       Modified:  RvH, 26 July 2002
                    the cluster keywords now gives correct results
       Modified:  RvH, 24 October 2002
                    complete rewrite
                    requires state_id as parameter (!!)
                    updated documentation
       Modified:  RvH, 28 October 2002
                    more bug-fixes...
       Modified:  RvH, 08 Januari 2003
                    more bug-fixes (keyword cluster),
                    and added the keyword rebin
       Modified:  RvH, 16 Januari 2003
                    added more documentation about NUM_OBS
       Modified:  RvH, 21 July 2003
                    made de align-keyword work correctly
       Modified:  RvH, 07 November 2003
                    made it work with the new IDL compile options
       Modified:  RvH, 19 November 2003
                    made the data selection also work on array "wave"
       Modified:  RvH, 17 May 2004
                    added keyword to obtain Signal error values
       Modified:  RvH, 18 October 2004
                    added keyword "norm" for normalisation of readouts
       Modified:  RvH, 18 October 2004
                    added keyword "coadd"
       Modified:  RvH, 15 June 2005
                    fixed several bugs for sampled data (using REBIN)
       Modified:  RvH, 07 December 2005
                    renamed pixel_val_err to pixel_err
       Modified:  RvH, 07 Februari 2006
                    bugfix removed optional keyword "state_id", which
                    collide with the parameter "state_id"
       Modified:  RvH, 06 July 2006
                    bugfix usage of Norm and/or Coadd keywords
                    patch came from Guenter Lightenberg
       Modified:  RvH, 18 July 2006
                    fixed bug when states with same ID have different
                    number of dataset records

(See get_lv1_mds_data.pro)


GET_LV1_MDS_STATE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_LV1_MDS_STATE

 PURPOSE:
	obtain SCIA level 1 state definitions for given selection criteria

 CATEGORY:
	SCIA level 1b and 1c data

 CALLING SEQUENCE:
	Result = GET_LV1_MDS_STATE( dsd, keywrd=keywrd, ... )

 INPUTS:
       dsd :    structure for Data Set Descriptors

 KEYWORD PARAMETERS:
    type_mds :  scalar of type integer to select MDS of type: 
                {!nadc.sciaNadir=1, !nadc.sciaLimb=2, !nadc.sciaOccult=3, !nadc.sciaMonitor=4}
    category :  read only selected category of measurements (scalar or array)
                (default or -1: all categories)
    state_id :  read only selected states (scalar or array)
                (default or -1: all states)
  OrbitPhase :  selection on orbit phase, required are 2 values. The
                orbit phase seletion is based on "States of the Product"
 geolocation :  vector of type float which defines the geografical
                region as [lat_min,lat_max,lon_min,lon_max] (using LADS)
       NoSAA :  set this keyword to inhibit to reject states with the
                SAA set (using SQADS) 
      period :  read only MDS within a time-window (scalar or array)
                date must be given in decimal julian 2000 day
                (default or -1: all data)
 state_posit :  relative index/indices to the state record(s), this
                is last selection applied, only counting those MDS(s)
                which contain data (default or -1: all data)
  indx_state :  named variable which contains the indices to the
                original state records as defined in the level 1b/1c product
       count :  named variable which contains the number of selected states
      status :  named variable which contains the error status (0 = ok)

 OUTPUTS:
	SCIA level 1b state records, or -1 if the selection is empty

 EXAMPLE:
	

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), March 2004
       Modified:  RvH, 08 Dec 2004
                    added selection on orbit phase

(See get_lv1_mds_state.pro)


GET_LV1_MDS_TIME

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_LV1_MDS_TIME

 PURPOSE:
       obtain decimal julian date for level 1 MDS records

 CATEGORY:
       SCIAMACHY level 1b/1c

 CALLING SEQUENCE:
       jday = GET_LV1_MDS_TIME( [state,] mds [, status=status] )

 INPUTS:
     [state :    structure for States of the product 
               DEPRECIATED, DO NOT USE!]
       mds :    a MDS1C_SCIA structure

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 OUTPUTS:
       modified (decimal) julian date for the year 2000.

 EXAMPLE:

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
       Input/Output Data Definition
       Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), 07 November 2002
       Modified:  RvH, 21 Jun 2005
                    use of parameter "state" is depreciated
       Modified:  RvH, 14 Apr 2004
                    small bugfixes added more error messages

(See get_lv1_mds_time.pro)


GET_SCIA_LEVEL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_SCIA_LEVEL

 PURPOSE:
	This function identifies the SCIAMACHY product level

 CATEGORY:
	SCIAMACHY

 CALLING SEQUENCE:
	Result = GET_SCIA_LEVEL( flname=flname )

 INPUTS:

 KEYWORD PARAMETERS:
      flname:	name of the SCIAMACHY file 

 OUTPUTS:
	This function returns a string, which identifies the level of
	the product: '0', '1B', '1C', '2N, '2O'', or 'UNKOWN'

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), 28 June 2002
       Modified:  RvH, 07 May 2003
                    perform more checks on input-file
       Modified:  RvH, 15 April 2005
                    added detection of NRT and Offline level 2 products

(See get_scia_level.pro)


GET_SCIA_MDS1_DATA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:   
       GET_SCIA_MDS1_DATA

 PURPOSE:
       read/calibrate MDS science data of a channel from one or more states

 CATEGORY:
       SCIA level 1b/1c data

 CALLING SEQUENCE:
       data = GET_SCIA_MDS1_DATA( dsd, stateID, chanID, meta=meta, $
                                  calib=calib, stateIndex=stateIndex, $
                                  norm=norm, status=status )

 INPUTS:
         dsd :    structure for Data Set Descriptors
     stateID :    read selected state (scalar)
      chanID :    channel number of science data to be returned (scalar)

 KEYWORD PARAMETERS:
        meta :  named variable which contains on return the Julian
                day and gelocation information of the data
  stateIndex :  named variable which contains the indices to the
                original state records as defined in the level 1b/1c
                product
 calibration :  string describing the calibration to be applied
                (default or -1: no calibration of the MDS data)

                0 : Memory Effect 
                1 : Leakage Correction 
                2 : PPG Correction 
                3 : Etalon Correction 
                4 : StrayLight Correction 
                5 : WaveLength Calibration 
                6 : Polarisation Sensitivity 
                7 : Radiance Sensitivity 
                8 : Division by Solar spectrum
                9 : Bad/Dead pixel mask

      norm   : default is to normalize the data to the shortest
               integration time in the state for the requested
               channel. However, setting this keyword will return BU/s
      status : named variable which contains the error status (0 = ok)

 SIDE EFFECTS:
       None

 ENVIRONMENT VARIABLE "SCIA_CORR_LOS":
       The values of the level 1b line-of-sight zenith angles are
       always larger than zero, and the azimuth angle jumps with 180
       degrees while scanning through nadir. 
       Setting the environment variable "SCIA_CORR_LOS" to one will
       modify these values as follows: removing the jump in the
       azimuth angles and returns negative zenith angles, when the
       original azimuth angle was larger than 180 degree.

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
       Input/Output Data Definition
       Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2007
       Modified:  RvH, 06 December 2007
                    added timestamp and geolocation record keyword (meta)
                    fixed several bugs
       Modified:  RvH, 06 December 2007
                    more checks build in for corrupted/in-complete products

(See get_scia_mds1_data.pro)


GET_SCIA_MDS1_WAVE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GET_SCIA_MDS1_WAVE

 PURPOSE: 
        obtain wavelength grid for a channel

 CATEGORY:
        SCIA level 1b/1c data

 CALLING SEQUENCE:
          result = GET_SCIA_MDS1_WAVE( dsd, chanID )

 INPUTS:
         dsd :  structure for Data Set Descriptors
      chanID :  channel number of science data to be returned (scalar)

 KEYWORD PARAMETERS:
     stateID :  read selected state (scalar), ignored when stateIndex is given
  stateIndex :  named variable which contains the indices to the
                original state records as defined in the level 1b/1c
                product, overrules stateID
      status : named variable which contains the error status (0 = ok)

 EXAMPLE:
       None

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2007

(See get_scia_mds1_wave.pro)


GET_SCIA_ORBITPHASE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_SCIA_ORBITPHASE

 PURPOSE:
	obtain orbitphase for given

 CATEGORY:
	

 CALLING SEQUENCE:
	Result = GET_SCIA_ORBITPHASE( julianDay )

 INPUTS:
	orbit:	        absolute orbit number
	julianDay:	julian Day (# days since 2000-01-01)

 KEYWORD PARAMETERS:
	eclipse_mode:	TRUE - return orbit phase as used for (old!) SDMF
       status:         error flag (0 = ok)

 OUTPUTS:
	Describe any outputs here.  For example, "This function returns the
	foobar superflimpt version of the input array."  This is where you
	should also document the return value for functions.

 PROCEDURE:
	You can describe the foobar superfloatation method being used here.
	You might not need this section for your routine.

 EXAMPLE:
	Please provide a simple example here. An example from the PICKFILE
	documentation is shown below. Please try to include examples that
       do not rely on variables or data files that are not defined in
       the example code. Your example should execute properly if typed
       in at the IDL command line with no other preparation.

 MODIFICATION HISTORY:
 	Written by:	

(See get_scia_orbitphase.pro)


GET_SCIA_QUALITY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_SCIA_QUALITY

 PURPOSE:
	obtain data quality of Sciamachy

 CATEGORY:
	

 CALLING SEQUENCE:
	Result = GET_SCIA_QUALITY( orbit, period=period )

 INPUTS:
	orbit:	        absolute orbit number

 KEYWORD PARAMETERS:
	period:	        first and last orbit affected by event

 OUTPUTS:
	data quality: 
                       0 = ok
                       1 = decontamination
                       2 = recovery ATC/TC affected
                       4 = data unavailable

 PROCEDURE:
	none

 EXAMPLE:
	none

 MODIFICATION HISTORY:
 	Written by:	R.M. van Hees (SRON), 25-09-2009

(See get_scia_quality.pro)


GET_SDMF_DARKFIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_SDMF_DARKFIT

 PURPOSE:
	obtain Dark parameters obtained by a linear fit through the State Darks

 CATEGORY:
	Sciamachy - SDMF

 CALLING SEQUENCE:
	GET_SDMF_DARKFIT, orbit, mtbl, analogOffset, darkCurrent

 INPUTS:
	orbit:	        absolute orbit number, a scalar or vector[min,max], 
                       range [1...]

 KEYWORD PARAMETERS:
	analogOffsetError: uncertainty in analogOffset
       darkCurrentError:  uncertainty in darkCurrent
       meanNoise:         average standard deviation (shortest PET)
       chiSquareFit:      chi-square of fit
       stateCount:        states used for fit: 8=1, 26=2, 46=4, 63=8, 67=16

       channel:        channel ID, named scalar, range [1..8]
       pixelID:        pixel ID, named scalar, range [1...8192]

       DARK_DB:        path to the SDMF Dark database
                       default: ./sdmf_dark.h5
                                /SCIA/share/SDMF/3.1/sdmf_dark.h5
       use_neighbours: flag to enable looking for neighboring valid dark
       status :        returns named variable with error flag (0 = ok)

 OUTPUTS:
       mtbl:           metaTable (array of structures)
       analogOffset:   analog offset (BU) or fixed pattern noise
       darkCurrent:    dark current (BU/s) or leackage current

 PROCEDURE:
	none

 EXAMPLE:
	- obtain for orbit=7502, all channels: analogOffset and darkCurrent
       IDL> GET_SDMF_DARKFIT, 7502, mtbl, analogOffset, darkCurrent

	- obtain for orbit=7502, channel=2: analogOffset and darkCurrent
       IDL> GET_SDMF_DARKFIT, 7502, mtbl, analogOffset, darkCurrent, channel=2

	- obtain for pixel=100 (all orbits): analogOffset and darkCurrent
       IDL> GET_SDMF_DARKFIT, -1, mtbl, analogOffset, darkCurrent, pixel=100

	- obtain for orbit range: analogOffset and darkCurrent
       IDL> GET_SDMF_DARKFIT, [11000,12000], mtbl, analogOffset, darkCurrent

 MODIFICATION HISTORY:
 	Written by:	R.M. van Hees (SRON), 26-01-2010
       Modified:  RvH added keyword use_neighbours, October 2010
       Modified:  RvH added keyword stateCount, January 2011
       Modified:  RvH, apply REFORM on output arrays, January 2011

(See get_sdmf_darkfit.pro)


GET_SDMF_DBPM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_SDMF_DBPM

 PURPOSE:
	Obtain dead/bad pixel mask from SDMF databases

 CATEGORY:
	Sciamachy - SDMF

; CALLING SEQUENCE:
	Result = GET_SDMF_BDPM( orbit, status=status, BDPM_DB=BDPM_DB)

 INPUTS:
	orbit:	        absolute orbit number, a scalar, range [1...]

 KEYWORD PARAMETERS:
	BDPM_DB:	path to the SDMF Dark database
                       default: ./sdmf_pixelmask.h5
                                /SCIA/share/SDMF/3.0/sdmf_pixelmask.h5
       status :        returns named variable with error flag (0 = ok)

 OUTPUTS:
	dead/bad pixel mask

 PROCEDURE:
	ToDo!

 EXAMPLE:
	Please provide!

 MODIFICATION HISTORY:
 	Written by:	R.M. van Hees (SRON), 22-09-2010

(See get_sdmf_bdpm.pro)


GET_SDMF_EXTRACT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_SDMF_EXTRACT

 PURPOSE:
	obtain calibration state parameters

 CATEGORY:
	Sciamachy - SDMF

 CALLING SEQUENCE:
	GET_SDMF_EXTRACT, orbit, stateID, mtbl

 INPUTS:
	orbit:	        absolute orbit number, a scalar or vector[min,max], 
                       range [1...]
       stateID:        Calibration State ID, a scalar, valid ID's are: 
                       8,16,26,39,46,48,52,59,61,62,63,65,67,69,70
       
 OUTPUTS:
       mtbl:           structure with rows of table metaTable

 KEYWORD PARAMETERS:
       channelNoiseMean:     
       channelNoiseAdev: 
       channelTempAdev:  
       histPMD:          
       histReadOut:      
       readoutCount:     
       readoutMean:      
       readoutNoise:     
       CALIB_DB:         path to the SDMF calibration states database
                         default: ./sdmf_extract_dark.h5
                                  /SCIA/share/SDMF/3.1/sdmf_extract_dark.h5
       status :          returns named variable with error flag (0 = ok)

 PROCEDURE:
	none

 EXAMPLE:
       Please add!

 MODIFICATION HISTORY:
 	Written by:	R.M. van Hees (SRON), 21-01-2011

(See get_sdmf_extract.pro)


GET_SDMF_EXTRACT_L1B

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_SDMF_EXTRACT_L1B

 PURPOSE:
	obtain calibration state parameters from L1b key- database

 CATEGORY:
	Sciamachy - SDMF

 CALLING SEQUENCE:
	GET_SDMF_EXTRACT_L1B, orbit, mtbl

 INPUTS:
	orbit:	        absolute orbit number, a scalar or vector[min,max], 
                       range [1...], or -1 to select all orbits

 OUTPUTS:
       mtbl:           structure with rows of table metaTable

 KEYWORD PARAMETERS:
       procStage:      character 'R' or 'U' (= default)

       AO:
       ERROR_AO:
       LC:
       ERROR_LC:
       VLC:
       ERROR_VLC:

       BDPM:

       GRID_BASE:
       GRID_COEFFS:

       SUN_DIFFUSER:

       channel:        channel ID, named scalar, range [1..8]
       pixelID:        pixel ID, named scalar, range [1...]

       CALIB_DB:       path to the SDMF calibration states database
                       default: ./sdmf_extract_l1b.h5
                                /SCIA/share/SDMF/3.1/sdmf_extract_l1b.h5
       status :        returns named variable with error flag (0 = ok)

 PROCEDURE:
	none

 EXAMPLE:
       Please add!

 MODIFICATION HISTORY:
 	Written by:	R.M. van Hees (SRON), 25-01-2011

(See get_sdmf_extract_l1b.pro)


GET_SDMF_STATEDARK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	GET_SDMF_STATEDARK

 PURPOSE:
	obtain fitted/smoothed State Dark parameters 

 CATEGORY:
	Sciamachy - SDMF

 CALLING SEQUENCE:
	GET_SDMF_STATEDARK, stateID, orbit, mtbl, signal

 INPUTS:
       stateID:        state ID
	orbit:	        absolute orbit number, a scalar or vector[min,max]
                       range [1...]

 KEYWORD PARAMETERS:
	noise:          standard deviation of the smoothed dark signal

       channel:        channel ID, named scalar, range [1..8]
       pixelID:        pixel ID, named scalar, range [1...]

       DARK_DB:        path to the SDMF Dark database
                       default: ./sdmf_dark.h5
                                /SCIA/share/SDMF/3.1/sdmf_dark.h5
       status :        returns named variable with error flag (0 = ok)

 OUTPUTS:
       mtbl:           metaTable (array of structures)
       signal:         smooth dark signal (BU)

 PROCEDURE:
	none

 EXAMPLE:
	- obtain dark signal for a given orbit=7502, all channels: 
       IDL> GET_SDMF_STATEDARK, 7502, mtbl, signal

	- obtain dark signal for a given orbit=7502, channel=2: 
       IDL> GET_SDMF_STATEDARK, 7502, mtbl, signal, channel=2

	- obtain dark signal of channel 1 for a given orbit range: 
       IDL> GET_SDMF_STATEDARK, [11000,12000], mtbl, signal, channel=1

	- obtain dark signal for a given pixel=100 (all orbits): 
       IDL> GET_SDMF_STATEDARK, -1, mtbl, signal, pixel=100

       - obtain dark signal for a given pixel=100 for selected orbit range: 
       IDL> GET_SDMF_STATEDARK, [11000,12000], mtbl, signal, pixel=100

 MODIFICATION HISTORY:
 	Written by:	R.M. van Hees (SRON), 26-01-2010

(See get_sdmf_statedark.pro)


GOME_LV1_FREE_FCD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GOME_LV1_FREE_FCD

 PURPOSE:
       release pointers in structure FCD_GOME

 CATEGORY:
       GOME level 1b data

 CALLING SEQUENCE:
       GOME_LV1_FREE_FCD, fcd

 INPUTS:
       mds :    structure for Measurement Data Sets (level 1c format)

 EXAMPLES:
       None

 REFERENCE:
       Product Specification Document
	of the GOME Data Processor
	Ref. ER-PS-DLR-GO-0016
	     Iss./Rev.3/C

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 30 Januari 2009
                    moved from gome_lv1_rd_fcd.pro to seperate module
       Modified:  RvH, 26 Febuari 2009
                    optimized the code for speed

(See gome_lv1_free_fcd.pro)


GOME_LV1_PCD_PMD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GOME_LV1_PCD_PMD

 PURPOSE:
       grep/calibrate Earth PMD data from a GOME Level 1b product

 CATEGORY:
       GOME level 1b

 CALLING SEQUENCE:
       gome_lv1_pcd_pmd, fsr, pcd, calibration=calibration, status=status

 INPUTS:
       fsr :    structure with File Structure Record
       pcd :    structure with the Pixel Specific Calibration Records

 KEYWORD PARAMETERS:
   status    :  returns named variable with error status (0 = ok)
  calibration:  string describing the calibration to be applied
                  (default or -1: no calibration of the PMD data)

               L : correct for fixed-pattern noise and leakage current
               P : correct signals for polarisation sensitivity
               I : absolute radiance calibration (Watt/(s cm^2 sr nm)
               U : unit conversion to photons/(s cm^2 sr nm)
             all : apply default calibration (='LPI')

 EXAMPLES:
       None

 REFERENCE:
       Product Specification Document
	of the GOME Data Processor
	Ref. ER-PS-DLR-GO-0016
	     Iss./Rev.3/C

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), April 2003

(See gome_lv1_pcd_pmd.pro)


GOME_LV1_RD_BDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GOME_LV1_RD_BDR

 PURPOSE:
       read/calibrate Earth Band Data Records from a GOME Level 1b product

 CATEGORY:
       GOME level 1b

 CALLING SEQUENCE:
       gome_lv1_rd_bdr, nband, fsr, pcd, rec, 
                        calibration=calibration, posit=posit, status=status

 INPUTS:
       nband :  integer with number of spectral band [1a=0,1b,2a..]
       fsr :    structure with File Structure Record
       pcd :    structure with the Pixel Specific Calibration Records

 OUTPUTS:
       rec :    structure with Spectral Band Records

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)
  calibration: string describing the calibration to be applied
                (default or -1: no calibration of the MDS data)

               L : correct for fixed-pattern noise and leakage current
               A : correct band 1a for cross-talk of the Peltier coolers
               F : correct signals for pixel-to-pixel variations
               S : correct signals for stray-light
               N : normalise the signals to 1 second integration time
               P : correct signals for polarisation sensitivity
               I : absolute radiance calibration (Watt/(s cm^2 sr nm)
               U : unit conversion to photons/(s cm^2 sr nm)
             all : apply default calibration (='LAFSNPIU')
     posit :    scalar of type integer with the index of an PCD 
                record specifying the Spectral Band Record to be
                extracted, starting at zero
 EXAMPLES:
       None

 REFERENCE:
       Product Specification Document
	of the GOME Data Processor
	Ref. ER-PS-DLR-GO-0016
	     Iss./Rev.3/C

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), March 2003

(See gome_lv1_rd_bdr.pro)


GOME_LV1_RD_FCD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GOME_LV1_RD_FCD

 PURPOSE:
       read Fixed Calibration Data Record from a PDS GOME Level 1b product

 CATEGORY:
       GOME level 1b

 CALLING SEQUENCE:
       gome_lv1_rd_fcd, fcd, status=status

 INPUTS:
       fcd :    structure with Fixed Calibration Data

 OUTPUTS:
       fcd :    structure with the Fixed Calibration Data Record

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       Product Specification Document
	of the GOME Data Processor
	Ref. ER-PS-DLR-GO-0016
	     Iss./Rev.3/C

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), March 2003
       Modified:  RvH, 18 August 2003
                    added function GOME_LV1_FREE_FCD
       Modified:  RvH, 15 December 2004
                    (NEW!) read the whole FCD structure
       Modified:  RvH, 30 Januari 2009
                    moved function GOME_LV1_FREE_FCD to seperate module

(See gome_lv1_rd_fcd.pro)


GOME_LV1_RD_FSR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GOME_LV1_RD_FSR

 PURPOSE:
       read File Structure Record from a PDS GOME Level 1b product

 CATEGORY:
       GOME level 1b

 CALLING SEQUENCE:
       gome_lv1_rd_fsr, fsr, status=status

 OUTPUTS:
       fsr :    structure with the File Structure Record

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       Product Specification Document
	of the GOME Data Processor
	Ref. ER-PS-DLR-GO-0016
	     Iss./Rev.3/C

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), March 2003

(See gome_lv1_rd_fsr.pro)


GOME_LV1_RD_PCD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GOME_LV1_RD_PCD

 PURPOSE:
       read Pixel Specific Calibration Records from a GOME Level 1b product

 CATEGORY:
       GOME level 1b

 CALLING SEQUENCE:
       gome_lv1_rd_pcd, fsr, sph, pcd, status=status

 INPUTS:
       fsr :    structure with the File Structure Record
       sph :    structure with the Specific Product Header

 OUTPUTS:
       pcd :    structure with the Pixel Specific Calibration Records

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       Product Specification Document
	of the GOME Data Processor
	Ref. ER-PS-DLR-GO-0016
	     Iss./Rev.3/C

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), March 2003

(See gome_lv1_rd_pcd.pro)


GOME_LV1_RD_SMBDR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GOME_LV1_RD_SMBDR

 PURPOSE:
       read/calibrate Sun Calibration Records from a GOME Level 1b product

 CATEGORY:
       GOME level 1b

 CALLING SEQUENCE:
       gome_lv1_rd_smbdr, nband, fsr, pcd, rec, 
                        calibration=calibration, posit=posit, status=status

 INPUTS:
       nband :  integer with number of spectral band [1a=0,1b,2a..]
       fsr :    structure with File Structure Record
       pcd :    structure with the Pixel Specific Calibration Records

 OUTPUTS:
       rec :    structure with Spectral Band Records

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)
  calibration: string describing the calibration to be applied
                (default or -1: no calibration of the MDS data)

               L : correct for fixed-pattern noise and leakage current
               A : correct band 1a for cross-talk of the Peltier coolers
               F : correct signals for pixel-to-pixel variations
               S : correct signals for stray-light
               N : normalise the signals to 1 second integration time
               P : correct signals for polarisation sensitivity
               I : absolute radiance calibration (Watt/(s cm^2 sr nm)
               U : unit conversion to photons/(s cm^2 sr nm)
             all : apply default calibration (='LAFSNPIU')
     posit :    scalar of type integer with the index of an PCD 
                record specifying the Spectral Band Record to be
                extracted, starting at zero
 EXAMPLES:
       None

 REFERENCE:
       Product Specification Document
	of the GOME Data Processor
	Ref. ER-PS-DLR-GO-0016
	     Iss./Rev.3/C

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), March 2003

(See gome_lv1_rd_smbdr.pro)


GOME_LV1_RD_SMCD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GOME_LV1_RD_SMCD

 PURPOSE:
       read Sun/Moon Calibration Records from a GOME Level 1b product

 CATEGORY:
       GOME level 1b

 CALLING SEQUENCE:
       gome_lv1_rd_smcd, fsr, sph, smcd, status=status

 INPUTS:
       source : string with value 'sun' of 'moon'
       fsr :    structure with the File Structure Record
       sph :    structure with the Specific Product Header

 OUTPUTS:
       smcd :    structure with the Pixel Specific Calibration Records

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       Product Specification Document
	of the GOME Data Processor
	Ref. ER-PS-DLR-GO-0016
	     Iss./Rev.3/C

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), March 2003

(See gome_lv1_rd_smcd.pro)


GOME_LV1_RD_SPH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GOME_LV1_RD_SPH

 PURPOSE:
       read Specific Product Header from a PDS GOME Level 1b product

 CATEGORY:
       GOME level 1b

 CALLING SEQUENCE:
       gome_lv1_rd_sph, fsr, sph, status=status

 INPUTS:
       fsr :    structure with the File Structure Record

 OUTPUTS:
       sph :    structure with the Specific Product Header

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       Product Specification Document
	of the GOME Data Processor
	Ref. ER-PS-DLR-GO-0016
	     Iss./Rev.3/C

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), March 2003

(See gome_lv1_rd_sph.pro)


GOME_LV1_SMCD_PMD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       GOME_LV1_SMCD_PMD

 PURPOSE:
       grep/calibrate Sun/Moon PMD data from a GOME Level 1b product

 CATEGORY:
       GOME level 1b

 CALLING SEQUENCE:
       gome_lv1_smcd_pmd, fsr, smcd, calibration=calibration, $
                status=status

 INPUTS:
       fsr :    structure with File Structure Record
       smcd :   structure with the Pixel Specific Calibration Records

 KEYWORD PARAMETERS:
   status    :  returns named variable with error status (0 = ok)
  calibration:  string describing the calibration to be applied
                  (default or -1: no calibration of the PMD data)

               L : correct for fixed-pattern noise and leakage current
               P : correct signals for polarisation sensitivity
               I : absolute radiance calibration (Watt/(s cm^2 sr nm)
               U : unit conversion to photons/(s cm^2 sr nm)
             all : apply default calibration (='LPI')

 EXAMPLES:
       None

 REFERENCE:
       Product Specification Document
	of the GOME Data Processor
	Ref. ER-PS-DLR-GO-0016
	     Iss./Rev.3/C

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), April 2003

(See gome_lv1_smcd_pmd.pro)


NADC_ERR_CLEAR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       NADC_ERR_CLEAR

 PURPOSE:
       clear current error stack of the underlaying C-routines

 CATEGORY:
       error handling

 CALLING SEQUENCE:
       NADC_ERR_CLEAR

 KEYWORD PARAMETERS:

 EXAMPLES:

 REFERENCE:

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), 28 June 2002

(See nadc_err_clear.pro)


NADC_ERR_TRACE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       NADC_ERR_TRACE

 PURPOSE:
       Display error messages produced by underlaying C-routines

 CATEGORY:
       error handling

 CALLING SEQUENCE:
       NADC_ERR_TRACE, /No_Exit

 KEYWORD PARAMETERS:
   No_Exit :    do not return control to the main program level

 EXAMPLES:


 REFERENCE:


 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002

(See nadc_err_trace.pro)


SCIA_APPLY_MEMCORR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_APPLY_MEMCORR

 PURPOSE:
	apply memory correction on cluster data

 CATEGORY:
	SCIAMACHY

 CALLING SEQUENCE:
	SCIA_APPLY_MEMCORR, state_id, coaddf, pet, pixel_ids, pixel_val, $
                           memcorr=memcorr, reset=reset

 INPUTS:
   state_id:   scalar (integer) with State ID (range 1..70)
     coaddf:	scalar (integer) with co-adding factor of data
        pet:   scalar (float) with pixel exposure time
  pixel_ids:   array with pixel numbers of data (range 0..8191)
  pixel_val:   array with read_outs of a cluster

 KEYWORD PARAMETERS:
    MEMCORR:	apply memory correction on Reticon data 
               (channel 1-5), a named variable can be used to
               speed-up a next call

      RESET:	calculate correction of first readout after a state
               reset. Always use this keyword, except when the scan
               is incomplete, in particular, for the SDMF databases

               IMPORTANT: value for reset should be orbit number, or
               the leakage current of orbit 20000 will be used

 OUTPUTS:
	This function corrects the data of a cluster (chan 1-5) for
	memory effects

 EXAMPLE:
	To Do !!!

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), 15 January 2009
       Modified:  RvH, 20 January 2009
                       Use State setup time to correct first readout
       Modified:  RvH, 18 May 2010
                       Improved algorithm to correct first readout of state

(See scia_apply_memcorr.pro)


SCIA_APPLY_NLINCORR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_APPLY_NLINCORR

 PURPOSE:
	apply non-linearity correction on cluster data

 CATEGORY:
	SCIAMACHY

 CALLING SEQUENCE:
	SCIA_APPLY_NLINCORR, coaddf, pixel_ids, pixel_val, nlincorr=nlincorr

 INPUTS:
     coaddf:	scalar (byte) with co-adding factor of data
  pixel_ids:   array with pixel numbers of data (range [0,8191])
  pixel_val:   array with read_outs of a cluster

 KEYWORD PARAMETERS:
   NLINCORR:	apply non-linearity correction on Epitaxx data 
               (channel 6-8), a named variable can be used to
               speed-up a next call

 OUTPUTS:
	This function corrects the data of a cluster (chan 6-8) for
	non-linearity effects

 EXAMPLE:
	To Do !!!

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), 15 January 2009

(See scia_apply_nlincorr.pro)


SCIA_DATE2MJD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_DATE2MJD

 PURPOSE:
        Sciamachy date conversion routine

 CALLING SEQUENCE:
       Result  = SCIA_DATE2MJD( date_str )

 INPUTS:
  date_str :    string in format dd/mm/yyyy hh:mm:ss.ssssss

 OUTPUTS:
  mjd      :    structure holding the modified julian time for year 2000

 EXAMPLES:
       None

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002

(See scia_date2mjd.pro)


SCIA_FCLOSE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_FCLOSE

 PURPOSE:
       general interface to open and close file, using a "C" FILE pointer

 CATEGORY:
       file handling

 CALLING SEQUENCE:
       stat = SCIA_FCLOSE

 INPUTS:
    flname :    string with the name of the file

 RETURNS:
      stat :    error status (0 = ok)

 EXAMPLES:
       stat = SCIA_FOPEN( flname_1 ) // opens the file with name flname_1
       .
       .   // read data sets from flname_1
       .
       stat = SCIA_FOPEN( flname_2 ) // closes flname_1, opens flname_2
       .
       .   // read data sets from flname_2
       .
       stat = SCIA_FCLOSE ()

 REFERENCE:
       

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 31 May 2002
                    renamed module to scia_fopen
       Modified:  RvH, 27 June 2002
                    moved scia_fclose to a separate module

(See scia_fclose.pro)


SCIA_FOPEN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_FOPEN

 PURPOSE:
       general interface to open and close file, using a "C" FILE pointer

 CATEGORY:
       file handling

 CALLING SEQUENCE:
       stat = SCIA_FOPEN( flname )

 INPUTS:
    flname :    string with the name of the file

 RETURNS:
      stat :    error status (0 = ok)

 EXAMPLES:
       stat = SCIA_FOPEN( flname_1 ) // opens the file with name flname_1
       .
       .   // read data sets from flname_1
       .
       stat = SCIA_FOPEN( flname_2 ) // closes flname_1, opens flname_2
       .
       .   // read data sets from flname_2
       .
       stat = SCIA_FCLOSE ()

 REFERENCE:
       

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 31 May 2002
                    renamed module to scia_fopen
       Modified:  RvH, 27 June 2002
                    moved scia_fclose to a separate module

(See scia_fopen.pro)


SCIA_HL_LV0_MDS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_HL_LV0_MDS

 PURPOSE:
	This function reads detector readouts for given stateID,
	stateIndex and channelID from a Sciamachy level 0 product

 CATEGORY:
	NADC_TOOLS - SCIAMACHY - LEVEL 0

 CALLING SEQUENCE:
	Result = SCIA_HL_LV0_MDS( flname, stateID, clusID )

 INPUTS:
      flname  :  Filename of the Sciamachy level 0 product

      stateID :  state ID of data to be selected (scalar)

       clusID :  cluster Index of science data to be selected (scalar)

 KEYWORD PARAMETERS:
  STATEINDEX :  index of state, use zero for the first occurrence of
                this state (with ID stateID) in the product

         PMD :  add PMD data to output structure
                - currently, the ouput only contains the collocated
                  PMD readouts. This should be all PMD readouts
                  within the integration time of the detector readout

         AUX :  add Auxiliary data to the output structure

 CALIBRATION :  string describing the calibration to be applied
                (default or -1: no calibration of the MDS data)

                0 : Memory effect
                    - coadded readouts are not corrected using PMD readouts
                1 : Dark current correction
                9 : Bad/Dead pixel mask

      status :  returns named variable with error status (0 = ok)

 OUTPUTS:
	This function returns the detector readouts of states with
	state ID equals stateID and channel ID equals chanID. By
	default the output structure contains the following elements:
         * science: float array with (calibrated) channel data
         * pixelID  unsigned int array with pixel IDs
         * jday:    double scalar with modified (decimal) Julian date
                    for the year 2000 
         * pet:     float scalar with pixel exposure time (sec)
         * clusID   byte scalar with cluster index
         * coaddf   byte scalar with coadd-factor
         * detTemp  float scalar with temperature of Detector block (K)

       keyword PMD will add the following elements:
         * pmd:     float array with the integrated PMD values
         * pmdTemp: float scalar with temperature PMD block (K)

       keyword AUX will add the following elements:
         * obmTemp: float scalar with temperature of optical bench (K)
         * asm:     float scalar with azimuth scan mirror position (degrees)
         * esm:     float scalar with elevation scan mirror position (degrees)

 PROCEDURE:
	<add text here>

 EXAMPLE:
       +++++ read data of cluster 55 from all Nadir states in a file +++++
	clus = scia_hl_lv0_mds( sciafl, 1, 55, calib='0,1,9' )
       FOR ii = 2,7 DO BEGIN
          clus_0 = scia_hl_lv0_mds( sciafl, ii, 55, calib='0,1,9' )
          IF SIZE( clus_0, /TNAME ) EQ 'STRUCT' THEN clus = [clus,clus_0]
       ENDFOR
       clus = clus[SORT(clus.jday)]

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), 10 October 2006
       Modified:       implemented correction for the obital
                       variation of darkcurrent [RvH (SRON), Oct 2006]
       Modified:       bugfix in collocating asm/esm angles, 
                       [RvH (SRON), June 2007]
       Modified:       use SCIA_APPLY_MEMCORR and SCIA_APPLY_NLINCORR
                       [RvH (SRON), Jan 2009]

(See scia_hl_lv0_mds.pro)


SCIA_HL_LV0_PIXELS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_HL_LV0_PIXELS

 PURPOSE:
	This function reads detector readouts for given channelID and
	pixelID from a sciamachy level 0 product

 CATEGORY:
	NADC_TOOLS - SCIAMACHY - LEVEL 0

 CALLING SEQUENCE:
	Result = SCIA_HL_LV0_PIXELS( flname, chanID, pixelID, jday=jday )

 INPUTS:
      flname :  Filename of the Sciamachy level 0 product

      chanID :  Channel ID

     pixelID :  Pixel ID

 KEYWORD PARAMETERS:
       coadd :  divide pixel counts by co-adding factor

        norm :  divide pixel counts by co-adding factor times pixel
                exposure time

      status :  returns named variable with error status (0 = ok)

 OUTPUTS:
	This function returns the detector readouts for a given
	channel and pixelID

 PROCEDURE:
	<add text here>

 EXAMPLE:
	<add examples here>

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), 30 August 2005
       Modified:  RvH, 31 August 2005
                    added keywords COADD and NORM

(See scia_hl_lv0_pixels.pro)


SCIA_HL_LV1_MDS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_HL_LV1_MDS

 PURPOSE:
	This function reads detector readouts for given stateID,
	stateIndex and clusterID from a Sciamachy level 1 product

 CATEGORY:
	NADC_TOOLS - SCIAMACHY - LEVEL 1

 CALLING SEQUENCE:
	Result = SCIA_HL_LV1_MDS( flname, stateID, clusterID )

 INPUTS:
      flname  :  Filename of the Sciamachy level 0 product

      stateID :  state ID of data to be selected (scalar)

    clusterID :  cluster ID of science data to be selected (scalar)

 KEYWORD PARAMETERS:
  STATEINDEX :  index of state, use zero for the first occurrence of
                this state (with ID stateID) in the product

       ERROR :  add estimate the total relative accuracy on the
                measured signal 

     FRACPOL :  add fractional polarization data to output structure

         PMD :  add PMD data to output structure

  GEO_CORNER :  default is to write only the center coordinates from
                the geolocation information. Use this keyword to get
                the corner coordinates too.

 CALIBRATION :  string describing the calibration to be applied
                (default or -1: no calibration of the MDS data)

                0 : Memory Effect 
                1 : Leakage Correction 
                2 : PPG Correction 
                3 : Etalon Correction 
                4 : StrayLight Correction 
                5 : WaveLength Calibration 
                6 : Polarisation Sensitivity 
                7 : Radiance Sensitivity 
                8 : Division by Solar spectrum
                9 : Bad/Dead pixel mask

                This only works on level 1b products

      status :  returns named variable with error status (0 = ok)

 OUTPUTS:
	This function returns the detector readouts of states with
	stateID equals stateID and clusterID equals clusterID. By
	default the output structure contains the following elements:
         * science: float array with (calibrated) cluster data
         * wave:    float array with the cluster wavelength grid
         * jday:    double scalar with modified (decimal) Julian date
                    for the year 2000 
         * lat:     float scalar with the central latitude coordinate
         * lon:     float scalar with the central longitude coordinate
         * sunz:    float scalar with the central Solar zenith angle
         * pet:     float scalar with the pixel exposure time
         * coaddf   byte scalar with the coadd-factor

       keyword FRACPOL will add the following elements:
         * Q:       float array with fractional polarization values Q
         * U:       float array with fractional polarization values U
         * wv_pol:  float array with represented wavelength for Q and U
         * gdf:     float array with GDF parameters

       keyword PMD will add the following elements:
         * pmd:     float array with the integrated PMD values

 PROCEDURE:
	<add text here>

 EXAMPLE:
	<add examples here>

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), 02 September 2006

(See scia_hl_lv1_mds.pro)


SCIA_HL_LV1_PIXELS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_HL_LV1_PIXELS

 PURPOSE:
	This function reads detector readouts for given channelID and
	pixelID from a sciamachy level 1 product

 CATEGORY:
	NADC_TOOLS - SCIAMACHY - LEVEL 1

 CALLING SEQUENCE:
	Result = SCIA_HL_LV1_PIXELS( flname, chanID, pixelID, jday=jday )

 INPUTS:
      flname :  Filename of the Sciamachy level 1 product

      chanID :  Channel ID

     pixelID :  Pixel ID

 KEYWORD PARAMETERS:
       coadd :  divide pixel counts by co-adding factor

        norm :  divide pixel counts by co-adding factor times pixel
                exposure time

      status :  returns named variable with error status (0 = ok)

 OUTPUTS:
	This function returns the detector readouts for a given
	channel and pixelID

 PROCEDURE:
	<add text here>

 EXAMPLE:
	<add examples here>

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), 31 August 2005

(See scia_hl_lv1_pixels.pro)


SCIA_HL_OPEN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_HL_OPEN

 PURPOSE:
	Open a Sciamachy file and read the PDS headers: MPH, SPH and DSD

 CATEGORY:
	NADC Sciamachy high level API

 CALLING SEQUENCE:
	SCIA_HL_OPEN, flname, dsd, $
	              mph=mph, sph=sph, level=level, status=status 
 INPUTS:
	flname :    string with the name of the Sciamachy file

 KEYWORD PARAMETERS:
	mph:    Main Product Header
       sph:    Specific Product Header
       level:  data product level: '0', '1B', '1C', '2', 'UNKNOWN'
       status: 0 = OK, 
               use function NADC_ERR_TRACE to examine source of error

 OUTPUTS:
	dsd:    Data Set Descriptor records

 SIDE EFFECTS:
	After a succesful call the Sciamachy file is opened and can be
	closed using the function SCIA_FCLOSE

 PROCEDURE:

 EXAMPLE:

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), February (2004)

(See scia_hl_open.pro)


SCIA_LV0_FREE_DET

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV0_FREE_DET

 PURPOSE:
       release pointers in structure MDS0_DET

 CATEGORY:
       SCIA level 0 data

 CALLING SEQUENCE:
       SCIA_LV0_FREE_DET, mds_det

 INPUTS:
       mds_det :    structure with Detector MDS records (MDS0_DET)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
       Input/Output Data Definition
       Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 30 Januari 2009
                    moved from scia_lv0_rd_det.pro to seperate module
       Modified:  RvH, 26 Febuari 2009
                    optimized the code for speed

(See scia_lv0_free_det.pro)


SCIA_LV0_MDS_TREND

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV0_MDS_TREND

 PURPOSE:
       Extract level 0 MDS data, optionally correct Reticon memory
       effect, Epitaxx non-linarity and/or normalize data to one
       second integration time 

 CATEGORY:
       SCIAMACHY level 0

 CALLING SEQUENCE:
       data = SCIA_LV0_MDS_TREND( mds_det, channel, pixels=pixels,
                                  posit=posit, state_id=state_id,
                                  memcorr=memcorr, nlincorr=nlincorr,
                                  align=align, coadd=coadd, norm=norm, 
                                  status=status )
 INPUTS:
   mds_det :    Array of type Structure MDS0_DET
   channel :    scalar specifying the channel to be extracted,
                valid range = [1:8]

 KEYWORD PARAMETERS:
  state_id :    read only data from a selected state
                (default or -1: no selection state ID)
    pixels :    lower and/or upper boundary of the pixel numbers to
                be extracted, valid range = [0:1023]
                 pixels=[p1:p2]    extract pixels between p1 and p2
                 pixels=-p1        extract pixels between 0 and p1
                 pixels=p2         extract pixels between p2 and 1023
     posit :    relative index or index-range [low,high] to MDS record(s)
     align :    if set to a non-zero value, the output array reflects
                the detector array layout
   memcorr :    apply memory correction on Reticon data 
                (channel 1-5), a named variable can be used to
                speed-up a next call
  nlincorr :    apply non-linearity correction on Epitaxx data
                (channels 6-8), a named variable can be used to
                speed-up a next call
     coadd :    divide data with the co-adding factor
      norm :    normalize data to one second integration time 
    status :    returns named variable with error status (0 = ok)

 OUTPUTS:
       float array with reticon data corrected for memory effect

 SIDE EFFECTS:
       Memory correction (Reference: SRON-SCIA-PhE-RP-011):
       - the first readout is not corrected (no assuptions are made)
       - it is assumed that the signal over integration time =>
         signal/coadd is constant, and a good approximation for the
         individual readouts in a coadding sequence
       non-Linearity correction (Reference: SRON-SCIA-PhE-RP-013)

 PROCEDURE:

 EXAMPLE:
       - extract all channel 2 data
            data_out = SCIA_LV0_MDS_TREND( mds_det, 2 )
  the return array is a float array of size [1024,N_ELEMENTS(mds_det)]

       - extract all channel 2 data, detector array pixel number equals 100
            data_out = SCIA_LV0_MDS_TREND( mds_det, 2, pixels=[100,100] )

  the return array is a float array of size [N_ELEMENTS(mds_det)]

       - extract all channel 2 data, detector array pixel number equals 100
            data_out = SCIA_LV0_MDS_TREND( mds_det, 2,
                                           pixels=[100,100], /align )
  the return array is a float array of size [1024,N_ELEMENTS(mds_det)]

       - extract channel 2 data of MDS records between 2 and 100,
         detector array pixel number equals 100
            data_out = SCIA_LV0_MDS_TREND( mds_det, 2, pos=[2,100]
                                           pixels=[100,100], /align )
  the return array is a float array of size [1024,99]

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), 08 April 2002
       Modified:  RvH, 09 April 2002
                    updated documentation
       Modified:  RvH, 19 April 2002
                    handle virtual channels correctly
       Modified:  RvH, 15 May 2002
                    handle array range under/overrun requests using
                           keywords [posit] or [pixels] gracefully
       Modified:  RvH, 06 May 2003
                    more checks on mds_det and posit 
                    do not modify return values of mds_det and posit
       Modified:  RvH, 02 Dec 2003
                    - applied all suggestions made by G. Lichtenberg
                      ==> much improved memory correction
                    - added non-linearity correction
                    - memory correction no longer implies normalization!
                    - changed keyword-parameters.
       Modified:  RvH, 01 Mar 2004
                    - add option to divide with the coadd-factor
                    - handle empty selections gracefully   
       Modified:  RvH, 03 March 2004
                    fixed several bugs and did some code clean-ups
       Modified:  RvH, 31 March 2004
                    fixed bug: replaced REPLICATE with safer REPLICATE_INPLACE
       Modified:  RvH, 28 April 2004
                    One MDS with coaddf > 1 can be memory corrected
       Modified:  RvH, 30 November 2004
                    Speeding-up this code!
       Modified:  RvH, 17 May 2007
                    Replaced confusing error message
       Modified:  RvH, 16 January 2009
                    code clean-ups & bug-fixes
                    usage of SCIA_APPLY_MEMCORR and SCIA_APPLY_NLINCORR
       Modified:  RvH, 20 January 2009
                    Adopted modified parameters for SCIA_APPLY_MEMCORR

(See scia_lv0_mds_trend.pro)


SCIA_LV0_RD_AUX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV0_RD_AUX

 PURPOSE:
       read selected SCIAMACHY level 0 Auxiliary MDS

 CATEGORY:
       SCIAMACHY level 0

 CALLING SEQUENCE:
       SCIA_LV0_RD_AUX, info, mds_aux, period=period,
                        category=category, state_id=state_id, $
                        posit=posit, status=status

 INPUTS:
      info :    structure holding info about MDS records

 OUTPUTS:
   mds_aux :    structure with Auxiliary MDS records

 KEYWORD PARAMETERS:
  category :    read only selected category of measurements (scalar or array)
                (default or -1: all categories)
  state_id :    read only selected states (scalar or array)
                (default or -1: all states)
     posit :    relative index or index-range [low,high] to MDS record(s)
    period :    read only MDS within a time-window (scalar or array)
                  date must be given in decimal julian 2000 day
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       read mds_aux.pmtc_hdr.pmtc_1 bitfields:
           phase :  ISHFT((mds_aux.pmtc_hdr.pmtc_1 AND ISHFT(15U,4)),-4)
           ndfm  :  mds_aux.pmtc_hdr.pmtc_1 AND ISHFT(3U,0)
           ncwm  :  ISHFT((mds_aux.pmtc_hdr.pmtc_1 AND ISHFT(3U,14)),-14)
           apsm  :  ISHFT((mds_aux.pmtc_hdr.pmtc_1 AND ISHFT(3U,12)),-12)
           wls   :  ISHFT((mds_aux.pmtc_hdr.pmtc_1 AND ISHFT(3U,10)),-10)
           sls   :  ISHFT((mds_aux.pmtc_hdr.pmtc_1 AND ISHFT(3U,8)),-8)

 REFERENCE:
       Measurement data definition and format description for
       SCIAMACHY, volume 14. PO-ID-DOR-SY-0032

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, February 2002
                    added keyword posit
       Modified:  RvH, February 2002
                    added keyword period
       Modified:  RvH, 22 March 2002
                    debugged data set position selection
       Modified:  RvH, 26 March 2002
                    added keyword state_id & category
       Modified:  RvH, 24 March 2003
                    check: 0 <= posit[0] <= posit[1] < array-size
       Modified:  RvH, 22 March 2010
                    added keywords: state_posit, indx_state, num_state
                    use new function GET_LV0_MDS_STATE

(See scia_lv0_rd_aux.pro)


SCIA_LV0_RD_DET

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV0_RD_DET

 PURPOSE:
       read selected SCIAMACHY level 0 Detector MDS

 CATEGORY:
       SCIAMACHY level 0

 CALLING SEQUENCE:
       SCIA_LV0_RD_DET, info, mds_det, count=count, category=category, $
                        state_id=state_id, state_posit=state_posit, $
                        indx_state=indx_state, num_state=num_state, $
                        channels=channels, period=period, $
                        posit=posit, status=status, 

 INPUTS:
      info :    structure holding info about MDS records

 OUTPUTS:
   mds_det :    structure with Detector MDS records (MDS0_DET)

 KEYWORD PARAMETERS:
  count      :  number of selected MDS records
  category   :  read only selected category of measurements (scalar or array)
                (default or -1: all categories)
  state_id   :  read only selected states (scalar or array)
                (default or -1: all states)
  state_posit:  relative index/indices to the state record(s), this
                is last selection applied, only counting those MDS(s)
                which contain data (default or -1: all data)
  indx_state :  named variable which contains the indices to the
                original state records as defined in the level 1b/1c
                product
  num_state  :  named variable which contains the number of selected states
  channels   :  read only selected channels (scalar or array)
                (default or -1: all channels)
  period     :  read only MDS within a time-window (scalar or array)
                date must be given in decimal julian 2000 day
                (default or -1: all data)
  posit      :  relative index or index-range [low,high] to MDS record(s)
  status     :  returns named variable with error status (0 = ok)

 SIDE EFFECTS:
       mds_det contains pointers to data. These have to be handled
       carefully. The routine SCIA_LV0_FREE_DET should be used to
       release heap variables allocated by SCIA_LV0_RD_DET. The
       program SCIA_LV0_RD_DET may be called more than once, using
       the same output variable, because any valid pointer associated
       with the output variable will be released using
       SCIA_LV0_FREE_DET 

 EXAMPLES:
       - read all Detector MDS 
         (on exit, status should be equal to zero):
       SCIA_LV0_RD, info, det, status=status

       - release all memory allocated by the previous read action:
       SCIA_LV0_FREE_DET, det

       - readl all infra red Detector MDS
       SCIA_LV0_RD, info, det, status=status, channel=[6,7,8]

       - read only Nadir pointing measurements
       SCIA_LV0_RD, info, det, status=status, category=1

       - read only Detector MDS of particular state, within a time
         window, and of these only the 2-nd and the fifth.
       SCIA_LV0_RD, info, det, status=status, state_id=[3,65,70],
       period=[702.6245629035,702.7645189], posit=[2,5]

       - Read bitfield "packet_hdr.api"
       vcid    = ISHFT(packet_hdr.api, -5) AND (NOT ISHFT(NOT 0us, 5))
       op_mode = packet_hdr.api AND (NOT ISHFT(NOT 0us, 5))

       - Read bitfield "data_hdr.rvd"
       config_id = ISHFT(data_hdr.rvd, -8)
       hsm       = ISHFT(data_hdr.rvd, -6) AND (NOT ISHFT(NOT 0us, 2))
       atc_id    = data_hdr.rvd AND (NOT ISHFT(NOT 0us, 6))

       - Read bitfield "data_hdr.id"
        = ISHFT(data_hdr.id, -4) AND (NOT ISHFT(NOT 0us, 4))
        = ISHFT(data_hdr.id, -8) AND (NOT ISHFT(NOT 0us, 4))

       - Read bitfield "pmtc_hdr.pmtc_1"
       ncwm  = ISHFT(pmtc_hdr.pmtc_1, -14)
       apsm  = ISHFT(pmtc_hdr.pmtc_1, -12) AND (NOT ISHFT(NOT 0us, 2))
       wls   = ISHFT(pmtc_hdr.pmtc_1, -10) AND (NOT ISHFT(NOT 0us, 2))
       sls   = ISHFT(pmtc_hdr.pmtc_1, -8) AND (NOT ISHFT(NOT 0us, 2))
       phase = ISHFT(pmtc_hdr.pmtc_1, -2) AND (NOT ISHFT(NOT 0us, 4))
       ndfm  = pmtc_hdr.pmtc_1 AND (NOT ISHFT(NOT 0us, 2))

       - Read bitfield "pmtc_hdr.az_param"
       type   = ISHFT(pmtc_hdr.az_param, -31)
       centre = ISHFT(pmtc_hdr.az_param, -30) AND (NOT ISHFT(NOT 0us, 1))
       filter = ISHFT(pmtc_hdr.az_param, -29) AND (NOT ISHFT(NOT 0us, 1))
       invert = ISHFT(pmtc_hdr.az_param, -28) AND (NOT ISHFT(NOT 0us, 1))
       corr   = ISHFT(pmtc_hdr.az_param, -24) AND (NOT ISHFT(NOT 0us, 1))
       rel    = ISHFT(pmtc_hdr.az_param, -20) AND (NOT ISHFT(NOT 0us, 4))
       h_w    = ISHFT(pmtc_hdr.az_param, -16) AND (NOT ISHFT(NOT 0us, 4))
       basic  = ISHFT(pmtc_hdr.az_param, -12) AND (NOT ISHFT(NOT 0us, 4))
       repeat = pmtc_hdr.az_param AND (NOT ISHFT(NOT 0us, 12))

       - Read bitfield "pmtc_hdr.elv_param"
       centre = ISHFT(pmtc_hdr.elv_param, -30) AND (NOT ISHFT(NOT 0us, 1))
       filter = ISHFT(pmtc_hdr.elv_param, -29) AND (NOT ISHFT(NOT 0us, 1))
       invert = ISHFT(pmtc_hdr.elv_param, -28) AND (NOT ISHFT(NOT 0us, 1))
       corr   = ISHFT(pmtc_hdr.elv_param, -24) AND (NOT ISHFT(NOT 0us, 4))
       rel    = ISHFT(pmtc_hdr.elv_param, -20) AND (NOT ISHFT(NOT 0us, 4))
       basic  = ISHFT(pmtc_hdr.elv_param, -12) AND (NOT ISHFT(NOT 0us, 4))
       repeat = pmtc_hdr.elv_param AND (NOT ISHFT(NOT 0us, 12))

       - Read bitfield "hdr.channel"
       clusters = ISHFT(hdr.channel, -8)
       chan_id  = ISHFT(hdr.channel, -4) AND (NOT ISHFT(NOT 0us, 4))
       is       = ISHFT(hdr.channel, -2) AND (NOT ISHFT(NOT 0us, 2))
       lu       = hdr.channel AND (NOT ISHFT(NOT 0us, 2))
       
       - Read bitfield "hdr.ratio_hdr"
       frame  = ISHFT(hdr.ratio_hdr, -8)
       ratio  = ISHFT(hdr.ratio_hdr, -3) AND (NOT ISHFT(NOT 0us, 5))
       status = hdr.ratio_hdr AND (NOT ISHFT(NOT 0us, 3))
 
       - Read bitfield "hdr.command_vis"
       etf   = ISHFT( hdr.command_vis, -18)
       mode  = ISHFT(hdr.command_vis, -16) AND (NOT ISHFT(NOT 0us, 2))
       sec   = ISHFT(hdr.command_vis, -7) AND (NOT ISHFT(NOT 0us, 9))
       ratio = ISHFT(hdr.command_vis, -2) AND (NOT ISHFT(NOT 0us, 5))
       cntrl = hdr.command_vis AND (NOT ISHFT(NOT 0us, 2))
       
       - Read bitfield "hdr.command_ir"
       etf   = ISHFT(hdr.command_ir, -18)
       mode  = ISHFT(hdr.command_ir, -16) AND (NOT ISHFT(NOT 0us, 2))
       comp  = ISHFT(hdr.command_ir, -14) AND (NOT ISHFT(NOT 0us, 2))
       bias  = ISHFT(hdr.command_ir, -8) AND (NOT ISHFT(NOT 0us, 3))
       pet   = ISHFT(hdr.command_ir, -2) AND (NOT ISHFT(NOT 0us, 4))
       cntrl = hdr.command_ir AND (NOT ISHFT(NOT 0us, 3))

 REFERENCE:
       Measurement data definition and format description for
       SCIAMACHY, volume 14. PO-ID-DOR-SY-0032

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, February 2002
                    Uses the new function GET_KEY_CHAN_HDR
       Modified:  RvH, February 2002
                    added keyword posit
       Modified:  RvH, 19 March 2002
                    obsoletes function GET_KEY_CHAN_HDR, added examples
       Modified:  RvH, 21 March 2002
                    set keywords to -1 results in no selection
       Modified:  RvH, 22 March 2002
                    debugged data set position selection
       Modified:  RvH, 31 May 2002
                    added keyword count, which returns the number of
                    MDS records
       Modified:  RvH, 4 October 2002
                    modified struct chan_hdr: renamed "counter" to "bcps"
       Modified:  RvH, 25 February 2003
                    added check on negative "posit" values
       Modified:  RvH, 24 March 2003
                    check: 0 <= posit[0] <= posit[1] < array-size
       Modified:  RvH, 30 August 2005
                    fixed several "brown-paperbag" bugs:
                     - dit not release memeory properly
                     - did not select mds_det for given channel
   	Modified: JMK, 22 Feb 2010
   	  	     keyword added to return selected info, info_det
       Modified:  RvH, 22 March 2010
                    added keywords: state_posit, indx_state, num_state
                    use new function GET_LV0_MDS_STATE

(See scia_lv0_rd_det.pro)


SCIA_LV0_RD_MDS_INFO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV0_RD_MDS_INFO

 PURPOSE:
       query the contents a SCIAMACHY level 0 product

 CATEGORY:
       SCIAMACHY level 0

 CALLING SEQUENCE:
       SCIA_LV0_RD_MDS_INFO, flname, dsd, info, status=status

 INPUTS:
       flname :    string with the name of the Sciamachy file
       dsd    :    structure for the DSD records

 OUTPUTS:
      info    :    structure holding info about MDS records

 KEYWORD PARAMETERS:
   status     :    returns named variable with error status
                     0   = ok
                    > 0  = could not read all records from product
                    < 0  = product corrupt

 EXAMPLES:
       

 REFERENCE:
       

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 12 April 2002
                    added keywords: info_fl and write
       Modified:  RvH, 28 May 2002
                    exit when read fails
       Modified:  RvH, 04 December 2002
                    added bcps to info-struct, only for for mds0_det
       Modified:  RvH, 20 December 2002
                    bugfix: align the mds0_info structure
       Modified:  RvH, 16 Januari 2006
                    adopted new function call to C-routine 
                    SCIA_LV0_RD_MDS_INFO, modified keywords accordingly

(See scia_lv0_rd_mds_info.pro)


SCIA_LV0_RD_PMD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV0_RD_PMD

 PURPOSE:
       read selected SCIAMACHY level 0 PMD MDS

 CATEGORY:
       SCIAMACHY level 0

 CALLING SEQUENCE:
       SCIA_LV0_RD_PMD, info, mds_pmd, period=period,
                        category=category, state_id=state_id, $
                        posit=posit, status=status 

 INPUTS:
      info :    structure holding info about MDS records

 OUTPUTS:
   mds_pmd :    structure with PMD MDS records

 KEYWORD PARAMETERS:
  category :    read only selected category of measurements (scalar or array)
                (default or -1: all categories)
  state_id :    read only selected states (scalar or array)
                (default or -1: all states)
     posit :    relative index or index-range [low,high] to MDS record(s)
    period :    read only MDS within a time-window (scalar or array)
                  date must be given in decimal julian 2000 day
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       

 REFERENCE:
       Measurement data definition and format description for
       SCIAMACHY, volume 14. PO-ID-DOR-SY-0032

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, February 2002
                    added keyword posit
       Modified:  RvH, February 2002
                    added keyword period
       Modified:  RvH, 22 March 2002
                    debugged data set position selection
       Modified:  RvH, 26 March 2002
                    added keyword state_id & category
       Modified:  RvH, 24 March 2003
                    check: 0 <= posit[0] <= posit[1] < array-size
       Modified:  RvH, 22 March 2010
                    added keywords: state_posit, indx_state, num_state
                    use new function GET_LV0_MDS_STATE

(See scia_lv0_rd_pmd.pro)


SCIA_LV0_RD_SPH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV0_RD_SPH

 PURPOSE:
       read Specific Product Header from a PDS SCIAMACHY Level 0 product

 CATEGORY:
       SCIAMACHY level 0

 CALLING SEQUENCE:
       scia_lv0_rd_sph, mph, sph, status=status

 OUTPUTS:
       sph :    structure with the SPH

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)

 EXAMPLES:
       

 REFERENCE:
       

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002

(See scia_lv0_rd_sph.pro)


SCIA_LV1C_RD_CALOPT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1C_RD_CALOPT

 PURPOSE:
       read the calibration options GADS to SciaL1C

 CATEGORY:
       SCIA level 1c data

 CALLING SEQUENCE:
       SCIA_LV1C_RD_CALOPT, dsd, calopt, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      calopt :  structure for the calibration options

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), July 2002
       Modified:  RvH, 11 December 2002
                    rearranged elements of structure "cal_options"

(See scia_lv1c_rd_calopt.pro)


SCIA_LV1C_RD_MDS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1C_RD_MDS

 PURPOSE:
       read MDS of one state from a SCIAMACHY level 1c product

 CATEGORY:
       SCIA level 1c data

 CALLING SEQUENCE:
       SCIA_LV1C_RD_MDS, dsd, mds, status=status, NotFree=NotFree, $
              type_mds=type_mds, category=category, state_id=state_id, $
              period=period, geolocation=geolocation, NoSAA=NoSAA, $
              indx_state=indx_state, num_state=num_state, $
              channels=channels, clusters=clusters, $
              pmd=pmd, polV=polV, NoMDS=NoMDS

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       mds :    structure for Measurement Data Sets (level 1c format)

 KEYWORD PARAMETERS:
    type_mds :  scalar of type integer to select MDS of type: 
                {!nadc.sciaNadir=1, !nadc.sciaLimb=2, $
                 !nadc.sciaOccult=3, !nadc.sciaMonitor=4}
    category :  read only selected category of measurements (scalar or array)
                (default or -1: all categories)
    state_id :  read only selected states (scalar or array)
                (default or -1: all states)
 geolocation :  vector of type float which defines the geografical
                region as [lat_min,lat_max,lon_min,lon_max] (using LADS)
       NoSAA :  set this keyword to inhibit to reject states with the
                SAA set (using SQADS) 
      period :  read only MDS within a time-window (scalar or array)
                date must be given in decimal julian 2000 day
                (default or -1: all data)
 state_posit :  relative index/indices to the state record(s), this
                is last selection applied, only counting those MDS(s)
                which contain data (default or -1: all data)
  indx_state :  named variable which contains the indices to the
                original state records as defined in the level 1b/1c
                product
   num_state :  named variable which contains the number of selected states

    channels :  read only selected channels (scalar or array)
                (default or -1: all channels)
    clusters :  read only selected clusters (scalar or array)
                (default or -1: all clusters)
         pmd : set this keyword to a named variable that will
                contain the level 1c PMD-MDS
        polV : set this keyword to a named variable that will
                contain the level 1c Polarisation values MDS
       NoMDS : set this keyword to inhibit reading of MDS data. On
                return the value of MDS will be zero
     NotFree : set this keyword to inhibit deallocation of the
                pointers in the input structure (Experts only!)
      status : named variable which contains the error status (0 = ok)

 SIDE EFFECTS:
       struct "mds" contains pointers to data. These have to be handled
       carefully. The routine SCIA_LV1_FREE_MDS should be used to
       release heap variables allocated by SCIA_LV1C_RD_MDS. The
       program SCIA_LV1C_RD_MDS may be called more than once, using
       the same output variable, because any valid pointer associated
       with the output variable will be released using
       SCIA_LV1_FREE_MDS

 EXAMPLES:
       - read all Limb states
       SCIA_LV1C_RD_MDS, dsd, mds, type_mds=!nadc.sciaLimb, status=status

       - read all Nadir states
       SCIA_LV1C_RD_MDS, dsd, mds, type_mds=!nadc.sciaNadir, status=status

       - read all Nadir states with state_id=7
       SCIA_LV1C_RD_MDS, dsd, mds, type_mds=!nadc.sciaNadir, $
                        state_id=7, status=status

        - as above, but read no MDS records only PMD-MDS records
       pmd = 1
       SCIA_LV1C_RD_MDS, dsd, mds, type_mds=!nadc.sciaNadir, $
                        state_id=7, status=status, /NoMDS, pmd=pmd

       - read all Nadir states with state_id=7, and return indices to
         occurrence of the state in the Scia product
       SCIA_LV1C_RD_MDS, dsd, mds, type_mds=!nadc.sciaNadir, $
                        state_id=7, indx_state=indx_state, status=status

       - read all Nadir states with state_id=7, only channels 7 & 8
       SCIA_LV1C_RD_MDS, dsd, mds, type_mds=!nadc.sciaNadir, $
                        state_id=7, channels=[7,8], status=status

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
       Input/Output Data Definition
       Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 6 August 2002
                    added keyword /NoMDS
       Modified:  RvH, 6 August 2002
                    complete rewrite
       Modified:  RvH, 2 August 2002
                    added selection of clusters
       Modified:  RvH, 9 September 2002
                    SCIA_LV1_RD_MDS: removed bug for option /NoMDS
       Modified:  RvH, 13 September 2002
                    SCIA_LV1_ONE_MDS: bugs for channel/cluster selection
       Modified:  RvH, 9 October 2002
                    SCIA_LV1C_ONE_MDS: Aaargh bug :-(
                    number of MDS could exceed number of clusters
       Modified:  RvH, 9 October 2002
                    GET_LV1_STATES: forgot to check "state.flag_mds"
       Modified:  RvH, 9 October 2002
                    SCIA_LV1_FREE_MDS: bug in TAG_NAMES test
       Modified:  RvH, 11 October 2002
                    the external functions are modified to return -1 
                    in case of an error. Thus now I check the return
                    value of LV1C_RD_MDS_PMD & LV1C_RD_MDS_POLV,
                    because a level 1c file may contain none of these
                    structures
       Modified:  RvH, 11 October 2002
                    SCIA_LV1_RD_MDS & SCIA_LV1C_RD_MDS, did not check
                    the variables returned by the reading routines
                    to be a structure
       Modified:  RvH, 31 October 2002
                    keywords PMD and POLV are checked with ARG_PRESENT
       Modified:  RvH, 15 November 2002
                    implemented new calibration options: Set_SCIA_Calib
       Modified:  RvH, 19 November 2002
                    check input file on data format: 1b or 1c, RvH
       Modified:  RvH, 19 November 2002
                    implemented new cluster mask routine: Set_SCIA_ClusMask
       Modified:  RvH, 11 December 2002
                    bugfix: incorrect use of CAL_OPTIONS for level 1c product
       Modified:  RvH, 12 December 2002
                    added option to calculate the reflectance
       Modified:  RvH, 16 April 2003
                    check number of state after calling GET_LV1_STATES
       Modified:  RvH, 17 April 2003
                    check if type_mds has a valid value
       Modified:  RvH, 12 May 2003
                    debugged MDS selection using type_mds;
                    silently ignore type_mds=-1
       Modified:  RvH, 2 Dec 2003
                    added integration time to structure polV for Thijs
       Modified:  RvH, 15 Mar 2004
                    added selection on SAA flag from SQADS
       Modified:  RvH, 22 Mar 2004
                    moved GET_LV1_STATES to separate module GET_LV1_MDS_STATE
                    added geolocation selection
                    removed obsolete paramter STATE
       Modified:  RvH, 31 Aug 2004
                    handle invalid cluster selection, gracefully
                    make sure we release MDS data from previous calls
       Modified:  RvH, 08 Dec 2004
                    bug fix: status=-1 when /NoMDS is used
                    added selection on orbit phase
       Modified:  RvH, 19 Jan 2005
                    bug fix: SCIA_LV1C_RD_POLV no need to use the
                    routine: CREATE_STRUCT
       Modified:  RvH, 07 Jul 2005
                    Do not stop reading data when the Level 1c
                    product doesn't contain PMD/polV records
                    and the keywords PMD or POLV are used
       Modified:  RvH, 07 December 2005
                    renamed pixel_val_err to pixel_err
       Modified:  RvH, 16 Januari 2006
                    SCIA_LV1_FREE_MDS: did not release geoC for monitor MDS
       Modified:  RvH, 30 Januari 2009
                    put the different procedures in seperate modules

(See scia_lv1c_rd_mds.pro)


SCIA_LV1_FREE_MDS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_FREE_MDS

 PURPOSE:
       release pointers in structure MDS1C_SCIA

 CATEGORY:
       SCIA level 1b and 1c data

 CALLING SEQUENCE:
       SCIA_LV1_FREE_MDS, mds

 INPUTS:
       mds :    structure for Measurement Data Sets (level 1c format)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
       Input/Output Data Definition
       Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 30 Januari 2009
                    moved from scia_lv1_rd_mds.pro to seperate module
       Modified:  RvH, 26 Febuari 2009
                    optimized the code for speed

(See scia_lv1_free_mds.pro)


SCIA_LV1_FREE_PMD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_FREE_PMD

 PURPOSE:
       release pointers in structure MDS1C_PMD

 CATEGORY:
       SCIA level 1b and 1c data

 CALLING SEQUENCE:
       SCIA_LV1_FREE_PMD, pmd

 INPUTS:
       pmd :    structure for PMD Measurement Data Sets (level 1c format)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
       Input/Output Data Definition
       Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 30 Januari 2009
                    moved from scia_lv1_rd_mds.pro to seperate module
       Modified:  RvH, 26 Febuari 2009
                    optimized the code for speed

(See scia_lv1_free_pmd.pro)


SCIA_LV1_FREE_POLV

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_FREE_POLV

 PURPOSE:
       release pointers in structure MDS1C_POLV

 CATEGORY:
       SCIA level 1b and 1c data

 CALLING SEQUENCE:
       SCIA_LV1_FREE_POLV, polv

 INPUTS:
       polv :    structure for Polarisation Measurement Data Sets

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
       Input/Output Data Definition
       Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 30 Januari 2009
                    moved from scia_lv1_rd_mds.pro to seperate module
       Modified:  RvH, 26 Febuari 2009
                    optimized the code for speed

(See scia_lv1_free_polv.pro)


SCIA_LV1_RD_ASFP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_ASFP

 PURPOSE:
       read Small Aperture Slit function parameters

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_ASFP, dsd, asfp, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
     asfp  :    structure for ASFP parameters

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_asfp.pro)


SCIA_LV1_RD_AUX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_AUX

 PURPOSE:
       read level 0 Auxiliary Data Packets

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_AUX, dsd, aux, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       aux :    structure for Auxiliary data packets

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 15 Novemeber 2002
                    a SCIA file may contain no Auxiliary DSD records at all!
       Modified:  RvH, 27 Novemeber 2002
                    bug fix: wrong declaration of struct aux_scia

(See scia_lv1_rd_aux.pro)


SCIA_LV1_RD_BASE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_BASE

 PURPOSE:
       read the Precise Basis of the Spectral Calibration Parameters

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_BASE, dsd, base, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      base :     structure for the Spectral BASE

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_base.pro)


SCIA_LV1_RD_CLCP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_CLCP

 PURPOSE:
       read Leakage Current Parameters (constant fraction) records

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_CLCP, dsd, clcp, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      clcp :    structure for leakage current parameters (constant)

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_clcp.pro)


SCIA_LV1_RD_DARK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_DARK

 PURPOSE:
       read average of the Dark Measurements per State

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_DARK, dsd, dark, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors
   
 OUTPUTS:
      dark :    structure for average of the dark measurements

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:    check number of datasets RvH (SRON), March 2002

(See scia_lv1_rd_dark.pro)


SCIA_LV1_RD_EKD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_EKD

 PURPOSE:
       read Errors on Key Data

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_EKD, dsd, ekd, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       ekd :    structure for errors on key data

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_ekd.pro)


SCIA_LV1_RD_LCPN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_LCPN

 PURPOSE:
       read Leakage Current Parameters (newly calculated partial set)

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       scia_lv1_rd_lcpn, dsd, lcpn, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      lcpn :    structure for leakage current parameters

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), xxxx 200x
       Modified:    check number of datasets RvH (SRON), March 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_lcpn.pro)


SCIA_LV1_RD_MDS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_MDS

 PURPOSE:
       read MDS of one state from a SCIAMACHY level 1b product

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_MDS, dsd, mds, status=status, NotFree=NotFree, $
              type_mds=type_mds, category=category, state_id=state_id, $
              period=period, geolocation=geolocation, NoSAA=NoSAA, $
              indx_state=indx_state, num_state=num_state, $
              channels=channels, clusters=clusters, $
              calibration=calibration, OrbitPhase=OrbitPhase, $
              pmd=pmd, polV=polV, NoMDS=NoMDS

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       mds :    structure for Measurement Data Sets (level 1c format)

 KEYWORD PARAMETERS:
    type_mds :  scalar of type integer to select MDS of type: 
                {!nadc.sciaNadir=1, !nadc.sciaLimb=2, $
                 !nadc.sciaOccult=3, !nadc.sciaMonitor=4}
    category :  read only selected category of measurements (scalar or array)
                (default or -1: all categories)
    state_id :  read only selected states (scalar or array)
                (default or -1: all states)
  OrbitPhase :  selection on orbit phase, required are 2 values. The
                orbit phase seletion is based on "States of the Product"
 geolocation :  vector of type float which defines the geografical
                region as [lat_min,lat_max,lon_min,lon_max] (using LADS)
       NoSAA :  set this keyword to inhibit to reject states with the
                SAA set (using SQADS) 
      period :  read only MDS within a time-window (scalar or array)
                date must be given in decimal julian 2000 day
                (default or -1: all data)
 state_posit :  relative index/indices to the state record(s), this
                is last selection applied, only counting those MDS(s)
                which contain data (default or -1: all data)
  indx_state :  named variable which contains the indices to the
                original state records as defined in the level 1b/1c
                product
   num_state :  named variable which contains the number of selected states

    channels :  read only selected channels (scalar or array)
                (default or -1: all channels)
    clusters :  read only selected clusters (scalar or array)
                (default or -1: all clusters)
 calibration :  string describing the calibration to be applied
                (default or -1: no calibration of the MDS data)

                0 : Memory Effect 
                1 : Leakage Correction 
                2 : PPG Correction 
                3 : Etalon Correction 
                4 : StrayLight Correction 
                5 : WaveLength Calibration 
                6 : Polarisation Sensitivity 
                7 : Radiance Sensitivity 
                8 : Division by Solar spectrum
                9 : Bad/Dead pixel mask

         pmd : set this keyword to a named variable that will
                contain the level 1c PMD-MDS
        polV : set this keyword to a named variable that will
                contain the level 1c Polarisation values MDS
       NoMDS : set this keyword to inhibit reading of MDS data. On
                return the value of MDS will be zero
     NotFree : set this keyword to inhibit deallocation of the
                pointers in the input structure (Experts only!)
      status : named variable which contains the error status (0 = ok)

 SIDE EFFECTS:
       struct "mds" contains pointers to data. These have to be handled
       carefully. The routine SCIA_LV1_FREE_MDS should be used to
       release heap variables allocated by SCIA_LV1_RD_MDS. The
       program SCIA_LV1_RD_MDS may be called more than once, using
       the same output variable, because any valid pointer associated
       with the output variable will be released using
       SCIA_LV1_FREE_MDS

 ENVIRONMENT VARIABLE "SCIA_CORR_LOS":
       The values of the level 1b line-of-sight zenith angles are
       always larger than zero, and the azimuth angle jumps with 180
       degrees while scanning through nadir. 
       Setting the environment variable "SCIA_CORR_LOS" to one will
       modify these values as follows: removing the jump in the
       azimuth angles and returns negative zenith angles, when the
       original azimuth angle was larger than 180 degree.

 EXAMPLES:
       - read all Limb states
       SCIA_LV1_RD_MDS, dsd, mds, type_mds=!nadc.sciaLimb, status=status

       - read all Nadir states
       SCIA_LV1_RD_MDS, dsd, mds, type_mds=!nadc.sciaNadir, status=status

       - read all Nadir states with state_id=7
       SCIA_LV1_RD_MDS, dsd, mds, type_mds=!nadc.sciaNadir, $
                        state_id=7, status=status

        - as above, but read no MDS records only PMD-MDS records
       pmd = 1
       SCIA_LV1_RD_MDS, dsd, mds, type_mds=!nadc.sciaNadir, $
                        state_id=7, status=status, /NoMDS, pmd=pmd

       - read all Nadir states with state_id=7, and return indices to
         occurrence of the state in the Scia product
       SCIA_LV1_RD_MDS, dsd, mds, type_mds=!nadc.sciaNadir, $
                        state_id=7, indx_state=indx_state, status=status

       - read all Nadir states with state_id=7, only channels 7 & 8
       SCIA_LV1_RD_MDS, dsd, mds, type_mds=!nadc.sciaNadir, $
                        state_id=7, channels=[7,8], status=status

       - read all Nadir states with state_id=7, only channels 7 & 8,
         apply calibration
       SCIA_LV1_RD_MDS, dsd, mds, type_mds=!nadc.sciaNadir, $
                        state_id=7, channels=[7,8], $
                        calibration='0,1,2,3,4,5,6', status=status

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
       Input/Output Data Definition
       Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 6 August 2002
                    added keyword /NoMDS
       Modified:  RvH, 6 August 2002
                    complete rewrite
       Modified:  RvH, 2 August 2002
                    added selection of clusters
       Modified:  RvH, 9 September 2002
                    SCIA_LV1_RD_MDS: removed bug for option /NoMDS
       Modified:  RvH, 13 September 2002
                    SCIA_LV1_ONE_MDS: bugs for channel/cluster selection
       Modified:  RvH, 9 October 2002
                    SCIA_LV1C_ONE_MDS: Aaargh bug :-(
                    number of MDS could exceed number of clusters
       Modified:  RvH, 9 October 2002
                    GET_LV1_STATES: forgot to check "state.flag_mds"
       Modified:  RvH, 9 October 2002
                    SCIA_LV1_FREE_MDS: bug in TAG_NAMES test
       Modified:  RvH, 11 October 2002
                    the external functions are modified to return -1 
                    in case of an error. Thus now I check the return
                    value of LV1C_RD_MDS_PMD & LV1C_RD_MDS_POLV,
                    because a level 1c file may contain none of these
                    structures
       Modified:  RvH, 11 October 2002
                    SCIA_LV1_RD_MDS & SCIA_LV1C_RD_MDS, did not check
                    the variables returned by the reading routines
                    to be a structure
       Modified:  RvH, 31 October 2002
                    keywords PMD and POLV are checked with ARG_PRESENT
       Modified:  RvH, 15 November 2002
                    implmented new calibration options: Set_SCIA_Calib
       Modified:  RvH, 19 November 2002
                    check input file on data format: 1b or 1c, RvH
       Modified:  RvH, 19 November 2002
                    implmented new cluster mask routine: Set_SCIA_ClusMask
       Modified:  RvH, 11 December 2002
                    bugfix: incorrect use of CAL_OPTIONS for level 1c product
       Modified:  RvH, 12 December 2002
                    added option to calculate the reflectance
       Modified:  RvH, 16 April 2003
                    check number of state after calling GET_LV1_STATES
       Modified:  RvH, 17 April 2003
                    check if type_mds has a valid value
       Modified:  RvH, 12 May 2003
                    debugged MDS selection using type_mds;
                    silently ignore type_mds=-1
       Modified:  RvH, 2 Dec 2003
                    added integration time to structure polV for Thijs
       Modified:  RvH, 15 Mar 2004
                    added selection on SAA flag from SQADS
       Modified:  RvH, 22 Mar 2004
                    moved GET_LV1_STATES to separate module GET_LV1_MDS_STATE
                    added geolocation selection
                    removed obsolete paramter STATE
       Modified:  RvH, 31 Aug 2004
                    handle invalid cluster selection, gracefully
                    make sure we release MDS data from previous calls
       Modified:  RvH, 08 Dec 2004
                    bug fix: status=-1 when /NoMDS is used
                    added selection on orbit phase
       Modified:  RvH, 19 Jan 2005
                    bug fix: SCIA_LV1C_RD_POLV no need to use the
                    routine: CREATE_STRUCT
       Modified:  RvH, 07 Jul 2005
                    Do not stop reading data when the Level 1c
                    product doesn't contain PMD/polV records
                    and the keywords PMD or POLV are used
       Modified:  RvH, 07 December 2005
                    renamed pixel_val_err to pixel_err
       Modified:  RvH, 16 Januari 2006
                    SCIA_LV1_FREE_MDS: did not release geoC for monitor MDS
       Modified:  RvH, 30 Januari 2009
                    put the different procedures in seperate modules

(See scia_lv1_rd_mds.pro)


SCIA_LV1_RD_PMD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_PMD

 PURPOSE:
       read PMD Data Packets

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_PMD, dsd, pmd, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       pmd :    structure for PMD data packets

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 15 Novemeber 2002
                    a SCIA file may contain no PMD DSD records at all!
       Modified:  RvH, 27 Novemeber 2002
                    bug fix: wrong declaration of struct pmd_scia

(See scia_lv1_rd_pmd.pro)


SCIA_LV1_RD_PPG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_PPG

 PURPOSE:
       read PPG/Etalon Parameters records

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_PPG, dsd, ppg, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       ppg :    structure with PPG/Etalon Parameters

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_ppg.pro)


SCIA_LV1_RD_PPGN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_PPGN

 PURPOSE:
       read PPG/Etalon Parameters (newly calculated)

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_PPGN, dsd, ppgn, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      ppgn :    structure for PPG/Etalon Parameters (new)

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000
       
 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:    check number of datasets RvH (SRON), March 2002

(See scia_lv1_rd_ppgn.pro)


SCIA_LV1_RD_PSPL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_PSPL

 PURPOSE:
       read Polarisation Sensitivity Parameters (Limb)

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_PSPL, dsd, pspl, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      pspl :    structure for Polarisation Sensitivity Parameters
                (limb)

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000
       
 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_pspl.pro)


SCIA_LV1_RD_PSPN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_PSPN

 PURPOSE:
       read Polarisation Sensitivity Parameters (Nadir)

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_PSPN, dsd, pspn, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      pspn :    structure for Polarisation Sensitivity Parameters

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_pspn.pro)


SCIA_LV1_RD_PSPO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_PSPO

 PURPOSE:
       read Polarisation Sensitivity Parameters (Occultation)

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_PSPO, dsd, pspo, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      pspo :    structure for Polarisation Sensitivity Parameters
                (occultation)

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000
       
 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_pspo.pro)


SCIA_LV1_RD_RSPL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_RSPL

 PURPOSE:
       read Radiance Sensitivity Parameters (Limb)

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_RSPL, dsd, rspl, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      rspl :    structure for Radiation Sensitivity Parameters (Limb)

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_rspl.pro)


SCIA_LV1_RD_RSPN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_RSPN

 PURPOSE:
       read Radiance Sensitivity Parameters (Nadir)

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_RSPN, dsd, rspn, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      rspn :    structure for Radiation Sensitivity Parameters 

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_rspn.pro)


SCIA_LV1_RD_RSPO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_RSPO

 PURPOSE:
       read Radiance Sensitivity Parameters (Occultation)

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_RSPO, dsd, rspo, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      rspo :    structure for Radiation Sensitivity Parameters (Occultation)

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_rspo.pro)


SCIA_LV1_RD_SCP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_SCP

 PURPOSE:
       read Spectral Calibration Parameters records

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_SCP, dsd, scp, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       scp :    structure for Spectral Calibration Parameters

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
            Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_scp.pro)


SCIA_LV1_RD_SCPN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_SCPN

 PURPOSE:
       read Spectral Calibration Parameters (newly calculated)

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_SCPN, dsd, scpn, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      scpn :    structure for Spectral Calibration Parameters (new)

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:    check number of datasets RvH (SRON), March 2002

(See scia_lv1_rd_scpn.pro)


SCIA_LV1_RD_SFP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_SFP

 PURPOSE:
       read Slit function parameters

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_SFP, dsd, sfp, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       sfp :    structure for Slit Parameters

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_sfp.pro)


SCIA_LV1_RD_SIP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_SIP

 PURPOSE:
       read Static Instrument Parameters

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_SIP, dsd, sip, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       sip :    structure for the Static Instrument Parameters

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_sip.pro)


SCIA_LV1_RD_SPH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_SPH

 PURPOSE:
       read Specific Product Header from a PDS SCIAMACHY Level 1b product

 CATEGORY:
       SCIAMACHY level 1b

 CALLING SEQUENCE:
       scia_lv1_rd_sph, mph, sph, status=status

 OUTPUTS:
       sph :    structure with the SPH

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more documentation

(See scia_lv1_rd_sph.pro)


SCIA_LV1_RD_SQADS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_SQADS

 PURPOSE:
       read Summary of Quality flags per state records

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_sqads, dsd, sqads, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
     sqads :    structure for Summary of Quality flags per state

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002

(See scia_lv1_rd_sqads.pro)


SCIA_LV1_RD_SRS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_SRS

 PURPOSE:
       read Sun Reference Spectrum records

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       scia_lv1_rd_srs, dsd, srs, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       srs :    structure for Sun reference spectrum

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_srs.pro)


SCIA_LV1_RD_SRSN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_SRSN

 PURPOSE:
       read Sun Reference Spectra (newly calculated)

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_SRSN, dsd, srsn, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      srsn :    structure for Sun reference spectra (new)

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:    check number of datasets RvH (SRON), March 2002

(See scia_lv1_rd_srsn.pro)


SCIA_LV1_RD_STATE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_STATE

 PURPOSE:
       read States of the Product

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_STATE, dsd, state, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
     state :    structure for States of the product

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 10 December 2002
                    renamed state_scia to state1_scia

(See scia_lv1_rd_state.pro)


SCIA_LV1_RD_VLCP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV1_RD_VLCP

 PURPOSE:
       read Leakage Current Parameters (variable fraction) records

 CATEGORY:
       SCIA level 1b data

 CALLING SEQUENCE:
       SCIA_LV1_RD_VLCP, dsd, vlcp, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      vlcp :    structure for leakage current parameters (variable)

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 0 to 1b Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0005
	     Isue 5, 21 July 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv1_rd_vlcp.pro)


SCIA_LV2_FREE_BIAS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV2_FREE_BIAS

 PURPOSE:
       release pointers in structure BIAS_SCIA

 CATEGORY:
       SCIA level 2 data

 CALLING SEQUENCE:
       SCIA_LV2_FREE_BIAS, bias

 INPUTS:
       bias :    BIAS Fitting Window Application Data sets

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 NRT Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0010
	     Isue 3/B, 29 May 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 30 Januari 2009
                    moved from scia_lv2_rd_bias.pro to seperate module
       Modified:  RvH, 26 Febuari 2009
                    optimized the code for speed

(See scia_lv2_free_bias.pro)


SCIA_LV2_FREE_CLD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV2_FREE_CLD

 PURPOSE:
       release pointers in structure CLD_SCIA

 CATEGORY:
       SCIA level 2 data

 CALLING SEQUENCE:
       SCIA_LV2_FREE_CLD, cld

 INPUTS:
       cld :    Cloud and Aerosol Data sets

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 NRT Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0010
	     Isue 3/B, 29 May 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 30 Januari 2009
                    moved from scia_lv2_rd_cld.pro to seperate module
       Modified:  RvH, 26 Febuari 2009
                    optimized the code for speed

(See scia_lv2_free_cld.pro)


SCIA_LV2_FREE_DOAS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV2_FREE_DOAS

 PURPOSE:
       release pointers in structure DOAS_SCIA

 CATEGORY:
       SCIA level 2 data

 CALLING SEQUENCE:
       SCIA_LV2_FREE_DOAS, doas

 INPUTS:
       doas :    DOAS Fitting Window Application Data sets

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 NRT Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0010
	     Isue 3/B, 29 May 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 30 Januari 2009
                    moved from scia_lv2_rd_doas.pro to seperate module
       Modified:  RvH, 26 Febuari 2009
                    optimized the code for speed

(See scia_lv2_free_doas.pro)


SCIA_LV2_RD_BIAS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV2_RD_BIAS

 PURPOSE:
       read BIAS Fitting Window Application Data set

 CATEGORY:
       SCIA level 2 NRT data products

 CALLING SEQUENCE:
       scia_lv2_rd_bias, bias_name, dsd, bias, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      bias :    BIAS Fitting Window Application Data sets

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 NRT Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0010
	     Isue 3/B, 29 May 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 22 May 2002
                    gave Offline and NRT parameters same names
       Modified:  RvH, 12 Nov 2002
                    increases MAX_COEFS_CROSS to n_fit = 10
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation
       Modified:  RvH, 30 Januari 2009
                    moved function SCIA_LV2_FREE_BIAS to seperate module

(See scia_lv2_rd_bias.pro)


SCIA_LV2_RD_CLD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV2_RD_CLD

 PURPOSE:
       read Cloud and Aerosol Data sets

 CATEGORY:
       SCIA level 2 NRT data products

 CALLING SEQUENCE:
       SCIA_LV2_RD_CLD, dsd, cld, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       cld :    structure for Cloud and Aerosol Data sets

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 NRT Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0010
	     Isue 3/B, 29 May 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 22 May 2002
                    gave Offline and NRT parameters same names
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation
       Modified:  RvH, 30 Januari 2009
                    moved function SCIA_LV2_FREE_CLD to seperate module

(See scia_lv2_rd_cld.pro)


SCIA_LV2_RD_DOAS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV2_RD_DOAS

 PURPOSE:
       read DOAS Fitting Window Application data sets

 CATEGORY:
       SCIA level 2 NRT data products

 CALLING SEQUENCE:
       scia_lv2_rd_doas, doas_name, dsd, doas, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      doas :    DOAS Fitting Window Application data sets

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 NRT Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0010
	     Isue 3/B, 29 May 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 22 May 2002
                    gave Offline and NRT parameters same names
       Modified:  RvH, 12 Nov 2002
                    increases MAX_COEFS_CROSS to n_fit = 10
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation
       Modified:  RvH, 30 Januari 2009
                    moved function SCIA_LV2_FREE_DOAS to seperate module

(See scia_lv2_rd_doas.pro)


SCIA_LV2_RD_GEO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV2_RD_GEO

 PURPOSE:
       read Geolocation Data Sets

 CATEGORY:
       SCIA level 2 NRT data product

 CALLING SEQUENCE:
       SCIA_LV2_RD_GEO, dsd, geo, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       geo :    structure for Geolocation Data sets

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 NRT Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0010
	     Isue 3/B, 29 May 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv2_rd_geo.pro)


SCIA_LV2_RD_SPH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV2_RD_SPH

 PURPOSE:
       read Specific Product Header from a PDS SCIAMACHY Level 2 product

 CATEGORY:
       SCIAMACHY level 2 NRT data product

 CALLING SEQUENCE:
       scia_lv2_rd_sph, mph, sph, status=status

 OUTPUTS:
       sph :    structure with the SPH

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 NRT Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0010
	     Isue 3/B, 29 May 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more documentation

(See scia_lv2_rd_sph.pro)


SCIA_LV2_RD_SQADS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV2_RD_SQADS

 PURPOSE:
       read Summary of Quality Flags per State

 CATEGORY:
       SCIA level 2 NRT data product

 CALLING SEQUENCE:
       SCIA_LV2_RD_SQADS, dsd, sqads, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
     sqads :    structure for Summary of Quality flags per state

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 NRT Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0010
	     Isue 3/B, 29 May 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified by: RvH adjusted to Simulated Products v.4, March 2002

(See scia_lv2_rd_sqads.pro)


SCIA_LV2_RD_STATE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_LV2_RD_STATE

 PURPOSE:
       read States of the Product

 CATEGORY:
       SCIA level 2 NRT/Off-line data products

 CALLING SEQUENCE:
       SCIA_LV2_RD_STATE, dsd, state, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
     state :    structure for States of the product

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 NRT Processing
	Input/Output Data Definition
	Ref. ENV-TN-DLR-SCIA-0010
	     Isue 3/B, 29 May 2000

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 10 December 2002
                    renamed state_scia to state2_scia
       Modified:  RvH, 20 Jan 2003
                    added more failure checking, and documentation

(See scia_lv2_rd_state.pro)


SCIA_MJD2DATE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_MJD2DATE

 PURPOSE:
       Sciamachy date conversion routine

 CALLING SEQUENCE:
       Result = SCIA_MJD2DATE( mjd )

 INPUTS:
    mjd    :    structure holding the modified julian time for year 2000

 OUTPUTS:
  date_str :    string: dd/mm/yyyy hh:mm:ss.ssssss

 EXAMPLES:
       None

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002

(See scia_mjd2date.pro)


SCIA_MJD2TIME

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_MJD2TIME

 PURPOSE:
       Sciamachy date conversion routine

 CALLING SEQUENCE:
       time_str = SCIA_MJD2TIME( mjd [, /nomsec] )

 INPUTS:
    mjd      :    structure holding the modified julian time for year 2000

 OUTPUTS:
    time_str :    string: hh:mm:ss[.ssssss]

 KEYWORD PARAMETERS:
   nomsec  :    no milli-seconds in output string

 EXAMPLES:
       None

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002

(See scia_mjd2time.pro)


SCIA_OL2_FREE_CLD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_OL2_FREE_CLD

 PURPOSE:
       release pointers in structure CLD_SCI_OL

 CATEGORY:
       SCIA level 2 data

 CALLING SEQUENCE:
       SCIA_OL2_FREE_CLD, cld

 INPUTS:
       cld :    Cloud and Aerosol Data sets (offline)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 Off-line Processing
	Input/Output Data Definition
	Ref. ENV-ID-DLR-SCI-2200-4
	     Isue 4/A, 09 Aug 2002

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 30 Januari 2009
                    moved from scia_ol2_rd_cld.pro to seperate module
       Modified:  RvH, 26 Febuari 2009
                    optimized the code for speed

(See scia_ol2_free_cld.pro)


SCIA_OL2_FREE_LFIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_OL2_FREE_LFIT

 PURPOSE:
       release pointers in structure LFIT_SCIA

 CATEGORY:
       SCIA level 2 data

 CALLING SEQUENCE:
       SCIA_OL2_FREE_LFIT, lfit

 INPUTS:
       lfit :    Limb/Occultation Fitting Window Application Data sets

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 Off-line Processing
	Input/Output Data Definition
	Ref. ENV-ID-DLR-SCI-2200-4
	     Isue 4/A, 09 Aug 2002

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 30 Januari 2009
                    moved from scia_ol2_rd_lfit.pro to seperate module
       Modified:  RvH, 26 Febuari 2009
                    optimized the code for speed

(See scia_ol2_free_lfit.pro)


SCIA_OL2_FREE_NFIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_OL2_FREE_NFIT

 PURPOSE:
       release pointers in structure NFIT_SCIA

 CATEGORY:
       SCIA level 2 data

 CALLING SEQUENCE:
       SCIA_OL2_FREE_NFIT, nfit

 INPUTS:
       nfit :    Nadir Fitting Window Application Data sets

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 Off-line Processing
	Input/Output Data Definition
	Ref. ENV-ID-DLR-SCI-2200-4
	     Isue 4/A, 09 Aug 2002

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 30 Januari 2009
                    moved from scia_ol2_rd_nfit.pro to seperate module
       Modified:  RvH, 26 Febuari 2009
                    optimized the code for speed

(See scia_ol2_free_nfit.pro)


SCIA_OL2_RD_CLD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_OL2_RD_CLD

 PURPOSE:
       read Cloud and Aerosol Data sets from a level 2 Off-line Product

 CATEGORY:
       SCIA level 2 off-line product

 CALLING SEQUENCE:
       SCIA_OL2_RD_CLD, dsd, cld, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       cld :    structure for Cloud and Aerosol Data sets

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 Off-line Processing
	Input/Output Data Definition
	Ref. ENV-ID-DLR-SCI-2200-4
	     Isue 4/A, 09 Aug 2002

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), January 2003
       Modified:  RvH, 24 March 2003
                    added checks on allocated memory and array sizes
       Modified:  RvH, 30 Januari 2009
                    moved function SCIA_OL2_FREE_CLD to seperate module

(See scia_ol2_rd_cld.pro)


SCIA_OL2_RD_LCLD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_OL2_RD_LCLD

 PURPOSE:
       read Limb Clouds Data set

 CATEGORY:
       SCIA level 2 Off-line data products

 CALLING SEQUENCE:
       scia_ol2_rd_lcld, dsd, lcld, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      lcld :    Limb Clouds Data sets

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       Volume 15: Envisat-1 Product Specifications
	
	Ref. IDEAS-SER-IPF-SPE-0398
	     Isue 3/L, 21 Jan 2010

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), January 2011

(See scia_ol2_rd_lcld.pro)


SCIA_OL2_RD_LFIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_OL2_RD_LFIT

 PURPOSE:
       read Limb/Occultation Fitting Window Application Data set

 CATEGORY:
       SCIA level 2 Off-line data products

 CALLING SEQUENCE:
       scia_ol2_rd_lfit, lfit_name, dsd, lfit, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      lfit :    Limb/Occultation Fitting Window Application Data sets

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       Volume 15: Envisat-1 Product Specifications
	
	Ref. IDEAS-SER-IPF-SPE-0398
	     Isue 3/L, 21 Jan 2010

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), January 2003
       Modified:  RvH, 25 March 2003
                    added checks on allocated memory and array sizes

(See scia_ol2_rd_lfit.pro)


SCIA_OL2_RD_LGEO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_OL2_RD_LGEO

 PURPOSE:
       read Geolocation Data Sets (Limb/Occultation)

 CATEGORY:
       SCIA level 2 Off-line data product

 CALLING SEQUENCE:
       SCIA_OL2_RD_LGEO, dsd, lgeo, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       lgeo :    structure for Limb/Occultation Geolocation Data sets

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 Off-line Processing
	Input/Output Data Definition
	Ref. ENV-ID-DLR-SCI-2200-4
	     Isue 4/A, 09 Aug 2002

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), January 2003

(See scia_ol2_rd_lgeo.pro)


SCIA_OL2_RD_NFIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_OL2_RD_NFIT

 PURPOSE:
       read Nadir Fitting Window Application Data set

 CATEGORY:
       SCIA level 2 Off-line data products

 CALLING SEQUENCE:
       scia_ol2_rd_nfit, nfit_name, dsd, nfit, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
      nfit :    Nadir Fitting Window Application Data sets

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       Volume 15: Envisat-1 Product Specifications
	
	Ref. IDEAS-SER-IPF-SPE-0398
	     Isue 3/L, 21 Jan 2010

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), January 2003
       Modified:  RvH, 25 March 2003
                    added checks on allocated memory and array sizes
       Modified:  RvH, 30 Januari 2009
                    moved function SCIA_OL2_FREE_NFIT to seperate module

(See scia_ol2_rd_nfit.pro)


SCIA_OL2_RD_NGEO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_OL2_RD_NGEO

 PURPOSE:
       read Geolocation Data Sets (Nadir)

 CATEGORY:
       SCIA level 2 Off-line data product

 CALLING SEQUENCE:
       SCIA_OL2_RD_NGEO, dsd, ngeo, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
       ngeo :    structure for NADIR Geolocation Data sets

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 Off-line Processing
	Input/Output Data Definition
	Ref. ENV-ID-DLR-SCI-2200-4
	     Isue 4/A, 09 Aug 2002

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), January 2003

(See scia_ol2_rd_ngeo.pro)


SCIA_OL2_RD_SPH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_OL2_RD_SPH

 PURPOSE:
       read Specific Product Header from a PDS SCIAMACHY Level 2 product

 CATEGORY:
       SCIAMACHY level 2 Off-line data product

 CALLING SEQUENCE:
       scia_ol2_rd_sph, mph, sph, status=status

 OUTPUTS:
       sph :    structure with the SPH

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 Off-line Processing
	Input/Output Data Definition
	Ref. ENV-ID-DLR-SCI-2200-4
	     Isue 4/A, 09 Aug 2002

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002
       Modified:  RvH, 20 Jan 2003
                    added more documentation

(See scia_ol2_rd_sph.pro)


SCIA_OL2_RD_SQADS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_OL2_RD_SQADS

 PURPOSE:
       read Summary of Quality Flags per State

 CATEGORY:
       SCIA level 2 Off-line data product

 CALLING SEQUENCE:
       SCIA_OL2_RD_SQADS, dsd, sqads, status=status

 INPUTS:
       dsd :    structure for Data Set Descriptors

 OUTPUTS:
     sqads :    structure for Summary of Quality flags per state

 KEYWORD PARAMETERS:
    status :    returns named variable with error status (0 = ok)

 EXAMPLES:
       None

 REFERENCE:
       SCIAMACHY Level 1b to 2 Off-line Processing
	Input/Output Data Definition
	Ref. ENV-ID-DLR-SCI-2200-4
	     Isue 4/A, 09 Aug 2002

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), January 2003

(See scia_ol2_rd_sqads.pro)


SCIA_ORBIT_TO_JD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_ORBIT_TO_JD

 PURPOSE:
	This function returns MJD for given orbit number

 CATEGORY:
	

 CALLING SEQUENCE:
	Result = SCIA_ORBIT_TO_JD( orbit_list )

 INPUTS:
	orbit_list:	list of orbit numbers

 OUTPUTS:
	list of modified julian dates (MJD2000) matching the input

 RESTRICTIONS:
	requires the Sciamachy Reference Orbit Event Excerpt to be available

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), 22 September 2010

(See scia_orbit_to_jd.pro)


SCIA_RD_DSD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_RD_DSD

 PURPOSE:
       read Data Set Description records of the PDS SCIAMACHY product

 CATEGORY:
       SCIAMACHY - PDS data format

 CALLING SEQUENCE:
       SCIA_RD_DSD, mph, dsd, status=status

 INPUTS:
       mph :    structure with the Main Product Header

 OUTPUTS:
       dsd :    structure for the DSD

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)

 EXAMPLES:
       

 REFERENCE:
       

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002

(See scia_rd_dsd.pro)


SCIA_RD_H5_MEMCORR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_RD_H5_MEMCORR

 PURPOSE:
	read memory correction keydata to HDF5 file

 CATEGORY:
	Sciamachy calibration

 CALLING SEQUENCE:
       SCIA_RD_H5_MEMCORR, memcorr

 INPUTS:
	memcorr:      memory correction keydata

 EXAMPLE:
	None

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), December 2003

(See scia_rd_h5_memcorr.pro)


SCIA_RD_H5_NLCORR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_RD_H5_NLCORR

 PURPOSE:
	read non-linearity correction keydata to HDF5 file

 CATEGORY:
	Sciamachy calibration

 CALLING SEQUENCE:
       SCIA_RD_H5_NLCORR, nlcorr, CurveLegend

 INPUTS:
	nlcorr:        non-linearity correction keydata
  CurveLegend:        curve-to-pixel relation

 EXAMPLE:
	None

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), December 2003
       Modified:  RvH, 03 March 2004
                    restructed valid range for interplation to 60000

(See scia_rd_h5_nlcorr.pro)


SCIA_RD_H5_STRAYLIGHT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_RD_H5_STRAYLIGHT

 PURPOSE:
	read Straylight keydata to HDF5 file

 CATEGORY:
	Sciamachy calibration

 CALLING SEQUENCE:
	SCIA_RD_H5_STRAYLIGHT, strayCorr

 INPUTS:
	strayCorr:      Straylight correction keydata (channel 2)

 EXAMPLE:
	None

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), October 2007

(See scia_rd_h5_straylight.pro)


SCIA_RD_LADS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_RD_LADS

 PURPOSE:
       read Geolocation of the state records

 CATEGORY:
       SCIA level 1b and 2 data

 CALLING SEQUENCE:
       SCIA_RD_LADS, dsd, lads, status=status

 INPUTS:
       dsd :    structure with the DSD records

 OUTPUTS:
      lads :    structure with the Geolocation of States

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)

 EXAMPLES:
       

 REFERENCE:
       

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002

(See scia_rd_lads.pro)


SCIA_RD_MPH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SCIA_RD_MPH

 PURPOSE:
       read Main Product Header of the PDS SCIAMACHY product

 CATEGORY:
       SCIAMACHY PDS headers

 CALLING SEQUENCE:
       SCIA_RD_MPH, mph, status=status

 OUTPUTS:
       mph :    structure with the Main Product Header

 KEYWORD PARAMETERS:
   status  :    returns named variable with error status (0 = ok)

 EXAMPLES:
       

 REFERENCE:
       

 MODIFICATION HISTORY:
       Written by:  Richard van Hees (SRON), February 2002

(See scia_rd_mph.pro)


SCIA_WR_H5_MEMCORR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_WR_H5_MEMCORR

 PURPOSE:
	write memory correction keydata to HDF5 file

 CATEGORY:
	Sciamachy calibration

 CALLING SEQUENCE:
       SCIA_WR_H5_MEMCORR, memcorr_fl=memcorr_fl

 KEYWORD PARAMETERS:
       memcorr_fl:  input file with memory correction values
                       [default: ./splmem_lut.txt]
 EXAMPLE:
	None

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), December 2003

(See scia_wr_h5_memcorr.pro)


SCIA_WR_H5_NLCORR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_WR_H5_NLCORR

 PURPOSE:
	write non-linearity correction keydata to HDF5 file

 CATEGORY:
	Sciamachy calibration

 CALLING SEQUENCE:
       SCIA_WR_H5_NLINCORR, nlincorr_fl=nlincorr_fl

 KEYWORD PARAMETERS:
       nlcorr_fl:  input file with non-linearity correction keydata
                       [default: ./splmem_lut.txt]
 EXAMPLE:
	None

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), December 2003
       Modified:  RvH, 03 March 2004
                    restructed valid range for interplation to 60000

(See scia_wr_h5_nlcorr.pro)


SCIA_WR_H5_STRAYLIGHT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SCIA_WR_H5_STRAYLIGHT

 PURPOSE:
	write Straylight keydata to HDF5 file

 CATEGORY:
	Sciamachy calibration

 CALLING SEQUENCE:
	SCIA_WR_H5_STRAYLIGHT, strayCorr, straylight_fl=straylight_fl

 INPUTS:
	strayCorr:      Straylight correction keydata (channel 2)

 KEYWORD PARAMETERS:
	straylight_fl:  input file with straylight correction values
                       [default: ./mxkd_ch.sav]

 EXAMPLE:
	None

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), October 2007

(See scia_wr_h5_straylight.pro)


SDMF_GET_GRP_METAINDEX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_GET_GRP_METAINDEX

 PURPOSE:
	obtain indices to rows of table metaTable

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
	Result = SDMF_GET_GRP_METAINDEX( locID, orbitList, state_list )

 INPUTS:
       locID:          HDF5 file handle
       orbitList:      list of (absolute) Orbit number(s)
       grpname:        group name

 OUTPUTS:
	This function returns an array with indices to rows of table
	"metaTable". If no rows are found, the functions returns: -1

 KEYWORDS:
       numIndx:        (output) number of indices found

 PROCEDURE:
	In principle you can read the metaTable of a state directly
	from the database using standard IDL routines, like this:

          IDL> file='/SCIA/share/SDMF/3.0/db/sdmf_extract.h5'
          IDL> fid = H5F_OPEN(file)
          IDL> dd = H5D_OPEN(fid, '/State_67/metaTable')
          IDL> mtbl = H5D_read( dd )

       This is reasonably fast, and the prefered method is you want
       to access all the records of a metaTable. However, if you are
       interesed in only data of one orbit than you should use this
       function.

       This function is internally used by the routines:
       SDMF_READ_METATABLE and SDMF_READ_METAHIST to obtain the
       number of rows and which rows have to be read from these
       compressed datasets. These functions are very fast
       (implmeneted in C) and have a small memory footprint.

 EXAMPLE:
	    ToDo...

 MODIFICATION HISTORY:
    	Written by:	Pieter van der Meer (SRON), July 2008
       Modified:   Pieter van der Meer (SRON), September 2008
                   * now able to use orbit list
                   * 2-pass system: more efficient buffer allocation

(See sdmf_get_grp_metaindex.pro)


SDMF_GET_METAINDEX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_GET_METAINDEX

 PURPOSE:
	obtain indices to rows of table metaTable

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
	Result = SDMF_GET_METAINDEX( locID, orbitList, stateList )

 INPUTS:
       locID:          HDF5 file handle
	orbitList:	(absolute) Orbit number, a scalar or list
	stateList:	State ID, a scalar or array, range [1..70]
                       special cases: 
                       * stateList = -1: loop over all states in database
                       * stateList = NaN: use orbitList in root of h5-file

 OUTPUTS:
	This function returns an array with indices to rows of table
	"metaTable". If no rows are found, the functions returns: -1

 PROCEDURE:
	In principle you can read the metaTable of a state directly
	from the database using standard IDL routines, like this:

          IDL> file='/SCIA/share/SDMF/3.0/db/sdmf_extract.h5'
          IDL> fid = H5F_OPEN(file)
          IDL> dd = H5D_OPEN(fid, '/State_67/metaTable')
          IDL> mtbl = H5D_read( dd )

       This is reasonably fast, and the prefered method is you want
       to access all the records of a metaTable. However, if you are
       interesed in only data of one orbit than you should use this
       function.

       This function is internally used by the routines:
       SDMF_READ_METATABLE and SDMF_READ_METAHIST to obtain the
       number of rows and which rows have to be read from these
       compressed datasets. These functions are very fast
       (implmeneted in C) and have a small memory footprint.

 EXAMPLE:
	ToDo...

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), February 2008

(See sdmf_get_metaindex.pro)


SDMF_GET_METAINDEX_ALT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_GET_METAINDEX_ALT

 PURPOSE:
       obtain indices to rows of table metaTable

 CATEGORY:
       SDMF - SCIA calibration

 CALLING SEQUENCE:
       Result = SDMF_GET_METAINDEX_ALT( locID, absOrbit, state_list )

 INPUTS:
       locID:      HDF5 file handle
       absOrbit:   (absolute) Orbit number, long scalar or 2 element lonarr 
                   (=orbit range)

 OUTPUTS:
 This function returns an array with indices to rows of table
 "metaTable". If no rows are found, the functions returns: -1

 PROCEDURE:

 EXAMPLE:
 ToDo...

 MODIFICATION HISTORY:
   Written by: Roald Schnerr (SRON), May 2008
               Modified version of SDMF_GET_METAINDEX, as this is no
               longer useable for all routines after the latest
               modifications (does all HDF I/O in C to enable reading
               of the hdf1.8 monitordatabase).

(See sdmf_get_metaindex_alt.pro)


SDMF_OVERWRITE_METATABLE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_OVERWRITE_METATABLE

 PURPOSE:
	read rows of given orbit from table /State_xx/metaTable. In
	addition, one can obtain readout statistics of calibration
	state executions.

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
       SDMF_OVERWRITE_METATABLE, absOrbit, state_list, mtbl, count=count, $
                 status=status, CALIB_DB=CALIB_DB, $
;                 coaddf=coaddf, mean=mean, noise=noise, pet=pet, $
;                 pixelRange=pixelRange

 INPUTS:
	absOrbit:	(absolute) Orbit number, a scalar
	state_list:	State ID, a scalar or array, range [1..70]
                       Special case [state_list = -1]: collect data
                       from all states

 OUTPUTS:
       state_list:     state IDs of mtbl records
	mtbl:           structure with rows of table metaTable

 KEYWORD PARAMETERS:
       CALIB_DB:       path to the calibration database
                       default: ./sdmf_extract.h5
                                /SCIA/share/SDMF/3.0/sdmf_extract.h5
       count:          number of valid readouts during the state
       coaddf:         co-adding factor
       mean:           average value of the readouts during the state
       noise:          noise estimate of the readouts during the state
       pet:            pixel exposure time

       pixelRange:     two element array with start and end pixel,
                       range [0..8191]
       status :        returns named variable with error flag (0 = ok)

 PROCEDURE:
	In principle you can read the metaTable of a state directly
	from the database using standard IDL routines, like this:

          IDL> file = '/SCIA/share/SDMF/3.0/sdmf_extract.h5'
          IDL> fid = H5F_OPEN( file )
          IDL> dd = H5D_OPEN( fid, '/State_67/metaTable' )
          IDL> mtbl = H5D_read( dd )
          IDL> H5D_close, dd
          IDL> H5F_close, fid

       This is reasonably fast, and the prefered method is you want
       to access all the records of a metaTable. However, it is not
       possible, nor advisable, to read the (compressed) readout
       statistics and histogram datasets at once due the large size
       of the (compressed) readout statistics and histogram datasets
       (> 1 GB). Reading a few records from these databases can be
       done like this:

          IDL> dd = H5D_OPEN( fid, '/State_67/readoutMean' )
          IDL> space_id = H5D_GET_SPACE( dd )
          IDL> mem_space_id = H5S_CREATE_SIMPLE([1,8192])
          IDL> H5S_SELECT_HYPERSLAB, space_id, [indx,0], [1,8192], /reset
          IDL> data = H5D_READ( dd, FILE_SPACE=space_id, $
                                MEMORY_SPACE=mem_space_id )

       However, the function below is written in C and therefore very
       fast, it is ment to be more convenient to use, and has a small
       memory footprint.

 EXAMPLE:
	ToDo...

 MODIFICATION HISTORY:
    	Written by:     Pieter van der Meer (SRON),  2008
       Modified by:    ..... ... (SRON), ... ....
                       * ...

(See sdmf_overwrite_metatable.pro)


SDMF_RD_PMD_DARK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_RD_PMD_DARK

 PURPOSE:
	Obtain PMD dark read-outs during a Dark state

 CATEGORY:
	

 CALLING SEQUENCE:
	SDMF_RD_PMD_DARK, orbit, stateID, mtbl, pmdHist;
 INPUTS:
	orbit:	        (absolute) Orbit number, a scalar, range [1...]
       stateID:        Calibration State ID, a scalar, valid ID's are: 
                       8,16,26,39,46,48,52,59,61,62,63,65,67,69,70

 OUTPUTS:
       mtbl:           structure with rows of table metaTable
       pmdHist         histogram structures of the raw PMD read-outs

 KEYWORD PARAMETERS:
	pmdMean:	average PMD darks (7 PMD's, high/low gain)
       pmdAdev:        adev of PMD darks (7 PMD's, high/low gain)

       CALIB_DB:       Full path to sdmf_extract_dark database (>= v3.1)
                       default: ./sdmf_extract_dark.h5
                                /SCIA/share/SDMF/3.1/sdmf_extract_dark.h5

 PROCEDURE:
	ToDo

 EXAMPLE:
	Please add!

 MODIFICATION HISTORY:
 	Written by:     Richard van Hees (SRON), Januari 2011

(See sdmf_rd_pmd_dark.pro)


SDMF_READ_CHANNELEVOLUTION

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_READ_CHANNELEVOLUTION

 PURPOSE:
	read table of given channel from channelevolution database.

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
	SDMF_READ_CHANNELEVOLUTION, channelindex, mtbl,
  	                            CALIB_DB=CALIB_DB, status=status

 INPUTS:
	channelindex:	index of channel [0=channel1..6=channel6+..8=channel8]
                       -1: all channels

 OUTPUTS:
	mtbl:           array of structures with channelevolution data

 KEYWORD PARAMETERS:
     CALIB_DB:         path to the SDMF channelevolution database
                       default: ./sdmf_channelevolution.h5
                                /SCIA/share/SDMF/3.0/sdmf_channelevolution.h5
     status :          returns named variable with error flag (0 = ok)

 PROCEDURE:
	ToDo...

 EXAMPLE:
	ToDo...

 MODIFICATION HISTORY:
 	Written by:	Roald Schnerr (SRON), April 2008

(See sdmf_read_channelevolution.pro)


SDMF_READ_DARKTABLE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_READ_DARKTABLE

 PURPOSE:
	read rows of given orbit from darkSignal metaTable. In
	addition, one can obtain dark correction parameters.

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
	SDMF_READ_DARKTABLE, absOrbit, mtbl, analogOffset=analogOffset, 
	         darkCurrent=darkCurrent, analogOffsError=analogOffsError,
	         darkCurrError=darkCurrError, chiSquareFit=chiSquareFit,
	         pixelRange=pixelRange, status=status, CALIB_DB=CALIB_DB

 INPUTS:
	absOrbit:	(absolute) Orbit number, a scalar, range [1...]

 OUTPUTS:
	mtbl:           structure with rows of table metaTable

 KEYWORD PARAMETERS:
     CALIB_DB:         path to the SDMF darkSignal database
                       default: ./sdmf_dark.h5
                                /SCIA/share/SDMF/3.0/sdmf_dark.h5
     analogOffset:     
     darkCurrent:      
     analogOffsError:  
     darkCurrError:
       
     pixelRange:       two element array with start and end pixel,
                       range [0..8191]
     status :          returns named variable with error flag (0 = ok)

 PROCEDURE:
	ToDo...

 EXAMPLE:
	ToDo...

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), February 2008
 	Modified by:	Pieter van der Meer (SRON), March 2008
   Modified by:  Roald Schnerr (SRON), May 2008
                   Adjusted call to SDMF_GET_METAINDEX, as this
                   function was modified and always returned array of 40

(See sdmf_read_darktable.pro)


SDMF_READ_LASTLIMB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_READ_LASTLIMB

 PURPOSE:
	read rows of given orbit from SDMF last-limb database.

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
	SDMF_READ_LASTLIMB, absOrbit, state_id, clus_id, mtbl, mds1c,
                           status=status, CALIB_LL_DB=CALIB_LL_DB

 INPUTS:
	absOrbit:	(absolute) Orbit number, a scalar
	state_id:	State ID, a scalar, range [1..70]

       clus_id:        Cluster ID, a scalar, range [1..40]

 OUTPUTS:
	mtbl:           structure with rows of table metaTable
       mds1c:          structure with last-limb measurements

 KEYWORD PARAMETERS:
       CALIB_LL_DB:    path to the SDMF last-limb database
                       default: ./sdmf_extract_ll.h5
                                /SCIA/share/SDMF/3.0/sdmf_extract_ll.h5
       status :        returns named variable with error flag (0 = ok)
       nonlin :        flag to request non-linearity correction

 PROCEDURE:
	Blah Blah Blah.

 EXAMPLE:
	ToDo...

 MODIFICATION HISTORY:
    	Written by:     Richard van Hees (SRON), January 2009
    	Modified by:    Pieter van der Meer (SRON), August 2009
    	                * added non-linearity correction

(See sdmf_read_lastlimb.pro)


SDMF_READ_MASKTABLE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_READ_MASKTABLE

 PURPOSE:
	read rows of given orbit from pixelMask metaTable. In
	addition, one can obtain pixelMask parameters.

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
	SDMF_READ_MASKTABLE, absOrbit, mtbl, CALIB_DB=CALIB_DB, /SMOOTH,
	     analogOffset=analogOffset, analogOffsError=analogOffsError,
	     darkCurrent=darkCurrent, darkCurrError=darkCurrError,
            residual=residual, noise=noise, wlsResponse=wlsResponse,
            sunResponse=sunResponse, pixelGain=pixelGain,
            chiSquare=chiSquare, invalid=invalid, combined=combined,
	     pixelRange=pixelRange, status=status

 INPUTS:
	absOrbit:	(absolute) Orbit number, a scalar, range [1...]

 OUTPUTS:
	mtbl:           structure with rows of table metaTable

 KEYWORD PARAMETERS:
     CALIB_DB:         path to the SDMF pixelMask database
                       default: ./sdmf_mask.h5
                                /SCIA/share/SDMF/3.0/sdmf_mask.h5
     SMOOTH:           flag, if set read smoothed pixelMask data
     analogOffset:     
     analogOffsError:  
     darkCurrent:      
     darkCurrError: 
     residual:         
     noise:            
     wlsResponse:      
     sunResponse:      
     pixelGain:        
     chiSquare:        
     invalid:          
     combined:
     pixelRange:       two element array with start and end pixel,
                       range [0..8191]
     status :          returns named variable with error flag (0 = ok)

 PROCEDURE:
	ToDo...

 EXAMPLE:
	ToDo...

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), February 2008

(See sdmf_read_masktable.pro)


SDMF_READ_METAHIST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_READ_METAHIST

 PURPOSE:
	read histograms of given orbit from table /State_xx/histReadOut.
	In addition, one can obtain related rows of table /State_xx/metaTable.

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
	SDMF_READ_METAHIST, absOrbit, state_list, sdmf_hist, mtbl=mtbl,
                 pixelRange=pixelRange, status=status, CALIB_DB=CALIB_DB

 INPUTS:
	absOrbit:	(absolute) Orbit number, a scalar, range [1...]

	state_list:	State ID, a scalar or array, range [1..70]
                       Special case [state_list = -1]: collect data
                       from all states

 OUTPUTS:
       sdmf_hist:      array of structures with histogram data per pixel
       

 KEYWORD PARAMETERS:
	mtbl:           structure with rows of table metaTable

       CALIB_DB:       path to the calibration database
                       default: ./sdmf_extract.h5
                                /SCIA/share/SDMF/3.0/sdmf_extract.h5

       pixelRange:     two element array with start and end pixel,
                       range [0..8191]

       status :        returns named variable with error flag (0 = ok)

 PROCEDURE:
	In principle you can read the metaTable of a state directly
	from the database using standard IDL routines, like this:

          IDL> file = '/SCIA/share/SDMF/3.0/sdmf_extract.h5'
          IDL> fid = H5F_OPEN( file )
          IDL> dd = H5D_OPEN( fid, '/State_67/metaTable' )
          IDL> mtbl = H5D_read( dd )
          IDL> H5Dclose( dd )

       This is reasonably fast, and the prefered method is you want
       to access all the records of a metaTable. However, it is not
       possible, nor advisable, to read the (compressed) readout
       histogram of all pixels at once due the large size
       of these datasets (>> 1 GB).

       The function below is written in C and therefore very fast, it
       is ment to be more convenient to use, and has a small memory
       footprint.

 EXAMPLE:
	ToDo...

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), February 2008

(See sdmf_read_metahist.pro)


SDMF_READ_METATABLE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_READ_METATABLE

 PURPOSE:
	read rows of given orbit from table /State_xx/metaTable. In
	addition, one can obtain readout statistics of calibration
	state executions.

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
	SDMF_READ_METATABLE, absOrbit, state_list, mtbl, count=count, $
                 coaddf=coaddf, mean=mean, noise=noise, pet=pet, $
                 pixelRange=pixelRange, status=status, CALIB_DB=CALIB_DB

 INPUTS:
	absOrbit:	(absolute) Orbit number, a scalar
	state_list:	State ID, a scalar or array, range [1..70]
                       Special case [state_list = -1]: collect data
                       from all states

 OUTPUTS:
       state_list:     state IDs of mtbl records
	mtbl:           structure with rows of table metaTable

 KEYWORD PARAMETERS:
       CALIB_DB:       path to the calibration database
                       default: ./sdmf_extract.h5
                                /SCIA/share/SDMF/3.0/sdmf_extract.h5
       count:          number of valid readouts during the state
       coaddf:         co-adding factor
       mean:           average value of the readouts during the state
       noise:          noise estimate of the readouts during the state
       pet:            pixel exposure time

       pixelRange:     two element array with start and end pixel,
                       range [0..8191]
       status :        returns named variable with error flag (0 = ok)

 PROCEDURE:
	In principle you can read the metaTable of a state directly
	from the database using standard IDL routines, like this:

          IDL> file = '/SCIA/share/SDMF/3.0/sdmf_extract.h5'
          IDL> fid = H5F_OPEN( file )
          IDL> dd = H5D_OPEN( fid, '/State_67/metaTable' )
          IDL> mtbl = H5D_read( dd )
          IDL> H5D_close, dd
          IDL> H5F_close, fid

       This is reasonably fast, and the prefered method is you want
       to access all the records of a metaTable. However, it is not
       possible, nor advisable, to read the (compressed) readout
       statistics and histogram datasets at once due the large size
       of the (compressed) readout statistics and histogram datasets
       (> 1 GB). Reading a few records from these databases can be
       done like this:

          IDL> dd = H5D_OPEN( fid, '/State_67/readoutMean' )
          IDL> space_id = H5D_GET_SPACE( dd )
          IDL> mem_space_id = H5S_CREATE_SIMPLE([1,8192])
          IDL> H5S_SELECT_HYPERSLAB, space_id, [indx,0], [1,8192], /reset
          IDL> data = H5D_READ( dd, FILE_SPACE=space_id, $
                                MEMORY_SPACE=mem_space_id )

       However, the function below is written in C and therefore very
       fast, it is ment to be more convenient to use, and has a small
       memory footprint.

 EXAMPLE:
	ToDo...

 MODIFICATION HISTORY:
    	Written by:     Richard van Hees (SRON), February 2008
 	    Modified by:    Pieter van der Meer (SRON), March 2008
                       * Changed order of return and close.
       Modified by:    Pieter van der Meer (SRON), September 2008
                       * Added option to read range of orbits (= fast!).

(See sdmf_read_metatable.pro)


SDMF_READ_ORBITLIST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SDMF_READ_ORBITLIST

 PURPOSE:
       read rows of given orbit from table /State_xx/metaTable. In
       addition, one can obtain readout statistics of calibration
       state executions.

 CATEGORY:
       SDMF - SCIA calibration

 CALLING SEQUENCE:
       RES = SDMF_READ_ORBITLIST( DB, GROUPNAME=GROUPNAME )

 INPUTS:
       db:       name of hdf5 database

 KEYWORDS:
       groupname: name of group inside database

 RETURNS:
       list of orbit numbers 

 PROCEDURE:

 EXAMPLE:
       ToDo...

 MODIFICATION HISTORY:
       Written by:     Pieter van der Meer (SRON), September 2008
       Modified by:    .. (...), ... 200x
                       * ...

(See sdmf_read_orbitlist.pro)


SDMF_READ_PIXEVTABLE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
   SDMF_READ_PIXEVTABLE

 PURPOSE:
   read rows of given orbit from pixel evolution metaTable. In
   addition, one can obtain pixel evolution parameters.

 CATEGORY:
   SDMF - SCIA calibration

 CALLING SEQUENCE:
   SDMF_READ_PIXEVTABLE, absOrbit, mtbl, pixelIndx, CALIB_DB=CALIB_DB, $
                        analogOffset=analogOffset, darkCurrent=darkCurrent, $
                        chiSquareFit=chiSquareFit, ppg=ppg, $
                        transmission=transmission, mask=mask, $
                        WlsTransmission=WlsTransmission, $
                        status=status

 INPUTS:
   absOrbit:   (absolute) Orbit number, a scalar, range [1...]

 OUTPUTS:
   mtbl:           structure with rows of table metaTable

 KEYWORD PARAMETERS:
     CALIB_DB:         path to the SDMF darkSignal database
                       default: ./sdmf_dark.h5
                                /SCIA/share/SDMF/3.0/sdmf_dark.h5
     analogOffset:     
     darkCurrent:      
     analogOffsError:  
     darkCurrError:
       
     pixelRange:       two element array with start and end pixel,
                       range [0..8191]
     status :          returns named variable with error flag (0 = ok)

 PROCEDURE:
   ToDo...

 EXAMPLE:
   ToDo...

 MODIFICATION HISTORY:
   Written by:     Pieter van der Meer (SRON), Jan 2009
   Modified by:    ..., .... 20--

(See sdmf_read_pixevtable.pro)


SDMF_READ_PPGTABLE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_READ_PPGTABLE

 PURPOSE:
	read rows of given orbit from pixelGain metaTable. In
	addition, one can obtain pixelGain parameters.

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
	SDMF_READ_PPGTABLE, absOrbit, mtbl, CALIB_DB=CALIB_DB,
	     analogOffset=analogOffset, analogOffsError=analogOffsError,
	     darkCurrent=darkCurrent, darkCurrentError=darkCurrentError,
            residual=residual, noise=noise, wlsResponse=wlsResponse,
            sunResponse=sunResponse, pixelGain=pixelGain,
            chiSquare=chiSquare, invalid=invalid, combined=combined,
	     pixelRange=pixelRange, status=status

 INPUTS:
	absOrbit:	(absolute) Orbit number, a scalar, range [1...]

 OUTPUTS:
	mtbl:           structure with rows of table metaTable

 KEYWORD PARAMETERS:
     CALIB_DB:         path to the SDMF pixelGain database
                       default: ./sdmf_ppg.h5
                                /SCIA/share/SDMF/3.0/sdmf_ppg.h5
     pixelGain:        pixel to pixel gain parameters
     pixelRange:       two element array with start and end pixel,
                       range [0..8191]
     status :          returns named variable with error flag (0 = ok)

 PROCEDURE:
	ToDo...

 EXAMPLE:
	ToDo...

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), February 2008
   Modified:   Pieter van der Meer (SRON), March 2008
               * h5f_close before return

(See sdmf_read_ppgtable.pro)


SDMF_READ_PRODUCTLIST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 SDMF_READ_PRODUCTLIST

 PURPOSE:
 read productlist from hdf file

 CATEGORY:
 SDMF - SCIA calibration

 CALLING SEQUENCE:
 Outlist = SDMF_READ_PRODUCTLIST, CALIB_DB, status=status

 INPUTS:
 CALIB_DB = database to read

 OUTPUTS:
  productList

 KEYWORD PARAMETERS:
     productIDs:       optional output parameter for productIDs
     status            -1=failed 1=ok

 PROCEDURE:
 ToDo...

 EXAMPLE:
 ToDo...

 MODIFICATION HISTORY:
       Written by  : Roald Schnerr (SRON), April 2008
       Modified by : P. van der Meer (SRON), Sep 2008
                     * HFD5 1.8 compliant version using C library

(See sdmf_read_productlist.pro)


SDMF_READ_SIMUDARK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SDMF_READ_SIMUDARK

 PURPOSE:
       read rows of given orbit from simultaneous fit darksignal metaTable. In
       addition, one can obtain dark correction parameters.

 CATEGORY:
       SDMF - SCIA calibration

 CALLING SEQUENCE:
       SDMF_READ_SIMUDARK, orbit, mtbl, CALIB_DB=database, ao=ao, lc=lc, 
       amp1=amp1, amp2=amp2, phase=phase, sig_ao=sig_ao, sig_lc=sig_lc,
       sig_amp1=sig_amp1, sig_amp2=sig_amp2, sig_phase=sig_phase, status=status

 INPUTS:
	    orbit:	(absolute) Orbit number, a scalar, range [1...]

 OUTPUTS:
       mtbl:           structure with rows of table metaTable

 KEYWORD PARAMETERS:
       CALIB_DB:       path to the SDMF darkSignal database
                       default: ./sdmf_simudark.h5
                                /SCIA/share/SDMF/3.0/sdmf_simudark.h5
       TODO..

 PROCEDURE:
       TODO...

 EXAMPLE:
       TODO...

 MODIFICATION HISTORY:
       Written by:  Pieter van der Meer (SRON), July 2008
       Modified by: Pieter van der Meer (SRON), August 2008
        * Added 1st harmonic

(See sdmf_read_simudark.pro)


SDMF_READ_SMR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_READ_SMR

 PURPOSE:
	read rows of given orbit from SMR metaTable. In
	addition, one can obtain SMR correction parameters.

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
	SDMF_READ_SMR, absOrbit, mtbl, smr=smr, readouts=readouts,
	         pixelRange=pixelRange, status=status, CALIB_DB=CALIB_DB

 INPUTS:
	absOrbit:	(absolute) Orbit number, a scalar, range [1...]

 OUTPUTS:
	mtbl:           structure with rows of table metaTable

 KEYWORD PARAMETERS:
     CALIB_DB:         path to the SDMF SMR database
                       default: ./sdmf_smr.h5
                                /SCIA/share/SDMF/3.0/sdmf_smr.h5
     use_neighbours:   flag to enable looking for neighbouring orbits
     normalise:        normalise spectrum to BU/s
     order_ch2:        flag to reverse channel 2 from measurement to science 
                        order
     pixelRange:       two element array with start and end pixel,
                       range [0..8191]
     status :          returns named variable with error flag (0 = ok)

     smr:              sun mean reference spectrum output
     readouts:         240 readouts used for sun mean reference spectrum output
     sunaz:            solar azimuth angle output
     sunel:            solar elevation angle output
     asm:              asm angle
     esm:              esm angle

 PROCEDURE:
	ToDo...

 EXAMPLE:
	ToDo...

 MODIFICATION HISTORY:
 	Written by:	Pieter van der Meer (SRON), May 2009
       Modified by:    ...., ... 20..

(See sdmf_read_smr.pro)


SDMF_READ_STATEDARK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_READ_STATEDARK

 PURPOSE:
	read rows of given orbit from statedark metaTable. In
	addition, one can obtain other data parameters.

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
       ToDo...

 INPUTS:
	absOrbit:	(absolute) Orbit number, a scalar, range [1...]

 OUTPUTS:
	mtbl:           structure with rows of table metaTable

 KEYWORD PARAMETERS:
     CALIB_DB:         path to the SDMF statedark database
                       default: ./sdmf_statedark.h5
                                /SCIA/share/SDMF/3.0/sdmf_statedark.h5
     status :          returns named variable with error flag (0 = ok)

 PROCEDURE:
	ToDo...

 EXAMPLE:
	ToDo...

 MODIFICATION HISTORY:
 	Written by:	Roald Schnerr (SRON), April 2008

(See sdmf_read_statedark.pro)


SDMF_READ_SUN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SDMF_READ_SUN

 PURPOSE:
	read rows of given orbit from SDMF Sun database.

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
	SDMF_READ_SUN, absOrbit, state_id, clus_id, mtbl, mds1c,
                           status=status, CALIB_SUN_DB=CALIB_SUN_DB

 INPUTS:
	absOrbit:	(absolute) Orbit number, a scalar
	state_id:	State ID, a scalar, range [1..70]

       clus_id:        Cluster ID, a scalar, range [1..40]

 OUTPUTS:
	mtbl:           structure with rows of table metaTable
       mds1c:          structure with Sun measurements

 KEYWORD PARAMETERS:
       CALIB_SUN_DB:   path to SDMF Sun measurements database
                       default: ./sdmf_extract_sun.h5
                                /SCIA/share/SDMF/3.0/sdmf_extract_sun.h5
       status :        returns named variable with error flag (0 = ok)

 PROCEDURE:
	Blah Blah Blah.

 EXAMPLE:
	ToDo...

 MODIFICATION HISTORY:
    	Written by:     Richard van Hees (SRON), January 2009
       Modified:  RvH, 22 January 2009
                    export geolocation data in structure geoL_scia

(See sdmf_read_sun.pro)


SDMF_READ_TRANSTABLE

[Previous Routine] [List of Routines]
 NAME:
	SDMF_READ_TRANSTABLE

 PURPOSE:
	read rows of given orbit from transmission metaTable. In
	addition, one can obtain transmission parameters.

 CATEGORY:
	SDMF - SCIA calibration

 CALLING SEQUENCE:
	SDMF_READ_TRANSTABLE, absOrbit, mtbl, CALIB_DB=CALIB_DB,
	       transmission, pixelRange=pixelRange, /WLS, status=status

 INPUTS:
	absOrbit:	(absolute) Orbit number, a scalar, range [1...]

 OUTPUTS:
	mtbl:           structure with rows of table metaTable

 KEYWORD PARAMETERS:
     CALIB_DB:         path to the SDMF transmission database
                       default: ./sdmf_trans.h5
                                /SCIA/share/SDMF/3.0/sdmf_trans.h5
     WLS:              flag, if set read WLS transmission data
     transmission:     
     pixelRange:       two element array with start and end pixel,
                       range [0..8191]
     status:           returns named variable with error flag (0 = ok)

 PROCEDURE:
	ToDo...

 EXAMPLE:
	ToDo...

 MODIFICATION HISTORY:
 	Written by:	Richard van Hees (SRON), February 2008

(See sdmf_read_transtable.pro)