-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.php
More file actions
33 lines (25 loc) · 1.24 KB
/
test.php
File metadata and controls
33 lines (25 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
define( 'DEBUG_MODE', true );
require_once( './cronos.php' );
$c = new CRONOS( 'abc123' ); // Replace with your API key.
// Collect data from COOP, CoCoRaHS, AWOS and ASOS networks for SECC states and filter out the COOP (pointless but testing)
$results = $c->listStations( array( 'COOP', 'CoCoRaHS', 'AWOS', 'ASOS' ), array( 'AL', 'FL', 'GA', 'NC', 'SC' ), array(), array( 'COOP' ), true );
echo "====================\nStart run\n====================\n";
// Collect the stations by network.
$networks = array();
foreach( $results as $r ) {
$networks[$r['network']][] = $r['station'];
}
if( DEBUG_MODE ) print_r( $results );
// Get daily weather information for the last week from ASOS network only.
$startdate = date('Y-m-d h:m:s', strtotime( '-15 days' ));
#$startdate = '2011--25';
$daily = $c->getHourlyData( $networks['ASOS'], $startdate, '', array('temp', 'rh' ) );
if( DEBUG_MODE) print_r( $daily ); // Uncomment for raw data from $daily
// Display the average tempurature per station per day (simple loop)
foreach( $daily as $d ) {
echo 'Tempurature for station '.$d['station'].' on '.$d['ob'].' was '.$d['temp'].".\n";
}
echo "====================\nEnd run\n====================\n";
echo "Max memory used: ".memory_get_peak_usage()."\n";
?>