Subs::UVOT2FITS (version 0.0)


package Subs::UVOT2FITS;
##############################################################################
#
# DESCRIPTION: This subroutine decodes the UVOT telemetry.
#
# HISTORY: 
# HISTORY: $Log: UVOT2FITS.pm,v $
# HISTORY: Revision 1.16  2004/12/10 02:20:31  apsop
# HISTORY: Changes to support mission pneumonic other than sw.
# HISTORY:
# HISTORY: Revision 1.15  2004/11/09 23:52:24  apsop
# HISTORY: Add in uvot2fits support for apids 776 and 782.
# HISTORY:
# HISTORY: Revision 1.14  2004/10/20 18:49:46  apsop
# HISTORY: Add in additonal apids which are handled by uvot2fits.
# HISTORY:
# HISTORY: Revision 1.13  2004/06/08 13:28:42  apsop
# HISTORY: Bug fix for analyzing memory dump data
# HISTORY:
# HISTORY: Revision 1.12  2004/06/07 23:59:55  apsop
# HISTORY: Add apids for memory dumps.
# HISTORY:
# HISTORY: Revision 1.11  2004/05/28 19:49:02  apsop
# HISTORY: Put in APID for GENIE image.
# HISTORY:
# HISTORY: Revision 1.10  2004/05/06 20:02:34  dah
# HISTORY: Add version number back into the header comments.
# HISTORY:
# HISTORY: Revision 1.9  2004/04/28 13:47:35  dah
# HISTORY: Make one method for extracting hk, and put it in Swift2FTIS superclass.
# HISTORY:
# HISTORY: Revision 1.8  2004/04/16 20:21:18  dah
# HISTORY: Begin using embedded history records
# HISTORY:
#
# VERSION: 0.0
#
#
##############################################################################


use Subs::Swift2FITS;
use Util::Tool;

@ISA = ('Subs::Swift2FITS');
use strict;

sub new {
    my $proto=shift;
    my $self=$proto->SUPER::new();

    $self->{DESCRIPTION}="Decoding UVOT Telemetry";

    return $self;
}

##################
# METHODS:
##################

sub body {
    my $self=shift;

    my $log     =$self->log();
    my $filename=$self->filename();
    my $procpar =$self->procpar();
    my $jobpar  =$self->jobpar();


    ##############################
    # collect the science APIDs
    ##############################
    my $apid605 = $filename->get("telemetry", "uvot", "*", 605);
    my $apid688 = $filename->get("telemetry", "uvot", "*", 688);
    my $apid704 = $filename->get("telemetry", "uvot", "*", 704);
    my $apid776 = $filename->get("telemetry", "uvot", "*", 776);
    my $apid782 = $filename->get("telemetry", "uvot", "*", 782);
    my $apid843 = $filename->get("telemetry", "uvot", "*", 843); #genie image
    my $apid848 = $filename->get("telemetry", "uvot", "*", 848); # end
    my $apid850 = $filename->get("telemetry", "uvot", "*", 850); # start
    my $apid853 = $filename->get("telemetry", "uvot", "*", 853);
    my $apid854 = $filename->get("telemetry", "uvot", "*", 854);
    my $apid855 = $filename->get("telemetry", "uvot", "*", 855); #uncomp image
    my $apid856 = $filename->get("telemetry", "uvot", "*", 856);
    my $apid857 = $filename->get("telemetry", "uvot", "*", 857);
    my $apid858 = $filename->get("telemetry", "uvot", "*", 858);
    my $apid860 = $filename->get("telemetry", "uvot", "*", 860);
    my $apid861 = $filename->get("telemetry", "uvot", "*", 861);
    my $apid1104 = $filename->get("telemetry", "uvot", "*", 1104);

    #############################
    # replace blanks with "NONE"
    #############################
    my $got_something=0;
    foreach ($apid605, $apid688, $apid704, $apid776, $apid782, $apid843, $apid848, $apid850, $apid853, 
	     $apid854, $apid855, $apid856, $apid857, $apid858, $apid860, $apid861, 
	     $apid1104) {
        unless($_) { $_ = "NONE"; }
        else       { ++$got_something; }
    }

    
    ######################################
    # set up and run UVOT2fits
    ######################################
    if($got_something) {
      my $mission = $jobpar->read("mission");
      my $filename_base = $mission . $jobpar->read("sequence");
      my $bin = $procpar->read("uvot2fits");
      my $uvot2fits = Util::PseudoFtool->new("$bin/uvot2fits");

      $uvot2fits->params({fitsname=>$filename_base,
                          path    => "./",
			  override  => $mission eq 'sw' ? 'no' : 'yes',
			  apid605  => $apid605,
			  apid688  => $apid688,
			  apid704  => $apid704,
			  apid776  => $apid776,
			  apid782  => $apid782,
			  apid843  => $apid843,
			  apid848  => $apid848,
			  apid850  => $apid850,
			  apid853  => $apid853,
			  apid854  => $apid854,
			  apid855  => $apid855,
			  apid856  => $apid856,
			  apid857  => $apid857,
			  apid858  => $apid858,
			  apid860  => $apid860,
			  apid861  => $apid861,
			  apid1104 => $apid1104,
			  clobber => "yes",
			  chatter => 8 });

      ############################
      # running uvot2fits
      ############################
      $log->entry("Running ".$uvot2fits->name() );
      $uvot2fits->run();

      if( $mission ne 'sw' ){
	foreach my $file ( glob 'sw???????????msu*' ){
	  my $newfile = $file;
	  $newfile =~ s/^sw/${mission}/;
	  rename $file, $newfile;
        }
      }
    } else {
        $log->entry("No UVOT science telemetry");
    }


    ###########################
    # now extract HK data
    ###########################
    $self->hk_extract('uvot');
    $self->hk_combine('uvot');

} # end of body method

1;