package Subs::LocateBurst; ############################################################################## # # DESCRIPTION: This subroutine determines the best available position for # DESCRIPTION: the burst. # # HISTORY: # HISTORY: $Log: LocateBurst.pm,v $ # HISTORY: Revision 1.11 2004/11/29 16:33:09 apsop # HISTORY: Add time test to use default Z values after launch. # HISTORY: # HISTORY: Revision 1.10 2004/09/14 18:52:34 apsop # HISTORY: Fix bug which was introduced in the source priority # HISTORY: # HISTORY: Revision 1.9 2004/08/31 01:33:35 apsop # HISTORY: Yet another bug fix for bat_z. # HISTORY: # HISTORY: Revision 1.8 2004/08/30 17:53:52 apsop # HISTORY: Another fix for calculating bat_z and bat_origin_z. # HISTORY: # HISTORY: Revision 1.7 2004/08/30 16:40:27 apsop # HISTORY: Test for zero when using inverse distance to calculate bat_z. # HISTORY: # HISTORY: Revision 1.6 2004/08/30 13:20:55 apsop # HISTORY: Obtain values for bat_z and bat_origin_z from HK. # HISTORY: # HISTORY: Revision 1.5 2004/08/17 13:55:51 apsop # HISTORY: Store info on burst in bat cataloge # HISTORY: # HISTORY: Revision 1.4 2004/05/06 20:02:34 dah # HISTORY: Add version number back into the header comments. # HISTORY: # HISTORY: Revision 1.3 2004/04/16 20:21:18 dah # HISTORY: Begin using embedded history records # HISTORY: # # VERSION: 0.0 # # ############################################################################## use Subs::Sub; @ISA = ("Subs::Sub"); use strict; sub new { my $proto=shift; my $self=$proto->SUPER::new(); $self->{DESCRIPTION}="Determining burst position"; return $self; } ################## # METHODS: ################## sub body { my $self=shift; my $log =$self->log(); my $filename=$self->filename(); my $procpar =$self->procpar(); my $jobpar =$self->jobpar(); ################################################################# # Get bat_z and origin_z values from bat hk. For in-flight data # go with default values in the parameter file. ################################################################# my $launch = Util::Date->new('2004-11-20T17:16:00'); if( $jobpar->read('tstart') < $launch->seconds() ){ my $hkfile = $filename->get('enhk', 'bat', '', 0); if( -f $hkfile ){ my $hkfits = Util::FITSfile->new($hkfile, 0); my @hdus = $hkfits->list_hdus(); my $bat_z = 0; unless( grep(/^hk161x001$/, @hdus) ){ $log->error(1, 'No 0x161 BAT HK data, using default Z values'); }else{ $hkfits->ext('hk161x001'); if( $hkfits->nrows() > 0 ){ my @invdist = $hkfits->cols('BBRIIMGINVDIST')->table(); my @flength = $hkfits->cols('BBRIIMGFLENGTH')->table(); $bat_z = 100.0 * (1.0 / $invdist[-1] + $flength[-1]) + 0.35 unless( $invdist[-1] == 0 ); $jobpar->set({bat_z => $bat_z, bat_origin_z => $flength[-1] * 100.0 + 0.35}); }else{ $log->error(1, 'No 0x161 BAT HK data, using default Z values'); } } }else{ $log->error(1, 'No BAT HK data, using default Z values'); } } ############################################################### # determine if the burst position is alreay set. # If so, we assume this is a human-assigned position which # we will assume is more reliable than any machine-determined # position ############################################################## my $root = $filename->sequence_specific(); my $ra = $jobpar->read("burst_ra"); my $dec = $jobpar->read("burst_dec"); my @bat_cen = $filename->get('tdmess', 'bat', 'ce', '*'); if( @bat_cen > 1 ){ @bat_cen = grep /^${root}/, @bat_cen; if( @bat_cen > 1 ){ $log->entry("More than one bat centroid message."); } } ###################################################### # Record if the 'burst' is in the BAT source catalogue ###################################################### if(@bat_cen){ my $cen_fits = Util::FITSfile->new($bat_cen[0], 0); $jobpar->set({burst_cat_src => 'yes'}) if $cen_fits->keyword('CATSRC') eq 'T'; } if($ra && $dec) { $log->entry("Using human assigned position RA=$ra Dec=$dec"); return; } my @xrt_cen = $filename->get('tdmess', 'xrt', 'ce', '*'); if( @xrt_cen > 1 ){ @xrt_cen = grep /^${root}/, @xrt_cen; if( @xrt_cen > 1 ){ $log->entry("More than one xrt centroid message."); } } if(@xrt_cen){ my $cen_fits = Util::FITSfile->new($xrt_cen[0], 0); $ra = $cen_fits->keyword('XRA_OBJ'); $dec = $cen_fits->keyword('XDEC_OBJ'); $log->entry("Using $xrt_cen[0] for burst position, RA = $ra, DEC = $dec."); $jobpar->set({burst_ra => $ra, burst_dec => $dec}); return; } if(@bat_cen){ my $cen_fits = Util::FITSfile->new($bat_cen[0], 0); $ra = $cen_fits->keyword('BRA_OBJ'); $dec = $cen_fits->keyword('BDEC_OBJ'); $log->entry("Using $bat_cen[0] for burst position, RA = $ra, DEC = $dec."); $jobpar->set({burst_ra => $ra, burst_dec => $dec}); return; } ################################################################# # for the moment we will set the burst position to the nominal # pointing direction. This is not the right thing to do. # what if it isn't a burst? ################################################################# $log->entry("Setting burst position to nominal pointing as a kludge"); $ra = $jobpar->read("ra"); $dec = $jobpar->read("dec"); $jobpar->set({burst_ra => $ra, burst_dec => $dec}); } # end of body method