package MOSEvents;
use strict;
use English;
use Carp;
use List::Util qw(min max);
use vars
qw(@ISA $VERSION $name $author $date $version @instList $numberOfStreams);
@ISA = qw(Module);
use ModuleResources;
$name=__PACKAGE__;
$VERSION='3.55';
$version = $VERSION;
$author='Dean Hinshaw,Richard West,Duncan John Fyfe,Ian Stewart,Duncan Law-Green,Eduardo Ojero,Ed Chapin,Jose V Perea';
$date='2018-07-25';
@instList=qw(emos1 emos2);
sub numberOfStreams {
return numberOfExposures();
}
sub evaluateRules {
return ignore() if ignored(module => 'ExpChooser',
instrument => thisInstrument,
stream => thisStream);
return ignore() if ($ENV{'PCMS_ISSLEW'});
start()
if complete(module => 'ExpChooser',
instrument => thisInstrument,
stream => thisStream)
and
complete(module => 'InstrumentHK',
instrument => thisInstrument,
stream => 1)
and
complete(module => 'GlobalHK',
instrument => 'all',
stream => 1);
}
my $flareFlags = ['UNDERSHOOT'
, 'BAD_E3E4'
, 'ON_BADROW'
, 'OUTSIDE_THRESHOLDS'
, 'OUT_OF_CCD_WINDOW'
, 'ON_BADPIX'
, 'COSMIC_RAY'
, 'IN_BAD_FRAME'
, 'OUT_OF_FOV'
, 'FLICKERING'
, 'ON_BADOFFSET'
];
my $eventlistFlags =['UNDERSHOOT'
, 'BAD_E3E4'
, 'ON_BADROW'
, 'OUTSIDE_THRESHOLDS'
, 'OUT_OF_CCD_WINDOW'
, 'ON_BADPIX'
, 'COSMIC_RAY'
, 'IN_BAD_FRAME'
, 'FLICKERING'
, 'ON_BADOFFSET'
];
sub performAction {
info("Module version number: $version");
my @extraopts;
my $exp_id=exposureID(instrument => thisInstrument
,stream => thisStream
);
info("Exposure ID: $exp_id");
my $filter=getExposureProperty(exp_id => $exp_id
,name => 'filter'
);
my $mode=getExposureProperty(exp_id => $exp_id
,name => 'mode'
);
info("Filter: $filter");
info("Instrument mode: $mode");
my @evFiles=findFile(class => 'ODF'
,instrument => thisInstrument
,exp_id => $exp_id
,content => '*events'
);
if ($#evFiles<0)
{
ppd("000005");
return success();
}
my @evFiles2;
my $auxFile=findFile(class => 'ODF'
,instrument => thisInstrument
,exp_id => $exp_id
,content => 'Auxiliary data'
,required => 'true'
);
my $attFile=findFile(class => 'product'
,instrument => 'all'
,content => 'Attitude time series'
,required => 'true'
);
my $hkGTIFile=findFile(class => 'intermediate'
,instrument => thisInstrument
,content => 'HK GTI'
);
my $mingtisize = 100;
my @ccxfiles = findFile(class => 'ODF'
,instrument => thisInstrument
,exp_id => $exp_id
,content => 'Counting cycle report'
);
unless (@ccxfiles) {
info("No counting cycle report found. Setting mingtisize=0");
$mingtisize = 0;
}
my @filter;
my $fovArea = 0;
foreach my $evFile0 (@evFiles)
{
my $ccd=readFITSKeyword(file => $evFile0,
extension => 2,
keyword => "CCDID"
);
if (manualintervention( instrument => thisInstrument . "ccd", exposure => $ccd ))
{
info("Manual Intervention. Ignoring CCD $ccd");
next;
}
my $node=readFITSKeyword(file => $evFile0,
extension => 2,
keyword => "CCDNODE"
);
my $datamode=readFITSKeyword(file => $evFile0,
extension => 2,
keyword => "DATATYPE"
);
info("First pass of events for CCD $ccd, node $node, mode=$datamode");
my $frameFile=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node, 'ccd' => $ccd,
content => 'Rectified frames'
);
my $gtiFile1=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node,
ccd => $ccd,
content => 'CCD GTI',
level => 1
);
my $evFile1=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node,
ccd => $ccd,
content => 'Processed events',
level => 1
);
@extraopts=();
@extraopts=(flagbadtimes => 'yes', ingtiset => $hkGTIFile)
if $hkGTIFile
;
doCommand('emframes',
auxiliaryset => $auxFile,
frameset => $frameFile,
withodfeventset => 'Y',
odfeventset => $evFile0,
neweventset => 'Y',
outeventset => $evFile1,
writegtiset => 'Y',
outgtiset => $gtiFile1,
@extraopts
) or return exception();
if( hasFITSKeyword(file=>$frameFile, extension=>'FRAMES', keyword=>'GAIN_CCD')
&& readFITSKeyword(file=>$frameFile, extension=>'FRAMES', keyword=>'GAIN_CCD') =~ /^LOW/
){
info("CCD $ccd is in low gain mode. Will not process events for this ccd.");
ppd(id => "000007" , ccd => $ccd , node => $node );
next;
}
push @evFiles2, $evFile0;
@extraopts=();
if( $datamode eq "IMAGE.EL" || $datamode eq "RIMAGE.EL" )
{
my $evFile2=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node,
ccd => $ccd,
content => 'Processed events',
level => 2
);
@extraopts=();
@extraopts=( rejectbade3 => 'N' )
unless ($datamode eq "IMAGE.EL");
my @ovfile=findFile(class => 'ODF',
instrument => thisInstrument,
ccd => $ccd,
node => $node,
content => 'Offset/variance mode events'
);
push(@extraopts, withoffvarsets => 'Y', offvarsets => join(" ",@ovfile))
if @ovfile;
ppd(id => "000006" , ccd => $ccd , node => $node) if @ovfile;
doCommand('emevents',
odfeventset => $evFile1,
eventset => $evFile2,
analysepatterns => 'N',
flagbadpixels => 'N',
splitdiagonals => 'N',
withframeset => 'Y',
frameset => $frameFile,
randomizeposition => 'N',
@extraopts)
or return exception();
doCommand('emenergy',
ineventset => $evFile2,
correctcti => 'N',
correctgain => 'N',
randomizeenergy => 'N')
or return exception();
$fovArea += readFITSKeyword(file => $evFile2
,extension => 'EVENTS'
,keyword => 'IN_FOV'
) if ( hasFITSKeyword(file => $evFile2
,extension => 'EVENTS'
,keyword => 'XMMEA_22'
)
);
}
}
my $hasBadpixGti = 0;
my $bpFlareGti;
my $backgrndBinsize = 26;
my $GTI_time_threshold=gtiTimeThreshold();
my $fovAreaThreshold = 10;
if( $fovArea > $fovAreaThreshold )
{
ppd(id => "000008" , data => { fovarea => $fovArea , threshold => $fovAreaThreshold } );
my $bpEvFile=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
content => 'Bad pix find event list'
);
my @outerEvFiles=findFile(class => 'intermediate'
,instrument => thisInstrument
,exp_id => $exp_id
,content => 'Processed events'
,level => 2
);
doCommand('evlistcomb'
,eventsets => [@outerEvFiles]
,imagingset => $bpEvFile
,instrument => 'emos'
,emosdatamodes => 'IMAGING'
);
$bpFlareGti=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
content => 'Bad pix flare GTI');
my $histoFile=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
content => 'Flare rates file',
level => 1);
if( hasFITSKeyword(file => $bpEvFile, extension => 'EVENTS', keyword => 'XMMEA_22') )
{
my $flareBitmask = getEventBitmask(file=>$bpEvFile, masks=>$flareFlags);
ppd(id => "000009" , data => { flarebitmask => $flareBitmask } );
doCommand('evselect'
,table => $bpEvFile
,writedss => 'N'
,updateexposure => 'N'
,withrateset => 'Y'
,rateset => $histoFile
,maketimecolumn => 'Y'
,makeratecolumn => 'Y'
,timebinsize => $backgrndBinsize
,timecolumn => 'TIME'
,expression => "(PATTERN==0) && #XMMEA_22 && ((FLAG & $flareBitmask) == 0)"
,withimageset => 'N'
) or return exception();
if( numberFITSRows(file=>$histoFile, extension=>'RATE') > 0 && check_min_max_rate_col($histoFile) )
{
my $optCmd = "bkgoptrate fracexpstyle=auto tssettabname=$histoFile:RATE withendtime=N withlowercutoffcount=N withmintimeratio=N ignorelowcnttail=Y withstarttime=N -w 10";
info("RUN: $optCmd");
my $optRate = `$optCmd`;
chomp $optRate;
info("OPTRATE: $optRate");
if ( $optRate ) {
doCommand('tabgtigen'
,table => $histoFile
,gtiset => $bpFlareGti
,expression => "RATE<$optRate"
,mingtisize => $mingtisize
) or return exception();
my $GTI_time=0;
if ($GTI_time_threshold)
{
$GTI_time = readFITSKeyword(file => $bpFlareGti
,extension => "STDGTI"
,keyword => "ONTIME"
);
ppd(id => "000010" , data => { ontime => $GTI_time , threshold => $GTI_time_threshold } );
info("Flare screening GTI_Time: $GTI_time, GTI_time_threshold: $GTI_time_threshold");
}
if ( numberFITSRows(file => $bpFlareGti, extension => 'STDGTI') > 0
&& ($GTI_time > $GTI_time_threshold || !$GTI_time_threshold)
)
{
ppd( id => "000011" );
$hasBadpixGti = 1;
}
} else {
info("OPTRATE: Empty. Skipping 'Bad pix flare GTI' creation");
}
}
}
}
$fovArea = 0;
foreach my $evFile0 (@evFiles2)
{
my $ccd=readFITSKeyword(file => $evFile0,
extension => 2,
keyword => "CCDID");
if (manualintervention( instrument => thisInstrument . "ccd", exposure => $ccd ))
{
info("Manual Intervention. Ignoring CCD $ccd");
next;
}
my $node=readFITSKeyword(file => $evFile0,
extension => 2,
keyword => "CCDNODE");
my $datamode=readFITSKeyword(file => $evFile0,
extension => 2,
keyword => "DATATYPE");
info("Second pass of events for CCD $ccd, node $node, mode=$datamode");
my $frameFile=findFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node, 'ccd' => $ccd,
content => 'Rectified frames');
my $evFile1=findFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node,
ccd => $ccd,
content => 'Processed events',
level => 1);
my $gtiFile1=findFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node,
ccd => $ccd,
content => 'CCD GTI',
level => 1);
my $evFile3=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node,
ccd => $ccd,
content => 'Processed events',
level => 3);
@extraopts=();
if( $datamode eq "IMAGE.EL" || $datamode eq "RIMAGE.EL" )
{
my $evFile2=findFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node,
ccd => $ccd,
content => 'Processed events',
level => 2);
my $badFile=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node,
ccd => $ccd,
content => 'Bad pixel list');
my $projFile=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node,
ccd => $ccd,
content => 'Projected image');
@extraopts=(findbright => 'N') if $hasBadpixGti;
doCommand('emeventsproj',
eventset => $evFile2,
rejectbadevents => 'Y',
evimageset => $projFile)
or return exception();
doCommand('embadpixfind',
evimageset => $projFile,
badpixset => $badFile,
includedeadpixels => 'Y',
@extraopts)
or return exception();
if($hasBadpixGti)
{
doCommand('evselect'
,writedss => 'N'
,updateexposure => 'N'
,table => $evFile2
,keepfilteroutput => 'Y'
,expression => "gti($bpFlareGti:STDGTI,TIME)"
,withimageset => 'N'
) or return exception();
doCommand('emeventsproj',
eventset => $evFile2,
rejectbadevents => 'Y',
evimageset => $projFile)
or return exception();
doCommand('embadpixfind',
evimageset => $projFile,
badpixset => $badFile,
finddead => 'N',
incremental => 'Y')
or return exception();
}
@extraopts=(getnewbadpix => 'Y'
,badpixset => $badFile
,getuplnkbadpix => 'Y'
,getotherbadpix => 'Y'
);
}
doCommand('badpix',
eventset => $evFile1,
withoutset => 'Y',
outset => $evFile3,
windowfilter => 'Y',
@extraopts)
or return exception();
@extraopts=();
my @ovfile=findFile(class => 'ODF',
instrument => thisInstrument,
ccd => $ccd,
node => $node,
content => 'Offset/variance mode events');
if ( @ovfile )
{
ppd( id => "000012" );
push(@extraopts, withoffvarsets => 'Y', offvarsets => join(" ",@ovfile));
}
push(@extraopts, splitdiagonals => 'N')
if $datamode eq "TIME.EL" || $datamode eq "CTIME.EL";
push(@extraopts, flagtruncatede1 => 'N')
if $datamode eq "CTIME.EL";
push(@extraopts, rejectbade3 => 'N')
unless $datamode eq "IMAGE.EL";
my $evFile4=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node,
ccd => $ccd,
content => 'Processed events',
level => 4
);
doCommand("emevents",
withframeset => 'Y',
frameset => $frameFile,
odfeventset => $evFile3,
eventset => $evFile4,
randomizeposition => 'Y',
randomizetime => 'Y',
@extraopts
) or return exception();
my $hkGtiFileAligned=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node,
ccd => $ccd,
content => 'Aligned HK GTI');
my $gtiFile2=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
node => $node,
ccd => $ccd,
content => 'CCD GTI',
level => 2);
if( fileExists(file => $hkGTIFile) )
{
ppd("000013");
if( ($datamode eq "IMAGE.EL" || $datamode eq "RIMAGE.EL") )
{
doCommand("gtialign",
gtitable => $hkGTIFile . ":STDGTI",
eventset => $evFile4,
outset => $hkGtiFileAligned)
or return exception();
}
else
{
copyFile(source => $hkGTIFile, destination => $hkGtiFileAligned);
doCommand("dscp",
from => "$hkGtiFileAligned:STDGTI",
to => "$hkGtiFileAligned:STDGTI" . $node . $ccd)
or return exception();
doCommand("dsrm",
objects => "$hkGtiFileAligned:STDGTI")
or return exception();
}
doCommand("gtimerge",
tables => "$hkGtiFileAligned $gtiFile1",
mergemode => 'and',
gtitable => "$gtiFile2:STDGTI" . $node . $ccd)
or return exception();
}
else
{
copyFile(source => $gtiFile1, destination => $gtiFile2);
}
push(@filter,"(CCDNR==${node}${ccd} && GTI($gtiFile2,TIME))");
doCommand("attcalc",
eventset => $evFile4,
refpointlabel => 'pnt',
withmedianpnt => 'true',
attitudelabel => 'ahf',
atthkset => $attFile)
or return exception();
@extraopts=();
push(@extraopts, getccdbkg => 'N', rejectbade3e4 => 'N')
unless $datamode eq "IMAGE.EL";
doCommand('emenergy',
ineventset => $evFile4,
randomizeenergy => 'Y',
@extraopts)
or return exception();
$fovArea += readFITSKeyword(file => $evFile4
,extension => 'EVENTS'
,keyword => 'IN_FOV'
) if ( hasFITSKeyword(file => $evFile4
,extension => 'EVENTS'
,keyword => 'XMMEA_22'
)
);
my $eventBitmask = getEventBitmask(file=>$evFile4, masks=>$eventlistFlags);
doCommand('evselect'
,table => "${evFile4}:EVENTS"
,destruct => 'Y'
,keepfilteroutput => 'Y'
,writedss => 'Y'
,updateexposure => 'N'
,expression => "(FLAG & $eventBitmask)==0"
,withimageset => 'N'
) or return exception();
}
@evFiles=findFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
content => 'Processed events',
level => 4);
my $tmpimgEvents=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
content => 'imaging mode event list');
my $tmptimEvents=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
content => 'timing mode event list');
doCommand('evlistcomb',
eventsets => [@evFiles],
imagingset => $tmpimgEvents,
timingset => $tmptimEvents,
instrument => 'emos',
maintable => 'EVENTS OFFSETS',
othertables => 'EXPOSURE STDGTI BADPIX' )
or return exception();
my $expr=join("||", @filter);
my $cifFile=findFile(class => 'product',
content => 'Calibration index file');
if(fileExists(file => $tmpimgEvents))
{
my $imgEvents=newFile(class => 'product',
instrument => thisInstrument,
exp_id => $exp_id,
content => 'EPIC MOS imaging mode event list');
my $eventBitmask = getEventBitmask(file=>$tmpimgEvents, masks=>$eventlistFlags);
doCommand('evselect'
,table => $tmpimgEvents
,filteredset => "${imgEvents}:EVENTS"
,withfilteredset => 'true'
,expression => "($expr) && (FLAG & $eventBitmask)==0"
,writedss => 'true'
,cleandss => 'true'
,updateexposure => 'true'
,keepfilteroutput => 'true'
,destruct => 'true'
,withimageset => 'N'
) or return exception();
doCommand('attcalc',
,eventset => $imgEvents,
,refpointlabel => 'pnt',
,withmedianpnt => 'true',
,attitudelabel => 'ahf',
,atthkset => $attFile,
,calctlmax => 'yes')
or return exception();
my $attGTIFilteredEvents = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'Att GTI filtered events'
);
my $attGTIFile = findFile(
class => 'intermediate'
, instrument => 'all'
, content => 'attitude GTI'
);
doCommand(
'evselect'
, table => $imgEvents
, filteredset => $attGTIFilteredEvents
, withfilteredset => 'Y'
, expression => "GTI($attGTIFile,TIME)"
)
or return exception();
doCommand(
'attcalc'
,eventset => $attGTIFilteredEvents
,refpointlabel => 'pnt'
,attitudelabel => 'ahf'
,withmedianpnt => 'Y'
,atthkset => $attFile
,calctlmax => 'yes'
,-w => 10
)
or return exception();
my $tlmin6_inter = readFITSKeyword(file => $attGTIFilteredEvents, extension => 'EVENTS', keyword => 'TLMIN6');
my $tlmax6_inter = readFITSKeyword(file => $attGTIFilteredEvents, extension => 'EVENTS', keyword => 'TLMAX6');
my $tlmin7_inter = readFITSKeyword(file => $attGTIFilteredEvents, extension => 'EVENTS', keyword => 'TLMIN7');
my $tlmax7_inter = readFITSKeyword(file => $attGTIFilteredEvents, extension => 'EVENTS', keyword => 'TLMAX7');
FITSUtils::writeKeyword($imgEvents, "EVENTS", "TLMIN6" => {value => $tlmin6_inter});
FITSUtils::writeKeyword($imgEvents, "EVENTS", "TLMAX6" => {value => $tlmax6_inter});
FITSUtils::writeKeyword($imgEvents, "EVENTS", "TLMIN7" => {value => $tlmin7_inter});
FITSUtils::writeKeyword($imgEvents, "EVENTS", "TLMAX7" => {value => $tlmax7_inter});
my $submode = readFITSKeyword(
file => $imgEvents
, extension => 'PRIMARY'
, keyword => 'SUBMODE'
) or return exception();
info("Imaging mode for ", thisInstrument , ", exposure: $exp_id : $submode. Producing FWC data...");
my $imgFWCEvents = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'EPIC MOS imaging mode FWC event list'
);
doCommand(
'evqpb'
, table => $imgEvents
, attfile => $attFile
, outset => $imgFWCEvents
, exposurefactor => 4
, calctlmax => 'Y'
, overwritesubmode => 'Y'
)
or return exception();
FITSUtils::writeKeyword($imgFWCEvents, "EVENTS", "TLMIN6" => {value => $tlmin6_inter});
FITSUtils::writeKeyword($imgFWCEvents, "EVENTS", "TLMAX6" => {value => $tlmax6_inter});
FITSUtils::writeKeyword($imgFWCEvents, "EVENTS", "TLMIN7" => {value => $tlmin7_inter});
FITSUtils::writeKeyword($imgFWCEvents, "EVENTS", "TLMAX7" => {value => $tlmax7_inter});
doCommand('dscopyblock',
blocks => "${cifFile}:CALINDEX",
to => $imgEvents)
or return exception();
if( $fovArea > 10 ){
my $flareGti=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
content => 'flare GTI');
my $histoFile=newFile(class => 'intermediate',
instrument => thisInstrument,
exp_id => $exp_id,
content => 'Flare background timeseries');
if( hasFITSKeyword(file => $imgEvents, extension => 'EVENTS', keyword => 'XMMEA_22') ){
my $flareBitmask = getEventBitmask(file=>$imgEvents, masks=>$flareFlags);
doCommand('evselect'
,table => $imgEvents
,writedss => 'Y'
,updateexposure => 'N'
,withrateset => 'Y'
,rateset => $histoFile
,timebinsize => $backgrndBinsize
,maketimecolumn => 'Y'
,timecolumn => 'TIME'
,expression => "(PATTERN==0) && #XMMEA_22 && ((FLAG & $flareBitmask) == 0)"
,withimageset => 'N'
) or return exception();
doCommand(
'tabcalc'
, tables => "$histoFile:RATE"
, columntype => 'real64'
, column => 'RATE'
, expression => "1000*COUNTS/($backgrndBinsize*$fovArea)"
)
or return exception();
my $start_time=readFITSKeyword(
file => $histoFile
, extension => 'RATE'
, keyword => "TSTART"
);
doCommand(
'tabcalc'
, tables => "$histoFile:RATE"
, columntype => 'real64'
, column => 'T_ELAPSED'
, expression => "TIME-$start_time"
)
or return exception();
my $fplotCommandFile = newFile(
class => 'intermediate'
, content => 'Flare bkg ts pco file'
, format => 'ASCII'
, extension => 'pco'
);
writeASCIIFile(
name => $fplotCommandFile
, text => [join("\n", "LA X TIME-$start_time (s)", 'LA G2 RATE (cts/s)', 'log y', 'PLOT', 'QUIT', '')]
);
my $flareBkgPs = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'F bkg ts'
, format => 'PS'
);
doCommand(
'fplot'
, infile => $histoFile
, xparm => 'T_ELAPSED'
, yparm => 'RATE'
, rows => '-'
, device => "$flareBkgPs/cps"
, pltcmd => '@'."$fplotCommandFile"
)
or return exception();
my $mos_tbinsize;
my $sourceFreeBackRates;
my $SFBLCRegionFileFaint;
my $SFBLCRegionFileBright;
my $SFBLCBackScal;
if( numberFITSRows(file=>$histoFile, extension=>'RATE') > 0 && check_min_max_rate_col($histoFile) )
{
my $retval = 0;
my $optCmd = "bkgoptrate fracexpstyle=auto tssettabname=$histoFile:RATE withendtime=N withlowercutoffcount=N withmintimeratio=N ignorelowcnttail=Y withstarttime=N -w 10";
info("CMD: $optCmd");
my $optRate = `$optCmd`;
$retval = $?;
if ($retval ne 0) { return exception("Error $retval returned by bkgoptrate: $!"); }
chomp $optRate;
info("OPTRATE: $optRate");
info("Performing second optimised GTI filter < $optRate");
doCommand('tabgtigen'
,table => $histoFile
,gtiset => $flareGti
,expression => "RATE<$optRate"
,mingtisize => $mingtisize
) or return exception();
}
info("==== starting source-free background flare lightcurve processing===");
my $SFBLCInputImage = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC input image'
, band => 8
, format => 'FITS'
);
my $attGTIFile = findFile(
class => 'intermediate'
, instrument => 'all'
, content => 'attitude GTI'
);
my $expr;
if (fileExists( file => $flareGti ) ){
$expr = "(GTI($flareGti, TIME) && GTI($attGTIFile, TIME) && PATTERN <= 12 && PI in (500:7500] && (FLAG & 0x766aa000)==0)";
} else {
$expr = "(GTI($attGTIFile, TIME) && PATTERN <= 12 && PI in (500:7500] && (FLAG & 0x766aa000)==0)";
}
my $xbin_SFBLC = 80;
my $ybin_SFBLC = 80;
doCommand(
'evselect'
, table => $imgEvents
, imageset => $SFBLCInputImage
, xcolumn => 'DETX'
, ycolumn => 'DETY'
, imagebinning => 'binSize'
, ximagebinsize => $xbin_SFBLC
, yimagebinsize => $ybin_SFBLC
, expression => $expr
, imagedatatype => 'Int32'
, withimagedatatype => 'true'
, writedss => 'true'
, updateexposure => 'true'
, keepfilteroutput => 'false'
) or return exception();
info("Creating vignetted exposure map");
my $SFBLCExpmap = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC exposure map'
, band => 8
, format => 'FITS'
);
doCommand(
'eexpmap'
, imageset => $SFBLCInputImage
, eventset => $imgEvents
, attitudeset => $attFile
, attrebin => 2
, expimageset => $SFBLCExpmap
, pimin => 500
, pimax => 7500
, withvignetting => 'yes'
, withdetcoords => 'yes'
) or return exception();
my $SFBLCNonVigExpmap = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC non-vig exposure map'
, band => 8
, format => 'FITS'
);
doCommand(
'eexpmap'
, imageset => $SFBLCInputImage
, eventset => $imgEvents
, attitudeset => $attFile
, attrebin => 2
, expimageset => $SFBLCNonVigExpmap
, pimin => 500
, pimax => 7500
, withvignetting => 'no'
, withdetcoords => 'yes'
) or return exception();
my $SFBLCDetmask = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC detmask'
, band => 8
, format => 'FITS'
);
doCommand(
'emask'
, detmaskset => $SFBLCDetmask
, expimageset => $SFBLCNonVigExpmap
, threshold1 => 0.5
, threshold2 => 1
) or return exception();
my $SFBLCDetMaskArith;
my $source_free_ts_expr;
if (! &ModuleUtil::isImageLimit($SFBLCInputImage,'',1000.0)) {
info("Running eboxdetect in local mode on MOS, exposure $exp_id...");
my $SFBLCBoxList = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC box-local source list'
, band => 8
, format => 'FITS'
);
my $SFBLCBoxListFaint = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC box-local source list faint subset'
, band => 8
, format => 'FITS'
);
my $SFBLCBoxListBright = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC box-local source list bright subset'
, band => 8
, format => 'FITS'
);
my $sso_object = $ENV{PCMS_SSO_OBJECT};
my $SFBLCBoxListDrop;
if ( $sso_object ){
info("DEBUG: Pipeline processing for a Moving Object = SSO. Object reference system. PCMS_SSO_OBJECT = $sso_object ");
$SFBLCBoxListDrop = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC box-local source list drop subset'
, band => 8
, format => 'FITS'
);
}
doCommand(
'eboxdetect'
, imagesets => $SFBLCInputImage
, expimagesets => $SFBLCNonVigExpmap
, detmasksets => $SFBLCDetmask
, boxlistset => $SFBLCBoxList
, usemap => 'false'
, likemin => 5
, boxsize => 5
, withdetmask => 'true'
, nruns => 1
, ecf => "1.0"
, pimin => 500
, pimax => 7500
) or return exception();
doCommand(
'fselect'
, infile => $SFBLCBoxList
, outfile => $SFBLCBoxListFaint
, expr => '(RATE <= 0.35)'
) or return exception();
doCommand(
'fselect'
, infile => $SFBLCBoxList
, outfile => $SFBLCBoxListBright
, expr => '(RATE > 0.35)'
) or return exception();
if ( $sso_object ){
doCommand(
'fselect'
, infile => $SFBLCBoxList
, outfile => $SFBLCBoxListDrop
, expr => "(SCTS > 30)"
) or return exception();
}
my $SFBLCTempFile = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC temp file'
, band => 8
, format => 'FITS'
);
$SFBLCRegionFileFaint = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC reg faint'
, band => 8
, format => 'FITS'
);
$SFBLCRegionFileBright = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC reg bright'
, band => 8
, format => 'FITS'
);
my $SFBLCRegionFileDrop;
if ( $sso_object ){
$SFBLCRegionFileDrop = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC reg drop'
, band => 8
, format => 'FITS'
);
}
my $lthresh = 50;
my $rad = 60;
my $rad2 = 100;
my $region_select;
my $region_select_drop;
if (thisInstrument =~ /mos1/) {
$region_select = "(ID_BAND == 1 && ID_INST == 2 && LIKE >= $lthresh && BOX_CTS > 0)";
} else {
$region_select = "(ID_BAND == 1 && ID_INST == 3 && LIKE >= $lthresh && BOX_CTS > 0)";
};
if (thisInstrument =~ /mos1/) {
$region_select_drop = "(ID_BAND == 1 && ID_INST == 2 && LIKE >= 30 && BOX_CTS > 0)";
} else {
$region_select_drop = "(ID_BAND == 1 && ID_INST == 3 && LIKE >= 30 && BOX_CTS > 0)";
};
doCommand(
'region'
, eventset => "${imgEvents}:EVENTS"
, tempset => $SFBLCTempFile
, srclisttab => $SFBLCBoxListFaint
, expression => $region_select
, operationstyle => 'global'
, fixedradius => $rad
, bkgregionset => "${SFBLCRegionFileFaint}:REGION"
, outunit => "detxy"
) or return exception();
doCommand(
'region'
, eventset => "${imgEvents}:EVENTS"
, tempset => $SFBLCTempFile
, srclisttab => $SFBLCBoxListBright
, expression => $region_select
, operationstyle => 'global'
, fixedradius => $rad2
, bkgregionset => "${SFBLCRegionFileBright}:REGION"
, outunit => "detxy"
) or return exception();
if ( $sso_object ){
doCommand(
'region'
, eventset => "${imgEvents}:EVENTS"
, tempset => $SFBLCTempFile
, srclisttab => $SFBLCBoxListDrop
, expression => $region_select_drop
, operationstyle => 'global'
, radiusstyle => 'enfrac'
, bkgregionset => "${SFBLCRegionFileDrop}:REGION"
, outunit => "detxy"
) or return exception();
}
my $sourceFreeEvalImage = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC evaluation image'
, band => 8
, format => 'FITS'
);
my $source_free_img_expr;
if ( fileExists( file => $flareGti ) ){
$source_free_img_expr = "((GTI($flareGti, TIME) && GTI($attGTIFile, TIME)) && PATTERN<=12 && PI in (500:7500] && (FLAG & 0x766aa000)==0 && (region($SFBLCRegionFileFaint,DETX,DETY) && region($SFBLCRegionFileBright,DETX,DETY)))";
} else {
$source_free_img_expr = "((GTI($attGTIFile, TIME)) && PATTERN<=12 && PI in (500:7500] && (FLAG & 0x766aa000)==0 && (region($SFBLCRegionFileFaint,DETX,DETY) && region($SFBLCRegionFileBright,DETX,DETY)))";
}
doCommand(
'evselect'
, table => $imgEvents
, imageset => $sourceFreeEvalImage
, xcolumn => 'DETX'
, ycolumn => 'DETY'
, withimageset => 'Y'
, imagebinning => 'binSize'
, ximagebinsize => $xbin_SFBLC
, yimagebinsize => $ybin_SFBLC
, expression => $source_free_img_expr
, imagedatatype => 'Int32'
, withimagedatatype => 'true'
, writedss => 'true'
, updateexposure => 'true'
, keepfilteroutput => 'false'
) or return exception();
my $SFBLCRegionFileMerged = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC reg merged'
, band => 8
, format => 'FITS'
);
doCommand(
'fmerge'
, infiles => [$SFBLCRegionFileBright, $SFBLCRegionFileFaint]
, outfile => $SFBLCRegionFileMerged
, columns => "SHAPE,DETX,DETY,R,ROTANG,COMPONENT"
, mextname => 'REGION'
, history => 'Y'
, copyprime => 'Y'
) or return exception();
doCommand(
'fparkey'
, value => 'pos'
, fitsfile => "${SFBLCRegionFileMerged}[REGION]"
, keyword => "MTYPE1"
, add => 'Y'
) or return exception();
doCommand(
'fparkey'
, value => 'DETX,DETY'
, fitsfile => "${SFBLCRegionFileMerged}[REGION]"
, keyword => "MFORM1"
, add => 'Y'
) or return exception();
my $SFBLCNonVigExpmapRegMask = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC non-vig exposure map reg mask'
, band => 8
, format => 'FITS'
);
$SFBLCDetMaskArith = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'SFBLC det mask arith'
, band => 8
, format => 'FITS'
);
my $SFBLCRegionFileMerged_rows = readFITSKeyword(
file => $SFBLCRegionFileMerged
, extension => 'REGION'
, keyword => 'NAXIS2'
);
if ( $SFBLCRegionFileMerged_rows ){
info("DEBUG - $SFBLCRegionFileMerged has $SFBLCRegionFileMerged_rows rows");
doCommand(
'regionmask'
, region => "${SFBLCRegionFileMerged}[REGION]"
, pixdefset => $SFBLCNonVigExpmap
, maskset => $SFBLCNonVigExpmapRegMask
, whichpixdef => 'image'
, withmaskset => 'Y'
) or return exception();
doCommand('farith'
,infil1 => $SFBLCNonVigExpmapRegMask
,infil2 => "${SFBLCDetmask}[MASK]"
,outfil => $SFBLCDetMaskArith
,ops => 'MUL'
) or return exception();
} else {
info("DEBUG - $SFBLCRegionFileMerged has 0 rows");
$SFBLCDetMaskArith = "${SFBLCDetmask}[MASK]";
}
info("Creating source-free in band light curve for MOS");
$source_free_ts_expr = "PATTERN<=12 && PI in (500:7500] && ((FLAG & 0x762ba000)==0) && (region($SFBLCRegionFileMerged,DETX,DETY))";
} else {
info("Creating in-band light curve for MOS (sparse image < 1000 counts)");
$source_free_ts_expr = "PATTERN<=12 && PI in (500:7500] && ((FLAG & 0x762ba000)==0)";
info("DEBUG - No sources removing in sparse image < 1000 counts");
$SFBLCDetMaskArith = "${SFBLCDetmask}[MASK]";
};
my %SFBLCDetMaskStat = &ModuleUtil::getImageStats($SFBLCDetMaskArith,'');
my $xbin = readFITSKeyword(
file => $SFBLCDetmask
, extension => 'MASK'
, keyword => 'CDELT1L'
);
my $ybin = readFITSKeyword(
file => $SFBLCDetmask
, extension => 'MASK'
, keyword => 'CDELT2L'
);
$SFBLCBackScal = $SFBLCDetMaskStat{sum} * $xbin * $ybin;
info("DEBUG - SFBLCBackScal = $SFBLCBackScal");
$mos_tbinsize = 26;
$sourceFreeBackRates = newFile(
class => 'product'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'EPIC flare background timeseries'
);
doCommand(
'evselect'
, table => $imgEvents
, expression => $source_free_ts_expr
, maketimecolumn => 'Y'
, makeratecolumn => 'Y'
, rateset => $sourceFreeBackRates
, timebinsize => $mos_tbinsize
, timecolumn => 'TIME'
, updateexposure => 'N'
, withrateset => 'Y'
, writedss => 'Y'
) or return exception();
my $tmpSourceFreeBackRates = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'Copy EPIC flare background timeseries'
);
my $optFlareGti;
my $sourceFreeLCCommandFile;
if ( readFITSKeyword( file => $sourceFreeBackRates, extension => 'RATE', keyword => 'EXPOSURE' ) ){
doCommand(
'epiclccorr'
, srctslist => $sourceFreeBackRates
, eventlist => $imgEvents
, outset => $tmpSourceFreeBackRates
, applyabsolutecorrections => 'N'
, allcamera => 'Y'
) or return exception();
copyFile(
source => $tmpSourceFreeBackRates
, destination => $sourceFreeBackRates
);
if ( defined($SFBLCBackScal) ){
doCommand(
'addattribute'
, set => "${sourceFreeBackRates}:RATE"
, attributename => 'BACKSCAL'
, attributetype => 'real'
, attributecomment => '"\"Backscale for flaring filtering\""'
, realvalue => $SFBLCBackScal
) or return exception();
}
info("Adding column for T_ELAPSED, using observation start time $start_time");
doCommand(
'tabcalc'
, column => 'T_ELAPSED'
, columntype => 'real64'
, expression => "TIME-$start_time"
, tables => "${sourceFreeBackRates}:RATE"
) or return exception();
my $snDiagFile = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'Flare GTI SN diagnostic'
, band => 8
, format => 'FITS'
);
my $hasOptFlareGti = 0;
my $rcut_mos;
if( numberFITSRows(file=>$sourceFreeBackRates, extension=>'RATE') > 0 && check_min_max_rate_col($sourceFreeBackRates) ){
my $retval = 0;
$rcut_mos = `bkgoptrate -V 0 -w 0 tssettabname=${sourceFreeBackRates}:RATE dooutputsntab=yes ignorelowcnttail=yes snsettabname=${snDiagFile}:SN_TO_BKGCUT`;
info("CMD: bkgoptrate -V 0 -w 0 tssettabname=${sourceFreeBackRates}:RATE dooutputsntab=yes ignorelowcnttail=yes snsettabname=${snDiagFile}:SN_TO_BKGCUT");
$retval = $?;
if ($retval ne 0) { return exception("Error $retval returned by bkgoptrate: $!"); }
if ($rcut_mos eq '') {
info("bkgoptrate call returns no value, skipping optimised flare GTI generation...");
} else {
if( fileExists(file => $sourceFreeBackRates) ) {
info("bkgoptrate returns optimum cut threshold: $rcut_mos");
doCommand(
'ftappend'
, infile => "${snDiagFile}[SN_TO_BKGCUT]"
, outfile => $sourceFreeBackRates
) or return exception();
doCommand(
'addattribute'
, set => "${sourceFreeBackRates}:RATE"
, attributename => 'FLCUTTHR'
, attributetype => 'real'
, attributecomment => '"\"Optimised flare cut threshold\""'
, realvalue => $rcut_mos
) or return exception();
$optFlareGti = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'Optimised flare GTI'
, band => 8
, format => 'FITS'
);
info("Creating GTI files with this threshold");
doCommand(
'tabgtigen'
, table => $sourceFreeBackRates
, gtiset => $optFlareGti
, expression => "RATE < ${rcut_mos}"
, mingtisize => 100
) or return exception();
}
$hasOptFlareGti = 1;
}
} else {
info("Flat TS. Do not run bkgoptrate, skipping optimised flare GTI generation...");
}
info("Make full in-band, source-free light curve plots");
my $sourceFreeLightCurvePS = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => "In-band source-free light curve"
, band => 8
, format => 'PS'
);
$sourceFreeLCCommandFile = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'In-band sf lc pco file'
, format => 'ASCII'
, extension => 'pco'
);
my $srcut = sprintf("%.3f",$rcut_mos);
writeASCIIFile(
name => $sourceFreeLCCommandFile
, text => [join("\n","LA X TIME-$start_time (s)",'LA G2 RATE (cts/s)','log y','lwid 5',"LA 1 P 0 $srcut LI 0 1 CO 4 \"$srcut\"",'PLOT','QUIT','')]
);
doCommand(
'fplot'
, infile => $sourceFreeBackRates
, xparm => 'T_ELAPSED'
, yparm => 'RATE'
, rows => '-'
, device => "${sourceFreeLightCurvePS}/CPS"
, pltcmd => '@'."$sourceFreeLCCommandFile"
) or return exception();
my ($snMin, $snMax);
if (fileExists( file => $snDiagFile )){
my $snBg = readFITSColumn(
file => $snDiagFile
, extension => 'SN_TO_BKGCUT'
, column => 'SN_RATIO'
) or return exception();
$snMin = min(@$snBg);
$snMax = max(@$snBg);
}
my $SNRCurvePS = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'In-band sf Signal to noise plot'
, band => 8
, format => 'PS'
);
my $SNRCommandFile = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'In-band sf Signal to noice pco file'
, format => 'ASCII'
, extension => 'pco'
);
writeASCIIFile(
name => $SNRCommandFile
,text => [join("\n","LA X Background rate cut (cts/s)",'LA G2 Signal-to-noise','lwid 5',"LA 1 Pos $srcut $snMax LI -90 1.0 CO 4 \"$srcut\"",'PLOT','QUIT','')]
);
doCommand(
'fplot'
, infile => "${sourceFreeBackRates}[SN_TO_BKGCUT]"
, xparm => 'BKGRATECUT'
, yparm => 'SN_RATIO'
, rows => '-'
, device => "${SNRCurvePS}/CPS"
, pltcmd => '@'."$SNRCommandFile"
) or return exception();
my $tempPS = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'In-band sf temp plot file'
, band => 8
, format => 'PS'
);
my $combiPS = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'In-band sf combi plot file'
, band => 8
, format => 'PS'
);
my $retval=0;
my $cli_1 = `gs -sDEVICE=pswrite -sOutputFile=${tempPS} -dNOPAUSE -dBATCH $sourceFreeLightCurvePS $SNRCurvePS`;
info("CMD: gs -sDEVICE=pswrite -sOutputFile=${tempPS} -dNOPAUSE -dBATCH $sourceFreeLightCurvePS $SNRCurvePS");
$retval = $?;
if ($retval ne 0) { return exception("Error returned by gs: $!"); }
$retval=0;
my $cli_2 = `psnup -s0.6 -2up ${tempPS} > ${combiPS}`;
info("CMD: psnup -s0.6 -2up ${tempPS} > ${combiPS}");
$retval=$?;
if ($retval ne 0) { return exception("Error returned by psnup: $!"); }
my $flareBkgPdf = newFile(
class => 'product'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'EPIC flare background timeseries'
, format => 'PDF'
);
PStoPDF(
source => $combiPS
, destination => $flareBkgPdf
)
or return exception();
} else {
info("No EXPOSURE keyword in TS, then No 'EPIC flare background timeseries'");
}
info("TESTING: Recreating light curves with only valid GTIs and regions left in");
my $optBackRates = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'Optimised flare bkg time series'
, band => 8
, format => 'FITS'
);
my $test_ts_expr = "GTI($attGTIFile, TIME) && PATTERN<=12 && PI in (500:7500] && ((FLAG & 0x762ba000)==0)";
if (fileExists( file => $SFBLCRegionFileFaint )) {
$test_ts_expr .= " && region($SFBLCRegionFileFaint,DETX,DETY)";
}
if (fileExists( file => $SFBLCRegionFileBright )) {
$test_ts_expr .= " && region($SFBLCRegionFileBright,DETX,DETY)";
}
if (fileExists( file => $optFlareGti )) {
$test_ts_expr .= " && GTI($optFlareGti,TIME)";
};
doCommand(
'evselect'
, expression => $test_ts_expr
, maketimecolumn => 'Y'
, makeratecolumn => 'Y'
, rateset => $optBackRates
, table => $imgEvents
, timebinsize => $mos_tbinsize
, updateexposure => 'N'
, withrateset => 'Y'
, writedss => 'Y'
) or return exception();
my $tmpOptBackRates = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'Copy optimised flare bkg time series'
, band => 8
, format => 'FITS'
);
if( (fileExists(file => $optFlareGti) && numberFITSRows(file=>$optFlareGti, extension=>'STDGTI') > 0) &&
!ModuleUtil::isColumnEmpty($optBackRates,"RATE") )
{
doCommand(
'epiclccorr'
, srctslist => $optBackRates
, eventlist => $imgEvents
, outset => $tmpOptBackRates
, applyabsolutecorrections => 'N'
, allcamera => 'Y'
) or return exception();
copyFile(
source => $tmpOptBackRates
, destination => $optBackRates
);
doCommand(
'tabcalc'
, column => 'T_ELAPSED'
, columntype => 'real64'
, expression => "TIME-$start_time"
, tables => "${optBackRates}:RATE"
) or return exception();
my $OptSourceFreeLightCurvePS = newFile(
class => 'intermediate'
, instrument => thisInstrument
, exp_id => $exp_id
, content => 'Opt in-band source-free light curve'
, band => 8
, format => 'PS'
);
doCommand(
'fplot'
, infile => $optBackRates
, xparm => 'T_ELAPSED'
, yparm => 'RATE'
, rows => '-'
, device => "${OptSourceFreeLightCurvePS}/CPS"
, pltcmd => '@'."$sourceFreeLCCommandFile"
) or return exception();
}
}
}
}
if(fileExists(file => $tmptimEvents)){
my $timEvents=newFile(class => 'product',
instrument => thisInstrument,
exp_id => $exp_id,
content => 'EPIC timing mode event list');
doCommand('evselect'
,table => $tmptimEvents
,filteredset => $timEvents
,withfilteredset => 'true'
,keepfilteroutput => 'true'
,updateexposure => 'true'
,writedss => 'true'
,cleandss => 'true'
,expression => $expr
,destruct => 'true'
,withimageset => 'N'
) or return exception();
doCommand('dscopyblock',
blocks => "${cifFile}:CALINDEX",
to => $timEvents)
or return exception();
}
return success();
}
sub check_min_max_rate_col
{
my ($file) = @_;
my $fileRATE = readFITSColumn(
file => $file
, extension => 'RATE'
, column => 'RATE'
) or return exception();
my $fileRATEMin = min(@$fileRATE);
my $fileRATEMax = max(@$fileRATE);
if ( $fileRATEMin != $fileRATEMax ){
return 1;
} else { return 0; }
}
1;