#-----------------------------------------------------------------------

nirlin.py is a simple Python script to linearize Gemini NIRI data.


#-----------------------------------------------------------------------
# INSTALLATION

Put nirlin.py in your path and make sure that Python, PyFITS and NumPy
are installed on your system.


#-----------------------------------------------------------------------
# EXAMPLE 1.  Get basic usage information by running with no arguments:

> nirlin.py

NAME
       nirlin.py - NIR linearization

SYNOPSIS
       nirlin.py [options] infile

DESCRIPTION
       Run on raw or nprepared Gemini NIRI data, this
       script calculates and applies a per-pixel linearity
       correction based on the counts in the pixel, the
       exposure time, the read mode, the bias level and the
       ROI.  Pixels over the maximum correctable value are
       set to BADVAL unless given the force flag.
       Note that you may use glob expansion in infile,
       however, any pattern matching characters (*,?)
       must be either quoted or escaped with a backslash.

OPTIONS
       -b <badval> : value to assign to uncorrectable pixels [0]
       -f : force correction on all pixels
       -o <file> : write output to <file> [l<inputfile>]
       -v : verbose debugging output

VERSION
       2011 Feb 5


#-----------------------------------------------------------------------
# EXAMPLE 2.  Run on a NIRI image using the default parameters:

> nirlin.py N20090112S0112.fits

...reading N20090112S0112.fits
...image dimensions = 1024 x 1024
...exposure time = 30.001 s
...mean of input image = 85.8700942993
...number of coadds = 3
...converting to counts / coadd...
...number of low noise reads = 1
...number of digital averages = 16
...read mode = medium-noise
...bias voltage = -0.583 V
...well depth = shallow
...upper limit for linearization = 12000 ADU/coadd
... 0.628096821109 < correction factors < 1.11220871884
...mean correction factor = 0.778385953326
...median correction factor = 0.781957767359
...setting out-of-range pixels to 0
...mean of output image = 74.8220560327
...updating header...
...writing lN20090112S0112.fits


#-----------------------------------------------------------------------
# EXAMPLE 3.  Run on an image in the rawdata directory, force the 
# linearity correction on all pixels (even if they may not be
# correctable), and output a file with the same name into a directory
# called processed:

> nirlin.py -f -o processed/N20090112S0112.fits rawdata/N20090112S0112.fits

...reading rawdata/N20090112S0112.fits
...image dimensions = 1024 x 1024
...exposure time = 30.001 s
...mean of input image = 85.8700942993
...number of coadds = 3
...converting to counts / coadd...
...number of low noise reads = 1
...number of digital averages = 16
...read mode = medium-noise
...bias voltage = -0.583 V
...well depth = shallow
...forcing linearity correction on all pixels
... 0.628096821109 < correction factors < 1.13473331128
...mean correction factor = 0.778389535869
...median correction factor = 0.781968504201
...mean of output image = 75.2653219841
...updating header...
...writing processed/N20090112S0112.fits


#-----------------------------------------------------------------------
