getDataVEXGRAZ.php
2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* @file getDataVEXGRAZ.php
* @version $Id: getDataVEXGRAZ.php,v 1.4 2009/08/26 09:32:56 budnik Exp $
* @brief DD_Server tools <br> Gets Data from VEXGRAZ
*
* @arg remDataSetID ddVIdir StartTime StopTime
* Env Vars: $DDBASE $DDBASEBIN \n
* Executables: ascii2nc(DECODERS) TimesUpdate TimesUpdateNoData clean
*
*/
require_once 'ddserver_ini.php';
require_once 'vexgraz_ini.php';
function name2DD($fileName) {
$ncName = prefix.substr($fileName,3,11).".nc";
return $ncName;
}
/*
* Args
*/
$id = $argv[1];
$ViDir = $argv[2];
$Start = $argv[3];
$Stop = $argv[4];
/*
* Lock VI directory for Updating
* Stamp -> this directory is being updated
*/
$LockName = $ViDir."/LOCK";
touch($LockName);
fprintf(STDERR,$ViDir." is LOCKED \n");
/*
* Clean VI directory
*/
system("cd ".$ViDir."; ./clean");
/*
* SPASE Web Service getDatasetUrl()
*/
$mySpaseDataAccess = new DataAccessSpase();
$urlArray = $mySpaseDataAccess->getDatasetUrl($id, $Start, $Stop);
if ($urlArray !== "NODATA")
foreach ($urlArray as $theUrl) {
copy($ViDir."/header.nc","temp.nc");
$fileArr = split("/",$theUrl);
$fileName = $fileArr[count($fileArr)-1];
/*
* Copy URL file to DD_Server dir and
* Convert ascii TAB to nc using header.nc
*/
copy($theUrl, $fileName);
system(DDBASEBIN."/ascii2nc ".$fileName." 1");
fprintf(STDERR, "FILE $theUrl TRANSLATED \n");
unlink($fileName);
$ncFile = name2DD($fileName);
/*
* Move new nc file to VIdir
*/
rename("temp.nc", $ViDir."/".$ncFile);
/*
* Updates VI time info
*/
system("cd ".$ViDir."; ".DDBASEBIN."/TimesUpdate -u ".prefix."_times.nc ".$ncFile);
fprintf(STDERR, "TIMES IS UPDATED \n");
}
/*
* Fill NODATA times in VI time info
*/
system("cd ".$ViDir."; ".DDBASEBIN."/TimesUpdateNoData ".prefix."_times.nc ".$argv[3]." ".$argv[4]);
/*
* Unlock VI dir
*/
unlink($LockName);
fprintf(STDERR, "UNLOCK \n");
?>