<commit_before><?php 
 include("../../config/settings.inc.php");
 include("../../include/database.inc.php");
 include("setup.php");

 include("../../include/myview.php");
 $t = new MyView();
 
 $t->thispage = "iem-sites";
 $t->title = "Current Data";
 $t->sites_current = "current"; 


 if (strpos($network, "_DCP") || strpos($network, "_COOP") ){
 	$table = '<p>This station reports observations in SHEF format.  The following
 			is a table of the most recent reports from this site identifier for
 			each reported SHEF variable';
 	$mesosite = iemdb('mesosite');
 	$shefcodes = Array();
 	$rs = pg_query($mesosite, "SELECT * from shef_physical_codes");
 	for($i=0;$row=@pg_fetch_assoc($rs,$i);$i++){
 		$shefcodes[ $row['code'] ] = $row['name'];
 	}
 	$durationcodes = Array();
 	$rs = pg_query($mesosite, "SELECT * from shef_duration_codes");
 	for($i=0;$row=@pg_fetch_assoc($rs,$i);$i++){
 		$durationcodes[ $row['code'] ] = $row['name'];
 	}
 	$extremumcodes = Array();
 	$rs = pg_query($mesosite, "SELECT * from shef_extremum_codes");
 	for($i=0;$row=@pg_fetch_assoc($rs,$i);$i++){
 		$extremumcodes[ $row['code'] ] = $row['name'];
 	}
 	
 	$pgconn = iemdb('access');
 	pg_query($pgconn, "SET time zone '". $metadata['tzname'] ."'");
 	$rs = pg_prepare($pgconn, "SELECT", "SELECT * from current_shef
 			where station = $1 ORDER by physical_code ASC");
 	$rs = pg_execute($pgconn, "SELECT", Array($station));
	$table .= "<table class=\"table table-striped\">
			<thead><tr><th>Physical Code</th><th>Duration</th><th>Extremum</th>
			<th>Valid</th><th>Value</th></thead>";
 	for($i=0;$row=@pg_fetch_assoc($rs,$i);$i++){
 		$ts = strtotime($row["valid"]);
 		$depth = "";
 		if ($row["depth"] > 0){
 			$depth = sprintf("%d inch", $row["depth"]);
 		}
 		$table .= sprintf("<tr><td>[%s] %s %s</td><td>[%s] %s</td><td>[%s] %s</td><td>%s</td><td>%s</td></tr>", 
 				$row["physical_code"],$shefcodes[$row["physical_code"]], $depth,
 				$row["duration"], $durationcodes[ $row["duration"] ], 
 				$row["extremum"] == 'Z'? '-': $row['extremum'] , $extremumcodes[ $row["extremum"] ],
 				date('d M Y g:i A', $ts), $row["value"]);
 	}
 	$table .= "</table>";
} else {
  include ("../../include/iemaccess.php");
  include ("../../include/iemaccessob.php");
  $iem = new IEMAccess($metadata["tzname"]);
  $iemob = $iem->getSingleSite($station);
  $rs = $iemob->db;

 $vardict = Array("lvalid" => "Observation Time", "tmpf" => "Air Temp [F]",
 		"max_tmpf" => "Maximum Air Temperature [F]", 
 		"min_tmpf" => "Minimum Air Temperature [F]",
   "dwpf" => "Dew Point [F]", "relh" => "Relative Humidity [%]",
   "drct" => "Wind Direction", "sknt" => "Wind Speed [knots]",
   "srad" => "Solar Radiation",
   "alti" => "Altimeter [inches]", "pday" => "Daily Precipitation [inches]",
   "pmonth" => "Monthly Precipitation [inches]",
   "gust" => "Wind Gust [knots]", 
 	"c1tmpf" => "Soil Temperature [F]",	
 	"c2tmpf" => "Soil Temperature [F]",	
 	"c3tmpf" => "Soil Temperature [F]",
 	"c4tmpf" => "Soil Temperature [F]",
 	"c5tmpf" => "Soil Temperature [F]",
 	"c1smv" => "Soil Moisture [%]",<commit_msg>fix timestamp presentation for HADS current ob<commit_after><?php 
 include("../../config/settings.inc.php");
 include("../../include/database.inc.php");
 require_once "setup.php";

 include("../../include/myview.php");
 $t = new MyView();
 
 $t->thispage = "iem-sites";
 $t->title = "Current Data";
 $t->sites_current = "current"; 


 if (strpos($network, "_DCP") || strpos($network, "_COOP") ){
 	$table = '<p>This station reports observations in SHEF format.  The following
 			is a table of the most recent reports from this site identifier for
 			each reported SHEF variable';
 	$mesosite = iemdb('mesosite');
 	$shefcodes = Array();
 	$rs = pg_query($mesosite, "SELECT * from shef_physical_codes");
 	for($i=0;$row=@pg_fetch_assoc($rs,$i);$i++){
 		$shefcodes[ $row['code'] ] = $row['name'];
 	}
 	$durationcodes = Array();
 	$rs = pg_query($mesosite, "SELECT * from shef_duration_codes");
 	for($i=0;$row=@pg_fetch_assoc($rs,$i);$i++){
 		$durationcodes[ $row['code'] ] = $row['name'];
 	}
 	$extremumcodes = Array();
 	$rs = pg_query($mesosite, "SELECT * from shef_extremum_codes");
 	for($i=0;$row=@pg_fetch_assoc($rs,$i);$i++){
 		$extremumcodes[ $row['code'] ] = $row['name'];
 	}
 	
 	$pgconn = iemdb('access');
 	$rs = pg_prepare($pgconn, "SELECT", "SELECT *, ".
 			"to_char(valid at time zone $1, 'dd Mon YYYY HH:MI AM') as ts ".
 			"from current_shef ".
 			"where station = $2 ORDER by physical_code ASC");
 	$rs = pg_execute($pgconn, "SELECT", Array($metadata['tzname'], $station));
	$table .= "<table class=\"table table-striped\">
			<thead><tr><th>Physical Code</th><th>Duration</th><th>Extremum</th>
			<th>Valid</th><th>Value</th></thead>";
 	for($i=0;$row=@pg_fetch_assoc($rs,$i);$i++){
 		$depth = "";
 		if ($row["depth"] > 0){
 			$depth = sprintf("%d inch", $row["depth"]);
 		}
 		$table .= sprintf("<tr><td>[%s] %s %s</td><td>[%s] %s</td><td>[%s] %s</td><td>%s</td><td>%s</td></tr>", 
 				$row["physical_code"],$shefcodes[$row["physical_code"]], $depth,
 				$row["duration"], $durationcodes[ $row["duration"] ], 
 				$row["extremum"] == 'Z'? '-': $row['extremum'] , $extremumcodes[ $row["extremum"] ],
 				$row["ts"], $row["value"]);
 	}
 	$table .= "</table>";
} else {
  include ("../../include/iemaccess.php");
  include ("../../include/iemaccessob.php");
  $iem = new IEMAccess($metadata["tzname"]);
  $iemob = $iem->getSingleSite($station);
  $rs = $iemob->db;

 $vardict = Array("lvalid" => "Observation Time", "tmpf" => "Air Temp [F]",
 		"max_tmpf" => "Maximum Air Temperature [F]", 
 		"min_tmpf" => "Minimum Air Temperature [F]",
   "dwpf" => "Dew Point [F]", "relh" => "Relative Humidity [%]",
   "drct" => "Wind Direction", "sknt" => "Wind Speed [knots]",
   "srad" => "Solar Radiation",
   "alti" => "Altimeter [inches]", "pday" => "Daily Precipitation [inches]",
   "pmonth" => "Monthly Precipitation [inches]",
   "gust" => "Wind Gust [knots]", 
 	"c1tmpf" => "Soil Temperature [F]",	
 	"c2tmpf" => "Soil Temperature [F]",	
 	"c3tmpf" => "Soil Temperature [F]",
 	"c4tmpf" => "Soil Temperature [F]",
 	"c5tmpf" => "Soil Temperature [F]",
 	"c1smv" => "Soil Moisture [%]",
{'fraction_non_alphanumeric': 0.2477890336066892, 'fraction_numerical': 0.004019938896928766, 'mean_word_length': 4.460930640913082, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 109, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4705177', 'n_tokens_mistral': 2603, 'n_tokens_neox': 2382, 'n_words': 476}