sw0 (version 1.0)


#! /aps/tools/perl/bin/perl  -w

##############################################################################
#
# DESCRIPTION: This is the processing script for Swift.
#
# HISTORY: $Log: sw0,v $
# HISTORY: Revision 1.88  2014/04/30 08:00:07  apsop
# HISTORY: Revert to com8.7
# HISTORY:
# HISTORY: Revision 1.87  2014/04/30 01:40:28  apsop
# HISTORY: Use com8.8.
# HISTORY:
# HISTORY: Revision 1.86  2014/02/27 08:07:03  apsop
# HISTORY: Use common/com8.7
# HISTORY:
# HISTORY: Revision 1.85  2012/09/06 07:06:49  apsop
# HISTORY: Use common/com8.6.
# HISTORY:
# HISTORY: Revision 1.84  2012/05/17 07:54:16  apsop
# HISTORY: Put use lib common before use lib sw, so that sw overrides common
# HISTORY:
# HISTORY: Revision 1.83  2012/01/13 19:51:32  apsop
# HISTORY: Install scripts REQUIRE path to be .../sw/test (edits to {st,sw}/procNNN)
# HISTORY:
# HISTORY: Revision 1.82  2012/01/12 07:07:33  apsop
# HISTORY: 3.15.03, HEASoft-6.11
# HISTORY:
# HISTORY: 2011-12-04 JRG as apsop on sdcdev: 3.15.03
# HISTORY:
# HISTORY: 2011-08-30 JRG as apsop on sdcdev: 3.15.02 uses HEASoft/FTOOLS 6.11
# HISTORY:
# HISTORY: Revision 1.81  2011/01/20 19:38:11  apsop
# HISTORY: Added calls to new modules that generate new level 3 products
# HISTORY: 	XrtGrbLc
# HISTORY: 	AddGTI2Att
# HISTORY: 	XrtProducts
# HISTORY: 	UvotAttitude
# HISTORY: Please, do not change the location of the call to UvotAttitude as this call
# HISTORY: should take place early on in the entire process to allow the correct and
# HISTORY: systematic usage of the UVOT attitude file (if made available)
# HISTORY:
# HISTORY: Revision 1.80  2009/12/22 16:29:10  apsop
# HISTORY: Changed "/aps/subsys/proc/sw/proc3.14.0" to "/aps/subsys/proc/st/proc3.14.0"
# HISTORY: to make it work with script install_test
# HISTORY:
# HISTORY: Revision 1.79  2009/12/20 19:31:57  apsop
# HISTORY: Removed some comments
# HISTORY:
# HISTORY: Revision 1.78  2009/12/18 14:37:18  apsop
# HISTORY: This release contains several new items:
# HISTORY:   1. call to Subs::UvotGraspCorr for apsect correction
# HISTORY:   2. call to Subs::UvotProduct, which generates gifs light curves
# HISTORY:   3. call to Subs::XrtGrbLc, which generates gifs light curves for GRB based on XRT data
# HISTORY:
# HISTORY: Revision 1.77  2009/08/03 13:21:56  apsop
# HISTORY: Added Subs::XrtPhasCorr and Subs::BATLightCurve
# HISTORY:
# HISTORY: Revision 1.76  2007/12/02 19:34:38  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.75  2007/09/11 18:49:16  apsop
# HISTORY: Run new MakeFilter object before xrt tasks, so filter file is available to them.
# HISTORY:
# HISTORY: Revision 1.74  2007/06/29 16:46:08  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.73  2007/04/19 15:47:17  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.72  2007/02/01 17:08:12  apsop
# HISTORY: New version of common code: Merge HEADAS and FTOOLS, clean up env variables, perl only pfile I/O.
# HISTORY:
# HISTORY: Revision 1.71  2006/09/10 20:21:50  apsop
# HISTORY: Version 7.2 of the common code.
# HISTORY:
# HISTORY: Revision 1.70  2006/08/01 21:24:34  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.69  2006/06/28 19:31:41  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.68  2006/05/26 19:41:19  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.67  2006/04/28 18:48:04  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.66  2006/04/28 13:11:29  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.65  2006/03/06 17:30:28  apsop
# HISTORY: New UvotTdrss module.
# HISTORY:
# HISTORY: Revision 1.64  2006/02/10 15:14:45  apsop
# HISTORY: Replace CheckInput with SWCheckInput.
# HISTORY:
# HISTORY: Revision 1.63  2006/02/03 16:42:46  apsop
# HISTORY: New version of common code - now all times GMT.
# HISTORY:
# HISTORY: Revision 1.62  2006/01/20 19:47:11  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.61  2006/01/11 19:51:04  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.60  2005/11/23 22:39:55  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.59  2005/11/15 20:15:51  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.56  2005/11/08 16:30:51  apsop
# HISTORY: Go back to using CheckInput instead of SWCheckInput. Remove obsolete BATLightCurves.  Add XrtTdrss.
# HISTORY:
# HISTORY: Revision 1.55  2005/08/31 18:09:53  apsop
# HISTORY: Use com5.2.  Enable XRTDB and BATDB modules.
# HISTORY:
# HISTORY: Revision 1.54  2005/06/01 13:47:45  apsop
# HISTORY: New version of common (5.1).  Use and call SWCheckInput instead of CheckInput.
# HISTORY:
# HISTORY: Revision 1.53  2005/04/11 02:17:19  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.52  2005/04/01 18:20:22  apsop
# HISTORY: New version of common software.
# HISTORY:
# HISTORY: Revision 1.51  2005/03/07 22:39:17  apsop
# HISTORY: Use common code version 4.3
# HISTORY:
# HISTORY: Revision 1.50  2005/02/25 20:41:22  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY:
# HISTORY: Revision 1.48  2005/01/06 16:39:24  apsop
# HISTORY: Comment out UVOTDB module as quick bug fix.
# HISTORY:
# HISTORY: Revision 1.47  2004/12/14 18:19:21  apsop
# HISTORY: New version of common code.
# HISTORY:
# HISTORY: Revision 1.44  2004/11/30 21:22:28  apsop
# HISTORY: Explicitly call SW0Filename, in order to support test pipeline.
# HISTORY:
# HISTORY: Revision 1.43  2004/11/30 03:12:55  apsop
# HISTORY: Use version 4.0 of common code.
# HISTORY:
# HISTORY: Revision 1.42  2004/11/19 22:19:15  apsop
# HISTORY: Fix accidental commit.
# HISTORY:
# HISTORY: Revision 1.38  2004/11/11 22:31:21  apsop
# HISTORY: Put in modules for full BAT event processing.
# HISTORY:
# HISTORY: Revision 1.37  2004/11/10 18:34:56  apsop
# HISTORY: Add in call to BATQmap
# HISTORY:
# HISTORY: Revision 1.36  2004/11/03 02:51:11  apsop
# HISTORY: Fix up mistake in previous version
# HISTORY:
# HISTORY: Revision 1.34  2004/10/13 02:24:46  apsop
# HISTORY: Use com3.9, and include XRTProducts module (commented out for now).
# HISTORY:
# HISTORY: Revision 1.33  2004/09/14 19:06:56  apsop
# HISTORY: Add new SortTdrss module.
# HISTORY:
# HISTORY: Revision 1.32  2004/09/01 14:47:12  apsop
# HISTORY: Switch use lib order of common and sw code.
# HISTORY:
# HISTORY: Revision 1.31  2004/08/30 13:26:37  apsop
# HISTORY: Use com 3.7
# HISTORY:
# HISTORY
# HISTORY: 0.0 -> 1.0 2003-07-09
# HISTORY: The script actually does something now
#
# VERSION: 1.0
#
##############################################################################

use strict;

# Put use lib common before sw, so mission-specific versions (sw)
# override common ones (use lib _pre_pends to @INC).
# "sw/test" directory is edited by install script to correct version.
use lib "/aps/subsys/proc/common/com8.7";
use lib "/aps/subsys/proc/sw/proc3.18.04";

use Util::SW0Filename;
BEGIN {$::FILENAME='Util::SW0Filename'}

use Subs::SWCheckInput;
use Subs::XrtCoords;
use Subs::UvotCoords;
use Subs::Spacecraft2FITS;
use Subs::BAT2FITS;
use Subs::XRT2FITS;
use Subs::XrtPhasCorr;
use Subs::UVOT2FITS;
use Subs::ExtractTiming;
use Subs::ExtractGTIs;
use Subs::Attitude;
use Subs::StartEndTimes;
use Subs::SortTdrss;
use Subs::LocateBurst;
use Subs::BATQmap;
use Subs::BATBurst;
use Subs::BATIntervals;
use Subs::BATSurvey;
use Subs::BATImages;
use Subs::MakeFilter;
use Subs::XrtEvents;
use Subs::XrtTdrss;
use Subs::UvotTdrss;
use Subs::Filter;
use Subs::XrtImages;
use Subs::UvotImages;

use Subs::UvotAttitude;

use Subs::NFILightCurves;
use Subs::BATSpectra;
use Subs::BATLightCurve;
use Subs::Spectra;
use Subs::CalSources;
use Subs::SW0Header;
use Subs::BATFinish;
use Subs::BATDB;
use Subs::UVOTReport;
use Subs::UVOTDB;
use Subs::XRTDB;
use Subs::XRTReport;
use Subs::SW0WrapUp;

use Subs::UvotGraspCorr;
use Subs::UvotProduct;
use Subs::XrtGrbLc;
use Subs::XrtProducts;
use Subs::AddGTI2Att;

##########################
# PROCESSING STEPS:
##########################

Subs::SWCheckInput->new()->run();

############################
# convert telemetry to FITS
############################
Subs::Spacecraft2FITS->new()->run();
Subs::BAT2FITS ->new()->run();
Subs::XRT2FITS ->new()->run();
Subs::XrtPhasCorr->new()->run();
Subs::UVOT2FITS->new()->run();

Subs::ExtractTiming->new()->run();

Subs::ExtractGTIs  ->new()->run();
Subs::Attitude     ->new()->run();
Subs::StartEndTimes->new()->run();

Subs::UvotAttitude ->new()->run();


Subs::XrtTdrss     ->new()->run();
Subs::UvotTdrss    ->new()->run();
Subs::SortTdrss    ->new()->run();
Subs::LocateBurst  ->new()->run();

#################################
# calibrate the unfiltered files
#################################
Subs::BATQmap      ->new()->run();
Subs::BATBurst     ->new()->run();
Subs::BATIntervals ->new()->run();

Subs::BATImages    ->new()->run();

Subs::BATSpectra   ->new()->run();
Subs::BATLightCurve->new()->run();

Subs::MakeFilter->new()->run();

Subs::XrtCoords->new()->run();
Subs::XrtEvents->new()->run();

Subs::UvotCoords->new()->run();

############################
# filter the data
###########################
Subs::Filter->new()->run();


##############################
# extract products
##############################
##Subs::BATSurvey->new()->run();

Subs::UvotImages    ->new()->run();
Subs::UvotGraspCorr->new()->run();
Subs::UvotProduct->new()->run();


Subs::XrtProducts   ->new()->run();
Subs::XrtGrbLc->new()->run();

###############################
# trend products
###############################

Subs::UVOTReport->new()->run();
Subs::UVOTDB->new()->run();
Subs::XRTDB->new()->run();
Subs::XRTReport->new()->run();
Subs::BATFinish->new()->run();
Subs::BATDB->new()->run();

# Adds GTI extension to spacecraft attitude file
Subs::AddGTI2Att->new()->run();

Subs::SW0Header ->new()->run();
Subs::SW0WrapUp ->new()->run();

exit 0;