Commit 25f87ff834fb7b2d3ac63f601bfcaf57c4f9f489
1 parent
0f7460c1
Exists in
master
and in
111 other branches
info for remote
Showing
4 changed files
with
127 additions
and
37 deletions
Show diff stats
php/RemoteDataCenter/CDAWEB.php
@@ -6,7 +6,8 @@ | @@ -6,7 +6,8 @@ | ||
6 | 6 | ||
7 | class CDAWEB extends RemoteDataCenterClientClass | 7 | class CDAWEB extends RemoteDataCenterClientClass |
8 | { | 8 | { |
9 | - | 9 | + //public $defaultFillValue = -1.e31; |
10 | + | ||
10 | protected function dataset2dd($id) | 11 | protected function dataset2dd($id) |
11 | { | 12 | { |
12 | return $id; | 13 | return $id; |
@@ -14,7 +15,7 @@ class CDAWEB extends RemoteDataCenterClientClass | @@ -14,7 +15,7 @@ class CDAWEB extends RemoteDataCenterClientClass | ||
14 | 15 | ||
15 | public function getParamSize() | 16 | public function getParamSize() |
16 | { | 17 | { |
17 | - $cmd = "ncinfo_remote ".RemoteData.$this->baseID."/".$this->infoFile." ".$this->ParamId; | 18 | + $cmd = "ncinfo_remote ".RemoteData.$this->baseID."/".$this->infoFile." ".$this->ParamId." 0"; |
18 | $res = shell_exec($cmd); | 19 | $res = shell_exec($cmd); |
19 | 20 | ||
20 | return $res; | 21 | return $res; |
@@ -28,6 +29,22 @@ class CDAWEB extends RemoteDataCenterClientClass | @@ -28,6 +29,22 @@ class CDAWEB extends RemoteDataCenterClientClass | ||
28 | return $res; | 29 | return $res; |
29 | } | 30 | } |
30 | 31 | ||
32 | + public function getParamUnits() | ||
33 | + { | ||
34 | + $cmd = "ncinfo_remote ".RemoteData.$this->baseID."/".$this->infoFile." ".$this->ParamId." 2"; | ||
35 | + $res = shell_exec($cmd); | ||
36 | + | ||
37 | + return $res; | ||
38 | + } | ||
39 | + | ||
40 | + public function getParamFillValue() | ||
41 | + { | ||
42 | + $cmd = "ncinfo_remote ".RemoteData.$this->baseID."/".$this->infoFile." ".$this->ParamId." 3"; | ||
43 | + $res = shell_exec($cmd); | ||
44 | + | ||
45 | + return $res; | ||
46 | + } | ||
47 | + | ||
31 | public function setInfoFile() | 48 | public function setInfoFile() |
32 | { | 49 | { |
33 | $this->infoFile = strtolower($this->ViId).".nc"; | 50 | $this->infoFile = strtolower($this->ViId).".nc"; |
php/RemoteDataCenter/RemoteDataCenterClientClass.php
@@ -9,7 +9,7 @@ class RemoteDataCenterClientClass | @@ -9,7 +9,7 @@ class RemoteDataCenterClientClass | ||
9 | public $baseDom = null, $dataCenter = null; | 9 | public $baseDom = null, $dataCenter = null; |
10 | public $baseDomName; | 10 | public $baseDomName; |
11 | public $baseID = null; | 11 | public $baseID = null; |
12 | - public $ViId = null, $ParamId = null; | 12 | + public $ViId = null, $ParamId = null, $defaultFillValue; |
13 | protected $client; | 13 | protected $client; |
14 | public $infoFile = null; | 14 | public $infoFile = null; |
15 | 15 |
php/RemoteDataCenter/RemoteParamManager.php
@@ -61,17 +61,30 @@ class RemoteParamManager | @@ -61,17 +61,30 @@ class RemoteParamManager | ||
61 | 61 | ||
62 | $this->center = new $baseId(); | 62 | $this->center = new $baseId(); |
63 | } | 63 | } |
64 | - | ||
65 | -/* | ||
66 | - <param xml:id="ace_r"> | ||
67 | - <get> | ||
68 | - <vi name="ace:orb:all"> | ||
69 | - <baseParam name="R"/> | ||
70 | - </vi></get> | ||
71 | - <process>$ace_orb_all_R/RADIUS_EARTH</process> | ||
72 | - <output/> | ||
73 | - </param> | ||
74 | -*/ | 64 | + |
65 | +// <param xml:id="imf"> | ||
66 | +// <info> | ||
67 | +// <name>imf</name> | ||
68 | +// <short_name>b_gse</short_name> | ||
69 | +// <components>bx,by,bz</components> | ||
70 | +// <units>nT</units> | ||
71 | +// <coordinates_system>GSE</coordinates_system> | ||
72 | +// <tensor_order/> | ||
73 | +// <si_conversion>1e-9>T</si_conversion> | ||
74 | +// <fill_value>-1.0E31</fill_value> | ||
75 | +// <ucd>phys.magField</ucd> | ||
76 | +// <dataset_id>ace-imf-all</dataset_id> | ||
77 | +// <instrument_id>ACE_MAG</instrument_id> | ||
78 | +// </info> | ||
79 | +// <get> | ||
80 | +// <vi name="ace:imf:all"> | ||
81 | +// <baseParam name="IMF"/> | ||
82 | +// </vi> | ||
83 | +// </get> | ||
84 | +// <process/> | ||
85 | +// <output/> | ||
86 | +// </param> | ||
87 | + | ||
75 | public function makeInternalParamXml() | 88 | public function makeInternalParamXml() |
76 | { | 89 | { |
77 | if (!$this->center->ViId) return false; | 90 | if (!$this->center->ViId) return false; |
@@ -91,13 +104,44 @@ class RemoteParamManager | @@ -91,13 +104,44 @@ class RemoteParamManager | ||
91 | $xml->appendChild($paramNode); | 104 | $xml->appendChild($paramNode); |
92 | 105 | ||
93 | $paramNode->setAttribute("xml:id", $this->paramId); | 106 | $paramNode->setAttribute("xml:id", $this->paramId); |
94 | - $getNode = $xml->createElement("get"); | ||
95 | - $viNode = $xml->createElement("vi"); | 107 | + |
108 | + $infoNode = $xml->createElement("info"); | ||
109 | + $infoNode->appendChild($xml->createElement("name",strtolower($this->center->ParamId))); | ||
110 | + $infoNode->appendChild($xml->createElement("short_name",strtolower($this->center->ParamId))); | ||
111 | + | ||
112 | + $size = $this->center->getParamSize(); | ||
113 | + //TODO spectra components | ||
114 | + if ($size > 1) | ||
115 | + { | ||
116 | + $components = strtolower($this->center->getParamComponents()); | ||
117 | + } | ||
118 | + else { | ||
119 | + $components = null; | ||
120 | + } | ||
121 | + | ||
122 | + $fillValue = $this->center->getParamFillValue(); | ||
123 | + if (!$fillValue) | ||
124 | + $fillValue = null; | ||
125 | + | ||
126 | + $infoNode->appendChild($xml->createElement("components",$components)); | ||
127 | + $infoNode->appendChild($xml->createElement("units",$this->center->getParamUnits())); | ||
128 | + $infoNode->appendChild($xml->createElement("coordinates_system")); | ||
129 | + $infoNode->appendChild($xml->createElement("tensor_order")); | ||
130 | + $infoNode->appendChild($xml->createElement("si_conversion")); | ||
131 | + $infoNode->appendChild($xml->createElement("fill_value", $fillValue)); | ||
132 | + $infoNode->appendChild($xml->createElement("ucd")); | ||
133 | + $infoNode->appendChild($xml->createElement("dataset_id")); | ||
134 | + $infoNode->appendChild($xml->createElement("instrument_id")); | ||
135 | + | ||
136 | + $getNode = $xml->createElement("get"); | ||
137 | + $viNode = $xml->createElement("vi"); | ||
96 | $baseParamNode = $xml->createElement("baseParam"); | 138 | $baseParamNode = $xml->createElement("baseParam"); |
97 | $baseParamNode->setAttribute("name", $this->center->ParamId); | 139 | $baseParamNode->setAttribute("name", $this->center->ParamId); |
98 | $viNode->setAttribute("name", strtolower(strtr($this->center->ViId,"_", ":"))); | 140 | $viNode->setAttribute("name", strtolower(strtr($this->center->ViId,"_", ":"))); |
99 | $viNode->appendChild($baseParamNode); | 141 | $viNode->appendChild($baseParamNode); |
100 | - $getNode->appendChild($viNode); | 142 | + $getNode->appendChild($viNode); |
143 | + | ||
144 | + $paramNode->appendChild($infoNode); | ||
101 | $paramNode->appendChild($getNode); | 145 | $paramNode->appendChild($getNode); |
102 | $paramNode->appendChild($xml->createElement("process")); | 146 | $paramNode->appendChild($xml->createElement("process")); |
103 | $paramNode->appendChild($xml->createElement("output")); | 147 | $paramNode->appendChild($xml->createElement("output")); |
@@ -111,7 +155,7 @@ class RemoteParamManager | @@ -111,7 +155,7 @@ class RemoteParamManager | ||
111 | 155 | ||
112 | protected function makeComponents($node, $size, $components) | 156 | protected function makeComponents($node, $size, $components) |
113 | { | 157 | { |
114 | - $compArray = explode(";",$components); | 158 | + $compArray = explode(",",$components); |
115 | 159 | ||
116 | for ($i = 0; $i < $size; $i++) | 160 | for ($i = 0; $i < $size; $i++) |
117 | { | 161 | { |
@@ -158,7 +202,7 @@ class RemoteParamManager | @@ -158,7 +202,7 @@ class RemoteParamManager | ||
158 | $this->center->setInfoFile(); | 202 | $this->center->setInfoFile(); |
159 | 203 | ||
160 | if (!$this->makeInternalParamXml()) return false; | 204 | if (!$this->makeInternalParamXml()) return false; |
161 | - | 205 | + |
162 | if (($size = $this->center->getParamSize()) > 1) | 206 | if (($size = $this->center->getParamSize()) > 1) |
163 | { | 207 | { |
164 | // make components and args | 208 | // make components and args |
php/src/ncinfo_remote.c
1 | +/* | ||
2 | + * get parameter info from CDAWEB dataset nc file | ||
3 | + * args : ncfile varId infoId | ||
4 | + * infoId : | ||
5 | + * 0 - dimension | ||
6 | + * 1 - labels | ||
7 | + * 2 - units | ||
8 | + * 3 - fillvalue | ||
9 | + */ | ||
10 | + | ||
1 | #include <stdio.h> | 11 | #include <stdio.h> |
2 | #include <stdlib.h> | 12 | #include <stdlib.h> |
3 | #include <string.h> | 13 | #include <string.h> |
@@ -22,16 +32,23 @@ main(int argc, char **argv) | @@ -22,16 +32,23 @@ main(int argc, char **argv) | ||
22 | size_t start[] = {0, 0}; | 32 | size_t start[] = {0, 0}; |
23 | size_t count[] = {1, 0}; | 33 | size_t count[] = {1, 0}; |
24 | size_t size, length; | 34 | size_t size, length; |
25 | - | ||
26 | - if (argc <= 2) { | 35 | + int infoId; |
36 | + float number_attr; | ||
37 | + | ||
38 | + const char *info[2]; | ||
39 | + info[0] = "UNITS"; | ||
40 | + info[1] = "_FillValue"; | ||
41 | + | ||
42 | + if (argc <= 3) { | ||
27 | printf("Incorrect number of arguments\n"); | 43 | printf("Incorrect number of arguments\n"); |
28 | exit(1); | 44 | exit(1); |
29 | } | 45 | } |
30 | - | 46 | + |
47 | + infoId = atoi(argv[3]); | ||
48 | + | ||
31 | stat = nc_open(argv[1],NC_WRITE|NC_SHARE,&ncID); check(stat); | 49 | stat = nc_open(argv[1],NC_WRITE|NC_SHARE,&ncID); check(stat); |
32 | 50 | ||
33 | stat = nc_inq_varid(ncID, argv[2], &varID); check(stat); | 51 | stat = nc_inq_varid(ncID, argv[2], &varID); check(stat); |
34 | - | ||
35 | stat = nc_inq_varndims(ncID, varID, &ndims); check(stat); | 52 | stat = nc_inq_varndims(ncID, varID, &ndims); check(stat); |
36 | 53 | ||
37 | stat = nc_inq_vardimid(ncID, varID, dimids); check(stat); | 54 | stat = nc_inq_vardimid(ncID, varID, dimids); check(stat); |
@@ -40,39 +57,32 @@ main(int argc, char **argv) | @@ -40,39 +57,32 @@ main(int argc, char **argv) | ||
40 | if (ndims > 1) | 57 | if (ndims > 1) |
41 | for (i = 1; i < ndims; i++) { | 58 | for (i = 1; i < ndims; i++) { |
42 | stat = nc_inq_dimlen(ncID, dimids[i], &len); check(stat); | 59 | stat = nc_inq_dimlen(ncID, dimids[i], &len); check(stat); |
43 | - if (argc == 3) | 60 | + if (infoId == 0) |
44 | { | 61 | { |
45 | fprintf(stdout, "%d ", len); | 62 | fprintf(stdout, "%d ", len); |
46 | } | 63 | } |
47 | } | 64 | } |
48 | else | 65 | else |
49 | - if (argc == 3) | 66 | + if (infoId == 0) |
50 | { | 67 | { |
51 | fprintf(stdout,"%d ", len); | 68 | fprintf(stdout,"%d ", len); |
52 | } | 69 | } |
53 | 70 | ||
54 | - if (argc == 4) | 71 | + if (infoId == 1) |
55 | { | 72 | { |
56 | size_t attlen = 0; | 73 | size_t attlen = 0; |
57 | - stat = nc_inq_attlen(ncID, varID, "LABL_PTR_1", &attlen); check(stat); | ||
58 | - // stat = nc_inq_atttype(ncID, varID, "LABL_PTR_1", &xtype); check(stat); | 74 | + stat = nc_inq_attlen(ncID, varID, "LABL_PTR_1", &attlen); check(stat); |
59 | 75 | ||
60 | unsigned char *string_attr = (unsigned char *)malloc(attlen * sizeof(char*)); | 76 | unsigned char *string_attr = (unsigned char *)malloc(attlen * sizeof(char*)); |
61 | stat = nc_get_att(ncID, varID, "LABL_PTR_1", string_attr); check(stat); | 77 | stat = nc_get_att(ncID, varID, "LABL_PTR_1", string_attr); check(stat); |
62 | - | ||
63 | - // printf("attribute = %s\n", string_attr); | 78 | + |
64 | stat = nc_inq_varid(ncID, string_attr, &labelID); check(stat); | 79 | stat = nc_inq_varid(ncID, string_attr, &labelID); check(stat); |
65 | - // stat = nc_inq_vartype(ncID, labelID, &xtype); check(stat); | ||
66 | - | ||
67 | - // printf("%d \n", xtype); | ||
68 | - | ||
69 | stat = nc_inq_varndims(ncID, labelID, &ndims); check(stat); | 80 | stat = nc_inq_varndims(ncID, labelID, &ndims); check(stat); |
70 | 81 | ||
71 | stat = nc_inq_vardimid(ncID, labelID, dimids); check(stat); | 82 | stat = nc_inq_vardimid(ncID, labelID, dimids); check(stat); |
72 | 83 | ||
73 | for (i = 0; i < ndims; i++) { | 84 | for (i = 0; i < ndims; i++) { |
74 | - stat = nc_inq_dimlen(ncID, dimids[i], &len); check(stat); | ||
75 | - // printf("%d \n", len); | 85 | + stat = nc_inq_dimlen(ncID, dimids[i], &len); check(stat); |
76 | if (i == 0) size = len; | 86 | if (i == 0) size = len; |
77 | if (i == 1) length = len; | 87 | if (i == 1) length = len; |
78 | } | 88 | } |
@@ -82,13 +92,32 @@ main(int argc, char **argv) | @@ -82,13 +92,32 @@ main(int argc, char **argv) | ||
82 | for (i = 0; i < size; i++) | 92 | for (i = 0; i < size; i++) |
83 | { | 93 | { |
84 | stat = nc_get_vara(ncID, labelID, start, count, string_var); check(stat); | 94 | stat = nc_get_vara(ncID, labelID, start, count, string_var); check(stat); |
85 | - fprintf(stdout, "%s;", string_var); | 95 | + fprintf(stdout, "%s", string_var); |
96 | + if (i < size -1) fprintf(stdout,","); | ||
86 | start[0]++; | 97 | start[0]++; |
87 | } | 98 | } |
88 | free(string_attr); | 99 | free(string_attr); |
89 | free(string_var); | 100 | free(string_var); |
90 | } | 101 | } |
91 | 102 | ||
103 | + if (infoId == 2) | ||
104 | + { | ||
105 | + size_t attlen = 0; | ||
106 | + stat = nc_inq_attlen(ncID, varID, info[infoId-2], &attlen); check(stat); | ||
107 | + | ||
108 | + unsigned char *string_attr = (unsigned char *)malloc(attlen * sizeof(char*)); | ||
109 | + stat = nc_get_att(ncID, varID, info[infoId-2], string_attr); check(stat); | ||
110 | + fprintf(stdout, "%s", string_attr); | ||
111 | + free(string_attr); | ||
112 | + } | ||
113 | + | ||
114 | + if (infoId == 3) | ||
115 | + { | ||
116 | + stat = nc_get_att(ncID, varID, info[infoId-2], &number_attr); check(stat); | ||
117 | + fprintf(stdout, "%e", number_attr); | ||
118 | + | ||
119 | + } | ||
120 | + | ||
92 | stat = nc_close(ncID); | 121 | stat = nc_close(ncID); |
93 | exit(0); | 122 | exit(0); |
94 | } | 123 | } |