Документ взят из кэша поисковой машины. Адрес оригинального документа : http://xmm.vilspa.esa.es/calibration/find_obs_logz_new.cgi
Дата изменения: Wed Jan 26 17:09:41 2011
Дата индексирования: Sat Apr 9 23:23:48 2016
Кодировка:

Поисковые слова: п п р р р р р р р р р п п п п п
#!/usr/local/bin/perl -w
#
###########################################################################
#
# cgi-bin/find_obs_logx
#
# CGI script to provide an obs entry from the Observation Log Tables
#
#++ History
#
# Version : 1.0
# Date : 09-Apr-2002
# Author : JRMP (SOC/XMM)
#--
#
# The following parameters are expected:
# rev_num = requested Revolution
# prp_num = requested Proposal
# obs_num = requested Observation
# ra_hhmm = requested Right Ascension
#
###########################################################################
#
use strict;
use diagnostics;
use CGI qw(:standard);

$| = 1;

my ($CATLOG_PATH) = "/data/xmm/html/htdocs/external/xmm_mission_plan/odf_pps/catstrip_";
my ($SORT_CATLOG) = "obsid";
my ($RADE_CATLOG) = "radec";
my ($CATLOG_EXTN) = ".shtml";

my ($rev, $obs, $prp, $ras, $rah, $ram, $ra);
my ($split, $ra_max, $ra_min, $ra1_max, $ra1_min, $ra2_max, $ra2_min);
my ($file_id, $cur_match);
my ($line, $i);
my ($n_hits) = 0;

#
# Display standard header
#
&print_top_ban("XMM-Newton Observation Log Summary Short Page");

# No parameters or empty => show error message

if (!param()) { &print_obs_log_sum(" Missing input parameter. Try again !"); }

my ($seen_par) = 0;
if (defined ($rev = param('rev_num')) && $rev ne "") { $seen_par++;}
if (defined ($prp = param('prp_num')) && $prp ne "") { $seen_par++;}
if (defined ($obs = param('obs_num')) && $obs ne "") { $seen_par++;}
if (defined ($ras = param('ra_hhmm')) && $ras ne "") { $seen_par++;}

&print_obs_log_sum(" Missing input parameter. Try again.") unless ($seen_par);
#
# Get the script parameters => at least one mandatory
# Parameters have the following priority: rev, prp, obs and ras (if one is found
# the following are disregarded).
#
# Revolution

if ($rev) {
while (length($rev) < 4) { $rev = "0" . $rev };
if ( $rev !~ /^\d{4}$/) {
&print_obs_log_sum(" Revolution $rev invalid. Try again.");
}
$file_id = &build_rev_file($rev);
}

# Proposal

elsif ($prp) {
while (length($prp) < 6) { $prp = "0" . $prp};
if ( $prp !~ /^\d{6}$/) {
&print_obs_log_sum(" Proposal ID $prp invalid. Try again.");
}
$file_id = $SORT_CATLOG;
}

# Observation

elsif ($obs) {
while (length($obs) < 10) { $obs = "0" . $obs};
if ( $obs !~ /^\d{10}$/) {
&print_obs_log_sum(" Observation ID $obs invalid. Try again.");
}
$file_id = $SORT_CATLOG;
}

# Right Ascension

elsif ($ras) {
#check well formatted ra (hh:mm)
($rah, $ram) = split(':', $ras);
while (length($rah) < 2) { $rah = "0" . $rah};
while (length($ram) < 2) { $ram = "0" . $ram};

if ( ($rah !~ /^\d{2}$/) || ($ram !~ /^\d{2}$/) ) {
&print_obs_log_sum(" Right Ascension $ras invalid. Use HH:MM");
}

if ( ($rah gt "23") || ($ram gt "59") ) {
&print_obs_log_sum(" Right Ascension $ras invalid. Use HH:MM");
}

$ra = 15.0 * $rah + $ram / 4.0;
$ra_min = $ra - 0.5;
$ra_max = $ra + 0.5;

$split = 0;
$ra1_max = $ra_max;
$ra1_min = $ra_min;

if ($ra_min < 0.0) {
$split = 1;
$ra1_max = $ra_max;
$ra1_min = 0.0;
$ra2_max = 360.0;
$ra2_min = $ra_min + 360.0;
}
elsif ($ra_max > 360.0) {
$split = 1;
$ra1_max = 360.0;
$ra1_min = $ra_min;
$ra2_max = $ra_max - 360.0;
$ra2_min = 0.0;
}

$file_id = $RADE_CATLOG;
}


else {
&print_obs_log_sum(" Missing input parameter. Try again.");
}

#
# Build full filename and read it
#
$file_id = $CATLOG_PATH . $file_id . $CATLOG_EXTN;

if (!-e $file_id) {
&print_obs_log_sum(" Revolution $rev invalid. Try again.");
}

open(FILOG,"< $file_id") or &print_obs_log_sum("Revolution $rev out of range");
my (@lines) = ;
close(FILOG);

my ($hit_line) = 0;
my ($found_prp) = 0;
my ($found_obs) = 0;
my ($revno) = 0;

if ($rev) { # Revolution search

foreach $line (@lines) {
$hit_line++;

if ($line =~ /(\d{4})_nice\.html\">\1/i) { # found a revolution line
$revno = $1;
last if ($revno gt $rev);
if ($revno eq $rev) { # it is our rev
my (@saved_lines) = (" \n");
push @saved_lines, $line;

$i = $hit_line;
while ($lines[$i] !~ /<\/TR>/i) { # until end of row
push @saved_lines, $lines[$i];
$i++;
}
&print_found_row($n_hits, @saved_lines);
$n_hits++;
}
}
}
}
elsif ($prp || $obs) { # Proposal or Obs search

foreach $line (@lines) {
$hit_line++;

next if ($line !~ /(\d{4})_nice\.html\">\1/i); # found a revolution line
my (@saved_lines) = (" \n");
push @saved_lines, $line;

$i = $hit_line;
while ($lines[$i] !~ /<\/TR>/i) { # until end of row
push @saved_lines, $lines[$i];
if ($lines[$i] =~ />(\d{10}) $cur_match = $1; # found observation row => try a match
if ($obs) {
if ($cur_match eq $obs) {$found_obs = 1;}
}
elsif ($prp) {
$cur_match = substr($cur_match,0,6);
if ($cur_match eq $prp) {$found_prp = 1;}
else {last;}
}
}
$i++;
}

if ($found_obs || $found_prp) {
&print_found_row($n_hits, @saved_lines);
$n_hits++;
$found_prp = 0;
}

if ($obs) {
last if ($found_obs);
last if ($obs lt $cur_match);
}

if ($prp) {last if ($prp lt $cur_match);}
}
}
elsif ($ras) { # Right Ascension search

foreach $line (@lines) {
$hit_line++;

next if ($line !~ /(\d{4})_nice\.html\">\1/i); # found a revolution line
my (@saved_lines) = (" \n");
push @saved_lines, $line;

$i = $hit_line;
while ($lines[$i] !~ /<\/TR>/i) { # until end of row
push @saved_lines, $lines[$i];
if ($lines[$i] =~ />(\d{2}):(\d{2}):(\d{2})\.\d{2} my ($cur_ra) = 15 * $1 + $2 / 4.0 + $3 / 240.;
if ($cur_ra >= $ra1_min && $cur_ra <= $ra1_max) {$found_obs = 1;}
if ($split) {
if ($cur_ra >= $ra2_min && $cur_ra <= $ra2_max) {$found_obs = 1;}
}
}
$i++;
}

if ($found_obs) {
&print_found_row($n_hits, @saved_lines);
$n_hits++;
$found_obs = 0;
}
}
}

&terminate($n_hits, $rev, $prp, $obs);


# END_OF_MAIN
#
########################################################################
#
#======================================================================
#
# START_OF_SUB print_obs_log_sum
#
# print_obs_log_sum
#
# generates the form data for obs searching
#
#
sub print_obs_log_sum {

my ($message) = shift;

print <

Error:


$message




END_OF_MESSAGE

exit;

} # END_OF_SUB print_obs_search_form
#
#======================================================================
#
# START_OF_SUB print_found_row
#
# print_found_row
#
# generates the table with the found observation
#
#
sub print_found_row {

my ($n_hits) = shift;
my (@par_list) = @_;

if (!$n_hits) {

print <




















END_OF_TABLE_HEAD

}

foreach (@par_list) { print; }
print " \n";

} # END_OF_SUB print_found_row
#
#======================================================================
#
# START_OF_SUB terminate
#
# terminate
#
# terminates the table or reports no match found
#
#
sub terminate {

my ($n_hits, $rev, $prp, $obs) = @_;

if (!$n_hits) {
print "

No match found for your query:

\n";
if ($rev) { print "

Revolution: $rev\n";}
elsif ($prp) { print "

Proposal: $prp\n";}
elsif ($obs) { print "

Observation: $obs\n";}
}
else {
print "

Orbit
#
Target Name UTC Obs Start
yyyy-mm-ddThh:mm:ss
RA
hh:mm:ss.s
DEC
dd:mm:ss.s
Obsid PN_Sch
Duration
PN_Est
Duration
PI ODF Date Production PPS Status
or PPS Date
Date Public M1 M2 PN R1 R2 OM
\n";
}

print <





EO_THIS_TABLE


print "\n\n";

} # END_OF_SUB terminate
#
#======================================================================
#
# START_OF_SUB print_top_ban
#
# print_top_ban
#
# generates the standard header of a HTML page
#
#
sub print_top_ban {

my ($title) = shift;

print header();

my $std_1st = `/bin/cat /data/xmm/html/htdocs/external/includes/std_1st.shtml`;
my $std_hdr = `/bin/cat /data/xmm/html/htdocs/external/includes/std_hdr.shtml`;
my $std_top = `/bin/cat /data/xmm/html/htdocs/external/includes/std_top_new.shtml`;

# Escape $std_1st
$std_1st =~ s/"/\"/g;

print < $std_1st
$title
$std_hdr
$title
$std_top




Your query:
END_OF_HEAD1

if ($rev) { print " Revolution $rev

 
\n" };
if ($prp) { print " Proposal $prp
 
\n" };
if ($obs) { print " Observation $obs
 
\n" };
if ($ras) { print " RA $ras
 
\n" };

} # END_OF_SUB print_top_ban


sub build_rev_file {
my ($rev) = shift;

my ($range) = int (($rev - 1)/100);

my $from = 100 * $range + 1;
my $to = 100 * ($range + 1);

while (length($from) < 4) { $from = "0" . $from; }
while (length($to ) < 4) { $to = "0" . $to ; }

return ( $from . "_" . $to );
}