@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | public function buildcloudlayer($metar) { |
12 | 12 | //print_r($metar); |
13 | 13 | $result = array(); |
14 | - foreach($metar['cloud'] as $key => $data) { |
|
14 | + foreach ($metar['cloud'] as $key => $data) { |
|
15 | 15 | $alt_m = $metar['cloud'][$key]['level']; |
16 | 16 | $alt_ft = $alt_m*3.28084; |
17 | 17 | $pressure = $metar['QNH']; |
18 | - $cumulus_base = 122.0 * ($metar['temperature'] - $metar['dew']); |
|
19 | - $stratus_base = 100.0 * (100.0 * $metar['rh'])*0.3048; |
|
18 | + $cumulus_base = 122.0*($metar['temperature'] - $metar['dew']); |
|
19 | + $stratus_base = 100.0*(100.0*$metar['rh'])*0.3048; |
|
20 | 20 | $coverage_norm = 0.0; |
21 | 21 | if ($metar['cloud'][$key]['type'] == 'Few') { |
22 | 22 | $coverage_norm = 2.0/8.0; |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | $layer_type = 'ns'; |
39 | 39 | } |
40 | 40 | } else { |
41 | - if ($cumulus_base * 0.80 < $alt_m && $cumulus_base * 1.20 > $alt_m) { |
|
41 | + if ($cumulus_base*0.80 < $alt_m && $cumulus_base*1.20 > $alt_m) { |
|
42 | 42 | $layer_type = 'cu'; |
43 | - } elseif ($stratus_base * 0.80 < $alt_m && $stratus_base * 1.40 > $alt_m) { |
|
43 | + } elseif ($stratus_base*0.80 < $alt_m && $stratus_base*1.40 > $alt_m) { |
|
44 | 44 | $layer_type = 'st'; |
45 | 45 | } else { |
46 | 46 | if ($alt_ft < 2000) { |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | } |
54 | 54 | } |
55 | 55 | //echo 'coverage norm : '.$coverage_norm.' - layer_type: '.$layer_type."\n"; |
56 | - $result[] = array('cov' => $coverage_norm, 'type' => $layer_type,'alt' => $alt_m,'rh' => $metar['rh']); |
|
56 | + $result[] = array('cov' => $coverage_norm, 'type' => $layer_type, 'alt' => $alt_m, 'rh' => $metar['rh']); |
|
57 | 57 | } |
58 | 58 | if (count($result) < 2 && $metar['rh'] > 60) { |
59 | - $result[] = array('cov' => 0.75, 'type' => 'ci','alt' => 4000,'rh' => $metar['rh']); |
|
59 | + $result[] = array('cov' => 0.75, 'type' => 'ci', 'alt' => 4000, 'rh' => $metar['rh']); |
|
60 | 60 | } |
61 | 61 | return $result; |
62 | 62 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | |
77 | 77 | // http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl?file=gfs.t05z.pgrb2full.0p50.f000&lev_10_m_above_ground=on&lev_surface=on&var_TMP=on&var_UGRD=on&var_VGRD=on&leftlon=0&rightlon=360&toplat=90&bottomlat=-90&dir=/gfs.2017111717 |
78 | 78 | $resolution = '0.5'; |
79 | - $baseurl = 'http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_'.($resolution === '1' ? '1p00':'0p50').'.pl'; |
|
80 | - $get = array('file' => 'gfs.t'.sprintf('%02d',(6*floor($hour/6))).($resolution === '1' ? 'z.pgrb2.1p00.f000' : 'z.pgrb2full.0p50.f000'), |
|
79 | + $baseurl = 'http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_'.($resolution === '1' ? '1p00' : '0p50').'.pl'; |
|
80 | + $get = array('file' => 'gfs.t'.sprintf('%02d', (6*floor($hour/6))).($resolution === '1' ? 'z.pgrb2.1p00.f000' : 'z.pgrb2full.0p50.f000'), |
|
81 | 81 | 'lev_10_m_above_ground' => 'on', |
82 | 82 | 'lev_surface' => 'on', |
83 | 83 | 'var_TMP' => 'on', |
@@ -87,21 +87,21 @@ discard block |
||
87 | 87 | 'rightlon' => 360, |
88 | 88 | 'toplat' => 90, |
89 | 89 | 'bottomlat' => -90, |
90 | - 'dir' => '/gfs.'.date('Ymd').sprintf('%02d',(6*floor($hour/6))) |
|
90 | + 'dir' => '/gfs.'.date('Ymd').sprintf('%02d', (6*floor($hour/6))) |
|
91 | 91 | ); |
92 | 92 | $url = $baseurl.'?'.http_build_query($get); |
93 | 93 | echo $url; |
94 | 94 | $Common = new Common(); |
95 | - $Common->download($url,$windpathsrc); |
|
95 | + $Common->download($url, $windpathsrc); |
|
96 | 96 | // Check if the downloaded file is in GRIB format |
97 | - $file = fopen($windpathsrc,"r"); |
|
97 | + $file = fopen($windpathsrc, "r"); |
|
98 | 98 | $firc = fgetc($file); |
99 | 99 | fclose($file); |
100 | 100 | if ($firc == 'G') { |
101 | 101 | system($grib2json.' --data --output '.$windpathdest.' --names --compact '.$windpathsrc); |
102 | 102 | } else { |
103 | 103 | // if not try previous run |
104 | - $this->nomad_wind(date('G')-6); |
|
104 | + $this->nomad_wind(date('G') - 6); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | $url = 'https://podaac.jpl.nasa.gov/ws/search/granule/?datasetId=PODAAC-OSCAR-03D01&itemsPerPage=1&sortBy=timeDesc&format=atom&pretty=false'; |
121 | 121 | $Common = new Common(); |
122 | 122 | $oscarlst = $Common->getData($url); |
123 | - $oscarlst_xml = json_decode(json_encode(simplexml_load_string($oscarlst)),true); |
|
123 | + $oscarlst_xml = json_decode(json_encode(simplexml_load_string($oscarlst)), true); |
|
124 | 124 | foreach ($oscarlst_xml['entry']['link'] as $oscarlnk) { |
125 | 125 | if ($oscarlnk['@attributes']['type'] == 'application/x-netcdf') { |
126 | - $Common->download($oscarlnk['@attributes']['href'],$wavepathsrc.'.gz'); |
|
126 | + $Common->download($oscarlnk['@attributes']['href'], $wavepathsrc.'.gz'); |
|
127 | 127 | break; |
128 | 128 | } |
129 | 129 | } |
@@ -63,7 +63,9 @@ |
||
63 | 63 | |
64 | 64 | public function nomad_wind($hour = '') { |
65 | 65 | global $globalWindsPath; |
66 | - if ($hour == '') $hour = date('G'); |
|
66 | + if ($hour == '') { |
|
67 | + $hour = date('G'); |
|
68 | + } |
|
67 | 69 | if (isset($globalWindsPath) && $globalWindsPath != '') { |
68 | 70 | $grib2json = $globalWindsPath['grib2json']; |
69 | 71 | $windpathsrc = $globalWindsPath['source']; |