package Util::LDPlist;
##############################################################################
#
# DESCRIPTION: This class handles a list of LDP files. In particular it
# DESCRIPTION: allows you to time sort such a list
# DESCRIPTION: The Util::EventFileList sub-class does even more specific things
# DESCRIPTION: for FITS event files.
#
# HISTORY:
# HISTORY: $Log: LDPlist.pm,v $
# HISTORY: Revision 1.4 2004/12/23 23:31:43 apsop
# HISTORY: Replace read_field call with call to get_ldp_time.
# HISTORY:
# HISTORY: Revision 1.3 2004/05/06 19:58:41 dah
# HISTORY: Add version number back into the header comments.
# HISTORY:
# HISTORY: Revision 1.2 2004/04/16 20:20:37 dah
# HISTORY: Begin using embedded history records
# HISTORY:
#
# VERSION: 0.0
#
#
##############################################################################
use Util::FileList;
@ISA=("Util::FileList");
use strict;
###############################################################################
# This is not much different from the inherited constructor. It also
# sets the extension specifier to undef and initializes some internal
# things needed for cataloging.
###############################################################################
sub new {
my $self=shift;
#####################################
# inherit generic list initialization
#####################################
$self=$self->SUPER::new(@_);
return $self;
}
##################################
# ACCESSORS:
##################################
########################
# METHODS:
########################
#############################################################################
#############################################################################
# returns a list of filenames and LDP header times alternating
# This can be conveniently turned into a hash
#############################################################################
sub times {
my $self=shift;
my $field = Util::Stool->new("get_ldp_time");
$field->verbose(0);
my @times=();
my $file;
foreach $file ($self->files() ) {
# extract the best time for the file
$field->command_line("-infile ", $file);
$field->run();
my $time = $field->stdout();
push @times, ($file => $time);
}
return @times;
}
#############################################################################
#############################################################################
# Returns another file list sorted by the given set of keywords.
#############################################################################
sub sort {
my $self=shift;
my %times = $self->times();
my @sorted = sort {$times{$a} <=> $times{$b}} $self->files();
return new Util::LDPlist(@sorted);
} # end of sort method
1;