%doc>
=head1 NAME
old_exposures.html
=head1 SYNOPSIS
Use:
old_exposures.html?instance="database_name"&nn="night_number"
=head1 Description
This mason component displays a table that shows the chunks that still need to
be processed by mops. For each chunk the table shows the number of exposures in the
chunk as well as the number of exposures that have been ingested into MOPS.
=head1 ARGUMENTS
=over 4
=item instance
Name of the database containing the MOPS data.
=item nn
The night number from which the chunks will be retrieved.
=back
=head1 AUTHOR
Denver Green, Edgreen@ifa.hawaii.eduE.
=head1 COPYRIGHT
Copyright 2012 by Institute for Astronomy, University of Hawaii.
=head1 DATE
18-Apr-2012
=cut
%doc>
<%perl>
my $show_chunk;
foreach $chunk (sort(keys(%chunks))) {
# Determine if the chunk has any fields with the status of ingested. As only
# nights that have ingested unprocessed fields are to be displayed.
$show_chunk = PS::MOPS::Admin::chunk_has_status($instance, $nn, $chunk, $FIELD_STATUS_INGESTED);
next if !$show_chunk;
%perl>
><% $utdate_str %> / NN <% $nn %>
<%perl>
# Exit for loop as we have found an ingested chunk that needs to be processed
last;
}
%perl>
<%args>
$instance => undef
$nn => undef
%args>
<%init>
use PS::MOPS::Admin qw(:all);
use PS::MOPS::Constants qw($FIELD_STATUS_INGESTED);
use PS::MOPS::Lib qw(:all);
use POSIX qw(strftime);
use Astro::Time;
my $date_id = "date_" . $nn;
# Debugging defines
my $mjd_id = "mjd_" . $nn;
my $year_id = "year_" . $nn;
my $month_id = "month_" . $nn;
my $day_id = "day_" . $nn;
my $utDate_id = "utDate_" . $nn;
my $nn_id = "nn_" . $nn;
# Convert night number to a nicely formated date string.
my $mjd = mopslib_nn2mjd(($nn + 1), -10); # Add 1 to nn so at to compensate for HI time zone
my ($day, $mon, $year) = mjd2cal($mjd);
my $utdate_str = make_nice_date_str($mjd);
# Get list of exposures downloaded to IPP from the summit.
my $ipp_exp_ref = PS::MOPS::Admin::list_ipp_fields($nn);
# Get list of exposures ingested into MOPS.
my $mops_exp_ref = PS::MOPS::Admin::list_mops_fields($instance, $nn);
# Get list of missing exposures.
my $missing_exp_ref = PS::MOPS::Admin::list_missing_exposures($instance, $nn);
# Combine IPP and MOPS exposures into one hash so as to make
# it easy to generate a table reporting the data.
my %chunks;
my $chunk;
my $total_exposures;
my $ingested_exposures;
foreach $chunk (keys(%$ipp_exp_ref)) {
$total_exposures = $ipp_exp_ref->{$chunk};
if (exists $mops_exp_ref->{$chunk}) {
$ingested_exposures = $mops_exp_ref->{$chunk};
} else {
$ingested_exposures = 0;
}
$chunks{$chunk} = [$total_exposures, $ingested_exposures];
}
sub make_nice_date_str {
my ($mjd) = @_;
my $unixtime = ($mjd - 40587) * 86400; # seconds since Unix epoch (40587 => Unix epoch Jan 1 1970)
return uc strftime("%a %d %b %Y UT", gmtime($unixtime));
}
%init>