XMM-Newton Science Analysis System
dpssvali (dpssvali-0.6) [xmmsas_20050815_1803-6.5.0]
Meta Index / Home Page
Algorithm
The SAS task dpssvali is written in perl.
**** define parameters
my $fitsfile="";
my $chkdir = "";
my $validlog = "";
my $invalidlog = "";
**** start of subroutine dpssvali
sub dpssvali{
$fitsfile=stringParameter("set");
$chkdir=stringParameter("checkdir");
$validlog=stringParameter("validlog");
$invalidlog=stringParameter("invalidlog");
**** check file permission
unless (-r $fitsfile) {
SAS::error("ARG_INPUT", "Dataset '$fitsfile' not readable");
}
**** check existence of ascii check files in given directory
unless (-d $chkdir) {
SAS::error("ARG_CHKDIR", "Directory '$chkdir' for tests not found");
}
*** open DPSS output files validlog and invalidlog
open VLOG, ">> $validlog" or
SAS::error("OPVAL", "Can't open validlog '$validlog': $!");
open ILOG, ">> $invalidlog" or
SAS::error("OPIVAL", "Can't open invalidlog '$invalidlog': $!");
print "in=$fitsfile\nDir=$chkdir\nval=$validlog\ninval=$invalidlog\n";
*** check existence of a check file attributed to a PPS product file name
my @chkfiles = determine_checks($fitsfile);
unless (@chkfiles) {
SAS::error("NOCHKS", "Can't determine checks for file: '$fitsfile'\n");
}
*** list check files which resulted into invalid PPS products
my @failed = check_fitsfile($fitsfile, @chkfiles);
if (@failed) {
SAS::error("FAIL", "File '$fitsfile' failed the following tests: " .
join(', ', @failed) . "\n");
} else {
exit 0;
}
}
*** perform checks according a selected PPS product file name
sub determine_checks {
my $file = shift;
$file =~ s|.*/||;
my $t6;
# here real algorithm for checkfiles ... use dummys now
if ( $file =~ /^P\d{10}\w\w\d{3}(\w{6})\d{5}\.\w{3}$/) {
$t6 = lc($1);
} else {
SAS::error("WRGNAM", "Filename does not comply to naming convention: '$file'\n");
}
my @chks = ();
@chks = $chkdir . '/expmap.chk' if $t6 eq 'expmap';
@chks = $chkdir . '/bkgmap.chk' if $t6 eq 'bkgmap';
@chks = $chkdir . '/exsnmp.chk' if $t6 eq 'exsnmp';
@chks = $chkdir . '/image.chk' if $t6 =~ /image_|oimage/;
@chks = $chkdir . '/mod8mp.chk' if $t6 eq 'mod8mp';
@chks = $chkdir . '/flafld.chk' if $t6 eq 'flafld';
@chks = $chkdir . '/imageom.chk' if $t6 eq 'simage';
@chks = $chkdir . '/omsrli.chk' if $t6 eq 'omsrli';
@chks = $chkdir . '/obsrls.chk' if $t6 eq 'obsrls';
@chks = $chkdir . '/swsrli.chk' if $t6 eq 'swsrli';
@chks;
}
**** list of XMM PPS files which failed the tests
sub check_fitsfile {
my $file = shift;
my (@checks) = @_;
my @failed_tests;
foreach my $chkfile ( @checks ) {
unless ( -r $chkfile ) {
SAS::error("MISCHECK", "Checkfile '$chkfile' not readable or missing\n");
}
system "dscheck --set=$file --checkfile=$chkfile"
and push @failed_tests, $chkfile;
}
if (@failed_tests) {
print ILOG "$fitsfile: ", join(', ', @failed_tests), "\n";
} else {
print VLOG "$fitsfile", "\n";
}
return @failed_tests
}
XMM-Newton SOC/SSC -- 2005-08-16