Subs::XRT2FITS (version 0.0)


package Subs::XRT2FITS;
##############################################################################
#
# DESCRIPTION: This subroutine runs the XRT tools delivered in build 1
#
# HISTORY: 
# HISTORY: $Log: XRT2FITS.pm,v $
# HISTORY: Revision 1.6  2004/12/10 02:19:38  apsop
# HISTORY: Changes to support mission pneumonic other than sw.
# HISTORY:
# HISTORY: Revision 1.5  2004/12/05 23:23:17  apsop
# HISTORY: Add override option to bat2fits.
# 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::SwiftSub;
use Util::PseudoFtool;
use Util::LDPlist;

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

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

    $self->{DESCRIPTION}="Decoding XRT 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();


    #######################################
    # get a time-sorted list of LDP files
    #######################################
    my $ldps = Util::LDPlist->new($filename->get("telemetry", "xrt", 
                                                 "ldp", "*") )
                            ->sort();

    ##################################################
    # append that to the rest of the telemetry files 
    ##################################################
    my $list = Util::FileList->new($filename->get("telemetry", "xrt", 
                                                  "head[23]", "*"),
                                   $ldps->files() );
    if($list->count() == 0) {
        ######################
        # no XRT telemetry
        ######################
        $log->entry("No XRT CCSDS files to process");
        return;
    } else {
        ########################
        # log what we are doing
        ########################
        $log->entry("Running xrt2fits on the following files: ".
                    join " ", $list->files() );
    }

    ###################################
    # set up and run XRT2FITS
    ###################################
    my $bin = $procpar->read("xrt2fits");
    my $xrt2fits = Util::PseudoFtool->new("$bin/xrt2fits");

    my $mission = $jobpar->read("mission");
    my $filename_base = $mission . $jobpar->read("sequence");

    $xrt2fits->params({fitsname  => $filename_base,
		       override  => $mission eq 'sw' ? 'no' : 'yes',
                       path      => "./",
                       telemetry => $list->as_param(),
                       clobber   => "yes",
                       chatter   => 1                  });

    $xrt2fits->run();
    
    if( $mission ne 'sw' ){
      foreach my $file ( glob 'sw???????????msx*' ){
	my $newfile = $file;
	$newfile =~ s/^sw/${mission}/;
        rename $file, $newfile;
      }
    }


} # end of body method