H routines

All GAMAP Routines

List routines by category:
Atmospheric Sciences | Benchmarking | Color | Date/Time | Doc | File & I/O | BPCH Format | Scientific Data Formats | GAMAP Examples | GAMAP Internals | GAMAP Utilities | GAMAP Data Manipulation | GAMAP Models & Grids | GAMAP Plotting | General | Graphics | Math & Units | Plotting | Regridding | Strings | Structures | Time Series

List routines by alphabetical order:
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Last modified: Tue Apr 4 10:50:25 2017.


List of Routines


Routine Descriptions

HCOLORBAR

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

 PURPOSE:
        Plot a horizontal colorbar.
        %%% NOTE: This is obsolete, you should use COLORBAR instead! %%%

 CATEGORY:
        Color

 CALLING SEQUENCE:
        HCOLORBAR, CX, CY, [,keywords]

 INPUTS:
        CX     -> [Min X, Max X] vector in NORMAL coords
        CY     -> [Min Y, Max Y] vector in NORMAL coords

 KEYWORD PARAMETERS:
        COLORS -> array of color levels
        LABELS -> string array of labels for the color levels

 OUTPUTS:
        None

 SUBROUTINES:
        None

 REQUIREMENTS:
        HCOLORBAR assumes n_elements(COLORS) >= n_elements(LABELS)+1

 NOTES:
       (1) HCOLORBAR is more or less obsolete.  You should use
           the COLORBAR routine instead.  However, there may be
           some applications where HCOLORBAR is required, so we
           keep this routine for backwards compatibility with
           older IDL code.

       (2) The colorbar will be plotted as follows:

             LABELS(0)   LABELS(1)                     LABELS(NL-1)
    +-----------+-----------+----------- // --------------+------------+
    | COLORS(0) | COLORS(1) | COLORS(2)  //  COLORS(NL-1) | COLORS(NL) |
    +-----------+-----------+----------- // --------------+------------+

        COLORS(0) = color index for data < first contour level
        COLORS(1) = color index for data between 1st and 2nd levels
           ...
        COLORS(NL) = color index for data >= the last contour level

        LABELS(0)  = label for the first contour level
        LABELS(1)  = label for the 2nd contour level, etc...
           ...
        LABELS(NL) = label for data >= the last contour level
  
 EXAMPLE:
        HCOLORBAR, [0.025, 0.275], [0.680, 0.690], $
           COLORS=[0,1,2,3,4,5],  LABELS=['1','2','3','4','5']

 MODIFICATION HISTORY:
        bmy, 10 Nov 1994: VERSION 1.00
        bmy, 24 Jun 1997: VERSION 1.01
        bmy, 30 Sep 1997: TOOLS VERSION 1.10
        bmy, 20 Nov 1997: TOOLS VERSION 1.11
        bmy, 02 Aug 1999: TOOLS VERSION 1.43 
                          - minor bug fix
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10
                          - Updated comments, cosmetic changes

(See /n/home09/ryantosca/IDL/gamap2/color/hcolorbar.pro)


HDF_GETSD

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

 PURPOSE: 
        Convenience routine to read scientific dataset variables 
        from Hierarchical Data Format (HDF) files

 CATEGORY:
        File & I/O, Scientific Data Formats

 CALLING SEQUENCE:
        DATA = HDF_GETSD( FID, NAME [, _EXTRA=e ] )

 INPUTS:
        FID -> HDF File ID, as returned by routine HDF_SD_START.

        NAME -> Name of the scientific dataset variable that
             you want to extract from the file.  

 KEYWORD PARAMETERS:
        _EXTRA=e -> Passes extra keywords to routine HDF_SD_GETDATA.

 OUTPUTS:
        DATA -> Array containing extracted data from the HDF file.

 SUBROUTINES:
        None

 REQUIREMENTS:
        Need to use a version of IDL w/ HDF routines installed.

 NOTES:
        Taken from MOP02Viewer by Yottana Khunatorn (bmy, 7/17/01)
        
 EXAMPLE:

        ; Make sure HDF is supported on this platform
        IF ( HDF_EXISTS() eq 0 ) then MESSAGE, 'HDF not supported!'

        ; Open the HDF file and get the file ID # (FID)
        FID = HDF_SD_START( 'fvdas_flk_01.ana.eta.20011027.hdf', /Read )
        IF ( FID lt 0 ) then MESSAGE, 'Error opening file!'

        ; Read the UWND field from disk
        DATA = HDF_GETSD( fId, 'UWND' )

        ; Close the file 
        HDF_SD_END, FID

 MODIFICATION HISTORY:
        bmy, 05 Nov 2001: VERSION 1.00
        bmy, 23 Apr 2002: TOOLS VERSION 1.50
                          - updated documentation
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/file_io/hdf_getsd.pro)


HDF_GETSDATTR

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

 PURPOSE: 
        Convenience routine to read attributes (global or variable-
        associated) from Hierarchical Data Format (HDF) files.

 CATEGORY:
        File & I/O, Scientific Data Formats

 CALLING SEQUENCE:
        DATA = HDF_GETSDATTR( ID, NAME [ , Keywords ] )

 INPUTS:
        ID -> HDF File ID as returned by routine HDF_SD_START,
             or scientific dataset ID, as returned by routine
             HDF_SD_SELECT.

        NAME -> Name of the attribute to be read from the HDF file.

 KEYWORD PARAMETERS:
        COUNT -> Returns the total number of values in the 
             specified attribute to the calling program.
 
        HDF_TYPE -> Returns the HDF type of the attribute to the
             calling program.  HDF types are returned as a scalar
             string.  Possible returned values are DFNT_NONE, 
             DFNT_CHAR, DFNT_FLOAT32, DFNT_FLOAT64, DFNT_INT8, 
             DFNT_INT16, DFNT_INT32, DFNT_UINT8, DFNT_UINT16, and 
             DFNT_UINT32.

        TYPE -> Returns the IDL type pf the attribute to the calling 
             program.  The type of the attribute is returned as a
             scalar string. Possible returned values are BYTE, INT, 
             LONG, FLOAT, DOUBLE, STRING, or UNKNOWN.

 OUTPUTS:
        DATA -> Array containing attribute data from the HDF file.

 SUBROUTINES:
        IDL HDF routines used:
        ==========================
        HDF_SD_AttrInfo  
        HDF_SD_AttrFind (function)

 REQUIREMENTS:
        Need to use a version of IDL w/ HDF routines installed.

 NOTES:
        None
        
 EXAMPLE:

        ; Make sure HDF is supported on this platform
        IF ( NCDF_EXISTS() eq 0 ) then MESSAGE, 'HDF not supported!'

        ; Open the HDF file and get the file ID # (FID)
        FID = HDF_SD_START( 'fvdas_flk_01.ana.eta.20011027.hdf', /READ )
        IF ( FID lt 0 ) then MESSAGE, 'Error opening file!'

        ; Read the Ak, Bk, and PTOP attributes from the HDF file
        ; These are GLOBAL attributes associated w/ the file
        AK   = HDF_GETSDATTR( FID, 'ak'   )
        BK   = HDF_GETSDATTR( FID, 'bk'   )
        PTOP = HDF_GETSDATTR( FID, 'ptop' )

        ; Close the HDF file 
        HDF_SD_END, FID

 MODIFICATION HISTORY:
        bmy, 30 Apr 2002: TOOLS VERSION 1.50
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/file_io/hdf_getsdattr.pro)


HDF_GETVD

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

 PURPOSE: 
        Convenience routine to read VDATA variables 
        from Hierarchical Data Format (HDF) files

 CATEGORY:
        File & I/O, Scientific Data Formats

 CALLING SEQUENCE:
        VDATA = HDF_GETVD( FID, NAME [, _EXTRA=e ] )

 INPUTS:
        FID -> HDF File ID, as returned by routine HDF_OPEN.

        NAME -> Name of the VDATA variable that you 
             want to extract from the file.  

 KEYWORD PARAMETERS:
        _EXTRA=e -> Passes extra keywords to routine HDF_VD_READ.

 OUTPUTS:
        VDATA -> Array containing extracted data from the HDF file.

 SUBROUTINES:
        None

 REQUIREMENTS:
        Need to use a version of IDL w/ HDF routines installed.

 NOTES:
        Taken from MOP02Viewer by Yottana Khunatorn (bmy, 7/17/01)
        
 EXAMPLE:
        FID = HDF_OPEN( 'fvdas_flk_01.ana.eta.20011027.hdf', /Read )
        IF ( FID lt 0 ) then Message, 'Error opening file!'
        PTOP = HDF_GETVD( fId, 'PTOP' ) 
        HDF_CLOSE, FID

             ; Opens an HDF-format file and gets the file ID.  Then
             ; call HDF_GETSD to return the PTOP variable from the 
             ; file.  Then close the file and quit.

 MODIFICATION HISTORY:
        bmy, 05 Nov 2001: VERSION 1.00
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/file_io/hdf_getvd.pro)


HDF_SETSD

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

 PURPOSE:
        Convenience routine to write data into the Hierarchical Data
        Format Scientific Dataset (HDF-SD) structure

 CATEGORY:
        File & I/O, Scientific Data Formats

 CALLING SEQUENCE:
        HDF_SETSD, FID, DATA, NAME [, Keywords ]

 INPUTS:
        FID -> HDF File ID, as returned by routine HDF_SD_START.

        DATA -> Data (array or scalar) to be written to HDF-SD format.

        NAME -> Name under which the data array will be saved 
             to the HDF file.  

 KEYWORD PARAMETERS:
        LONGNAME -> Longer descriptive name for the data.  This will 
             be saved as the "long_name" attribute.  Default is ''.

        RANGE -> A 2-element vector containing the [min,max] of
             the data array.  If not passed, RANGE will be computed
             (but only for numeric data types).  RANGE will be saved 
             to the HDF file as the "valid_range" attribute.

        _EXTRA=e -> picks up extra keywords for HDF_SD_SETINFO, such
             as FILL, UNIT, COORDSYS, etc...

 OUTPUTS:
        None

 SUBROUTINES:
        Uses the following IDL HDF routines:
        ===========================================
        HDF_SD_Create (function)  HDF_SD_SetInfo
        HDF_SD_AddData            HDF_SD_EndAccess 
        DATATYPE      (function) 

 REQUIREMENTS:
        Need to use a version of IDL w/ HDF routines installed.

 NOTES:
        (1) Since HDF supports the STRING type, we do not have to
            treat BYTE data like ASCII characters (cf ncdf_set.pro)

 EXAMPLE:
 
        ; Find out if HDF is supported on this platform
        IF ( HDF_EXISTS() eq 0 ) then MESSAGE, 'HDF not supported!'

        ; Open the HDF file
        FID = HDF_SD_START( 'myhdf.hdf', /Create )
        IF ( FID lt 0 ) then Message, 'Error opening file!'

        ; Write data to disk
        HDF_SETSD, FID, DATA, 'NOx',         $
                   LONGNAME='Nitrogen Oxide',$
                   UNIT='v/v',               $
                   FILL=0.0, 

        ; Close HDF File
        HDF_SD_END, FID

             ; Writes NOx data to an HDF file.

 MODIFICATION HISTORY:
        bmy, 17 Apr 2002: TOOLS VERSION 1.50
        bmy, 11 Sep 2002: TOOLS VERSION 1.51
                          - Now call routine DATATYPE to determine
                            the type of the data so that we can
                            write all data types to the HDF file.
                          - Don't add the RANGE attribute to
                            the HDF file for a string type value.
                          - Updated comments 
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10

(See /n/home09/ryantosca/IDL/gamap2/file_io/hdf_setsd.pro)


HIST_ND

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

 PURPOSE:

       Perform an N-dimensional histogram, also known as the joint
       density function of N variables, ala HIST_2D.

 CATEGORY:
       Regridding

 CALLING SEQUENCE:
       hist=HIST_ND(V,BINSIZE,MIN=,MAX=,NBINS=,REVERSE_INDICES=)

 INPUTS:

       V: A NxP array representing P data points in N dimensions.  

       BINSIZE: The size of the bin to use. Either an N point vector
         specifying a separate size for each dimension, or a scalar,
         which will be used for all dimensions.  If BINSIZE is not
         passed, NBINS must be.

 OPTIONAL INPUTS: 

       MIN: The minimum value for the histogram.  Either a P point
         vector specifying a separate minimum for each dimension, or
         a scalar, which will be used for all dimensions.  If
         omitted, the natural minimum within the dataset will be
         used.

       MAX: The maximum value for the histogram.  Either a P point
         vector specifying a separate maximmum for each dimension, or
         a scalar, which will be used for all dimensions. If omitted,
         the natural maximum within the dataset will be used.

       NBINS: Rather than specifying the binsize, you can pass NBINS,
         the number of bins in each dimension, which can be a P point
         vector, or a scalar.  If BINSIZE it also passed, NBINS will
         be ignored, otherwise BINSIZE will then be calculated as
         binsize=(max-min)/nbins.  Note that *unlike* RSI's version
         of histogram as of IDL 5.4, this keyword actually works as
         advertised, giving you NBINS bins over the range min to max.

 KEYWORD PARAMETERS:
       
       MIN,MAX,NBINS: See above
       
       REVERSE_INDICES: Set to a named variable to receive the
         reverse indices, for mapping which points occurred in a
         given bin.  Note that this is a 1-dimensional reverse index
         vector (see HISTOGRAM).  E.g., to find the indices of points
         which fell in a histogram bin [i,j,k], look up:

             ind=[i+nx*(j+ny*k)]
             ri[ri[ind]:ri[ind+1]-1]

         See also ARRAY_INDICES for converting in the other
         direction.

 OUTPUTS:

       hist: The N-Dimensional histogram, of size N1xN2xN3x...xND
         where the Ni's are the number of bins implied by the data,
         and/or optional inputs min, max and binsize.

 OPTIONAL OUTPUTS:

       The reverse indices.

 EXAMPLE:
       
       v=randomu(sd,3,100)
       h=hist_nd(v,.25,MIN=0,MAX=1,REVERSE_INDICES=ri)

 SEE ALSO:

       HISTOGRAM, HIST_2D

 MODIFICATION HISTORY:

       Mon Mar 5 09:45:53 2007, J.D. Smith 

               Correctly trim out of range elements from the
               histogram, when MIN/MAX are specified. Requires IDL
               v6.1 or later.

       Tue Aug 19 09:13:43 2003, J.D. Smith 

               Slight update to BINSIZE logic to provide consistency
               with HIST_2D.

       Fri Oct 11 10:10:01 2002, J.D. Smith 

               Updated to use new DIMENSION keyword to MAX/MIN.

       Fri Apr 20 12:57:34 2001, JD Smith 

               Slight update to NBINS logic.  More aggressive keyword
               checking.

       Wed Mar 28 19:41:10 2001, JD Smith 

               Written, based on HIST_2D, and suggestions of CM.

   phs, bmy, 30 May 2008: GAMAP VERSION 2.12
                          - Added to GAMAP under "Regridding" category
   

(See /n/home09/ryantosca/IDL/gamap2/regridding/hist_nd.pro)


HYSTAT (FUNCTION)

[Previous Routine] [List of Routines]
 NAME:
        HYSTAT (function)

 PURPOSE:
        Compute atmospheric pressures in hydrostatic equilibrium.
        This function is adapted from the Harvard photochemical
        point model (CHEM1D).

 CATEGORY:
        Atmospheric Sciences 

 CALLING SEQUENCE:
        pressure = HYSTAT,alt,temp,psurf,g0,rearth

 INPUTS:
        ALT -> Altitude in km. This can be a single value or an array.

        TEMP -> Temperatures corresponding to the altitudes in ALT

        PSURF -> A surface pressure value in mbar. Default is 1013.25 mbar.

        G0 -> acceleration du eto gravity in m/s2. Default is 9.80665 m/s2 .

        REARTH -> Radius of the earth in km. Default is 6356.77 km.

 KEYWORD PARAMETERS:
        none

 OUTPUTS:
        None

 SUBROUTINES:
        None

 REQUIREMENTS:
        None

 NOTES:
        None

 EXAMPLE:
        ALT = FINDGEN(20)               ; create altitude array 0..19 km
        TEMP = TEMP = 205.+(19-ALT)*4.  ; a semi-realistic temperature 
                                        ; profile
        PRESS = HYSTAT(ALT,TEMP)        ; compute pressures
        PRINT, PRESS

           1013.25   896.496   791.815   698.104   614.349   
           539.613   473.041   413.843   361.298   314.745   
           273.581   237.254   205.261   177.146   152.492   
           130.924   112.098   95.7080   81.4736   69.1443

 MODIFICATION HISTORY:
        mgs, 21 Aug 1998: VERSION 1.00
  bmy & phs, 13 Jul 2007: GAMAP VERSION 2.10
                          - Updated comments

(See /n/home09/ryantosca/IDL/gamap2/atm_sci/hystat.pro)