Extended IDL Help

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: Wed Aug 13 22:06:15 2008.


List of Routines

VIEW/DOWNLOAD CODE


Routine Descriptions

FINDCLIP

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

 DESCRIPTION:
  This function estimates how to scale a first moment map of a data
  cube such that regions of interest will show a maximal velocity
  range. The idea is to calculate lower and upper bounds to the
  velocities in the first moment map. Pixels outside these boundaries
  should be set to these boundaries, effectively compressing the range of
  values to display on a screen. This is accomplished by finding whch
  range of velocities cover a set of pixels in a first moment map
  whose values in the zeroth moment map occupy most of the total flux
  in that map. This is meant to mimic what the IDL astronomy routine
  SIGRANGE does for a single image.

 CALLING SEQUENCE:
  result=FINDCLIP(inmom0, inmom1, [FRACTION=fraction, /NOZERO])

 INPUTS:
  inmom0: A 2d image giving the zeroth moment of some data cube
  inmom1: A 2d image giving the first moment of the same data cube

 KEYWORD PARAMETERS:
  FRACTION: Set this keyword to be what fraction of the mom0 map flux
            is contained within pixels which fall inbetween the output
            velocity boundaries in the mom1 map. If not set, 0.9 is used.
  NOZERO: If set, treat zeroes in the input maps as missing data.

 OUTPUT:
  A 2 element vector giving two velocities. The pixels falling
  between the range of these two values in inmom1 have values in
  inmom0 which together comprise 0.9 (or FRACTION) of the total flux
  in inmom0.

 MODIFICATION HISTORY:
  August 13, 2008: Written by Chris Beaumont

(See findclip.pro)


GCROT

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

 PURPOSE:
   This function computes, as a function of galactic coordinates, the
   angle between a vector pointing towards the galactic north pole
   and a vector pointing towards the North Celestial Pole. This can
   be used to commonly orient images aligned to ecliptic and galactic
   coordinate systems.

 CALLING SEQUENCE:
   result=GCROT(L,B,/DEGREE,/RADIAN)

 INPUTS:
   L:   Galactic longitude. Radians are assumed unless /DEGREE is set.
   B:   Galactic latitude. Radians are assumed unless /DEGREE is set.

 KEYWORD PARAMETERS:
   /DEGREE: If set, the input and output are given in degrees.
   
 OUTPUT:
   The clockwise rotation that aligns the galactic north pole with
   the NCP (in J2000 coordinates). In radians by default.

 RESTRICTIONS:
   This has not been tested for accuracy higher than roughly .5
   degrees. I wouldn't use this to determine the orientation of spectra
   slits or other high precision tasks without testing first.

 MODIFICATION HISTORY:
   Written by: Chris Beaumont, May 2008.
   June 2008 Chris Beaumont- Added /degree keyword. cnb

(See gcrot.pro)


KDIST

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

 PURPOSE:
  This function calculates the near and far kinematic distances for a
  given galactic longitude and radial velocity. The calculation uses
  the Galactic rotaion model of Brand and Blitz 1993, A&A, 275 : 67.

 CALLING SEQUENCE:
  result=KDIST( Latitude, Velocity, [/RADIANS])

 INPUTS:
  Latitude: Galactic Latitude. Currently must be in the range [-180,
  180] in degrees.

  Velocity: Radial velocity in km/s

 KEYWORD PARAMETERS:
  /RADIANS: If set, input Latitude is in radians

 OUTPUT:
  The two element vector [near_distance, far_distance] in kpc.

 RESTRICTIONS:
  Currently only computes distances for objects in the inner galaxy.  

 MODIFICATION HISTORY:
  Written by: Chris Beaumont, June 2008.
  June 23, 2008: Changed name from kinematic_distance to kdist. cnb
  June 23, 2008: Fixed bug in modding l with 2 pi. cnb
  July 17, 2008: Removed degrees keyword. Added radians. cnb
  July 17, 2008: Changed things so that, if l is a variable, it isn't modified

(See kdist.pro)


KDISTERR

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

 DESCRIPTION:
  This function calculates the two kinematic distances, with errors,
  for a given object whose velocity is known to some precision.

 CALLING SEQUENCE:
  result=KDISTERR( l, vlow, vhigh, [/RADIANS, /SILENT])

 INPUTS:
  l: The galactic longitude of the source given in degrees (or
     radians, if /RADIANS is set)
  vlow: The lower bound for the radial velocity estimate, in km/s
  vhigh: The uppper bound for the radial velocity estimate, in km/s

 OPTIONAL KEYWORDS:
  RADIANS: If set, l is given in radians
  SILENT: If set, textual summary of the results are suppressed

 OUTPUT:
  A 4 element vector. The first and third elements give the near and
  far kinematic distances in kpc, while the second and fourth give
  error estimates.

 RESTRICTIONS:
  This only works for objects with latitudes between 270 degrees and
  90 degrees, for which there are two possible kinematic distances

 FUNCTIONS CALLED:
  kdist

 MODIFICATION HISTORY:
  June 2008: Written by Chris Beaumont

(See kdisterr.pro)


NEXTAST

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

 PURPOSE:
  This function returns a structure of astrometry parameters parsed
  from a FITS header. It is meant to mimic the IDL Astronomy User's
  Library routine 'EXTAST', but is generalized to handing
  N-dimensional data files (e.g. spectral data cubes). Note, however,
  that EXTAST handles a wider variety of astrometry parameters and,
  I'm sure, is much more robust for 2D FITS files

 CALLING SEQUENCE:
  result=EXTAST(header)

 INPUTS:
  header: A string array containing a fits header (ie, the output
  from mrdfits)

 OUTPUTS;
  An anonymous structure with the following tags:
     .NAXIS- the number of axes in the file
     .SZ - An NAXIS element array containing NAXIS1...NAXIS[N]
     .CD - An NAXIS x NAXIS array holding the CD/cdelt keywords.
           CD[i,j]=CD[I]_J. If the header uses CDELT keywords
           instead, they are converted to matrix form (CDELT1 =
           CD1_1)
     .CRPIX - An NAXIS element array containing the CRPIX keywords
     .CRVAL - An NAXIS element array containing the CRVAl keywords
     .CTYPE - An NAXIS element array containing the CTYPE keywords

 RESTRICTIONS:
  Error checking is limited. This was developed and tested for fits
  files using cdelt or cdi_j keywords, with no distortion or other
  fancy features. 

 FUNCTIONS CALLED:
  SXPAR

 CATEGORY:
  FITS manipulation, Astrometry
 
 MODIFICATION HISTORY:
  July 27, 2008: Written by Chris Beaumont

(See nextast.pro)


NICER

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
  NICER
 
 DESCRIPTION:
  This function estimates the reddening to a star based on its JHK
  colors. Based on the NICER algorithm (Lombardi and Alves, 2001).

 CALLING SEQUENCE:
  result=NICER(j,dj,h,dh,k,dk)
 
 INPUTS:
  J,H,K: scalar or n-element vectors of a set of J,H,K magnitudes of a
         star. If any data are missing, insert fake data and see next
         sentnce.
  dH,dJ,dK: scalar or n-element vectors of the errors in the JHK
            colors. If any JHK data are unknown, insert fake data for
            those entries, and make the corresponding error entry
            extremely large. This will cause the algorithm to ignore
            the fake data point during fitting.

 OUTPUT:
  A 2 x n element array giving nth row gives the magnitudes of
  visual extinction, with associated error, estimated for star n.

 CATEGORIES:
  Photometry, Interstellar extinction

 MODIFICATION HISTORY:
  July 2008: Written by Chris Beaumont

(See nicer.pro)


POSTAGESTAMP

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

 DESCRIPTION:
  This function extracts a subregion from a 2 or 3-dimensional FITS
  image. It uses a nearest-neighbor regridding scheme.

 CALLING SEQUENCE:
  result=POSTAGESTAMP(im, head, cen, wid, scale, [/NAN])

 INPUTS:
  IM: A 2- or 3-dimensional image array
  HEAD: The FITS header corresponding to IM (as is generated by
        MRDFITS, for example)
  CEN: A  2 or 3 element array giving the center of the desired
       subfield in 'real sky units' (i.e. whatever real sky units are
       assumed within the CRVAL keywords of HEAD)
  WID: A 2 or 3 element array giving the size of the extracted
       subfield in 'real sky units' (see note for CEN)
  SCALE: A 2 or 3 element array giving the size of the output pixels
         in real sky units (whatever real sky units are assumed in
         the CD or CDELT keywords of HEAD) 

 KEYWORD PARAMETERS:
  NAN: If set and nonzero, regions of the subimage which lie outside
  the boundaries of the input image are output as NaN. Otherwise,
  they are output as zero.

 EXAMPLE:
  Given im and head, extract a .25 x .25 degree field centered at
  (a,d)=(10.,20.) where each pixel is .002 degrees

    result=postagestamp(in,head,[10.,20.],[.25,.25],.[.002,.002])
  
  Repeat, but this time preserve the convention that RA increases to
  the left in sky images:

    result=postagestamp(in,head,[10.,20.],[.25,.25],[-.002,.002])

 SIDE EFFECTS:
  The coordinates of CEN will always be the exact center of the
  output image, and the pixels will always be exactly the size given
  by scale. However, the output images have an odd number of pixels
  along each axis, and thus may be a pixel or two different from the
  size requested by WID.

  This function uses SKY2PIX, which provides rather limited
  astrometry capabilities (e.g. no corrections for field curvature or
  other higher order distortion terms).

 FUNCTIONS CALLED:
  NEXTAST, SKY2PIX, SXPAR

 CATEGORY:
  FITS image manipulation, astrometry

 MODIFICATION HISTORY:
  August 9, 2008: Written by Chris Beaumont

(See postagestamp.pro)


SKY2PIX

[Previous Routine] [List of Routines]
 NAME:
  SKY2PIX
 
 PURPOSE:
  This function translates between 'real' coordinates (eg, ra dec) to
  pixel coordinates in a fits file. Pixel co-ordinates are given as
  zero-indexed values (IDL convention) as opposed to 1-indexed (FITS
  convention). This was designed as a substute for ad2xy for
  multi-dimensional fits files (eg spectral data cubes, where extast
  chokes)

 CALLING SEQUENCE:
  result=sky2pix(header,coords,/backwards)

 INPUTS:
  header: A string array containing a fits header (eg, from mrdfits)
  Coords: An n by m array containing the n-dimensional coordinates of
          m datapoints. These are 'real sky' coordinates, unless the
          backwards keyword is set. If some of the higher dimensional
          coordinates are not needed for conversion, they may be
          omitted. If this is the case, however, only the first n
          dimensions will be given on output.

 OPTIONAL KEYWORDS:
  backwards: coords are given in pixel coordinates, and the output is
  given in sky coordinates

 OUTPUT:
  result: An array contining the pixel coordinates of the real coordinates
  given by coords. This array is the same size as coords.

  result [i,j] contains the coordinate component of the jth data point
  along the ith pixel dimension. 

  result[*,j] contains the coordinate of the jth data point.

 EXAMPLES:
   find the pixel location of (ra,dec,vel)=(5,6,7) in header h
   IDL> result=sky2pix(h,[5,6,7])
   
   find the pixel location of (ra,dec)=(5,6) in a data cube with
   header h, but whose third dimension (velocity) is not needed for
   the converstion
   IDL> result=sky2pix(h,[5,6])
   Note: result has only 2 dimensions, corresponding to the images
   x,y coords. The Z coordinate (velocity) is not used or returned

 RESTRICTIONS:
  The program relies upon NEXTAST, and thus isn't robust to unusual
  FITS files. This is meant to correctly convert coordinates using
  headers with crpix,crval,and cdelt or cd. If the header has extra
  information (distortion terms, projection terms) necessary for
  proper astrometry calculations, sky2pix will not give correct
  answers.

 FUNCTIONS CALLED:
  NEXTAST

 CATEGORY:
  astrometry, coordinate conversion

 MODIFICATION HISTORY:
  July 27 2008: Written by Chris Beaumont

(See sky2pix.pro)