| 1149 | | open(STATION_ID_SQLFILE,'>>../sql_in_situ_station_id/in_situ_station_id_'.$institution_code_value.'_' |
|---|
| 1150 | | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| 1151 | | print STATION_ID_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| 1152 | | print STATION_ID_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| 1153 | | print STATION_ID_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| 1154 | | print STATION_ID_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| 1155 | | print STATION_ID_SQLFILE "-- title = $title_value\n"; |
|---|
| 1156 | | print STATION_ID_SQLFILE "-- institution = $institution_value\n"; |
|---|
| 1157 | | print STATION_ID_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| 1158 | | print STATION_ID_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| 1159 | | print STATION_ID_SQLFILE "-- source = $source_value\n"; |
|---|
| 1160 | | print STATION_ID_SQLFILE "-- references = $references_value\n"; |
|---|
| 1161 | | print STATION_ID_SQLFILE "-- contact = $contact_value\n"; |
|---|
| 1162 | | print STATION_ID_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| 1163 | | print STATION_ID_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| 1164 | | print STATION_ID_SQLFILE "INSERT INTO in_situ_station_id ("; |
|---|
| 1165 | | print STATION_ID_SQLFILE "station_id,"; |
|---|
| 1166 | | print STATION_ID_SQLFILE "title,"; |
|---|
| 1167 | | print STATION_ID_SQLFILE "institution,"; |
|---|
| 1168 | | print STATION_ID_SQLFILE "institution_url,"; |
|---|
| 1169 | | print STATION_ID_SQLFILE "institution_dods_url,"; |
|---|
| 1170 | | print STATION_ID_SQLFILE "source,"; |
|---|
| 1171 | | print STATION_ID_SQLFILE "refs,"; |
|---|
| 1172 | | print STATION_ID_SQLFILE "contact"; |
|---|
| 1173 | | print STATION_ID_SQLFILE ") "; |
|---|
| 1174 | | print STATION_ID_SQLFILE "VALUES ("; |
|---|
| 1175 | | print STATION_ID_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| 1176 | | print STATION_ID_SQLFILE ','.'\''.$title_value.'\''; |
|---|
| 1177 | | print STATION_ID_SQLFILE ','.'\''.$institution_value.'\''; |
|---|
| 1178 | | print STATION_ID_SQLFILE ','.'\''.'<a href='.$institution_url_value.' target= _blank>'.$institution_url_value.'</a>'.'\''; |
|---|
| 1179 | | print STATION_ID_SQLFILE ','.'\''.'<a href='.$institution_dods_url_value.' target= _blank>'.$institution_dods_url_value.'</a>'.'\''; |
|---|
| 1180 | | print STATION_ID_SQLFILE ','.'\''.$source_value.'\''; |
|---|
| 1181 | | print STATION_ID_SQLFILE ','.'\''.$references_value.'\''; |
|---|
| 1182 | | print STATION_ID_SQLFILE ','.'\''.$contact_value.'\''; |
|---|
| 1183 | | print STATION_ID_SQLFILE ");\n"; |
|---|
| 1184 | | close(STATION_ID_SQLFILE); |
|---|
| 1185 | | } |
|---|
| | 1283 | if( $bWriteSQLFiles ) |
|---|
| | 1284 | { |
|---|
| | 1285 | open(STATION_ID_SQLFILE,'>>../sql_in_situ_station_id/in_situ_station_id_'.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| | 1286 | print STATION_ID_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| | 1287 | print STATION_ID_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| | 1288 | print STATION_ID_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| | 1289 | print STATION_ID_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| | 1290 | print STATION_ID_SQLFILE "-- title = $title_value\n"; |
|---|
| | 1291 | print STATION_ID_SQLFILE "-- institution = $institution_value\n"; |
|---|
| | 1292 | print STATION_ID_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| | 1293 | print STATION_ID_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| | 1294 | print STATION_ID_SQLFILE "-- source = $source_value\n"; |
|---|
| | 1295 | print STATION_ID_SQLFILE "-- references = $references_value\n"; |
|---|
| | 1296 | print STATION_ID_SQLFILE "-- contact = $contact_value\n"; |
|---|
| | 1297 | print STATION_ID_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| | 1298 | print STATION_ID_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| | 1299 | print STATION_ID_SQLFILE "INSERT INTO in_situ_station_id ("; |
|---|
| | 1300 | print STATION_ID_SQLFILE "station_id,"; |
|---|
| | 1301 | print STATION_ID_SQLFILE "title,"; |
|---|
| | 1302 | print STATION_ID_SQLFILE "institution,"; |
|---|
| | 1303 | print STATION_ID_SQLFILE "institution_url,"; |
|---|
| | 1304 | print STATION_ID_SQLFILE "institution_dods_url,"; |
|---|
| | 1305 | print STATION_ID_SQLFILE "source,"; |
|---|
| | 1306 | print STATION_ID_SQLFILE "refs,"; |
|---|
| | 1307 | print STATION_ID_SQLFILE "contact"; |
|---|
| | 1308 | print STATION_ID_SQLFILE ") "; |
|---|
| | 1309 | print STATION_ID_SQLFILE "VALUES ("; |
|---|
| | 1310 | print STATION_ID_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| | 1311 | print STATION_ID_SQLFILE ','.'\''.$title_value.'\''; |
|---|
| | 1312 | print STATION_ID_SQLFILE ','.'\''.$institution_value.'\''; |
|---|
| | 1313 | print STATION_ID_SQLFILE ','.'\''.'<a href='.$institution_url_value.' target= _blank>'.$institution_url_value.'</a>'.'\''; |
|---|
| | 1314 | print STATION_ID_SQLFILE ','.'\''.'<a href='.$institution_dods_url_value.' target= _blank>'.$institution_dods_url_value.'</a>'.'\''; |
|---|
| | 1315 | print STATION_ID_SQLFILE ','.'\''.$source_value.'\''; |
|---|
| | 1316 | print STATION_ID_SQLFILE ','.'\''.$references_value.'\''; |
|---|
| | 1317 | print STATION_ID_SQLFILE ','.'\''.$contact_value.'\''; |
|---|
| | 1318 | print STATION_ID_SQLFILE ");\n"; |
|---|
| | 1319 | close(STATION_ID_SQLFILE); |
|---|
| | 1320 | } |
|---|
| | 1321 | } |
|---|
| | 1322 | |
|---|
| | 1323 | #DWR 4/5/2008 |
|---|
| | 1324 | #Implemented code to write the obsKML files. |
|---|
| | 1325 | my %ObsHash; |
|---|
| | 1326 | my $rObsHash = \%ObsHash; |
|---|
| | 1327 | my $strPlatformID = $institution_code_value.'.'.$platform_code_value.'.'.$package_code_value; |
|---|
| | 1328 | obsKMLSubRoutines::KMLAddPlatformHashEntry( $strPlatformID, $institution_url_value, $latitude_value[0], $longitude_value[0], $rObsHash ); |
|---|
| 1188 | | if ($#water_level > -1) { |
|---|
| 1189 | | open(WATER_LEVEL_SQLFILE,'>>../sql/water_level_prod_'.$institution_code_value.'_' |
|---|
| 1190 | | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| 1191 | | print WATER_LEVEL_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| 1192 | | print WATER_LEVEL_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| 1193 | | print WATER_LEVEL_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| 1194 | | print WATER_LEVEL_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| 1195 | | print WATER_LEVEL_SQLFILE "-- title = $title_value\n"; |
|---|
| 1196 | | print WATER_LEVEL_SQLFILE "-- institution = $institution_value\n"; |
|---|
| 1197 | | print WATER_LEVEL_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| 1198 | | print WATER_LEVEL_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| 1199 | | print WATER_LEVEL_SQLFILE "-- source = $source_value\n"; |
|---|
| 1200 | | print WATER_LEVEL_SQLFILE "-- references = $references_value\n"; |
|---|
| 1201 | | print WATER_LEVEL_SQLFILE "-- contact = $contact_value\n"; |
|---|
| 1202 | | print WATER_LEVEL_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| 1203 | | print WATER_LEVEL_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| 1204 | | for my $i (0..$#water_level) { |
|---|
| 1205 | | for my $j (0..$#this_water_level_data) { |
|---|
| 1206 | | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| 1207 | | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| 1208 | | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| 1209 | | |
|---|
| 1210 | | if ($water_level[$i]{'data'}[$j] != $missing_value_value |
|---|
| 1211 | | && $water_level[$i]{'data'}[$j] != $Fill_value_value |
|---|
| 1212 | | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| 1213 | | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| 1214 | | print WATER_LEVEL_SQLFILE "INSERT INTO water_level_prod ("; |
|---|
| 1215 | | print WATER_LEVEL_SQLFILE "station_id,"; |
|---|
| 1216 | | print WATER_LEVEL_SQLFILE "time_stamp,"; |
|---|
| 1217 | | print WATER_LEVEL_SQLFILE "z,"; |
|---|
| 1218 | | print WATER_LEVEL_SQLFILE "positive,"; |
|---|
| 1219 | | print WATER_LEVEL_SQLFILE "water_level,"; |
|---|
| 1220 | | print WATER_LEVEL_SQLFILE "reference,"; |
|---|
| 1221 | | print WATER_LEVEL_SQLFILE "reference_to_mllw,"; |
|---|
| 1222 | | print WATER_LEVEL_SQLFILE "reference_to_msl,"; |
|---|
| 1223 | | print WATER_LEVEL_SQLFILE "reference_to_navd88,"; |
|---|
| 1224 | | print WATER_LEVEL_SQLFILE "title,"; |
|---|
| 1225 | | print WATER_LEVEL_SQLFILE "institution,"; |
|---|
| 1226 | | print WATER_LEVEL_SQLFILE "institution_url,"; |
|---|
| 1227 | | print WATER_LEVEL_SQLFILE "institution_dods_url,"; |
|---|
| 1228 | | print WATER_LEVEL_SQLFILE "source,"; |
|---|
| 1229 | | print WATER_LEVEL_SQLFILE "refs,"; |
|---|
| 1230 | | print WATER_LEVEL_SQLFILE "contact,"; |
|---|
| 1231 | | print WATER_LEVEL_SQLFILE "the_geom"; |
|---|
| 1232 | | print WATER_LEVEL_SQLFILE ") "; |
|---|
| 1233 | | print WATER_LEVEL_SQLFILE "VALUES ("; |
|---|
| 1234 | | print WATER_LEVEL_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| 1235 | | print WATER_LEVEL_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$j].'\''; |
|---|
| 1236 | | if ($water_level[$i]{'height'} == $missing_value_value |
|---|
| 1237 | | || $water_level[$i]{'height'} == $Fill_value_value) { |
|---|
| 1238 | | print WATER_LEVEL_SQLFILE ','.'\'\''; |
|---|
| | 1331 | if ($#water_level > -1) |
|---|
| | 1332 | { |
|---|
| | 1333 | if( $bWriteSQLFiles ) |
|---|
| | 1334 | { |
|---|
| | 1335 | open(WATER_LEVEL_SQLFILE,'>>../sql/water_level_prod_'.$institution_code_value.'_' |
|---|
| | 1336 | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| | 1337 | print WATER_LEVEL_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| | 1338 | print WATER_LEVEL_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| | 1339 | print WATER_LEVEL_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| | 1340 | print WATER_LEVEL_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| | 1341 | print WATER_LEVEL_SQLFILE "-- title = $title_value\n"; |
|---|
| | 1342 | print WATER_LEVEL_SQLFILE "-- institution = $institution_value\n"; |
|---|
| | 1343 | print WATER_LEVEL_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| | 1344 | print WATER_LEVEL_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| | 1345 | print WATER_LEVEL_SQLFILE "-- source = $source_value\n"; |
|---|
| | 1346 | print WATER_LEVEL_SQLFILE "-- references = $references_value\n"; |
|---|
| | 1347 | print WATER_LEVEL_SQLFILE "-- contact = $contact_value\n"; |
|---|
| | 1348 | print WATER_LEVEL_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| | 1349 | print WATER_LEVEL_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| | 1350 | for my $i (0..$#water_level) { |
|---|
| | 1351 | for my $j (0..$#this_water_level_data) { |
|---|
| | 1352 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 1353 | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| | 1354 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 1355 | |
|---|
| | 1356 | if ($water_level[$i]{'data'}[$j] != $missing_value_value |
|---|
| | 1357 | && $water_level[$i]{'data'}[$j] != $Fill_value_value |
|---|
| | 1358 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 1359 | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| | 1360 | print WATER_LEVEL_SQLFILE "INSERT INTO water_level_prod ("; |
|---|
| | 1361 | print WATER_LEVEL_SQLFILE "station_id,"; |
|---|
| | 1362 | print WATER_LEVEL_SQLFILE "time_stamp,"; |
|---|
| | 1363 | print WATER_LEVEL_SQLFILE "z,"; |
|---|
| | 1364 | print WATER_LEVEL_SQLFILE "positive,"; |
|---|
| | 1365 | print WATER_LEVEL_SQLFILE "water_level,"; |
|---|
| | 1366 | print WATER_LEVEL_SQLFILE "reference,"; |
|---|
| | 1367 | print WATER_LEVEL_SQLFILE "reference_to_mllw,"; |
|---|
| | 1368 | print WATER_LEVEL_SQLFILE "reference_to_msl,"; |
|---|
| | 1369 | print WATER_LEVEL_SQLFILE "reference_to_navd88,"; |
|---|
| | 1370 | print WATER_LEVEL_SQLFILE "title,"; |
|---|
| | 1371 | print WATER_LEVEL_SQLFILE "institution,"; |
|---|
| | 1372 | print WATER_LEVEL_SQLFILE "institution_url,"; |
|---|
| | 1373 | print WATER_LEVEL_SQLFILE "institution_dods_url,"; |
|---|
| | 1374 | print WATER_LEVEL_SQLFILE "source,"; |
|---|
| | 1375 | print WATER_LEVEL_SQLFILE "refs,"; |
|---|
| | 1376 | print WATER_LEVEL_SQLFILE "contact,"; |
|---|
| | 1377 | print WATER_LEVEL_SQLFILE "the_geom"; |
|---|
| | 1378 | print WATER_LEVEL_SQLFILE ") "; |
|---|
| | 1379 | print WATER_LEVEL_SQLFILE "VALUES ("; |
|---|
| | 1380 | print WATER_LEVEL_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| | 1381 | print WATER_LEVEL_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$j].'\''; |
|---|
| | 1382 | if ($water_level[$i]{'height'} == $missing_value_value |
|---|
| | 1383 | || $water_level[$i]{'height'} == $Fill_value_value) { |
|---|
| | 1384 | print WATER_LEVEL_SQLFILE ','.'\'\''; |
|---|
| | 1385 | } |
|---|
| | 1386 | else { |
|---|
| | 1387 | $this_val = sprintf("%.2f",$water_level[$i]{'height'}); |
|---|
| | 1388 | print WATER_LEVEL_SQLFILE ','.$this_val; |
|---|
| | 1389 | } |
|---|
| | 1390 | print WATER_LEVEL_SQLFILE ','.'\''.$height_var{'positive'}.'\''; |
|---|
| | 1391 | $this_val = sprintf("%.2f",$water_level[$i]{'data'}[$j]); |
|---|
| | 1392 | print WATER_LEVEL_SQLFILE ','.$this_val; |
|---|
| | 1393 | print WATER_LEVEL_SQLFILE ','.'\''.$water_level[$i]{'reference'}.'\''; |
|---|
| | 1394 | |
|---|
| | 1395 | |
|---|
| | 1396 | if (length $water_level[$i]{'reference_to_mllw'} > 0) { |
|---|
| | 1397 | $this_val = sprintf("%.2f",$water_level[$i]{'reference_to_mllw'}); |
|---|
| | 1398 | } |
|---|
| | 1399 | else { |
|---|
| | 1400 | $this_val = 'NULL'; |
|---|
| | 1401 | } |
|---|
| | 1402 | |
|---|
| | 1403 | print WATER_LEVEL_SQLFILE ','.$this_val; |
|---|
| | 1404 | if (length $water_level[$i]{'reference_to_msl'} > 0) { |
|---|
| | 1405 | $this_val = sprintf("%.2f",$water_level[$i]{'reference_to_msl'}); |
|---|
| | 1406 | } |
|---|
| | 1407 | else { |
|---|
| | 1408 | $this_val = 'NULL'; |
|---|
| | 1409 | } |
|---|
| | 1410 | |
|---|
| | 1411 | print WATER_LEVEL_SQLFILE ','.$this_val; |
|---|
| | 1412 | if (length $water_level[$i]{'reference_to_navd88'} > 0) { |
|---|
| | 1413 | $this_val = sprintf("%.2f",$water_level[$i]{'reference_to_navd88'}); |
|---|
| | 1414 | } |
|---|
| | 1415 | else { |
|---|
| | 1416 | $this_val = 'NULL'; |
|---|
| | 1417 | } |
|---|
| | 1418 | |
|---|
| | 1419 | print WATER_LEVEL_SQLFILE ','.$this_val; |
|---|
| | 1420 | print WATER_LEVEL_SQLFILE ','.'\''.$title_value.'\''; |
|---|
| | 1421 | print WATER_LEVEL_SQLFILE ','.'\''.$institution_value.'\''; |
|---|
| | 1422 | print WATER_LEVEL_SQLFILE ','.'\''.'<a href='.$institution_url_value.' target= _blank>'.$institution_url_value.'</a>'.'\''; |
|---|
| | 1423 | print WATER_LEVEL_SQLFILE ','.'\''.'<a href='.$institution_dods_url_value.' target= _blank>'.$institution_dods_url_value.'</a>'.'\''; |
|---|
| | 1424 | print WATER_LEVEL_SQLFILE ','.'\''.$source_value.'\''; |
|---|
| | 1425 | print WATER_LEVEL_SQLFILE ','.'\''.$references_value.'\''; |
|---|
| | 1426 | print WATER_LEVEL_SQLFILE ','.'\''.$contact_value.'\''; |
|---|
| | 1427 | print WATER_LEVEL_SQLFILE ",GeometryFromText('POINT("; |
|---|
| | 1428 | print WATER_LEVEL_SQLFILE $longitude_value[0].' '.$latitude_value[0]; |
|---|
| | 1429 | print WATER_LEVEL_SQLFILE ")',-1));\n"; |
|---|
| 1240 | | else { |
|---|
| 1241 | | $this_val = sprintf("%.2f",$water_level[$i]{'height'}); |
|---|
| 1242 | | print WATER_LEVEL_SQLFILE ','.$this_val; |
|---|
| | 1431 | } |
|---|
| | 1432 | |
|---|
| | 1433 | print WATER_LEVEL_SQLFILE "\n"; |
|---|
| | 1434 | } |
|---|
| | 1435 | close(WATER_LEVEL_SQLFILE); |
|---|
| | 1436 | } |
|---|
| | 1437 | if( $bWriteobsKMLFile ) |
|---|
| | 1438 | { |
|---|
| | 1439 | my $MLLWDataVal = 'NULL'; |
|---|
| | 1440 | my $MSLDataVal = 'NULL'; |
|---|
| | 1441 | my $NavD88DataVal = 'NULL'; |
|---|
| | 1442 | my $Height = ''; |
|---|
| | 1443 | |
|---|
| | 1444 | for my $i (0..$#water_level) |
|---|
| | 1445 | { |
|---|
| | 1446 | for my $j (0..$#this_water_level_data) |
|---|
| | 1447 | { |
|---|
| | 1448 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 1449 | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| | 1450 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 1451 | |
|---|
| | 1452 | if ($water_level[$i]{'data'}[$j] != $missing_value_value |
|---|
| | 1453 | && $water_level[$i]{'data'}[$j] != $Fill_value_value |
|---|
| | 1454 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 1455 | && $this_time_stamp_sec > $oldest_ok_timestamp) |
|---|
| | 1456 | { |
|---|
| | 1457 | |
|---|
| | 1458 | #DWR 4/3/2008 |
|---|
| | 1459 | if ($water_level[$i]{'height'} != $missing_value_value |
|---|
| | 1460 | && $water_level[$i]{'height'} != $Fill_value_value) |
|---|
| | 1461 | { |
|---|
| | 1462 | $this_val = sprintf("%.2f",$water_level[$i]{'height'}); |
|---|
| | 1463 | $Height = $this_val; |
|---|
| | 1464 | } |
|---|
| | 1465 | $this_val = sprintf("%.2f",$water_level[$i]{'data'}[$j]); |
|---|
| | 1466 | |
|---|
| | 1467 | $DataVal = $water_level[$i]{'reference'}; |
|---|
| | 1468 | |
|---|
| | 1469 | if (length $water_level[$i]{'reference_to_mllw'} > 0) { |
|---|
| | 1470 | $this_val = sprintf("%.2f",$water_level[$i]{'reference_to_mllw'}); |
|---|
| | 1471 | } |
|---|
| | 1472 | else { |
|---|
| | 1473 | $this_val = 'NULL'; |
|---|
| | 1474 | } |
|---|
| | 1475 | $MLLWDataVal = $this_val; |
|---|
| | 1476 | |
|---|
| | 1477 | if (length $water_level[$i]{'reference_to_msl'} > 0) { |
|---|
| | 1478 | $this_val = sprintf("%.2f",$water_level[$i]{'reference_to_msl'}); |
|---|
| | 1479 | } |
|---|
| | 1480 | else { |
|---|
| | 1481 | $this_val = 'NULL'; |
|---|
| | 1482 | } |
|---|
| | 1483 | $MSLDataVal = $this_val; |
|---|
| | 1484 | |
|---|
| | 1485 | if (length $water_level[$i]{'reference_to_navd88'} > 0) { |
|---|
| | 1486 | $this_val = sprintf("%.2f",$water_level[$i]{'reference_to_navd88'}); |
|---|
| | 1487 | } |
|---|
| | 1488 | else { |
|---|
| | 1489 | $this_val = 'NULL'; |
|---|
| | 1490 | } |
|---|
| | 1491 | #DWR 4/5/2008 |
|---|
| | 1492 | $NavD88DataVal = $this_val; |
|---|
| 1244 | | print WATER_LEVEL_SQLFILE ','.'\''.$height_var{'positive'}.'\''; |
|---|
| 1245 | | $this_val = sprintf("%.2f",$water_level[$i]{'data'}[$j]); |
|---|
| 1246 | | print WATER_LEVEL_SQLFILE ','.$this_val; |
|---|
| 1247 | | print WATER_LEVEL_SQLFILE ','.'\''.$water_level[$i]{'reference'}.'\''; |
|---|
| 1248 | | if (length $water_level[$i]{'reference_to_mllw'} > 0) { |
|---|
| 1249 | | $this_val = sprintf("%.2f",$water_level[$i]{'reference_to_mllw'}); |
|---|
| 1250 | | } |
|---|
| 1251 | | else { |
|---|
| 1252 | | $this_val = 'NULL'; |
|---|
| 1253 | | } |
|---|
| 1254 | | print WATER_LEVEL_SQLFILE ','.$this_val; |
|---|
| 1255 | | if (length $water_level[$i]{'reference_to_msl'} > 0) { |
|---|
| 1256 | | $this_val = sprintf("%.2f",$water_level[$i]{'reference_to_msl'}); |
|---|
| 1257 | | } |
|---|
| 1258 | | else { |
|---|
| 1259 | | $this_val = 'NULL'; |
|---|
| 1260 | | } |
|---|
| 1261 | | print WATER_LEVEL_SQLFILE ','.$this_val; |
|---|
| 1262 | | if (length $water_level[$i]{'reference_to_navd88'} > 0) { |
|---|
| 1263 | | $this_val = sprintf("%.2f",$water_level[$i]{'reference_to_navd88'}); |
|---|
| 1264 | | } |
|---|
| 1265 | | else { |
|---|
| 1266 | | $this_val = 'NULL'; |
|---|
| 1267 | | } |
|---|
| 1268 | | print WATER_LEVEL_SQLFILE ','.$this_val; |
|---|
| 1269 | | print WATER_LEVEL_SQLFILE ','.'\''.$title_value.'\''; |
|---|
| 1270 | | print WATER_LEVEL_SQLFILE ','.'\''.$institution_value.'\''; |
|---|
| 1271 | | print WATER_LEVEL_SQLFILE ','.'\''.'<a href='.$institution_url_value.' target= _blank>'.$institution_url_value.'</a>'.'\''; |
|---|
| 1272 | | print WATER_LEVEL_SQLFILE ','.'\''.'<a href='.$institution_dods_url_value.' target= _blank>'.$institution_dods_url_value.'</a>'.'\''; |
|---|
| 1273 | | print WATER_LEVEL_SQLFILE ','.'\''.$source_value.'\''; |
|---|
| 1274 | | print WATER_LEVEL_SQLFILE ','.'\''.$references_value.'\''; |
|---|
| 1275 | | print WATER_LEVEL_SQLFILE ','.'\''.$contact_value.'\''; |
|---|
| 1276 | | print WATER_LEVEL_SQLFILE ",GeometryFromText('POINT("; |
|---|
| 1277 | | print WATER_LEVEL_SQLFILE $longitude_value[0].' '.$latitude_value[0]; |
|---|
| 1278 | | print WATER_LEVEL_SQLFILE ")',-1));\n"; |
|---|
| 1279 | | } |
|---|
| 1280 | | } |
|---|
| 1281 | | print WATER_LEVEL_SQLFILE "\n"; |
|---|
| 1282 | | } |
|---|
| 1283 | | close(WATER_LEVEL_SQLFILE); |
|---|
| 1284 | | } |
|---|
| 1285 | | |
|---|
| | 1494 | obsKMLSubRoutines::KMLAddObsToHash( 'water_level', |
|---|
| | 1495 | $time_formatted_values[$j], |
|---|
| | 1496 | $MLLWDataVal, |
|---|
| | 1497 | 1, |
|---|
| | 1498 | $strPlatformID, |
|---|
| | 1499 | $Height, |
|---|
| | 1500 | 'm(MLLW)', |
|---|
| | 1501 | $rObsHash ); |
|---|
| | 1502 | obsKMLSubRoutines::KMLAddObsToHash( 'water_level', |
|---|
| | 1503 | $time_formatted_values[$j], |
|---|
| | 1504 | $MSLDataVal, |
|---|
| | 1505 | 2, |
|---|
| | 1506 | $strPlatformID, |
|---|
| | 1507 | $Height, |
|---|
| | 1508 | 'm(MSL)', |
|---|
| | 1509 | $rObsHash ); |
|---|
| | 1510 | obsKMLSubRoutines::KMLAddObsToHash( 'water_level', |
|---|
| | 1511 | $time_formatted_values[$j], |
|---|
| | 1512 | $NavD88DataVal, |
|---|
| | 1513 | 3, |
|---|
| | 1514 | $strPlatformID, |
|---|
| | 1515 | $Height, |
|---|
| | 1516 | 'm(NAVD88)', |
|---|
| | 1517 | $rObsHash ); |
|---|
| | 1518 | } |
|---|
| | 1519 | } |
|---|
| | 1520 | } |
|---|
| | 1521 | } |
|---|
| 1288 | | open(SST_SQLFILE,'>>../sql/sst_prod_'.$institution_code_value.'_' |
|---|
| 1289 | | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| 1290 | | print SST_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| 1291 | | print SST_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| 1292 | | print SST_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| 1293 | | print SST_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| 1294 | | print SST_SQLFILE "-- title = $title_value\n"; |
|---|
| 1295 | | print SST_SQLFILE "-- institution = $institution_value\n"; |
|---|
| 1296 | | print SST_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| 1297 | | print SST_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| 1298 | | print SST_SQLFILE "-- source = $source_value\n"; |
|---|
| 1299 | | print SST_SQLFILE "-- references = $references_value\n"; |
|---|
| 1300 | | print SST_SQLFILE "-- contact = $contact_value\n"; |
|---|
| 1301 | | print SST_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| 1302 | | print SST_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| 1303 | | for my $i (0..$#sea_surface_temperature) { |
|---|
| 1304 | | for my $j (0..$#this_sea_surface_temperature_data) { |
|---|
| 1305 | | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| 1306 | | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| 1307 | | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 1524 | if( $bWriteSQLFiles ) |
|---|
| | 1525 | { |
|---|
| | 1526 | open(SST_SQLFILE,'>>../sql/sst_prod_'.$institution_code_value.'_' |
|---|
| | 1527 | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| | 1528 | print SST_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| | 1529 | print SST_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| | 1530 | print SST_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| | 1531 | print SST_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| | 1532 | print SST_SQLFILE "-- title = $title_value\n"; |
|---|
| | 1533 | print SST_SQLFILE "-- institution = $institution_value\n"; |
|---|
| | 1534 | print SST_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| | 1535 | print SST_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| | 1536 | print SST_SQLFILE "-- source = $source_value\n"; |
|---|
| | 1537 | print SST_SQLFILE "-- references = $references_value\n"; |
|---|
| | 1538 | print SST_SQLFILE "-- contact = $contact_value\n"; |
|---|
| | 1539 | print SST_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| | 1540 | print SST_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| 1309 | | if ($sea_surface_temperature[$i]{'data'}[$j] != $missing_value_value |
|---|
| 1310 | | && $sea_surface_temperature[$i]{'data'}[$j] != $Fill_value_value |
|---|
| 1311 | | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| 1312 | | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| 1313 | | print SST_SQLFILE "INSERT INTO sst_prod ("; |
|---|
| 1314 | | print SST_SQLFILE "station_id,"; |
|---|
| 1315 | | print SST_SQLFILE "time_stamp,"; |
|---|
| 1316 | | print SST_SQLFILE "z,"; |
|---|
| 1317 | | print SST_SQLFILE "positive,"; |
|---|
| 1318 | | print SST_SQLFILE "temperature_celcius,"; |
|---|
| 1319 | | print SST_SQLFILE "title,"; |
|---|
| 1320 | | print SST_SQLFILE "institution,"; |
|---|
| 1321 | | print SST_SQLFILE "institution_url,"; |
|---|
| 1322 | | print SST_SQLFILE "institution_dods_url,"; |
|---|
| 1323 | | print SST_SQLFILE "source,"; |
|---|
| 1324 | | print SST_SQLFILE "refs,"; |
|---|
| 1325 | | print SST_SQLFILE "contact,"; |
|---|
| 1326 | | print SST_SQLFILE "the_geom"; |
|---|
| 1327 | | print SST_SQLFILE ") "; |
|---|
| 1328 | | print SST_SQLFILE "VALUES ("; |
|---|
| 1329 | | print SST_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| 1330 | | print SST_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$j].'\''; |
|---|
| 1331 | | if ($sea_surface_temperature[$i]{'height'} == $missing_value_value |
|---|
| 1332 | | || $sea_surface_temperature[$i]{'height'} == $Fill_value_value) { |
|---|
| 1333 | | print SST_SQLFILE ','.'\'\''; |
|---|
| | 1542 | my $DataVal = 'NULL'; |
|---|
| | 1543 | my $Height = ''; |
|---|
| | 1544 | for my $i (0..$#sea_surface_temperature) { |
|---|
| | 1545 | for my $j (0..$#this_sea_surface_temperature_data) { |
|---|
| | 1546 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 1547 | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| | 1548 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 1549 | |
|---|
| | 1550 | if ($sea_surface_temperature[$i]{'data'}[$j] != $missing_value_value |
|---|
| | 1551 | && $sea_surface_temperature[$i]{'data'}[$j] != $Fill_value_value |
|---|
| | 1552 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 1553 | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| | 1554 | print SST_SQLFILE "INSERT INTO sst_prod ("; |
|---|
| | 1555 | print SST_SQLFILE "station_id,"; |
|---|
| | 1556 | print SST_SQLFILE "time_stamp,"; |
|---|
| | 1557 | print SST_SQLFILE "z,"; |
|---|
| | 1558 | print SST_SQLFILE "positive,"; |
|---|
| | 1559 | print SST_SQLFILE "temperature_celcius,"; |
|---|
| | 1560 | print SST_SQLFILE "title,"; |
|---|
| | 1561 | print SST_SQLFILE "institution,"; |
|---|
| | 1562 | print SST_SQLFILE "institution_url,"; |
|---|
| | 1563 | print SST_SQLFILE "institution_dods_url,"; |
|---|
| | 1564 | print SST_SQLFILE "source,"; |
|---|
| | 1565 | print SST_SQLFILE "refs,"; |
|---|
| | 1566 | print SST_SQLFILE "contact,"; |
|---|
| | 1567 | print SST_SQLFILE "the_geom"; |
|---|
| | 1568 | print SST_SQLFILE ") "; |
|---|
| | 1569 | print SST_SQLFILE "VALUES ("; |
|---|
| | 1570 | print SST_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| | 1571 | print SST_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$j].'\''; |
|---|
| | 1572 | if ($sea_surface_temperature[$i]{'height'} == $missing_value_value |
|---|
| | 1573 | || $sea_surface_temperature[$i]{'height'} == $Fill_value_value) { |
|---|
| | 1574 | print SST_SQLFILE ','.'\'\''; |
|---|
| | 1575 | } |
|---|
| | 1576 | else { |
|---|
| | 1577 | $this_val = sprintf("%.2f",$sea_surface_temperature[$i]{'height'}); |
|---|
| | 1578 | print SST_SQLFILE ','.$this_val; |
|---|
| | 1579 | } |
|---|
| | 1580 | |
|---|
| | 1581 | print SST_SQLFILE ','.'\''.$height_var{'positive'}.'\''; |
|---|
| | 1582 | $this_val = sprintf("%.2f",$sea_surface_temperature[$i]{'data'}[$j]); |
|---|
| | 1583 | |
|---|
| | 1584 | |
|---|
| | 1585 | print SST_SQLFILE ','.$this_val; |
|---|
| | 1586 | print SST_SQLFILE ','.'\''.$title_value.'\''; |
|---|
| | 1587 | print SST_SQLFILE ','.'\''.$institution_value.'\''; |
|---|
| | 1588 | print SST_SQLFILE ','.'\''.'<a href='.$institution_url_value.' target= _blank>'.$institution_url_value.'</a>'.'\''; |
|---|
| | 1589 | print SST_SQLFILE ','.'\''.'<a href='.$institution_dods_url_value.' target= _blank>'.$institution_dods_url_value.'</a>'.'\''; |
|---|
| | 1590 | print SST_SQLFILE ','.'\''.$source_value.'\''; |
|---|
| | 1591 | print SST_SQLFILE ','.'\''.$references_value.'\''; |
|---|
| | 1592 | print SST_SQLFILE ','.'\''.$contact_value.'\''; |
|---|
| | 1593 | print SST_SQLFILE ",GeometryFromText('POINT("; |
|---|
| | 1594 | print SST_SQLFILE $longitude_value[0].' '.$latitude_value[0]; |
|---|
| | 1595 | print SST_SQLFILE ")',-1));\n"; |
|---|
| 1361 | | open(SBT_SQLFILE,'>>../sql/bottom_water_temp_prod_'.$institution_code_value.'_' |
|---|
| 1362 | | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| 1363 | | print SBT_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| 1364 | | print SBT_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| 1365 | | print SBT_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| 1366 | | print SBT_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| 1367 | | print SBT_SQLFILE "-- title = $title_value\n"; |
|---|
| 1368 | | print SBT_SQLFILE "-- institution = $institution_value\n"; |
|---|
| 1369 | | print SBT_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| 1370 | | print SBT_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| 1371 | | print SBT_SQLFILE "-- source = $source_value\n"; |
|---|
| 1372 | | print SBT_SQLFILE "-- references = $references_value\n"; |
|---|
| 1373 | | print SBT_SQLFILE "-- contact = $contact_value\n"; |
|---|
| 1374 | | print SBT_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| 1375 | | print SBT_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| 1376 | | for my $i (0..$#sea_bottom_temperature) { |
|---|
| 1377 | | for my $j (0..$#this_sea_bottom_temperature_data) { |
|---|
| 1378 | | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| 1379 | | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| 1380 | | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 1650 | if( $bWriteSQLFiles ) |
|---|
| | 1651 | { |
|---|
| | 1652 | open(SBT_SQLFILE,'>>../sql/bottom_water_temp_prod_'.$institution_code_value.'_' |
|---|
| | 1653 | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| | 1654 | print SBT_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| | 1655 | print SBT_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| | 1656 | print SBT_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| | 1657 | print SBT_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| | 1658 | print SBT_SQLFILE "-- title = $title_value\n"; |
|---|
| | 1659 | print SBT_SQLFILE "-- institution = $institution_value\n"; |
|---|
| | 1660 | print SBT_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| | 1661 | print SBT_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| | 1662 | print SBT_SQLFILE "-- source = $source_value\n"; |
|---|
| | 1663 | print SBT_SQLFILE "-- references = $references_value\n"; |
|---|
| | 1664 | print SBT_SQLFILE "-- contact = $contact_value\n"; |
|---|
| | 1665 | print SBT_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| | 1666 | print SBT_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| 1382 | | if ($sea_bottom_temperature[$i]{'data'}[$j] != $missing_value_value |
|---|
| 1383 | | && $sea_bottom_temperature[$i]{'data'}[$j] != $Fill_value_value |
|---|
| 1384 | | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| 1385 | | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| 1386 | | print SBT_SQLFILE "INSERT INTO bottom_water_temp_prod ("; |
|---|
| 1387 | | print SBT_SQLFILE "station_id,"; |
|---|
| 1388 | | print SBT_SQLFILE "time_stamp,"; |
|---|
| 1389 | | print SBT_SQLFILE "z,"; |
|---|
| 1390 | | print SBT_SQLFILE "positive,"; |
|---|
| 1391 | | print SBT_SQLFILE "temperature_celcius,"; |
|---|
| 1392 | | print SBT_SQLFILE "title,"; |
|---|
| 1393 | | print SBT_SQLFILE "institution,"; |
|---|
| 1394 | | print SBT_SQLFILE "institution_url,"; |
|---|
| 1395 | | print SBT_SQLFILE "institution_dods_url,"; |
|---|
| 1396 | | print SBT_SQLFILE "source,"; |
|---|
| 1397 | | print SBT_SQLFILE "refs,"; |
|---|
| 1398 | | print SBT_SQLFILE "contact,"; |
|---|
| 1399 | | print SBT_SQLFILE "the_geom"; |
|---|
| 1400 | | print SBT_SQLFILE ") "; |
|---|
| 1401 | | print SBT_SQLFILE "VALUES ("; |
|---|
| 1402 | | print SBT_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| 1403 | | print SBT_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$j].'\''; |
|---|
| 1404 | | if ($sea_bottom_temperature[$i]{'height'} == $missing_value_value |
|---|
| 1405 | | || $sea_bottom_temperature[$i]{'height'} == $Fill_value_value) { |
|---|
| 1406 | | print SBT_SQLFILE ','.'\'\''; |
|---|
| | 1668 | for my $i (0..$#sea_bottom_temperature) { |
|---|
| | 1669 | for my $j (0..$#this_sea_bottom_temperature_data) { |
|---|
| | 1670 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 1671 | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| | 1672 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 1673 | |
|---|
| | 1674 | if ($sea_bottom_temperature[$i]{'data'}[$j] != $missing_value_value |
|---|
| | 1675 | && $sea_bottom_temperature[$i]{'data'}[$j] != $Fill_value_value |
|---|
| | 1676 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 1677 | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| | 1678 | print SBT_SQLFILE "INSERT INTO bottom_water_temp_prod ("; |
|---|
| | 1679 | print SBT_SQLFILE "station_id,"; |
|---|
| | 1680 | print SBT_SQLFILE "time_stamp,"; |
|---|
| | 1681 | print SBT_SQLFILE "z,"; |
|---|
| | 1682 | print SBT_SQLFILE "positive,"; |
|---|
| | 1683 | print SBT_SQLFILE "temperature_celcius,"; |
|---|
| | 1684 | print SBT_SQLFILE "title,"; |
|---|
| | 1685 | print SBT_SQLFILE "institution,"; |
|---|
| | 1686 | print SBT_SQLFILE "institution_url,"; |
|---|
| | 1687 | print SBT_SQLFILE "institution_dods_url,"; |
|---|
| | 1688 | print SBT_SQLFILE "source,"; |
|---|
| | 1689 | print SBT_SQLFILE "refs,"; |
|---|
| | 1690 | print SBT_SQLFILE "contact,"; |
|---|
| | 1691 | print SBT_SQLFILE "the_geom"; |
|---|
| | 1692 | print SBT_SQLFILE ") "; |
|---|
| | 1693 | print SBT_SQLFILE "VALUES ("; |
|---|
| | 1694 | print SBT_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| | 1695 | print SBT_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$j].'\''; |
|---|
| | 1696 | if ($sea_bottom_temperature[$i]{'height'} == $missing_value_value |
|---|
| | 1697 | || $sea_bottom_temperature[$i]{'height'} == $Fill_value_value) { |
|---|
| | 1698 | print SBT_SQLFILE ','.'\'\''; |
|---|
| | 1699 | } |
|---|
| | 1700 | else { |
|---|
| | 1701 | $this_val = sprintf("%.2f",$sea_bottom_temperature[$i]{'height'}); |
|---|
| | 1702 | print SBT_SQLFILE ','.$this_val; |
|---|
| | 1703 | } |
|---|
| | 1704 | |
|---|
| | 1705 | print SBT_SQLFILE ','.'\''.$height_var{'positive'}.'\''; |
|---|
| | 1706 | $this_val = sprintf("%.2f",$sea_bottom_temperature[$i]{'data'}[$j]); |
|---|
| | 1707 | |
|---|
| | 1708 | |
|---|
| | 1709 | print SBT_SQLFILE ','.$this_val; |
|---|
| | 1710 | print SBT_SQLFILE ','.'\''.$title_value.'\''; |
|---|
| | 1711 | print SBT_SQLFILE ','.'\''.$institution_value.'\''; |
|---|
| | 1712 | print SBT_SQLFILE ','.'\''.'<a href='.$institution_url_value.' target= _blank>'.$institution_url_value.'</a>'.'\''; |
|---|
| | 1713 | print SBT_SQLFILE ','.'\''.'<a href='.$institution_dods_url_value.' target= _blank>'.$institution_dods_url_value.'</a>'.'\''; |
|---|
| | 1714 | print SBT_SQLFILE ','.'\''.$source_value.'\''; |
|---|
| | 1715 | print SBT_SQLFILE ','.'\''.$references_value.'\''; |
|---|
| | 1716 | print SBT_SQLFILE ','.'\''.$contact_value.'\''; |
|---|
| | 1717 | print SBT_SQLFILE ",GeometryFromText('POINT("; |
|---|
| | 1718 | print SBT_SQLFILE $longitude_value[0].' '.$latitude_value[0]; |
|---|
| | 1719 | print SBT_SQLFILE ")',-1));\n"; |
|---|
| 1436 | | open(AIR_TEMP_SQLFILE,'>>../sql/air_temperature_prod_'.$institution_code_value.'_' |
|---|
| 1437 | | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| 1438 | | print AIR_TEMP_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| 1439 | | print AIR_TEMP_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| 1440 | | print AIR_TEMP_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| 1441 | | print AIR_TEMP_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| 1442 | | print AIR_TEMP_SQLFILE "-- title = $title_value\n"; |
|---|
| 1443 | | print AIR_TEMP_SQLFILE "-- institution = $institution_value\n"; |
|---|
| 1444 | | print AIR_TEMP_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| 1445 | | print AIR_TEMP_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| 1446 | | print AIR_TEMP_SQLFILE "-- source = $source_value\n"; |
|---|
| 1447 | | print AIR_TEMP_SQLFILE "-- references = $references_value\n"; |
|---|
| 1448 | | print AIR_TEMP_SQLFILE "-- contact = $contact_value\n"; |
|---|
| 1449 | | print AIR_TEMP_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| 1450 | | print AIR_TEMP_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| 1451 | | for my $i (0..$#air_temperature) { |
|---|
| 1452 | | for my $j (0..$#this_air_temperature_data) { |
|---|
| 1453 | | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| 1454 | | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| 1455 | | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 1776 | #DWR 4/5/2008 |
|---|
| | 1777 | if( $bWriteSQLFiles ) |
|---|
| | 1778 | { |
|---|
| | 1779 | open(AIR_TEMP_SQLFILE,'>>../sql/air_temperature_prod_'.$institution_code_value.'_' |
|---|
| | 1780 | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| | 1781 | print AIR_TEMP_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| | 1782 | print AIR_TEMP_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| | 1783 | print AIR_TEMP_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| | 1784 | print AIR_TEMP_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| | 1785 | print AIR_TEMP_SQLFILE "-- title = $title_value\n"; |
|---|
| | 1786 | print AIR_TEMP_SQLFILE "-- institution = $institution_value\n"; |
|---|
| | 1787 | print AIR_TEMP_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| | 1788 | print AIR_TEMP_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| | 1789 | print AIR_TEMP_SQLFILE "-- source = $source_value\n"; |
|---|
| | 1790 | print AIR_TEMP_SQLFILE "-- references = $references_value\n"; |
|---|
| | 1791 | print AIR_TEMP_SQLFILE "-- contact = $contact_value\n"; |
|---|
| | 1792 | print AIR_TEMP_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| | 1793 | print AIR_TEMP_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| | 1794 | for my $i (0..$#air_temperature) { |
|---|
| | 1795 | for my $j (0..$#this_air_temperature_data) { |
|---|
| | 1796 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 1797 | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| | 1798 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 1799 | |
|---|
| | 1800 | my $DataValue = 'NULL'; |
|---|
| | 1801 | my $Height = ''; |
|---|
| | 1802 | if ($air_temperature[$i]{'data'}[$j] != $missing_value_value |
|---|
| | 1803 | && $air_temperature[$i]{'data'}[$j] != $Fill_value_value |
|---|
| | 1804 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 1805 | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| | 1806 | print AIR_TEMP_SQLFILE "INSERT INTO air_temperature_prod ("; |
|---|
| | 1807 | print AIR_TEMP_SQLFILE "station_id,"; |
|---|
| | 1808 | print AIR_TEMP_SQLFILE "time_stamp,"; |
|---|
| | 1809 | print AIR_TEMP_SQLFILE "z,"; |
|---|
| | 1810 | print AIR_TEMP_SQLFILE "positive,"; |
|---|
| | 1811 | print AIR_TEMP_SQLFILE "temperature_celcius,"; |
|---|
| | 1812 | print AIR_TEMP_SQLFILE "the_geom"; |
|---|
| | 1813 | print AIR_TEMP_SQLFILE ") "; |
|---|
| | 1814 | print AIR_TEMP_SQLFILE "VALUES ("; |
|---|
| | 1815 | print AIR_TEMP_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| | 1816 | print AIR_TEMP_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$j].'\''; |
|---|
| | 1817 | if ($air_temperature[$i]{'height'} == $missing_value_value |
|---|
| | 1818 | || $air_temperature[$i]{'height'} == $Fill_value_value) { |
|---|
| | 1819 | print AIR_TEMP_SQLFILE ',NULL'; |
|---|
| | 1820 | } |
|---|
| | 1821 | else { |
|---|
| | 1822 | $this_val = sprintf("%.2f",$air_temperature[$i]{'height'}); |
|---|
| | 1823 | print AIR_TEMP_SQLFILE ','.$this_val; |
|---|
| | 1824 | } |
|---|
| | 1825 | print AIR_TEMP_SQLFILE ','.'\''.$height_var{'positive'}.'\''; |
|---|
| | 1826 | $this_val = sprintf("%.2f",$air_temperature[$i]{'data'}[$j]); |
|---|
| | 1827 | print AIR_TEMP_SQLFILE ','.$this_val; |
|---|
| | 1828 | print AIR_TEMP_SQLFILE ",GeometryFromText('POINT("; |
|---|
| | 1829 | print AIR_TEMP_SQLFILE $longitude_value[0].' '.$latitude_value[0]; |
|---|
| | 1830 | print AIR_TEMP_SQLFILE ")',-1));\n"; |
|---|
| | 1831 | |
|---|
| | 1832 | } |
|---|
| | 1833 | } |
|---|
| | 1834 | print AIR_TEMP_SQLFILE "\n"; |
|---|
| | 1835 | } |
|---|
| | 1836 | close(AIR_TEMP_SQLFILE); |
|---|
| | 1837 | } |
|---|
| | 1838 | #DWR 4/5/2008 |
|---|
| | 1839 | if( $bWriteobsKMLFile ) |
|---|
| | 1840 | { |
|---|
| | 1841 | my $DataVal = 'NULL'; |
|---|
| | 1842 | my $Height = ''; |
|---|
| | 1843 | for my $i (0..$#air_temperature) |
|---|
| | 1844 | { |
|---|
| | 1845 | for my $j (0..$#air_temperature) |
|---|
| | 1846 | { |
|---|
| | 1847 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 1848 | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| | 1849 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| 1498 | | open(WIND_SQLFILE,'>>../sql/wind_prod_'.$institution_code_value.'_' |
|---|
| 1499 | | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| 1500 | | print WIND_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| 1501 | | print WIND_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| 1502 | | print WIND_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| 1503 | | print WIND_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| 1504 | | print WIND_SQLFILE "-- title = $title_value\n"; |
|---|
| 1505 | | print WIND_SQLFILE "-- institution = $institution_value\n"; |
|---|
| 1506 | | print WIND_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| 1507 | | print WIND_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| 1508 | | print WIND_SQLFILE "-- source = $source_value\n"; |
|---|
| 1509 | | print WIND_SQLFILE "-- references = $references_value\n"; |
|---|
| 1510 | | print WIND_SQLFILE "-- contact = $contact_value\n"; |
|---|
| 1511 | | print WIND_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| 1512 | | print WIND_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| 1513 | | for my $i (0..$#wind_speed) { |
|---|
| 1514 | | my $j = 0; |
|---|
| 1515 | | while ($j <= $#wind_from_direction |
|---|
| 1516 | | && $wind_from_direction[$j]{'height'} != $wind_speed[$i]{'height'}) { |
|---|
| 1517 | | $j++; |
|---|
| 1518 | | } |
|---|
| 1519 | | if ($j > $#wind_from_direction) { |
|---|
| 1520 | | die "ABORT! Could not find matching wind_from_direction for $wind_speed[$i] {'var_name'}.\n"; |
|---|
| 1521 | | } |
|---|
| 1522 | | else { |
|---|
| 1523 | | for my $k (0..$#this_wind_speed_data) { |
|---|
| 1524 | | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| 1525 | | $this_time_stamp = $time_formatted_values[$k]; |
|---|
| 1526 | | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| 1527 | | |
|---|
| 1528 | | if ($wind_speed[$i]{'data'}[$k] != $missing_value_value |
|---|
| 1529 | | && $wind_speed[$i]{'data'}[$k] != $Fill_value_value |
|---|
| 1530 | | && $wind_from_direction[$j]{'data'}[$k] != $missing_value_value |
|---|
| 1531 | | && $wind_from_direction[$j]{'data'}[$k] != $Fill_value_value |
|---|
| 1532 | | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| 1533 | | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| 1534 | | print WIND_SQLFILE "INSERT INTO wind_prod ("; |
|---|
| 1535 | | print WIND_SQLFILE "station_id,"; |
|---|
| 1536 | | print WIND_SQLFILE "time_stamp,"; |
|---|
| 1537 | | print WIND_SQLFILE "z,"; |
|---|
| 1538 | | print WIND_SQLFILE "positive,"; |
|---|
| 1539 | | print WIND_SQLFILE "wind_speed,"; |
|---|
| 1540 | | print WIND_SQLFILE "wind_gust,"; |
|---|
| 1541 | | print WIND_SQLFILE "wind_from_direction,"; |
|---|
| 1542 | | print WIND_SQLFILE "can_be_normalized,"; |
|---|
| 1543 | | print WIND_SQLFILE "title,"; |
|---|
| 1544 | | print WIND_SQLFILE "institution,"; |
|---|
| 1545 | | print WIND_SQLFILE "institution_url,"; |
|---|
| 1546 | | print WIND_SQLFILE "institution_dods_url,"; |
|---|
| 1547 | | print WIND_SQLFILE "source,"; |
|---|
| 1548 | | print WIND_SQLFILE "refs,"; |
|---|
| 1549 | | print WIND_SQLFILE "contact,"; |
|---|
| 1550 | | print WIND_SQLFILE "the_geom"; |
|---|
| 1551 | | print WIND_SQLFILE ") "; |
|---|
| 1552 | | print WIND_SQLFILE "VALUES ("; |
|---|
| 1553 | | print WIND_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| 1554 | | print WIND_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$k].'\''; |
|---|
| 1555 | | if ($wind_speed[$i]{'height'} == $missing_value_value |
|---|
| 1556 | | || $wind_speed[$i]{'height'} == $Fill_value_value) { |
|---|
| 1557 | | print WIND_SQLFILE ','.'\'\''; |
|---|
| 1558 | | } |
|---|
| 1559 | | else { |
|---|
| 1560 | | $this_val = sprintf("%.2f",$wind_speed[$i]{'height'}); |
|---|
| | 1890 | #dwr 4/5/2008 |
|---|
| | 1891 | if( $bWriteSQLFiles ) |
|---|
| | 1892 | { |
|---|
| | 1893 | open(WIND_SQLFILE,'>>../sql/wind_prod_'.$institution_code_value.'_' |
|---|
| | 1894 | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| | 1895 | print WIND_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| | 1896 | print WIND_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| | 1897 | print WIND_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| | 1898 | print WIND_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| | 1899 | print WIND_SQLFILE "-- title = $title_value\n"; |
|---|
| | 1900 | print WIND_SQLFILE "-- institution = $institution_value\n"; |
|---|
| | 1901 | print WIND_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| | 1902 | print WIND_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| | 1903 | print WIND_SQLFILE "-- source = $source_value\n"; |
|---|
| | 1904 | print WIND_SQLFILE "-- references = $references_value\n"; |
|---|
| | 1905 | print WIND_SQLFILE "-- contact = $contact_value\n"; |
|---|
| | 1906 | print WIND_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| | 1907 | print WIND_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| | 1908 | for my $i (0..$#wind_speed) { |
|---|
| | 1909 | my $j = 0; |
|---|
| | 1910 | while ($j <= $#wind_from_direction |
|---|
| | 1911 | && $wind_from_direction[$j]{'height'} != $wind_speed[$i]{'height'}) { |
|---|
| | 1912 | $j++; |
|---|
| | 1913 | } |
|---|
| | 1914 | if ($j > $#wind_from_direction) { |
|---|
| | 1915 | die "ABORT! Could not find matching wind_from_direction for $wind_speed[$i] {'var_name'}.\n"; |
|---|
| | 1916 | } |
|---|
| | 1917 | else { |
|---|
| | 1918 | for my $k (0..$#this_wind_speed_data) { |
|---|
| | 1919 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 1920 | $this_time_stamp = $time_formatted_values[$k]; |
|---|
| | 1921 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 1922 | |
|---|
| | 1923 | if ($wind_speed[$i]{'data'}[$k] != $missing_value_value |
|---|
| | 1924 | && $wind_speed[$i]{'data'}[$k] != $Fill_value_value |
|---|
| | 1925 | && $wind_from_direction[$j]{'data'}[$k] != $missing_value_value |
|---|
| | 1926 | && $wind_from_direction[$j]{'data'}[$k] != $Fill_value_value |
|---|
| | 1927 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 1928 | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| | 1929 | print WIND_SQLFILE "INSERT INTO wind_prod ("; |
|---|
| | 1930 | print WIND_SQLFILE "station_id,"; |
|---|
| | 1931 | print WIND_SQLFILE "time_stamp,"; |
|---|
| | 1932 | print WIND_SQLFILE "z,"; |
|---|
| | 1933 | print WIND_SQLFILE "positive,"; |
|---|
| | 1934 | print WIND_SQLFILE "wind_speed,"; |
|---|
| | 1935 | print WIND_SQLFILE "wind_gust,"; |
|---|
| | 1936 | print WIND_SQLFILE "wind_from_direction,"; |
|---|
| | 1937 | print WIND_SQLFILE "can_be_normalized,"; |
|---|
| | 1938 | print WIND_SQLFILE "title,"; |
|---|
| | 1939 | print WIND_SQLFILE "institution,"; |
|---|
| | 1940 | print WIND_SQLFILE "institution_url,"; |
|---|
| | 1941 | print WIND_SQLFILE "institution_dods_url,"; |
|---|
| | 1942 | print WIND_SQLFILE "source,"; |
|---|
| | 1943 | print WIND_SQLFILE "refs,"; |
|---|
| | 1944 | print WIND_SQLFILE "contact,"; |
|---|
| | 1945 | print WIND_SQLFILE "the_geom"; |
|---|
| | 1946 | print WIND_SQLFILE ") "; |
|---|
| | 1947 | print WIND_SQLFILE "VALUES ("; |
|---|
| | 1948 | print WIND_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| | 1949 | print WIND_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$k].'\''; |
|---|
| | 1950 | if ($wind_speed[$i]{'height'} == $missing_value_value |
|---|
| | 1951 | || $wind_speed[$i]{'height'} == $Fill_value_value) { |
|---|
| | 1952 | print WIND_SQLFILE ','.'\'\''; |
|---|
| | 1953 | } |
|---|
| | 1954 | else { |
|---|
| | 1955 | $this_val = sprintf("%.2f",$wind_speed[$i]{'height'}); |
|---|
| | 1956 | print WIND_SQLFILE ','.$this_val; |
|---|
| | 1957 | } |
|---|
| | 1958 | |
|---|
| | 1959 | print WIND_SQLFILE ','.'\''.$height_var{'positive'}.'\''; |
|---|
| | 1960 | $this_val = sprintf("%.2f",$wind_speed[$i]{'data'}[$k]); |
|---|
| 1574 | | } |
|---|
| 1575 | | $this_val = sprintf("%.2f",$wind_from_direction[$j]{'data'}[$k]); |
|---|
| 1576 | | print WIND_SQLFILE ','.$this_val; |
|---|
| 1577 | | print WIND_SQLFILE ','.'\''.$wind_speed[$i]{'can_be_normalized'}.'\''; |
|---|
| 1578 | | print WIND_SQLFILE ','.'\''.$title_value.'\''; |
|---|
| 1579 | | print WIND_SQLFILE ','.'\''.$institution_value.'\''; |
|---|
| 1580 | | print WIND_SQLFILE ','.'\''.'<a href='.$institution_url_value.' target= _blank>'.$institution_url_value.'</a>'.'\''; |
|---|
| 1581 | | print WIND_SQLFILE ','.'\''.'<a href='.$institution_dods_url_value.' target= _blank>'.$institution_dods_url_value.'</a>'.'\''; |
|---|
| 1582 | | print WIND_SQLFILE ','.'\''.$source_value.'\''; |
|---|
| 1583 | | print WIND_SQLFILE ','.'\''.$references_value.'\''; |
|---|
| 1584 | | print WIND_SQLFILE ','.'\''.$contact_value.'\''; |
|---|
| 1585 | | print WIND_SQLFILE ",GeometryFromText('POINT("; |
|---|
| 1586 | | print WIND_SQLFILE $longitude_value[0].' '.$latitude_value[0]; |
|---|
| 1587 | | print WIND_SQLFILE ")',-1));\n"; |
|---|
| | 1977 | print WIND_SQLFILE ','.'\''.$wind_speed[$i]{'can_be_normalized'}.'\''; |
|---|
| | 1978 | print WIND_SQLFILE ','.'\''.$title_value.'\''; |
|---|
| | 1979 | print WIND_SQLFILE ','.'\''.$institution_value.'\''; |
|---|
| | 1980 | print WIND_SQLFILE ','.'\''.'<a href='.$institution_url_value.' target= _blank>'.$institution_url_value.'</a>'.'\''; |
|---|
| | 1981 | print WIND_SQLFILE ','.'\''.'<a href='.$institution_dods_url_value.' target= _blank>'.$institution_dods_url_value.'</a>'.'\''; |
|---|
| | 1982 | print WIND_SQLFILE ','.'\''.$source_value.'\''; |
|---|
| | 1983 | print WIND_SQLFILE ','.'\''.$references_value.'\''; |
|---|
| | 1984 | print WIND_SQLFILE ','.'\''.$contact_value.'\''; |
|---|
| | 1985 | print WIND_SQLFILE ",GeometryFromText('POINT("; |
|---|
| | 1986 | print WIND_SQLFILE $longitude_value[0].' '.$latitude_value[0]; |
|---|
| | 1987 | print WIND_SQLFILE ")',-1));\n"; |
|---|
| | 1988 | |
|---|
| | 1989 | } |
|---|
| 1590 | | } |
|---|
| 1591 | | print WIND_SQLFILE "\n"; |
|---|
| 1592 | | } |
|---|
| 1593 | | close(WIND_SQLFILE); |
|---|
| | 1992 | print WIND_SQLFILE "\n"; |
|---|
| | 1993 | } |
|---|
| | 1994 | close(WIND_SQLFILE); |
|---|
| | 1995 | } |
|---|
| | 1996 | #DWR 4/5/2008 |
|---|
| | 1997 | if( $bWriteobsKMLFile ) |
|---|
| | 1998 | { |
|---|
| | 1999 | for my $i (0..$#wind_speed) |
|---|
| | 2000 | { |
|---|
| | 2001 | my $j = 0; |
|---|
| | 2002 | while ($j <= $#wind_from_direction |
|---|
| | 2003 | && $wind_from_direction[$j]{'height'} != $wind_speed[$i]{'height'}) |
|---|
| | 2004 | { |
|---|
| | 2005 | $j++; |
|---|
| | 2006 | } |
|---|
| | 2007 | if ($j > $#wind_from_direction) |
|---|
| | 2008 | { |
|---|
| | 2009 | die "ABORT! Could not find matching wind_from_direction for $wind_speed[$i] {'var_name'}.\n"; |
|---|
| | 2010 | } |
|---|
| | 2011 | else |
|---|
| | 2012 | { |
|---|
| | 2013 | for my $k (0..$#this_wind_speed_data) |
|---|
| | 2014 | { |
|---|
| | 2015 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 2016 | $this_time_stamp = $time_formatted_values[$k]; |
|---|
| | 2017 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 2018 | |
|---|
| | 2019 | my $WindSpdDataVal = 'NULL'; |
|---|
| | 2020 | my $WindDirDataVal = 'NULL'; |
|---|
| | 2021 | my $WindGstDataVal = 'NULL'; |
|---|
| | 2022 | my $Height = ''; |
|---|
| | 2023 | if ($wind_speed[$i]{'data'}[$k] != $missing_value_value |
|---|
| | 2024 | && $wind_speed[$i]{'data'}[$k] != $Fill_value_value |
|---|
| | 2025 | && $wind_from_direction[$j]{'data'}[$k] != $missing_value_value |
|---|
| | 2026 | && $wind_from_direction[$j]{'data'}[$k] != $Fill_value_value |
|---|
| | 2027 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 2028 | && $this_time_stamp_sec > $oldest_ok_timestamp) |
|---|
| | 2029 | { |
|---|
| | 2030 | if ($wind_speed[$i]{'height'} != $missing_value_value |
|---|
| | 2031 | && $wind_speed[$i]{'height'} != $Fill_value_value) |
|---|
| | 2032 | { |
|---|
| | 2033 | $Height = sprintf("%.2f",$wind_speed[$i]{'height'}); |
|---|
| | 2034 | } |
|---|
| | 2035 | |
|---|
| | 2036 | $this_val = sprintf("%.2f",$wind_speed[$i]{'data'}[$k]); |
|---|
| | 2037 | if( length( $this_val ) > 0 ) |
|---|
| | 2038 | { |
|---|
| | 2039 | $WindSpdDataVal = $this_val; |
|---|
| | 2040 | } |
|---|
| | 2041 | |
|---|
| | 2042 | if ($wind_gust[$j]{'data'}[$k] != $missing_value_value |
|---|
| | 2043 | && $wind_gust[$j]{'data'}[$k] != $Fill_value_value |
|---|
| | 2044 | && $wind_gust[$j]{'data'}[$k] != '') |
|---|
| | 2045 | { |
|---|
| | 2046 | $WindGstDataVal = sprintf("%.2f",$wind_gust[$j]{'data'}[$k]); |
|---|
| | 2047 | } |
|---|
| | 2048 | |
|---|
| | 2049 | $this_val = sprintf("%.2f",$wind_from_direction[$j]{'data'}[$k]); |
|---|
| | 2050 | #DWR 4/5/2008 |
|---|
| | 2051 | if( length( $this_val ) > 0 ) |
|---|
| | 2052 | { |
|---|
| | 2053 | $WindDirDataVal = $this_val; |
|---|
| | 2054 | } |
|---|
| | 2055 | } |
|---|
| | 2056 | my $strUnits; |
|---|
| | 2057 | $strUnits = obsKMLSubRoutines::UnitsStringConversion( $wind_speed[$i]{'units'}, $XMLControlFile ); |
|---|
| | 2058 | if( length( $strUnits ) == 0 ) |
|---|
| | 2059 | { |
|---|
| | 2060 | $strUnits = $wind_speed[$i]{'units'}; |
|---|
| | 2061 | } |
|---|
| | 2062 | |
|---|
| | 2063 | obsKMLSubRoutines::KMLAddObsToHash( 'wind_speed', |
|---|
| | 2064 | $time_formatted_values[$j], |
|---|
| | 2065 | $WindSpdDataVal, |
|---|
| | 2066 | 1, |
|---|
| | 2067 | $strPlatformID, |
|---|
| | 2068 | $Height, |
|---|
| | 2069 | $strUnits, |
|---|
| | 2070 | $rObsHash ); |
|---|
| | 2071 | $strUnits = ''; |
|---|
| | 2072 | $strUnits = obsKMLSubRoutines::UnitsStringConversion( $wind_from_direction[$i]{'units'}, $XMLControlFile ); |
|---|
| | 2073 | if( length( $strUnits ) == 0 ) |
|---|
| | 2074 | { |
|---|
| | 2075 | $strUnits = $wind_from_direction[$i]{'units'}; |
|---|
| | 2076 | } |
|---|
| | 2077 | obsKMLSubRoutines::KMLAddObsToHash( 'wind_from_direction', |
|---|
| | 2078 | $time_formatted_values[$j], |
|---|
| | 2079 | $WindDirDataVal, |
|---|
| | 2080 | 1, |
|---|
| | 2081 | $strPlatformID, |
|---|
| | 2082 | $Height, |
|---|
| | 2083 | $strUnits, |
|---|
| | 2084 | $rObsHash ); |
|---|
| | 2085 | $strUnits = ''; |
|---|
| | 2086 | $strUnits = obsKMLSubRoutines::UnitsStringConversion( $wind_gust[$i]{'units'}, $XMLControlFile ); |
|---|
| | 2087 | if( length( $strUnits ) == 0 ) |
|---|
| | 2088 | { |
|---|
| | 2089 | $strUnits = $wind_gust[$i]{'units'}; |
|---|
| | 2090 | } |
|---|
| | 2091 | obsKMLSubRoutines::KMLAddObsToHash( 'wind_gust', |
|---|
| | 2092 | $time_formatted_values[$j], |
|---|
| | 2093 | $WindGstDataVal, |
|---|
| | 2094 | 1, |
|---|
| | 2095 | $strPlatformID, |
|---|
| | 2096 | $Height, |
|---|
| | 2097 | $strUnits, |
|---|
| | 2098 | $rObsHash ); |
|---|
| | 2099 | } |
|---|
| | 2100 | } |
|---|
| | 2101 | } |
|---|
| | 2102 | } |
|---|
| 1600 | | open(AIR_PRESSURE_SQLFILE,'>>../sql/air_pressure_prod_'.$institution_code_value.'_' |
|---|
| 1601 | | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| 1602 | | print AIR_PRESSURE_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| 1603 | | print AIR_PRESSURE_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| 1604 | | print AIR_PRESSURE_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| 1605 | | print AIR_PRESSURE_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| 1606 | | print AIR_PRESSURE_SQLFILE "-- title = $title_value\n"; |
|---|
| 1607 | | print AIR_PRESSURE_SQLFILE "-- institution = $institution_value\n"; |
|---|
| 1608 | | print AIR_PRESSURE_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| 1609 | | print AIR_PRESSURE_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| 1610 | | print AIR_PRESSURE_SQLFILE "-- source = $source_value\n"; |
|---|
| 1611 | | print AIR_PRESSURE_SQLFILE "-- references = $references_value\n"; |
|---|
| 1612 | | print AIR_PRESSURE_SQLFILE "-- contact = $contact_value\n"; |
|---|
| 1613 | | print AIR_PRESSURE_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| 1614 | | print AIR_PRESSURE_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| 1615 | | for my $i (0..$#air_pressure) { |
|---|
| 1616 | | for my $j (0..$#this_air_pressure_data) { |
|---|
| 1617 | | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| 1618 | | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| 1619 | | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| 1620 | | |
|---|
| 1621 | | if ($air_pressure[$i]{'data'}[$j] != $missing_value_value |
|---|
| 1622 | | && $air_pressure[$i]{'data'}[$j] != $Fill_value_value |
|---|
| 1623 | | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| 1624 | | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| 1625 | | print AIR_PRESSURE_SQLFILE "INSERT INTO air_pressure_prod ("; |
|---|
| 1626 | | print AIR_PRESSURE_SQLFILE "station_id,"; |
|---|
| 1627 | | print AIR_PRESSURE_SQLFILE "time_stamp,"; |
|---|
| 1628 | | print AIR_PRESSURE_SQLFILE "z,"; |
|---|
| 1629 | | print AIR_PRESSURE_SQLFILE "positive,"; |
|---|
| 1630 | | print AIR_PRESSURE_SQLFILE "pressure,"; |
|---|
| 1631 | | print AIR_PRESSURE_SQLFILE "the_geom"; |
|---|
| 1632 | | print AIR_PRESSURE_SQLFILE ") "; |
|---|
| 1633 | | print AIR_PRESSURE_SQLFILE "VALUES ("; |
|---|
| 1634 | | print AIR_PRESSURE_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| 1635 | | print AIR_PRESSURE_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$j].'\''; |
|---|
| 1636 | | if ($air_pressure[$i]{'height'} == $missing_value_value |
|---|
| 1637 | | || $air_pressure[$i]{'height'} == $Fill_value_value) { |
|---|
| 1638 | | print AIR_PRESSURE_SQLFILE ',NULL'; |
|---|
| | 2109 | if( $bWriteSQLFiles ) |
|---|
| | 2110 | { |
|---|
| | 2111 | open(AIR_PRESSURE_SQLFILE,'>>../sql/air_pressure_prod_'.$institution_code_value.'_' |
|---|
| | 2112 | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| | 2113 | print AIR_PRESSURE_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| | 2114 | print AIR_PRESSURE_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| | 2115 | print AIR_PRESSURE_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| | 2116 | print AIR_PRESSURE_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| | 2117 | print AIR_PRESSURE_SQLFILE "-- title = $title_value\n"; |
|---|
| | 2118 | print AIR_PRESSURE_SQLFILE "-- institution = $institution_value\n"; |
|---|
| | 2119 | print AIR_PRESSURE_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| | 2120 | print AIR_PRESSURE_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| | 2121 | print AIR_PRESSURE_SQLFILE "-- source = $source_value\n"; |
|---|
| | 2122 | print AIR_PRESSURE_SQLFILE "-- references = $references_value\n"; |
|---|
| | 2123 | print AIR_PRESSURE_SQLFILE "-- contact = $contact_value\n"; |
|---|
| | 2124 | print AIR_PRESSURE_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| | 2125 | print AIR_PRESSURE_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| | 2126 | for my $i (0..$#air_pressure) { |
|---|
| | 2127 | for my $j (0..$#this_air_pressure_data) { |
|---|
| | 2128 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 2129 | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| | 2130 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 2131 | |
|---|
| | 2132 | if ($air_pressure[$i]{'data'}[$j] != $missing_value_value |
|---|
| | 2133 | && $air_pressure[$i]{'data'}[$j] != $Fill_value_value |
|---|
| | 2134 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 2135 | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| | 2136 | print AIR_PRESSURE_SQLFILE "INSERT INTO air_pressure_prod ("; |
|---|
| | 2137 | print AIR_PRESSURE_SQLFILE "station_id,"; |
|---|
| | 2138 | print AIR_PRESSURE_SQLFILE "time_stamp,"; |
|---|
| | 2139 | print AIR_PRESSURE_SQLFILE "z,"; |
|---|
| | 2140 | print AIR_PRESSURE_SQLFILE "positive,"; |
|---|
| | 2141 | print AIR_PRESSURE_SQLFILE "pressure,"; |
|---|
| | 2142 | print AIR_PRESSURE_SQLFILE "the_geom"; |
|---|
| | 2143 | print AIR_PRESSURE_SQLFILE ") "; |
|---|
| | 2144 | print AIR_PRESSURE_SQLFILE "VALUES ("; |
|---|
| | 2145 | print AIR_PRESSURE_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| | 2146 | print AIR_PRESSURE_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$j].'\''; |
|---|
| | 2147 | if ($air_pressure[$i]{'height'} == $missing_value_value |
|---|
| | 2148 | || $air_pressure[$i]{'height'} == $Fill_value_value) { |
|---|
| | 2149 | print AIR_PRESSURE_SQLFILE ',NULL'; |
|---|
| | 2150 | } |
|---|
| | 2151 | else { |
|---|
| | 2152 | $this_val = sprintf("%.2f",$air_pressure[$i]{'height'}); |
|---|
| | 2153 | print AIR_PRESSURE_SQLFILE ','.$this_val; |
|---|
| | 2154 | } |
|---|
| | 2155 | |
|---|
| | 2156 | print AIR_PRESSURE_SQLFILE ','.'\''.$height_var{'positive'}.'\''; |
|---|
| | 2157 | $this_val = sprintf("%.2f",$air_pressure[$i]{'data'}[$j]); |
|---|
| | 2158 | |
|---|
| | 2159 | print AIR_PRESSURE_SQLFILE ','.$this_val; |
|---|
| | 2160 | print AIR_PRESSURE_SQLFILE ",GeometryFromText('POINT("; |
|---|
| | 2161 | print AIR_PRESSURE_SQLFILE $longitude_value[0].' '.$latitude_value[0]; |
|---|
| | 2162 | print AIR_PRESSURE_SQLFILE ")',-1));\n"; |
|---|
| 1661 | | open(SALINITY_SQLFILE,'>>../sql/salinity_prod_'.$institution_code_value.'_' |
|---|
| 1662 | | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| 1663 | | print SALINITY_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| 1664 | | print SALINITY_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| 1665 | | print SALINITY_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| 1666 | | print SALINITY_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| 1667 | | print SALINITY_SQLFILE "-- title = $title_value\n"; |
|---|
| 1668 | | print SALINITY_SQLFILE "-- institution = $institution_value\n"; |
|---|
| 1669 | | print SALINITY_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| 1670 | | print SALINITY_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| 1671 | | print SALINITY_SQLFILE "-- source = $source_value\n"; |
|---|
| 1672 | | print SALINITY_SQLFILE "-- references = $references_value\n"; |
|---|
| 1673 | | print SALINITY_SQLFILE "-- contact = $contact_value\n"; |
|---|
| 1674 | | print SALINITY_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| 1675 | | print SALINITY_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| 1676 | | for my $i (0..$#salinity) { |
|---|
| 1677 | | for my $j (0..$#this_salinity_data) { |
|---|
| 1678 | | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| 1679 | | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| 1680 | | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| 1681 | | |
|---|
| 1682 | | print "debug: $salinity[$i]{'data'}[$k]\n"; |
|---|
| 1683 | | if ($salinity[$i]{'data'}[$j] != $missing_value_value |
|---|
| 1684 | | && $salinity[$i]{'data'}[$j] != $Fill_value_value |
|---|
| 1685 | | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| 1686 | | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| 1687 | | print SALINITY_SQLFILE "INSERT INTO salinity_prod ("; |
|---|
| 1688 | | print SALINITY_SQLFILE "station_id,"; |
|---|
| 1689 | | print SALINITY_SQLFILE "time_stamp,"; |
|---|
| 1690 | | print SALINITY_SQLFILE "z,"; |
|---|
| 1691 | | print SALINITY_SQLFILE "positive,"; |
|---|
| 1692 | | print SALINITY_SQLFILE "salinity,"; |
|---|
| 1693 | | print SALINITY_SQLFILE "the_geom"; |
|---|
| 1694 | | print SALINITY_SQLFILE ") "; |
|---|
| 1695 | | print SALINITY_SQLFILE "VALUES ("; |
|---|
| 1696 | | print SALINITY_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| 1697 | | print SALINITY_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$j].'\''; |
|---|
| 1698 | | if ($salinity[$i]{'height'} == $missing_value_value |
|---|
| 1699 | | || $salinity[$i]{'height'} == $Fill_value_value) { |
|---|
| 1700 | | print SALINITY_SQLFILE ',NULL'; |
|---|
| | 2221 | if( $bWriteSQLFiles ) |
|---|
| | 2222 | { |
|---|
| | 2223 | open(SALINITY_SQLFILE,'>>../sql/salinity_prod_'.$institution_code_value.'_' |
|---|
| | 2224 | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| | 2225 | print SALINITY_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| | 2226 | print SALINITY_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| | 2227 | print SALINITY_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| | 2228 | print SALINITY_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| | 2229 | print SALINITY_SQLFILE "-- title = $title_value\n"; |
|---|
| | 2230 | print SALINITY_SQLFILE "-- institution = $institution_value\n"; |
|---|
| | 2231 | print SALINITY_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| | 2232 | print SALINITY_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| | 2233 | print SALINITY_SQLFILE "-- source = $source_value\n"; |
|---|
| | 2234 | print SALINITY_SQLFILE "-- references = $references_value\n"; |
|---|
| | 2235 | print SALINITY_SQLFILE "-- contact = $contact_value\n"; |
|---|
| | 2236 | print SALINITY_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| | 2237 | print SALINITY_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| | 2238 | for my $i (0..$#salinity) { |
|---|
| | 2239 | for my $j (0..$#this_salinity_data) { |
|---|
| | 2240 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 2241 | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| | 2242 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 2243 | |
|---|
| | 2244 | #print "debug: $salinity[$i]{'data'}[$k]\n"; |
|---|
| | 2245 | if ($salinity[$i]{'data'}[$j] != $missing_value_value |
|---|
| | 2246 | && $salinity[$i]{'data'}[$j] != $Fill_value_value |
|---|
| | 2247 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 2248 | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| | 2249 | print SALINITY_SQLFILE "INSERT INTO salinity_prod ("; |
|---|
| | 2250 | print SALINITY_SQLFILE "station_id,"; |
|---|
| | 2251 | print SALINITY_SQLFILE "time_stamp,"; |
|---|
| | 2252 | print SALINITY_SQLFILE "z,"; |
|---|
| | 2253 | print SALINITY_SQLFILE "positive,"; |
|---|
| | 2254 | print SALINITY_SQLFILE "salinity,"; |
|---|
| | 2255 | print SALINITY_SQLFILE "the_geom"; |
|---|
| | 2256 | print SALINITY_SQLFILE ") "; |
|---|
| | 2257 | print SALINITY_SQLFILE "VALUES ("; |
|---|
| | 2258 | print SALINITY_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| | 2259 | print SALINITY_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$j].'\''; |
|---|
| | 2260 | if ($salinity[$i]{'height'} == $missing_value_value |
|---|
| | 2261 | || $salinity[$i]{'height'} == $Fill_value_value) { |
|---|
| | 2262 | print SALINITY_SQLFILE ',NULL'; |
|---|
| | 2263 | } |
|---|
| | 2264 | else { |
|---|
| | 2265 | $this_val = sprintf("%.2f",$salinity[$i]{'height'}); |
|---|
| | 2266 | print SALINITY_SQLFILE ','.$this_val; |
|---|
| | 2267 | } |
|---|
| | 2268 | |
|---|
| | 2269 | print SALINITY_SQLFILE ','.'\''.$height_var{'positive'}.'\''; |
|---|
| | 2270 | $this_val = sprintf("%.2f",$salinity[$i]{'data'}[$j]); |
|---|
| | 2271 | |
|---|
| | 2272 | print SALINITY_SQLFILE ','.$this_val; |
|---|
| | 2273 | print SALINITY_SQLFILE ",GeometryFromText('POINT("; |
|---|
| | 2274 | print SALINITY_SQLFILE $longitude_value[0].' '.$latitude_value[0]; |
|---|
| | 2275 | print SALINITY_SQLFILE ")',-1));\n"; |
|---|
| | 2276 | } |
|---|
| | 2277 | } |
|---|
| | 2278 | print SALINITY_SQLFILE "\n"; |
|---|
| | 2279 | } |
|---|
| | 2280 | close(SALINITY_SQLFILE); |
|---|
| | 2281 | } |
|---|
| | 2282 | #DWR 4/5/2008 |
|---|
| | 2283 | if( $bWriteobsKMLFile ) |
|---|
| | 2284 | { |
|---|
| | 2285 | my $DataVal = 'NULL'; |
|---|
| | 2286 | my $Height = ''; |
|---|
| | 2287 | for my $i (0..$#salinity) |
|---|
| | 2288 | { |
|---|
| | 2289 | for my $j (0..$#this_salinity_data) |
|---|
| | 2290 | { |
|---|
| | 2291 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 2292 | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| | 2293 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 2294 | |
|---|
| | 2295 | my $DataVal = 'NULL'; |
|---|
| | 2296 | my $Height = ''; |
|---|
| | 2297 | if ($salinity[$i]{'data'}[$j] != $missing_value_value |
|---|
| | 2298 | && $salinity[$i]{'data'}[$j] != $Fill_value_value |
|---|
| | 2299 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 2300 | && $this_time_stamp_sec > $oldest_ok_timestamp) |
|---|
| | 2301 | { |
|---|
| | 2302 | if ($salinity[$i]{'height'} != $missing_value_value |
|---|
| | 2303 | && $salinity[$i]{'height'} != $Fill_value_value) |
|---|
| | 2304 | { |
|---|
| | 2305 | $Height = sprintf("%.2f",$salinity[$i]{'height'}); |
|---|
| | 2306 | } |
|---|
| | 2307 | $DataVal = sprintf("%.2f",$salinity[$i]{'data'}[$j]); |
|---|
| | 2308 | } |
|---|
| | 2309 | my $strUnits; |
|---|
| | 2310 | if( lc( $salinity[$i]{'units'} ) eq 'ppt' ) |
|---|
| | 2311 | { |
|---|
| | 2312 | $strUnits = 'psu'; |
|---|
| 1723 | | if ($#sea_surface_eastward_current > -1) { |
|---|
| 1724 | | open(CURRENT_IN_SITU_SQLFILE,'>>../sql/current_in_situ_prod_'.$institution_code_value.'_' |
|---|
| 1725 | | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| 1726 | | print CURRENT_IN_SITU_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| 1727 | | print CURRENT_IN_SITU_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| 1728 | | print CURRENT_IN_SITU_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| 1729 | | print CURRENT_IN_SITU_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| 1730 | | print CURRENT_IN_SITU_SQLFILE "-- title = $title_value\n"; |
|---|
| 1731 | | print CURRENT_IN_SITU_SQLFILE "-- institution = $institution_value\n"; |
|---|
| 1732 | | print CURRENT_IN_SITU_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| 1733 | | print CURRENT_IN_SITU_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| 1734 | | print CURRENT_IN_SITU_SQLFILE "-- source = $source_value\n"; |
|---|
| 1735 | | print CURRENT_IN_SITU_SQLFILE "-- references = $references_value\n"; |
|---|
| 1736 | | print CURRENT_IN_SITU_SQLFILE "-- contact = $contact_value\n"; |
|---|
| 1737 | | print CURRENT_IN_SITU_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| 1738 | | print CURRENT_IN_SITU_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| 1739 | | for my $i (0..$#sea_surface_eastward_current) { |
|---|
| 1740 | | my $j = 0; |
|---|
| 1741 | | while ($j <= $#sea_surface_northward_current |
|---|
| 1742 | | && $sea_surface_northward_current[$j]{'height'} != $sea_surface_eastward_current[$i]{'height'}) { |
|---|
| 1743 | | $j++; |
|---|
| 1744 | | } |
|---|
| 1745 | | if ($j > $#sea_surface_northward_current) { |
|---|
| 1746 | | die "ABORT! Could not find matching sea_surface_northward_current for $sea_surface_eastward_current[$i] {'var_name'}.\n"; |
|---|
| 1747 | | } |
|---|
| 1748 | | else { |
|---|
| 1749 | | for my $k (0..$#this_sea_surface_eastward_current_data) { |
|---|
| 1750 | | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| 1751 | | $this_time_stamp = $time_formatted_values[$k]; |
|---|
| 1752 | | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| 1753 | | |
|---|
| 1754 | | #print "debug: $sea_surface_eastward_current[$i]{'data'}[$k]\n"; |
|---|
| 1755 | | if ($sea_surface_eastward_current[$i]{'data'}[$k] != $missing_value_value |
|---|
| 1756 | | && $sea_surface_eastward_current[$i]{'data'}[$k] != $Fill_value_value |
|---|
| 1757 | | && $sea_surface_northward_current[$j]{'data'}[$k] != $missing_value_value |
|---|
| 1758 | | && $sea_surface_northward_current[$j]{'data'}[$k] != $Fill_value_value |
|---|
| 1759 | | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| 1760 | | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| 1761 | | print CURRENT_IN_SITU_SQLFILE "INSERT INTO current_in_situ_prod ("; |
|---|
| 1762 | | print CURRENT_IN_SITU_SQLFILE "station_id,"; |
|---|
| 1763 | | print CURRENT_IN_SITU_SQLFILE "time_stamp,"; |
|---|
| 1764 | | print CURRENT_IN_SITU_SQLFILE "z,"; |
|---|
| 1765 | | print CURRENT_IN_SITU_SQLFILE "positive,"; |
|---|
| 1766 | | print CURRENT_IN_SITU_SQLFILE "eastward_current,"; |
|---|
| 1767 | | print CURRENT_IN_SITU_SQLFILE "northward_current,"; |
|---|
| 1768 | | print CURRENT_IN_SITU_SQLFILE "surface_or_bottom,"; |
|---|
| 1769 | | print CURRENT_IN_SITU_SQLFILE "the_geom"; |
|---|
| 1770 | | print CURRENT_IN_SITU_SQLFILE ") "; |
|---|
| 1771 | | print CURRENT_IN_SITU_SQLFILE "VALUES ("; |
|---|
| 1772 | | print CURRENT_IN_SITU_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| 1773 | | print CURRENT_IN_SITU_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$k].'\''; |
|---|
| 1774 | | if ($sea_surface_eastward_current[$i]{'height'} == $missing_value_value |
|---|
| 1775 | | || $sea_surface_eastward_current[$i]{'height'} == $Fill_value_value) { |
|---|
| 1776 | | print CURRENT_IN_SITU_SQLFILE ','.'\'\''; |
|---|
| | 2336 | if ($#sea_surface_eastward_current > -1) |
|---|
| | 2337 | { |
|---|
| | 2338 | if( $bWriteSQLFiles ) |
|---|
| | 2339 | { |
|---|
| | 2340 | open(CURRENT_IN_SITU_SQLFILE,'>>../sql/current_in_situ_prod_'.$institution_code_value.'_' |
|---|
| | 2341 | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| | 2342 | print CURRENT_IN_SITU_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| | 2343 | print CURRENT_IN_SITU_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| | 2344 | print CURRENT_IN_SITU_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| | 2345 | print CURRENT_IN_SITU_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| | 2346 | print CURRENT_IN_SITU_SQLFILE "-- title = $title_value\n"; |
|---|
| | 2347 | print CURRENT_IN_SITU_SQLFILE "-- institution = $institution_value\n"; |
|---|
| | 2348 | print CURRENT_IN_SITU_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| | 2349 | print CURRENT_IN_SITU_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| | 2350 | print CURRENT_IN_SITU_SQLFILE "-- source = $source_value\n"; |
|---|
| | 2351 | print CURRENT_IN_SITU_SQLFILE "-- references = $references_value\n"; |
|---|
| | 2352 | print CURRENT_IN_SITU_SQLFILE "-- contact = $contact_value\n"; |
|---|
| | 2353 | print CURRENT_IN_SITU_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| | 2354 | print CURRENT_IN_SITU_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| | 2355 | for my $i (0..$#sea_surface_eastward_current) { |
|---|
| | 2356 | my $j = 0; |
|---|
| | 2357 | while ($j <= $#sea_surface_northward_current |
|---|
| | 2358 | && $sea_surface_northward_current[$j]{'height'} != $sea_surface_eastward_current[$i]{'height'}) { |
|---|
| | 2359 | $j++; |
|---|
| | 2360 | } |
|---|
| | 2361 | if ($j > $#sea_surface_northward_current) { |
|---|
| | 2362 | die "ABORT! Could not find matching sea_surface_northward_current for $sea_surface_eastward_current[$i] {'var_name'}.\n"; |
|---|
| | 2363 | } |
|---|
| | 2364 | else { |
|---|
| | 2365 | for my $k (0..$#this_sea_surface_eastward_current_data) { |
|---|
| | 2366 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 2367 | $this_time_stamp = $time_formatted_values[$k]; |
|---|
| | 2368 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 2369 | |
|---|
| | 2370 | #print "debug: $sea_surface_eastward_current[$i]{'data'}[$k]\n"; |
|---|
| | 2371 | if ($sea_surface_eastward_current[$i]{'data'}[$k] != $missing_value_value |
|---|
| | 2372 | && $sea_surface_eastward_current[$i]{'data'}[$k] != $Fill_value_value |
|---|
| | 2373 | && $sea_surface_northward_current[$j]{'data'}[$k] != $missing_value_value |
|---|
| | 2374 | && $sea_surface_northward_current[$j]{'data'}[$k] != $Fill_value_value |
|---|
| | 2375 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 2376 | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| | 2377 | print CURRENT_IN_SITU_SQLFILE "INSERT INTO current_in_situ_prod ("; |
|---|
| | 2378 | print CURRENT_IN_SITU_SQLFILE "station_id,"; |
|---|
| | 2379 | print CURRENT_IN_SITU_SQLFILE "time_stamp,"; |
|---|
| | 2380 | print CURRENT_IN_SITU_SQLFILE "z,"; |
|---|
| | 2381 | print CURRENT_IN_SITU_SQLFILE "positive,"; |
|---|
| | 2382 | print CURRENT_IN_SITU_SQLFILE "eastward_current,"; |
|---|
| | 2383 | print CURRENT_IN_SITU_SQLFILE "northward_current,"; |
|---|
| | 2384 | print CURRENT_IN_SITU_SQLFILE "surface_or_bottom,"; |
|---|
| | 2385 | print CURRENT_IN_SITU_SQLFILE "the_geom"; |
|---|
| | 2386 | print CURRENT_IN_SITU_SQLFILE ") "; |
|---|
| | 2387 | print CURRENT_IN_SITU_SQLFILE "VALUES ("; |
|---|
| | 2388 | print CURRENT_IN_SITU_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| | 2389 | print CURRENT_IN_SITU_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$k].'\''; |
|---|
| | 2390 | if ($sea_surface_eastward_current[$i]{'height'} == $missing_value_value |
|---|
| | 2391 | || $sea_surface_eastward_current[$i]{'height'} == $Fill_value_value) { |
|---|
| | 2392 | print CURRENT_IN_SITU_SQLFILE ','.'\'\''; |
|---|
| | 2393 | } |
|---|
| | 2394 | else { |
|---|
| | 2395 | $this_val = sprintf("%.2f",$sea_surface_eastward_current[$i]{'height'}); |
|---|
| | 2396 | print CURRENT_IN_SITU_SQLFILE ','.$this_val; |
|---|
| | 2397 | |
|---|
| | 2398 | } |
|---|
| | 2399 | print CURRENT_IN_SITU_SQLFILE ','.'\''.$height_var{'positive'}.'\''; |
|---|
| | 2400 | $this_val = sprintf("%.2f",$sea_surface_eastward_current[$i]{'data'}[$k]); |
|---|
| | 2401 | |
|---|
| | 2402 | print CURRENT_IN_SITU_SQLFILE ','.$this_val; |
|---|
| | 2403 | $this_val = sprintf("%.2f",$sea_surface_northward_current[$j]{'data'}[$k]); |
|---|
| | 2404 | |
|---|
| | 2405 | print CURRENT_IN_SITU_SQLFILE ','.$this_val; |
|---|
| | 2406 | print CURRENT_IN_SITU_SQLFILE ','.'\'surface\''; |
|---|
| | 2407 | print CURRENT_IN_SITU_SQLFILE ",GeometryFromText('POINT("; |
|---|
| | 2408 | print CURRENT_IN_SITU_SQLFILE $longitude_value[0].' '.$latitude_value[0]; |
|---|
| | 2409 | print CURRENT_IN_SITU_SQLFILE ")',-1));\n"; |
|---|
| 1778 | | else { |
|---|
| 1779 | | $this_val = sprintf("%.2f",$sea_surface_eastward_current[$i]{'height'}); |
|---|
| 1780 | | print CURRENT_IN_SITU_SQLFILE ','.$this_val; |
|---|
| | 2411 | |
|---|
| | 2412 | } |
|---|
| | 2413 | } |
|---|
| | 2414 | print CURRENT_IN_SITU_SQLFILE "\n"; |
|---|
| | 2415 | } |
|---|
| | 2416 | close(CURRENT_IN_SITU_SQLFILE); |
|---|
| | 2417 | } |
|---|
| | 2418 | #DWR 4/5/2008 |
|---|
| | 2419 | if( $bWriteobsKMLFile ) |
|---|
| | 2420 | { |
|---|
| | 2421 | for my $i (0..$#sea_surface_eastward_current) |
|---|
| | 2422 | { |
|---|
| | 2423 | my $j = 0; |
|---|
| | 2424 | while ($j <= $#sea_surface_northward_current |
|---|
| | 2425 | && $sea_surface_northward_current[$j]{'height'} != $sea_surface_eastward_current[$i]{'height'}) |
|---|
| | 2426 | { |
|---|
| | 2427 | $j++; |
|---|
| | 2428 | } |
|---|
| | 2429 | if ($j > $#sea_surface_northward_current) |
|---|
| | 2430 | { |
|---|
| | 2431 | die "ABORT! Could not find matching sea_surface_northward_current for $sea_surface_eastward_current[$i] {'var_name'}.\n"; |
|---|
| | 2432 | } |
|---|
| | 2433 | else |
|---|
| | 2434 | { |
|---|
| | 2435 | for my $k (0..$#this_sea_surface_eastward_current_data) |
|---|
| | 2436 | { |
|---|
| | 2437 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 2438 | $this_time_stamp = $time_formatted_values[$k]; |
|---|
| | 2439 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 2440 | |
|---|
| | 2441 | my $ECurrentDataVal = 'NULL'; |
|---|
| | 2442 | my $NCurrentDataVal = 'NULL'; |
|---|
| | 2443 | my $Height = ''; |
|---|
| | 2444 | |
|---|
| | 2445 | if ($sea_surface_eastward_current[$i]{'data'}[$k] != $missing_value_value |
|---|
| | 2446 | && $sea_surface_eastward_current[$i]{'data'}[$k] != $Fill_value_value |
|---|
| | 2447 | && $sea_surface_northward_current[$j]{'data'}[$k] != $missing_value_value |
|---|
| | 2448 | && $sea_surface_northward_current[$j]{'data'}[$k] != $Fill_value_value |
|---|
| | 2449 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 2450 | && $this_time_stamp_sec > $oldest_ok_timestamp) |
|---|
| | 2451 | { |
|---|
| | 2452 | if ($sea_surface_eastward_current[$i]{'height'} != $missing_value_value |
|---|
| | 2453 | && $sea_surface_eastward_current[$i]{'height'} != $Fill_value_value) |
|---|
| | 2454 | { |
|---|
| | 2455 | $Height = sprintf("%.2f",$sea_surface_eastward_current[$i]{'height'}); |
|---|
| | 2456 | } |
|---|
| | 2457 | $ECurrentDataVal = sprintf("%.2f",$sea_surface_eastward_current[$i]{'data'}[$k]); |
|---|
| | 2458 | |
|---|
| | 2459 | $NCurrentDataVal = sprintf("%.2f",$sea_surface_northward_current[$j]{'data'}[$k]); |
|---|
| | 2460 | |
|---|
| 1804 | | open(WAVE_SQLFILE,'>>../sql/wave_in_situ_prod_'.$institution_code_value.'_' |
|---|
| 1805 | | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| 1806 | | print WAVE_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| 1807 | | print WAVE_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| 1808 | | print WAVE_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| 1809 | | print WAVE_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| 1810 | | print WAVE_SQLFILE "-- title = $title_value\n"; |
|---|
| 1811 | | print WAVE_SQLFILE "-- institution = $institution_value\n"; |
|---|
| 1812 | | print WAVE_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| 1813 | | print WAVE_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| 1814 | | print WAVE_SQLFILE "-- source = $source_value\n"; |
|---|
| 1815 | | print WAVE_SQLFILE "-- references = $references_value\n"; |
|---|
| 1816 | | print WAVE_SQLFILE "-- contact = $contact_value\n"; |
|---|
| 1817 | | print WAVE_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| 1818 | | print WAVE_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| 1819 | | for my $i (0..$#significant_wave_height) { |
|---|
| 1820 | | for my $j (0..$#this_significant_wave_height_data) { |
|---|
| 1821 | | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| 1822 | | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| 1823 | | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 2502 | if( $bWriteSQLFiles ) |
|---|
| | 2503 | { |
|---|
| | 2504 | open(WAVE_SQLFILE,'>>../sql/wave_in_situ_prod_'.$institution_code_value.'_' |
|---|
| | 2505 | .$platform_code_value.'_'.$package_code_value.'.sql'); |
|---|
| | 2506 | print WAVE_SQLFILE "-- format_category = $format_category_value\n"; |
|---|
| | 2507 | print WAVE_SQLFILE "-- institution_code = $institution_code_value\n"; |
|---|
| | 2508 | print WAVE_SQLFILE "-- platform_code = $platform_code_value\n"; |
|---|
| | 2509 | print WAVE_SQLFILE "-- package_code = $package_code_value\n"; |
|---|
| | 2510 | print WAVE_SQLFILE "-- title = $title_value\n"; |
|---|
| | 2511 | print WAVE_SQLFILE "-- institution = $institution_value\n"; |
|---|
| | 2512 | print WAVE_SQLFILE "-- institution_url = $institution_url_value\n"; |
|---|
| | 2513 | print WAVE_SQLFILE "-- institution_dods_url = $institution_dods_url_value\n"; |
|---|
| | 2514 | print WAVE_SQLFILE "-- source = $source_value\n"; |
|---|
| | 2515 | print WAVE_SQLFILE "-- references = $references_value\n"; |
|---|
| | 2516 | print WAVE_SQLFILE "-- contact = $contact_value\n"; |
|---|
| | 2517 | print WAVE_SQLFILE "-- missing_value = $missing_value_value\n"; |
|---|
| | 2518 | print WAVE_SQLFILE "-- _FillValue = $Fill_value_value\n"; |
|---|
| | 2519 | for my $i (0..$#significant_wave_height) { |
|---|
| | 2520 | for my $j (0..$#this_significant_wave_height_data) { |
|---|
| | 2521 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 2522 | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| | 2523 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 2524 | |
|---|
| | 2525 | my $DomWaveDataVal = 'NULL'; |
|---|
| | 2526 | my $SigWaveHgtDataVal = 'NULL'; |
|---|
| | 2527 | my $Height = ''; |
|---|
| | 2528 | |
|---|
| | 2529 | if ($significant_wave_height[$i]{'data'}[$j] != $missing_value_value |
|---|
| | 2530 | && $significant_wave_height[$i]{'data'}[$j] != $Fill_value_value |
|---|
| | 2531 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 2532 | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| | 2533 | print WAVE_SQLFILE "INSERT INTO wave_in_situ_prod ("; |
|---|
| | 2534 | print WAVE_SQLFILE "station_id,"; |
|---|
| | 2535 | print WAVE_SQLFILE "time_stamp,"; |
|---|
| | 2536 | print WAVE_SQLFILE "z,"; |
|---|
| | 2537 | print WAVE_SQLFILE "positive,"; |
|---|
| | 2538 | print WAVE_SQLFILE "significant_wave_height,"; |
|---|
| | 2539 | print WAVE_SQLFILE "dominant_wave_period,"; |
|---|
| | 2540 | print WAVE_SQLFILE "the_geom"; |
|---|
| | 2541 | print WAVE_SQLFILE ") "; |
|---|
| | 2542 | print WAVE_SQLFILE "VALUES ("; |
|---|
| | 2543 | print WAVE_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| | 2544 | print WAVE_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$j].'\''; |
|---|
| | 2545 | if ($significant_wave_height[$i]{'height'} == $missing_value_value |
|---|
| | 2546 | || $significant_wave_height[$i]{'height'} == $Fill_value_value) { |
|---|
| | 2547 | print WAVE_SQLFILE ',NULL'; |
|---|
| | 2548 | } |
|---|
| | 2549 | else { |
|---|
| | 2550 | $this_val = sprintf("%.2f",$significant_wave_height[$i]{'height'}); |
|---|
| | 2551 | print WAVE_SQLFILE ','.$this_val; |
|---|
| | 2552 | |
|---|
| | 2553 | #DWR 4/5/2008 |
|---|
| | 2554 | $Height = $this_val; |
|---|
| | 2555 | } |
|---|
| | 2556 | print WAVE_SQLFILE ','.'\''.$height_var{'positive'}.'\''; |
|---|
| | 2557 | if ($significant_wave_height[$i]{'data'}[$j] == $missing_value_value |
|---|
| | 2558 | || $significant_wave_height[$i]{'data'}[$j] == $Fill_value_value |
|---|
| | 2559 | || $significant_wave_height[$i]{'data'}[$j] == '') { |
|---|
| | 2560 | print WAVE_SQLFILE ',NULL'; |
|---|
| | 2561 | } |
|---|
| | 2562 | else { |
|---|
| | 2563 | $this_val = sprintf("%.2f",$significant_wave_height[$i]{'data'}[$j]); |
|---|
| | 2564 | print WAVE_SQLFILE ','.$this_val; |
|---|
| | 2565 | #DWR 4/5/2008 |
|---|
| | 2566 | $SigWaveHgtDataVal = $this_val; |
|---|
| | 2567 | } |
|---|
| | 2568 | if ($dominant_wave_period[$i]{'data'}[$j] == $missing_value_value |
|---|
| | 2569 | || $dominant_wave_period[$i]{'data'}[$j] == $Fill_value_value |
|---|
| | 2570 | || $dominant_wave_period[$i]{'data'}[$j] == '') { |
|---|
| | 2571 | print WAVE_SQLFILE ',NULL'; |
|---|
| | 2572 | } |
|---|
| | 2573 | else { |
|---|
| | 2574 | $this_val = sprintf("%.2f",$dominant_wave_period[$i]{'data'}[$j]); |
|---|
| | 2575 | print WAVE_SQLFILE ','.$this_val; |
|---|
| | 2576 | #DWR 4/5/2008 |
|---|
| | 2577 | $DomWaveDataVal = $this_val; |
|---|
| | 2578 | } |
|---|
| | 2579 | print WAVE_SQLFILE ",GeometryFromText('POINT("; |
|---|
| | 2580 | print WAVE_SQLFILE $longitude_value[0].' '.$latitude_value[0]; |
|---|
| | 2581 | print WAVE_SQLFILE ")',-1));\n"; |
|---|
| | 2582 | } |
|---|
| | 2583 | } |
|---|
| | 2584 | print WAVE_SQLFILE "\n"; |
|---|
| | 2585 | #DWR 4/3/2008 |
|---|
| | 2586 | my $strUnits; |
|---|
| | 2587 | $strUnits = obsKMLSubRoutines::UnitsStringConversion( $dominant_wave_period[$i]{'units'}, $XMLControlFile ); |
|---|
| | 2588 | if( length( $strUnits ) == 0 ) |
|---|
| | 2589 | { |
|---|
| | 2590 | $strUnits = $dominant_wave_period[$i]{'units'}; |
|---|
| | 2591 | } |
|---|
| | 2592 | |
|---|
| | 2593 | obsKMLSubRoutines::KMLAddObsToHash( 'dominant_wave_period', |
|---|
| | 2594 | $time_formatted_values[$j], |
|---|
| | 2595 | $DomWaveDataVal, |
|---|
| | 2596 | 1, |
|---|
| | 2597 | $strPlatformID, |
|---|
| | 2598 | $Height, |
|---|
| | 2599 | $strUnits, |
|---|
| | 2600 | $rObsHash ); |
|---|
| | 2601 | $strUnits = ''; |
|---|
| | 2602 | $strUnits = obsKMLSubRoutines::UnitsStringConversion( $significant_wave_height[$i]{'units'}, $XMLControlFile ); |
|---|
| | 2603 | if( length( $strUnits ) == 0 ) |
|---|
| | 2604 | { |
|---|
| | 2605 | $strUnits = $significant_wave_height[$i]{'units'}; |
|---|
| | 2606 | } |
|---|
| | 2607 | obsKMLSubRoutines::KMLAddObsToHash( 'significant_wave_height', |
|---|
| | 2608 | $time_formatted_values[$j], |
|---|
| | 2609 | $SigWaveHgtDataVal, |
|---|
| | 2610 | 1, |
|---|
| | 2611 | $strPlatformID, |
|---|
| | 2612 | $Height, |
|---|
| | 2613 | $strUnits, |
|---|
| | 2614 | $rObsHash ); |
|---|
| 1825 | | if ($significant_wave_height[$i]{'data'}[$j] != $missing_value_value |
|---|
| 1826 | | && $significant_wave_height[$i]{'data'}[$j] != $Fill_value_value |
|---|
| 1827 | | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| 1828 | | && $this_time_stamp_sec > $oldest_ok_timestamp) { |
|---|
| 1829 | | print WAVE_SQLFILE "INSERT INTO wave_in_situ_prod ("; |
|---|
| 1830 | | print WAVE_SQLFILE "station_id,"; |
|---|
| 1831 | | print WAVE_SQLFILE "time_stamp,"; |
|---|
| 1832 | | print WAVE_SQLFILE "z,"; |
|---|
| 1833 | | print WAVE_SQLFILE "positive,"; |
|---|
| 1834 | | print WAVE_SQLFILE "significant_wave_height,"; |
|---|
| 1835 | | print WAVE_SQLFILE "dominant_wave_period,"; |
|---|
| 1836 | | print WAVE_SQLFILE "the_geom"; |
|---|
| 1837 | | print WAVE_SQLFILE ") "; |
|---|
| 1838 | | print WAVE_SQLFILE "VALUES ("; |
|---|
| 1839 | | print WAVE_SQLFILE '\''.$institution_code_value.'_'.$platform_code_value.'_'.$package_code_value.'\''; |
|---|
| 1840 | | print WAVE_SQLFILE ','.'timestamp without time zone \''.$time_formatted_values[$j].'\''; |
|---|
| 1841 | | if ($significant_wave_height[$i]{'height'} == $missing_value_value |
|---|
| 1842 | | || $significant_wave_height[$i]{'height'} == $Fill_value_value) { |
|---|
| 1843 | | print WAVE_SQLFILE ',NULL'; |
|---|
| | 2616 | } |
|---|
| | 2617 | close(WAVE_SQLFILE); |
|---|
| | 2618 | } |
|---|
| | 2619 | #DWR 4/5/2008 |
|---|
| | 2620 | if( $bWriteobsKMLFile ) |
|---|
| | 2621 | { |
|---|
| | 2622 | for my $i (0..$#significant_wave_height) |
|---|
| | 2623 | { |
|---|
| | 2624 | for my $j (0..$#this_significant_wave_height_data) |
|---|
| | 2625 | { |
|---|
| | 2626 | $this_station_id = $institution_code_value.'_'.$platform_code_value.'_'.$package_code_value; |
|---|
| | 2627 | $this_time_stamp = $time_formatted_values[$j]; |
|---|
| | 2628 | $this_time_stamp_sec = timelocal(substr($this_time_stamp,17,2),substr($this_time_stamp,14,2),substr($this_time_stamp,11,2),substr($this_time_stamp,8,2),(substr($this_time_stamp,5,2)-1),substr($this_time_stamp,0,4)); |
|---|
| | 2629 | |
|---|
| | 2630 | my $DomWaveDataVal = 'NULL'; |
|---|
| | 2631 | my $SigWaveHgtDataVal = 'NULL'; |
|---|
| | 2632 | my $Height = ''; |
|---|
| | 2633 | |
|---|
| | 2634 | if ($significant_wave_height[$i]{'data'}[$j] != $missing_value_value |
|---|
| | 2635 | && $significant_wave_height[$i]{'data'}[$j] != $Fill_value_value |
|---|
| | 2636 | && $this_station_id_top_ts < $this_time_stamp_sec |
|---|
| | 2637 | && $this_time_stamp_sec > $oldest_ok_timestamp) |
|---|
| | 2638 | { |
|---|
| | 2639 | if ($significant_wave_height[$i]{'height'} != $missing_value_value |
|---|
| | 2640 | && $significant_wave_height[$i]{'height'} != $Fill_value_value) |
|---|
| | 2641 | { |
|---|
| | 2642 | $Height = sprintf("%.2f",$significant_wave_height[$i]{'height'}); |
|---|
| | 2643 | } |
|---|
| | 2644 | print WAVE_SQLFILE ','.'\''.$height_var{'positive'}.'\''; |
|---|
| | 2645 | if ($significant_wave_height[$i]{'data'}[$j] == $missing_value_value |
|---|
| | 2646 | || $significant_wave_height[$i]{'data'}[$j] == $Fill_value_value |
|---|
| | 2647 | || $significant_wave_height[$i]{'data'}[$j] == '') |
|---|
| | 2648 | { |
|---|
| | 2649 | $SigWaveHgtDataVal = sprintf("%.2f",$significant_wave_height[$i]{'data'}[$j]); |
|---|
| | 2650 | } |
|---|
| | 2651 | if ($dominant_wave_period[$i]{'data'}[$j] == $missing_value_value |
|---|
| | 2652 | || $dominant_wave_period[$i]{'data'}[$j] == $Fill_value_value |
|---|
| | 2653 | || $dominant_wave_period[$i]{'data'}[$j] == '') |
|---|
| | 2654 | { |
|---|
| | 2655 | $DomWaveDataVal = sprintf("%.2f",$dominant_wave_period[$i]{'data'}[$j]); |
|---|
| | 2656 | } |
|---|
| 1845 | | else { |
|---|
| 1846 | | $this_val = sprintf("%.2f",$significant_wave_height[$i]{'height'}); |
|---|
| 1847 | | print WAVE_SQLFILE ','.$this_val; |
|---|
| 1848 | | } |
|---|
| 1849 | | print WAVE_SQLFILE ','.'\''.$height_var{'positive'}.'\''; |
|---|
| 1850 | | if ($significant_wave_height[$i]{'data'}[$j] == $missing_value_value |
|---|
| 1851 | | || $significant_wave_height[$i]{'data'}[$j] == $Fill_value_value |
|---|
| 1852 | | || $significant_wave_height[$i]{'data'}[$j] == '') { |
|---|
| 1853 | | print WAVE_SQLFILE ',NULL'; |
|---|
| 1854 | | } |
|---|
| 1855 | | else { |
|---|
| 1856 | | $this_val = sprintf("%.2f",$significant_wave_height[$i]{'data'}[$j]); |
|---|
| 1857 | | print WAVE_SQLFILE ','.$this_val; |
|---|
| 1858 | | } |
|---|
| 1859 | | if ($dominant_wave_period[$i]{'data'}[$j] == $missing_value_value |
|---|
| 1860 | | || $dominant_wave_period[$i]{'data'}[$j] == $Fill_value_value |
|---|
| 1861 | | || $dominant_wave_period[$i]{'data'}[$j] == '') { |
|---|
| 1862 | | print WAVE_SQLFILE ',NULL'; |
|---|
| 1863 | | } |
|---|
| 1864 | | else { |
|---|
| 1865 | | $this_val = sprintf("%.2f",$dominant_wave_period[$i]{'data'}[$j]); |
|---|
| 1866 | | print WAVE_SQLFILE ','.$this_val; |
|---|
| 1867 | | } |
|---|
| 1868 | | print WAVE_SQLFILE ",GeometryFromText('POINT("; |
|---|
| 1869 | | print WAVE_SQLFILE $longitude_value[0].' '.$latitude_value[0]; |
|---|
| 1870 | | print WAVE_SQLFILE ")',-1));\n"; |
|---|
| 1871 | | } |
|---|
| 1872 | | } |
|---|
| 1873 | | print WAVE_SQLFILE "\n"; |
|---|
| 1874 | | } |
|---|
| 1875 | | close(WAVE_SQLFILE); |
|---|
| 1876 | | } |
|---|
| | 2658 | } |
|---|
| | 2659 | my $strUnits; |
|---|
| | 2660 | $strUnits = obsKMLSubRoutines::UnitsStringConversion( $dominant_wave_period[$i]{'units'}, $XMLControlFile ); |
|---|
| | 2661 | if( length( $strUnits ) == 0 ) |
|---|
| | 2662 | { |
|---|
| | 2663 | $strUnits = $dominant_wave_period[$i]{'units'}; |
|---|
| | 2664 | } |
|---|
| | 2665 | |
|---|
| | 2666 | obsKMLSubRoutines::KMLAddObsToHash( 'dominant_wave_period', |
|---|
| | 2667 | $time_formatted_values[$j], |
|---|
| | 2668 | $DomWaveDataVal, |
|---|
| | 2669 | 1, |
|---|
| | 2670 | $strPlatformID, |
|---|
| | 2671 | $Height, |
|---|
| | 2672 | $strUnits, |
|---|
| | 2673 | $rObsHash ); |
|---|
| | 2674 | $strUnits = ''; |
|---|
| | 2675 | $strUnits = obsKMLSubRoutines::UnitsStringConversion( $significant_wave_height[$i]{'units'}, $XMLControlFile ); |
|---|
| | 2676 | if( length( $strUnits ) == 0 ) |
|---|
| | 2677 | { |
|---|
| | 2678 | $strUnits = $significant_wave_height[$i]{'units'}; |
|---|
| | 2679 | } |
|---|
| | 2680 | obsKMLSubRoutines::KMLAddObsToHash( 'significant_wave_height', |
|---|
| | 2681 | $time_formatted_values[$j], |
|---|
| | 2682 | $SigWaveHgtDataVal, |
|---|
| | 2683 | 1, |
|---|
| | 2684 | $strPlatformID, |
|---|
| | 2685 | $Height, |
|---|
| | 2686 | $strUnits, |
|---|
| | 2687 | $rObsHash ); |
|---|
| | 2688 | |
|---|
| | 2689 | } |
|---|
| | 2690 | } |
|---|
| | 2691 | } |
|---|
| | 2692 | #DWR 4/5/2008 |
|---|
| | 2693 | if( $bWriteobsKMLFile ) |
|---|
| | 2694 | { |
|---|
| | 2695 | my $strXMLPath = ''; |
|---|
| | 2696 | my $strDate = `date +%Y-%m-%dT%H-%M-%S`; |
|---|
| | 2697 | chomp( $strDate ); |
|---|
| | 2698 | #$strXMLPath = "../sql/$strPlatformID-$strDate.kml"; |
|---|
| | 2699 | $strXMLPath = "$strObsKMLFilePath/$strPlatformID-$strDate.kml"; |
|---|
| | 2700 | #print( "$strXMLPath\n" ); |
|---|
| | 2701 | obsKMLSubRoutines::BuildKMLFile( \%ObsHash, $strXMLPath ); |
|---|
| | 2702 | } |
|---|