package OMExpAnalyse;
use strict;
use English;
use Carp;
use vars
qw(@ISA $VERSION $name $author $date $version @instList $numberOfStreams);
@ISA = qw(Module);
use ModuleResources;
# Declare identity, version, author, date, etc.
$name = __PACKAGE__;
$VERSION = '1.06';
$version = $VERSION;
$author="Duncan John Fyfe";
$date="29-Jan-2007";
#
# ChangeLog
# =========
#
# Version 1.06 - 2007-01-29 (DJF)
# ------------
#
# + Telemetry drops can make the 'Priority window data' file unavailable. Change to ignore such exposures
# rather than fail.
#
# Version 1.05 - 2002-02-22 (DJF)
# ------------
#
# + omprep, change from default modeset=0 to modeset=3
#
# Version 1.04 - 2002-02-22 (DJF)
# ------------
#
# + Moved omprep to generate dummy prepThFile irrespective of status of
# the odfThFile as this dummy is needed in the OMImageAnalyse module.
#
# Version 1.03 - 2002-02-20 (DJF)
# ------------
#
# + Added tests to Tracking history and Tracking star time series creation.
# The tests are needed to prevent entries being created for products when
# either the THX file does not exist OR it contains all zeros.
#
# Version 1.02 - 2001-11-26 (DJF)
# ------------
#
# + Removed exposure mode identifiction. This has been
# Move to OMFastAnalyse and OMImageAnalyse. The selection
# criterea are complicated and a simple flag is not sufficient
# to accomodate them.
#
# Version 1.01 - 2001-10-31 (DJF)
# ------------
#
# + Added some info statements to give more useful logs
#
# Version 1.00 - 2001-10-09 (DJF)
# ------------
#
# + Initial version.
#
# Declare list of instruments this module is interested in
@instList=qw(om);
# Number of streams
sub numberOfStreams {
return numberOfExposures();
}
sub evaluateRules {
# If upstream module has been ignored, so if this one
return ignore() if ignored(module => 'ExpChooser',
instrument => thisInstrument,
stream => thisStream);
return ignore() if ignored(module => 'OMgetFlat',
instrument => thisInstrument,
stream => 1);
# Start conditions
start()
if complete(module => 'ExpChooser'
,instrument => thisInstrument
,stream => thisStream
)
and complete(module => 'GlobalHK'
,instrument => 'all'
,stream => 1
)
and complete(module => 'OMgetFlat'
,instrument => thisInstrument
,stream => 1
);
}
sub performAction {
info("Module version number: $version");
# Misc. variables
my (@extraopts);
# Find exposure ID
my $exp_id=exposureID(instrument => thisInstrument,
stream => thisStream);
# Find window data file
my $windowFile=findFile(class => 'odf'
,instrument => thisInstrument
,exp_id => $exp_id
,content => 'Priority window data'
);
unless ( fileExists( file => $windowFile) )
{
info("ODF Priority window data missing. Unable to continue.");
return ignore();
}
# Find periodic housekeeping file
my $phkFile=findFile(class => 'odf',
instrument => thisInstrument,
content => 'Periodic housekeeping',
required => 'true');
# Find non-periodic housekeeping file
my $nphkFile=findFile(class => 'odf',
instrument => thisInstrument,
content => 'Non-periodic housekeeping',
required => 'true');
# Flat created by omflatgen
my $flatGenFile=findFile(class => 'intermediate',
instrument => thisInstrument,
content => 'OM Flatfield');
# Initial call to omprep
my $odfThFile=findFile(class => 'odf',
instrument => thisInstrument,
exp_id => $exp_id,
content => 'Tracking history');
my $omprepSet = $odfThFile?$odfThFile:"DUMMYTHX.FIT";
# Need this outside the following 'if' because OMImageAnalyse needs the
# prepThFile even if it is empy even if it is empty
my $prepThFile=newFile(class => 'intermediate'
,instrument => thisInstrument
,exp_id => $exp_id
,content => 'omprep tracking history'
);
doCommand('omprep'
,nphset => $nphkFile
,pehset => $phkFile
,wdxset => $windowFile
,outset => $prepThFile
,set => $omprepSet
,modeset => 3
) or return exception();
if ($odfThFile) {
# Call omthconv to make a tracking history time series
my $TmpthTimeSeries=newFile(class => 'intermediate'
,instrument => thisInstrument
,exp_id => $exp_id
,content => 'OM TRACKING STAR TIMESERIES'
);
doCommand('omthconv'
,thxset => $prepThFile
,nphset => $nphkFile
,outset => $TmpthTimeSeries
) or return exception();
if (fileExists(file => $TmpthTimeSeries)) {
# Copy intermediate to prodcut
my $thTimeSeries=newFile(class => 'product'
,instrument => thisInstrument
,exp_id => $exp_id
,content => 'OM TRACKING STAR TIMESERIES'
);
copyFile(source => $TmpthTimeSeries
,destination => $thTimeSeries
);
}
# Make the tracking history plot
my $psTHplot=newFile(class => 'intermediate'
,instrument => thisInstrument
,exp_id => $exp_id
,content => 'OM TRACKING HISTORY PLOT'
,'format' => 'PS'
);
doCommand('omdrifthist'
,set => $prepThFile
,plotfile => $psTHplot
) or return exception();
if( fileExists(file => $psTHplot) ){
my $pdfTHplot=newFile(class => 'product'
,instrument => thisInstrument
,exp_id => $exp_id
,content => 'OM TRACKING HISTORY PLOT'
,'format' => 'PDF'
);
PStoPDF(source => $psTHplot
,destination => $pdfTHplot
) or return exception();
}
}
return success();
}
1;