package Subs::SwiftSub; ############################################################################## # # HISTORY: # HISTORY: $Log: SwiftSub.pm,v $ # HISTORY: Revision 1.6 2007/04/01 19:13:19 apsop # HISTORY: Calculate version numbers and store in job par. # HISTORY: # HISTORY: Revision 1.5 2006/04/28 18:41:46 apsop # HISTORY: Fix bug in testing for presence of queue file. # HISTORY: # HISTORY: Revision 1.4 2005/11/08 19:22:28 apsop # HISTORY: Populate the TIMELIST and DATALIST hashes. Used to be an SWCheckInput. # HISTORY: # HISTORY: Revision 1.3 2004/05/06 20:02:34 dah # HISTORY: Add version number back into the header comments. # HISTORY: # HISTORY: Revision 1.2 2004/04/16 20:21:18 dah # HISTORY: Begin using embedded history records # HISTORY: # # VERSION: 0.0 # # ############################################################################## use Subs::Sub; use Util::AttTool; @ISA = ("Subs::Sub"); use strict; sub BEGIN { my $procpar = Subs::Sub->procpar(); my $filename = Subs::Sub->filename(); my $log = Subs::Sub->log(); my $jobpar = Subs::Sub->jobpar(); Util::AttTool->dirs($procpar->read('acs2fits'), $procpar->read('headas').'/lib'); ############################################### # Put info on data already processed into hash ############################################### my @data = split(' ', $jobpar->read('datalist')); @{$jobpar->{DATALIST}}{@data} = (1) x @data; ##################################################### # Hash about relative times, ie time since burst and # final processing ##################################################### $jobpar->{TIMELIST} = {}; foreach (glob('day_*.flag')){ $jobpar->{TIMELIST}->{ (/(day_\w+)\.flag/)[0] } = 1; } if(-f 'final_for_archive.lock'){ $jobpar->{TIMELIST}->{final} = 1; $jobpar->set({finalproc => 'yes'}); } #################################### # Get software versions #################################### my $fversion; open VER, $procpar->read('ftools').'/syspfiles/ftools.par'; while (<VER>){ $fversion = $1 if /version,s,h,+"([^",]*)"/; } close VER; my $sversion = Util::Tool->new($procpar->read('headas') .'/bin', 'swiftversion') ->run(); ############################################################################### # Sometimes for an 'official' release they put '_S' and the end of the version ############################################################################### $sversion =~ s/_S$//; my $soft_version = 'Hea_' . $fversion . '_' . $sversion->stdout(); chomp $soft_version; $jobpar->set({softver => $soft_version}); ##################### # Get caldb versions ##################### my $caldb = $procpar->read('caldb'); my @cal_vers; foreach my $inst qw(bat uvota xrt mis){ my $fits = Util::FITSfile->new("$caldb/data/swift/$inst/caldb.indx"); my $ckey = $fits->keyword('CALDBVER'); $ckey = '?' unless $ckey; push @cal_vers, substr($inst, 0, 1) . $ckey; } $jobpar->set({caldbver => join('_', @cal_vers)}); ##################################################### # Get the earliest and latest times from the queue # file ##################################################### my $qname = $jobpar->read('sequence') . '.queue'; if( -f $qname && open(QUEUE, "$qname") ){ my (@starts, @stops); while(<QUEUE>){ my @fields = split(' '); push @starts, $fields[2]; push @stops, $fields[3]; } close QUEUE; $jobpar->{TIMELIST}->{start} = (sort {$a <=> $b} @starts)[0]; $jobpar->{TIMELIST}->{stop} = (sort {$b <=> $a} @stops)[0]; }else{ $log->error(1, "Unable to open $qname, $!"); } }