#-----------------------------------------------------------------------------
# IRACproc: IRAC Post-BCD Processing v4.3 CHANGES
#-----------------------------------------------------------------------------
(c) 2005 Mike Schuster, Massimo Marengo (mmarengo@cfa.harvard.edu)
(c) 2005 SAO - Smithsonian Astrophysical Observatory

Harvard-Smithsonian Center for Astrophysics
Smithsonian Astrophysical Observatory

31 JUL 2008

#-----------------------------------------------------------------------------
# New for v4.3
#-----------------------------------------------------------------------------

New High Dynamic Range (HDR) PSFs, and improved PSF-subtraction routine 
psfsub_bcd

New routine cleanup - deletes unnecessary IRACproc output

Routines psfmask_bcd and psfuncrop_bcd now psfmask_fits and psfuncrop_fits

Improved image selection based on WCS coordinates in mkmosaic_bcd (WCS_BOX 
option removed)

Improved BAD value handling (esp. coadd_fits, project2D)

Improved memory usage (esp. deriv_fits)

Improved support for large images in cropout_bcd, backgrnd2D

#-----------------------------------------------------------------------------
# New for v4.2
#-----------------------------------------------------------------------------
New wrapper/log (my_iracproc) for batch processing a single IRAC data set

Final mosaic pixel scale is now set with mkmosaic_bcd (instead of fixup).
The script refixup will reset the configuration files for an existing 
IRACproc directory structure.

mkmosaic_bcd STEP 6 now writes CREATOR header keyword from first image in 
bcd image list into final mosaic header - this is the SSC pipeline version

Notes for background fitting/subtraction in large mosaics

Notes for dark frame subtraction and background registering near saturated 
sources

New routine for coadding individual sub-array image packs before coadding the 
resulting images with mkmosaic_bcd - this is a significant improvement over 
previous methods

Updated Pmasks from SSC web site

Revised setup

General improvements to code (subroutines, etc.)

New subroutine pedsub_fits for subtracting images, pedestals, etc (replaces 
pedestal_bcd).

coadd_fits now includes options to calculate the minimum, maximum, biased 
median, division of two images, and patch a PSF peak onto a saturated core 
(also - improved memory usage, bug fixes, etc.). There are also new 
methodologies for outlier rejection that are based on the type of pixel stack 
distribution.

#-----------------------------------------------------------------------------
# New for v4.1.2
#-----------------------------------------------------------------------------
Fixed several bugs in coadd_fits and project2D routines 
(affects bad values - NaN's, and dimensions of output images)

coadd_fits now includes an option to calculate the Absolute Minimum Deviation 
image

Improved outlier rejection for coadd_fits

#-----------------------------------------------------------------------------
# New for v4.1.1
#-----------------------------------------------------------------------------
Fixed minor bug in coadd_fits routine (affects only headers of output files)

#-----------------------------------------------------------------------------
# New for v4.1
#-----------------------------------------------------------------------------
MOPEX option USE_REFINED_POINTING now set to 0 (not used) since S13+ 
pipelines have improved the pointing inserted into CRVAL1 and CRVAL2

Additional documentation for IRACproc and the main perl and perlDL routines

fixup script is now more compatible with other contributed software for IRAC

General improvements to code (memory usage, subroutines, etc.)

coadd_fits routine replaces coadd_bcd (includes drizzle option and improved 
outlier rejection)

coadd_fits now includes an option to calculate a color image

No longer distribute specialized routines for Nearby Stars program

Simplified PDL installation outside CfA

pgplot is no longer required by IRACproc

#-----------------------------------------------------------------------------
# New for v4.0 beta
#-----------------------------------------------------------------------------
Improved outlier rejection for shallow coverage (2-4 frames)

Elimination of IRAF dependencies for co-addition

Simpler, 5-step process for producing mosaic images

Accommodation for performing additional preprocessing of data outside IRACproc

Keyword options in mkmosaic_bcd that add flexibility to customize processing 
parameters

Additional keyword options in mkmopex_bcd that help to sort through BCD 
frames to select only those frames for further processing that are 'on' or 
'off' field, as well as within a box specified by WCS coordinates

Added the 'mode' as an option for determining the background pedestal in an 
image - available in all PDL routines that have the option "BACKGRND"

Some improved documentation

#-----------------------------------------------------------------------------
# Beta software for v3.3
#-----------------------------------------------------------------------------
4-step process for measuring photometry

Photometry scripts (see HOWTO_PHOT)

Script for correlating photometry from up to 4 channels (correlate.pl)

#-----------------------------------------------------------------------------
# New for v3.3
#-----------------------------------------------------------------------------
Outlier rejection improved for high coverage (>~10 frames)

Fixed bug in coadd_bcd that caused unnecessary interpolation of images

coadd_bcd will now trim PSF-subtracted images to their original size and can 
subtract multiple PSFs with the "diff" method

New routines for masking/cropping PSF artifacts (psfmask_bcd, multimask_bcd, 
and psfuncrop_bcd)

Proc #6: mkmetmap replaces mksrcmap (_src.fits images are now _bmet.fits)

Proc #8 (cropout) can now crop an image section by specifying its center and 
size in addition to its corners

Added options to fixup and multi_fixup scripts that allow user customization

Eliminated redundant configuration files

Simplified setup process

The IRACproc directory is now IRACproc/

#-----------------------------------------------------------------------------
# New for v3.2.1
#-----------------------------------------------------------------------------
Fixed bug in coadd_bcd that truncated WCS header keywords

#-----------------------------------------------------------------------------
# New for v3.2
#-----------------------------------------------------------------------------
Outlier rejection improved for moderate coverage (4-24 frames)

Latest Pmasks from the SSC are included (including Sub-Array)

A master Fiducial Image Frame can be created for all channels

The number of files that can be processed has been increased

Proc #1 (fixup) can now group one or more related AORs into one directory for 
processing, multi_fixup will run fixup in batch mode

Proc #6 (mksrcmap) now has parameter "scale" for fine tuning outlier rejection

Proc #8 (cropout) is now done in PDL (vs. IRAF for previous versions) and has 
more functionality

Update for coadd_bcd: multiple PSF subtraction now uses 'diff' function, etc.

The _expmap.fits images are now simply the coverage maps for each mosaic 
(_mosaic_cov.fits)

The measure/ and PSFsub/ directories have been replaced with analysis/
The useless/ directory has been replaced with .iracproc_tmp/

The contents of IRAC_proc/config/ are now copied to <SRC>/Lists/ so that 
copies of the configuration files are modified by the user

IRAC_proc is now distributed independently from the HDR PSFs

PSFs are available as IRAC_psfs-<VER>.tgz (PSFs have new file names)
Go into IRAC_proc/ and untar

#-----------------------------------------------------------------------------
# New for v3.1
#-----------------------------------------------------------------------------
IRAC_proc will now run on any standard RedHat Linux system with PDL, PGPlot, 
MOPEX, and IRAF/STSDAS installed

IRACproc can now be installed anywhere on your linux system

Simplified installation

The IRAC_proc directory no longer contains the version number

Bug fix and update for coadd_bcd

The outputs from Processing steps #1-8 are unchanged from IRAC_proc_2.0

#-----------------------------------------------------------------------------
# New for v3.0
#-----------------------------------------------------------------------------
PSFs and PSF subtraction software

Notes on how to handle Sub-Array data

Improved documentation

The outputs from Processing steps #1-8 are unchanged from IRAC_proc_2.0

Processing is more user friendly

The number of files that can be processed has been increased

#-----------------------------------------------------------------------------
# New for v2.0
#-----------------------------------------------------------------------------
Mosaic can now be made as large as MOPEX can handle

Slightly improved outlier rejection

Each channel can be processed independently

Alternative provided to visually inspecting each BCD frame before processing

Source maps (_srcmap.fits) and matched source maps (_matchsrc.fits) for each 
mosaic are no longer produced

Copies each mosaic are no longer placed in <SRC>/