Source for file day.php
Documentation is available at day.php
* UARS Day display and edit interface.
* This file displays a viewable and an editable version of a given UARS day.
* This file is part of HRDIODB.
* HRDIODB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* HRDIODB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with HRDIODB; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/** Configuration file */
require_once("conf.php");
/** Debugging functions */
require_once("debugging.php");
require_once("uars_day_class.php");
/** HRDI database class */
require_once("hrdi_db_class.php");
require_once("session_class.php");
require_once("user_class.php");
require_once("common_class.php");
// Figure out if we're interactive or offline
// HRDI database instance
// Create class instances based on current running mode
$user = new user($hdb, $session);
$page_title = "Day View";
// Get the UARS day from the argument
// We can't edit in offline mode
// See if we're in edit mode
// If we're in edit mode, make sure we're authenticated
if ($edit && !$user->authenticated()) {
$session->set_var("page", $_SERVER['REQUEST_URI']);
// Redirect to user login
// If we're in edit mode, make sure we're an admin user
if ($edit && !$user->is_admin()) {
require_once("header.php");
error("You need to be an admin to edit day data");
require_once("footer.php");
// Get the UARS day from the GET or POST data
$uars_day = isset ($_POST['UARS_Day']) ? $_POST['UARS_Day'] : @$_GET['uars_day'];
print "Error: UARS day is not valid";
require_once("header.php");
error("UARS Day is not valid");
require_once("footer.php");
// Create a UARS day class instance
$show_planned = @$_GET['show_planned'];
// Check to see if we're updating day data
if (isset ($_POST['save'])) {
if ($day->save($_POST)) {
// Redirect to view the day
// Include the correct header
require_once("offline_header.php");
require_once("header.php");
/* Figure out the PHP version. This is important since in version 4.3.8 there
* is a nasty padding bug in the printf() family of functions. We determine
* the padding based on the version, since only 4.3.8 should be affected.
// Print the Previous / Next day links
print "<div class=\"prev_next\">";
$link = "day_$pday.html";
$link = "day.php?uars_day=$pday";
print "<a href=\"$link\">← Day $pday</a>";
if ($day->day < $day->newest) {
print " ";
$link = "day_$nday.html";
$link = "day.php?uars_day=$nday";
print "<a href=\"$link\">Day $nday →</a>";
// Display the day table, taking into account edit mode
<table class="hrdi" id="day">
<form method="post" action=" <?php print "{ $_SERVER['PHP_SELF']}? uars_day={ $day->day}"?>">
<input type="hidden" name="UARS_Day" value=" <?php print $day->day?>">
<td class="label" colspan="3">HRDI Observational Database</td>
<td class="label_nb" colspan="2" align="right">
// Display correct week view link
$link = "week_". floor(($day->day + 3) / 7). ".html";
$link = "week.php?uars_day={$day->day}";
print "<a href=\"$link\">View week for day {$day->day}</ a> ";
// Display Edit / View link if appropriate
if (!$offline && $user->authenticated() && $user->is_admin()) {
print " | <a href=\"day.php?uars_day={$day->day}\"> View</ a> ";
print " | <a href=\"day.php?uars_day={$day->day}& edit=1\"> Edit</ a> ";
<td class="label"> <?php print common::deflink("Year - Day of Year", "YDoY")?></td>
<td class="data" colspan="2" nowrap> <?php print $day->data['Year']?> - <?php print $day->data['Day_Of_Year']?></td>
<td colspan="2" rowspan="3" class="label" style="white-space: normal">
<?php print common::deflink("Data Composition of Day", "Composition")?><br/>
Percentages relative to 24 hours of possible data collection. Percentage of:
<td class="label"> <?php print common::deflink("UARS Day", "UARS_Day")?></td>
<td class="data" colspan="2" align="center"> <?php print @$day->data['UARS_Day']?></td>
<td class="label"> <?php print common::deflink("Date", "Date")?></td>
<td class="data" colspan="2" align="center" nowrap> <?php print $day->data['Date']?></td>
<td class="label"> <?php print common::deflink("Flight Direction", "Flight")?></td>
<td class="data" colspan="2" align="center" nowrap>
<input id="fdf" type="radio" name="Flight_Direction" value="F" <?php print (common::get_value('Flight_Direction', $_POST, $day->data) == "F") ? "checked" : ""?>> <label for="fdf">Forward</label><br/>
<input id="fdb" type="radio" name="Flight_Direction" value="B" <?php print (common::get_value('Flight_Direction', $_POST, $day->data) == "B") ? "checked" : ""?>> <label for="fdb">Backward</label><br/>
<input id="fdm" type="radio" name="Flight_Direction" value="M" <?php print (common::get_value('Flight_Direction', $_POST, $day->data) == "M") ? "checked" : ""?>> <label for="fdm">Maneuver</label>
print @$day->display_data['Flight_Direction'];
<td class="label"> <?php print common::deflink("Mesosphere Lower Thermosphere Data", "Therm")?></td>
<td class="data" nowrap align=right> <?php print @$day->data['pcnt_Day_Mes_Low_Therm']?></td>
<td class="label"> <?php print common::deflink("Day Of Week", "DoW")?></td>
<td class="data" colspan="2" align="center" > <?php print $day->data['Day_Of_Week']?></td>
<td class="label"> <?php print common::deflink("Stratosphere Data", "Strat")?></td>
<td class="data" nowrap align=right> <?php print @$day->data['pcnt_Day_Strat']?></td>
<td class="label"> <?php print common::deflink("Beta Angle (Noon UT) (degrees)", "Beta")?></td>
<td class="data" colspan="2" align="right">
<input type="text" name="Beta_Angle" size="7" maxlength="7" value=" <?php print common::get_value('Beta_Angle', $_POST, $day->data)?>">
print @$day->data['Beta_Angle'];
<td class="label"> <?php print common::deflink("Other Science Data", "Other")?></td>
<td class="data" nowrap align=right> <?php print @$day->data['pcnt_Day_Other_Sci']?></td>
<td class="label"> <?php print common::deflink("Data Quality", "Quality")?></td>
<td class="data" colspan="2" align="center" nowrap>
* Care must be taken to differentiate between a value of 0 and
* a value of NULL for the data valid flag. PHP understands them
* to be different, but both ($valid == NULL) and ($valid == 0)
* would return TRUE if $foo was NULL. To get the right result,
* still use ($foo == NULL) but use ($foo === "0") for the second
<input id="unspecified" type="radio" name="Data_Valid" value="NULL"
<?php print (($valid == "NULL") || ($valid == NULL)) ? "checked" : ""?>
> <label for="unspecified">Unspecified</label><br/>
<input id="valid" type="radio" name="Data_Valid" value="1"
<?php print ($valid == 1) ? "checked" : ""?>
> <label for="valid">Valid</label><br/>
<input id="not_valid" type="radio" name="Data_Valid" value="0"
<?php print ($valid === "0") ? "checked" : ""?>
> <label for="not_valid">Not Valid</label>
if (@$day->data['Data_Valid'] == NULL) {
} elseif (@$day->data['Data_Valid'] == 1) {
} else if (@$day->data['Data_Valid'] === "0") {
<td class="label"> <?php print common::deflink("Daytime Data", "Daytime")?></td>
<td class="data" nowrap align=right> <?php print @$day->data['pcnt_Day_Day']?></td>
<td class="label"> <?php print common::deflink("Coefficient Version", "Coefficient")?></td>
<td class="data" align="center" colspan="2">
<input type="text" name="Coeff_Ver" size="2" maxlength="2" value=" <?php print common::get_value('Coeff_Ver', $_POST, $day->data)?>">
print @$day->data['Coeff_Ver'];
<td class="label"> <?php print common::deflink("Nighttime Data", "Nighttime")?></td>
<td class="data" nowrap align=right> <?php print @$day->data['pcnt_Day_Night']?></td>
<td class="label"> <?php print common::deflink("Yaw Period", "Yaw")?></td>
<td class="data" colspan="2" align="center">
<input type="text" name="Yaw_Period" size="3" maxlength="3" value=" <?php print common::get_value('Yaw_Period', $_POST, $day->data)?>">
print @$day->data['Yaw_Period'];
<td class="label"> <?php print common::deflink("Calibration Data", "Calibration")?></td>
<td class="data" nowrap align=right> <?php print @$day->data['pcnt_Day_Calib']?></td>
<td class="label" colspan="3"> <?php print common::deflink("Instrument Temperature (°C)", "Temp")?></td>
<td class="label"> <?php print common::deflink("Science or Calibration Data", "Science")?></td>
<td class="data" nowrap align=right> <?php print @$day->data['pcnt_Day_Sci_Calib']?></td>
<td class="label"> <?php print common::deflink("Mean ± Std. Deviation", "Temp")?></td>
<td class="data" align=right> <?php printf("%.2f", @$day->data['Inst_Temp_Mean']) ?></td>
<td class="data" align=right> <?php printf("%.2f", @$day->data['Inst_Temp_Std_Dev']) ?></td>
<td class="label"> <?php print common::deflink("Time Powered On", "Time")?></td>
<td class="data" nowrap align=right> <?php print @$day->data['pcnt_Day_On']?></td>
<td class="label"> <?php print common::deflink("Minimum/Maximum", "Temp")?></td>
<td class="data" align=right> <?php printf("%.2f", @$day->data['Inst_Temp_Min']) ?></td>
<td class="data" align=right> <?php printf("%.2f", @$day->data['Inst_Temp_Max']) ?></td>
<td class="label"> <?php print common::deflink("Total Possible Data Collected", "Total")?></td>
<td class="data" nowrap align=right> <?php print @$day->data['pcnt_Day_Poss_Collect']?></td>
<td class="label"> <?php print common::deflink("Telescope Slew Rate", "Telescope")?> (deg/s)</td>
<td class="data" align=right> <?php printf("%.2f", @$day->data['Telescope_Slew_Rate']) ?></td>
<td class="label"> </td>
<td class="label"> <?php print common::deflink("Idle Mode", "Idle")?></td>
<td class="data" nowrap align=right> <?php print @$day->data['pcnt_Day_Idle']?></td>
<td class="label" id="comments"> <?php print common::deflink("Comments", "Comments")?></td>
<td class="data" colspan="4">
<textarea name="Comments" cols="50" rows="3"
<td colspan="5" class="label" align="right">
<input type="button" value="Cancel" onClick="location.href='day.php?uars_day= <?php print $day->day?>'">
<input type="submit" name="save" value="Save">
<table class="hrdi" id="modes">
<td class="label" colspan="6"> <?php print common::deflink("Modes", "Modes")?></td>
<td class="label_nb" align="right">
if (!$offline && $user->authenticated() && $user->is_admin()) {
print "<a href=\"editmodes.php?uars_day={$day->day}\"> Edit</ a> ";
<td width="49%"> <?php print common::deflink("Description", "Description")?></td>
// The link for showing/hiding Pids in Case 1 below
$pid_message_link = "<a href=\""
. ($edit ? "&edit=1" : "");
$pid_message_link .= "\">hide planned pids</a>";
$pid_message_link .= "&show_planned=1\">display planned pids</a>";
* These are the messages displayed at the bottom of the Pids table.
* This was designed per the original e-mail.
* Case 1: If there is at least one 'No' value, display only the PID
* lines containing 'No' values by default, since the presence of
* an un-planned PID indicates non-nominal information
* Case 2: If the current calendar day is <= the day being shown
* Case 3: If all PIDs for the day are marked 'Yes' in the Planned field, the
* current calendar day is > the day being shown, and the data valid flag is
* Case 4: If all PIDs for the day are marked 'Yes' in the Planned field, the
* current calendar day is > the day being shown, and the data valid flag is
* Case 5: If all PIDs for the day are marked 'Yes' in the Planned field, the
* current calendar day is > the day being shown, and the data valid flag is
$pid_messages[0] = ""; // This message should never show up
$pid_messages[1] = "HRDI did not operate as planned today.";
$pid_messages[1] .= " ($pid_message_link)";
$pid_messages[2] = "These modes are planned for execution.";
$pid_messages[3] = "Data for this day is not yet validated.";
$pid_messages[4] = "HRDI operated as planned on this day.";
$pid_messages[5] = "HRDI operated as planned on this day but the data is not valid.";
foreach ($day->modes as $mode) {
foreach ($day->modes as $mode) {
if ($mode['Planned'] && !$all_planned && !$show_planned) {
<td> <?php print $mode['Process_ID']?></td>
<td nowrap> <?php print $mode['Azimuth1']?></td>
<td nowrap> <?php print $mode['Azimuth2']?></td>
<td nowrap> <?php print $mode['Azimuth3']?></td>
<td nowrap> <?php print $mode['Azimuth4']?></td>
<td> <?php print $mode['Description']?></td>
<td> <?php print ($mode['Planned'] ? "Yes" : "No")?></td>
* Add any necessary mode rows to meet the "minimum" number
for ($i = $shown_modes; $i < $min_mode_rows; $i++ ) {
print "<tr class=\"data\">
* Please see the comment block further up regarding comparing the
* values to NULL and to 0.
} else if (time() <= $day->day_ts) {
} else if ($all_planned && (time() > $day->day_ts) && (@$day->data['Data_Valid'] == NULL)) {
} else if ($all_planned && (time() > $day->day_ts) && (@$day->data['Data_Valid'] == 1)) {
} else if ($all_planned && (time() > $day->day_ts) && (@$day->data['Data_Valid'] === "0")) {
<td colspan="7"> <?php print $pid_messages[$case]?></td>
<table class="hrdi" id="files">
<td> <?php print common::deflink("Downloadable Data (D) and Plots (P)", "Files")?></td>
foreach ($day->files as $file) {
<td><a href=" <?php print $file['Filename']?>"> <?php print $file['Description']?></a></td>
* Add any necessary file rows to meet the "minimum" number
for ($i = count($day->files); $i < $min_file_rows; $i++ ) {
print "<tr class=\"data\">
<table class="hrdi" id="coverage">
<td class="label" rowspan="2"> <?php print common::deflink("Coverage", "Coverage")?></td>
<td class="c_label" colspan="4"> <?php print common::deflink("Warm Side", "Warm")?></td>
<td class="c_label" colspan="4"> <?php print common::deflink("Cold Side", "Cold")?></td>
<td class="c_label" colspan="2"> <?php print common::deflink("Day", "Day")?></td>
<td class="c_label" colspan="2"> <?php print common::deflink("Night", "Night")?></td>
<td class="c_label" colspan="2"> <?php print common::deflink("Day", "Day")?></td>
<td class="c_label" colspan="2"> <?php print common::deflink("Night", "Night")?></td>
<td class="label"> <?php print common::deflink("Node", "Node")?></td>
<td class="c_label"> <?php print common::deflink("Asc", "Asc")?></td>
<td class="c_label"> <?php print common::deflink("Desc", "Desc")?></td>
<td class="c_label"> <?php print common::deflink("Asc", "Asc")?></td>
<td class="c_label"> <?php print common::deflink("Desc", "Desc")?></td>
<td class="c_label"> <?php print common::deflink("Asc", "Asc")?></td>
<td class="c_label"> <?php print common::deflink("Desc", "Desc")?></td>
<td class="c_label"> <?php print common::deflink("Asc", "Asc")?></td>
<td class="c_label"> <?php print common::deflink("Desc", "Desc")?></td>
<td class="label"> <?php print common::deflink("Local Time", "Local")?> (60° North) (hours)</td>
<td class="label"> <?php print common::deflink("Local Time", "Local")?> (30° North) (hours)</td>
<td class="label"> <?php print common::deflink("Local Time", "Local")?> (Equator) (hours)</td>
<td class="label"> <?php print common::deflink("Local Time", "Local")?> (30° South) (hours)</td>
<td class="label"> <?php print common::deflink("Local Time", "Local")?> (60° South) (hours)</td>
<td class="label"> <?php print common::deflink("Latitude Minimum", "Lmin")?> (degrees)</td>
<td class="label"> <?php print common::deflink("Latitude Maximum", "Lmax")?> (degrees)</td>
require_once("footer.php");
|