Commit a63e610847e41910a5b240192ce9ea227b692e26
1 parent
fa5a398d
Exists in
master
and in
6 other branches
Fix scripts for HAPI & EPN-TAP (cf. #11867)
Showing
2 changed files
with
74 additions
and
28 deletions
Show diff stats
update_amda/makeEPNTAPGranules.php
... | ... | @@ -41,7 +41,7 @@ $mapping = array( |
41 | 41 | 'c2_resol_max' => '', |
42 | 42 | 'c3_resol_min' => '', |
43 | 43 | 'c3_resol_max' => '', |
44 | - 'spatial_frame_type' => '', | |
44 | + 'spatial_frame_type' => 'none', | |
45 | 45 | 'incidence_min' => '', |
46 | 46 | 'incidence_max' => '', |
47 | 47 | 'emergence_min' => '', |
... | ... | @@ -55,7 +55,7 @@ $mapping = array( |
55 | 55 | 'creation_date' => '@@creation_date@@', |
56 | 56 | 'modification_date' => '@@modification_date@@', |
57 | 57 | 'release_date' => '@@release_date@@', |
58 | - 'service_title' => 'AMDADB', | |
58 | + 'service_title' => 'amdadb', | |
59 | 59 | 'access_url' => '@@amda_rest_api_entry_point@@getGranule.php?obs_id=@@dataset_id@@&start=@@granule_start_time_timestamp@@&stop=@@granule_stop_time_timestamp@@', |
60 | 60 | 'access_format' => 'application/x-cdf-istp', |
61 | 61 | 'target_region' => '@@target_region@@', |
... | ... | @@ -86,14 +86,15 @@ function parseSampling($sampling) { |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | -function parseProcessingLevel($info) { | |
90 | - if (strpos($info, 'L1') !== FALSE) { | |
91 | - return '2'; | |
92 | - } | |
93 | - if (strpos($info, 'L3') !== FALSE) { | |
94 | - return '5'; | |
89 | +function parseProcessingLevel($processing_level) { | |
90 | + switch ($processing_level) { | |
91 | + case 'Uncalibrated': | |
92 | + return '2'; | |
93 | + case 'ValueAdded': | |
94 | + return '5'; | |
95 | + default: | |
96 | + return '3'; | |
95 | 97 | } |
96 | - return '3'; | |
97 | 98 | } |
98 | 99 | |
99 | 100 | function getEpnTapMeasurementType($measurement_type, $UCDs) { |
... | ... | @@ -104,14 +105,14 @@ function getEpnTapMeasurementType($measurement_type, $UCDs) { |
104 | 105 | break; |
105 | 106 | case 'IonComposition': |
106 | 107 | case 'NeutralGas': |
107 | - $generic_ucd = 'phys.composition'; | |
108 | + $generic_ucd = 'phys'; | |
108 | 109 | break; |
109 | 110 | case 'EnergeticParticles': |
110 | - $generic_ucd = 'phys.particle'; | |
111 | + $generic_ucd = 'phys'; | |
111 | 112 | break; |
112 | 113 | case 'Waves': |
113 | 114 | case 'Waves.Passive': |
114 | - $generic_ucd = 'em.pw'; | |
115 | + $generic_ucd = 'phys'; | |
115 | 116 | break; |
116 | 117 | case 'Ephemeris': |
117 | 118 | $generic_ucd = 'pos.ephem'; |
... | ... | @@ -138,9 +139,10 @@ function getEpnTapMeasurementType($measurement_type, $UCDs) { |
138 | 139 | echo "[WARNING] UCD - Unknown measurement type: ".$measurement_type.PHP_EOL; |
139 | 140 | break; |
140 | 141 | } |
141 | - if (!empty($generic_ucd) && !in_array($generic_ucd, $UCDs)) | |
142 | + if (!empty($generic_ucd) && !in_array($generic_ucd, $UCDs)) { | |
142 | 143 | array_unshift($UCDs, $generic_ucd); |
143 | - return implode(';', $UCDs); | |
144 | + } | |
145 | + return implode('#', $UCDs); | |
144 | 146 | } |
145 | 147 | |
146 | 148 | function timestampToJulianDay($timestamp) { |
... | ... | @@ -161,6 +163,7 @@ function getTargetClass($spaseRegion) { |
161 | 163 | case "Asteroid": |
162 | 164 | return "asteroid"; |
163 | 165 | case "Comet": |
166 | + case "Rosetta@C-G": | |
164 | 167 | return "comet"; |
165 | 168 | case "Earth": |
166 | 169 | case "Jupiter": |
... | ... | @@ -180,6 +183,12 @@ function getTargetClass($spaseRegion) { |
180 | 183 | return "interplanetary_medium"; |
181 | 184 | case "Sun": |
182 | 185 | return "star"; |
186 | + case "Bepi": | |
187 | + case "Juno": | |
188 | + case "SolO": | |
189 | + case "PSP": | |
190 | + case "Cassini": | |
191 | + return "spacecraft"; | |
183 | 192 | } |
184 | 193 | echo "[WARNING] Error in ObservatoryRegion definition : ".$spaseRegion.PHP_EOL; |
185 | 194 | return "planet"; |
... | ... | @@ -203,6 +212,7 @@ function getTargetName($targetClass, $spaseRegion, $missionName, $dataset_id) { |
203 | 212 | case "comet": |
204 | 213 | switch ($missionName) { |
205 | 214 | case "Rosetta": |
215 | + case "Rosetta@C-G": | |
206 | 216 | return "67P"; |
207 | 217 | case "Giotto": |
208 | 218 | return "1P"; |
... | ... | @@ -213,9 +223,21 @@ function getTargetName($targetClass, $spaseRegion, $missionName, $dataset_id) { |
213 | 223 | case "ICE": |
214 | 224 | if ($dataset_id == "ice-mag-p21") |
215 | 225 | return "21P"; |
226 | + case "Solar Wind Propagation Models": | |
227 | + if (in_array($dataset_id, array("bls-ros-omni", "tao-ros-sw"))) | |
228 | + return "67P"; | |
216 | 229 | } |
217 | - echo "[WARNING] Comet Id not defined for mission : ".$missionName.PHP_EOL; | |
230 | + echo "[WARNING] Comet Id not defined for mission : ".$missionName." - ".$dataset_id.PHP_EOL; | |
218 | 231 | return ""; |
232 | + case "spacecraft": | |
233 | + switch ($spaseRegion) { | |
234 | + case "SolO": | |
235 | + return "SolarOrbiter"; | |
236 | + case "Bepi": | |
237 | + return "BepiColombo"; | |
238 | + default: | |
239 | + return $spaseRegion; | |
240 | + } | |
219 | 241 | } |
220 | 242 | echo "[WARNING] Cannot retrieve target name from target class : ".$targetClass.PHP_EOL; |
221 | 243 | return ""; |
... | ... | @@ -276,13 +298,13 @@ $xpath = new DOMXpath($doc); |
276 | 298 | $output_file_handle = fopen($output_file, 'w'); |
277 | 299 | fputcsv($output_file_handle, array_keys($mapping)); |
278 | 300 | |
279 | -$dataset_nodes = $xpath->query("/dataRoot/dataCenter/mission/instrument/dataset | /dataRoot/dataCenter/mission/observatory/instrument/dataset | /dataRoot/dataCenter/mission/instrument/datasetGroup/dataset"); | |
301 | +$dataset_nodes = $xpath->query("/dataRoot/dataCenter/mission/instrument/dataset | /dataRoot/dataCenter/mission/observatory/instrument/dataset | /dataRoot/dataCenter/mission/instrument/datasetGroup/dataset | /dataRoot/dataCenter/mission/observatory/instrument/datasetGroup/dataset"); | |
280 | 302 | $datasets = array(); |
281 | 303 | foreach ($dataset_nodes as $dataset_node) { |
282 | 304 | $dataset_place_holders = array(); |
283 | 305 | //Dataset id |
284 | 306 | $datasetId = $dataset_node->getAttribute("xml:id"); |
285 | - //if ($datasetId != 'psp-het-1hr') | |
307 | + //if ($datasetId != 'so-pas-mom') | |
286 | 308 | // continue; |
287 | 309 | if (empty($datasetId)) { |
288 | 310 | echo "[WARNING] Cannot retrieve dataset id".PHP_EOL; |
... | ... | @@ -293,11 +315,17 @@ foreach ($dataset_nodes as $dataset_node) { |
293 | 315 | //Exclude dataset with group |
294 | 316 | $to_exclude = FALSE; |
295 | 317 | $crt_node = $dataset_node; |
318 | + $time_restriction = 0; | |
296 | 319 | while (($crt_node != NULL) && !$to_exclude) { |
297 | 320 | if ($crt_node->nodeType == XML_ELEMENT_NODE) { |
298 | 321 | $group = $crt_node->getAttribute("group"); |
299 | 322 | if (!empty($group)) { |
300 | - $to_exclude = TRUE; | |
323 | + $restriction = $crt_node->getAttribute("restriction"); | |
324 | + if (empty($restriction)) | |
325 | + $to_exclude = TRUE; | |
326 | + $time_restriction = strtotime($restriction); | |
327 | + if ($time_restriction === FALSE) | |
328 | + $to_exclude = TRUE; | |
301 | 329 | } |
302 | 330 | } |
303 | 331 | $crt_node = $crt_node->parentNode; |
... | ... | @@ -313,22 +341,28 @@ foreach ($dataset_nodes as $dataset_node) { |
313 | 341 | $ucd = trim($parameter_node->getAttribute('ucd')); |
314 | 342 | if (empty($ucd)) |
315 | 343 | continue; |
316 | - $ucd_list = explode(';', $ucd); | |
344 | + if (!in_array($ucd, $UCDs)) { | |
345 | + $UCDs[] = $ucd; | |
346 | + } | |
347 | + /*$ucd_list = explode(';', $ucd); | |
317 | 348 | foreach ($ucd_list as $u) { |
318 | 349 | $u = trim($u); |
319 | 350 | if (empty($u)) |
320 | 351 | continue; |
321 | 352 | if (!in_array($u, $UCDs)) |
322 | 353 | $UCDs[] = $u; |
323 | - } | |
354 | + }*/ | |
324 | 355 | } |
325 | 356 | |
326 | 357 | $dataset_place_holders['min_sampling'] = parseSampling($dataset_node->getAttribute("sampling")); |
327 | 358 | $dataset_place_holders['max_sampling'] = parseSampling($dataset_node->getAttribute("maxSampling")); |
359 | + if (empty($dataset_place_holders['max_sampling'])) { | |
360 | + $dataset_place_holders['max_sampling'] = $dataset_place_holders['min_sampling']; | |
361 | + } | |
328 | 362 | $dataset_place_holders['spase_resource_id'] = $dataset_node->getAttribute("spaseId"); |
329 | 363 | $dataset_place_holders['spase_measurement_type'] = $dataset_node->getAttribute("measurement_type"); |
330 | 364 | $dataset_place_holders['measurement_type'] = getEpnTapMeasurementType($dataset_place_holders['spase_measurement_type'], $UCDs); |
331 | - $dataset_place_holders['processing_level'] = parseProcessingLevel($dataset_node->getAttribute("xml:id")); | |
365 | + $dataset_place_holders['processing_level'] = parseProcessingLevel($dataset_node->getAttribute("processing_level")); | |
332 | 366 | $target = $dataset_node->getAttribute("target"); |
333 | 367 | |
334 | 368 | |
... | ... | @@ -384,13 +418,16 @@ foreach ($dataset_nodes as $dataset_node) { |
384 | 418 | $mission_name = $observatory_node->getAttribute('name'); |
385 | 419 | } |
386 | 420 | $dataset_place_holders['mission_name'] = utf8_encode($mission_name); |
421 | + if ($dataset_node->getAttribute('simulation') == '1') { | |
422 | + $dataset_place_holders['mission_name'] = 'Simulation'; | |
423 | + } | |
387 | 424 | $dataset_place_holders['instrument_name'] = preg_replace('/[^:\/\(\) \w-]/', ' ', $instrument_name); |
388 | 425 | if ($dataset_place_holders['instrument_name'] != $instrument_name) { |
389 | - echo "=================> ".$dataset_place_holders['instrument_name'].PHP_EOL; | |
390 | - } | |
391 | - if (!empty($dataset_group_node)) { | |
392 | - if ($dataset_place_holders['processing_level'] == 'L2') { | |
393 | - $dataset_place_holders['processing_level'] = parseProcessingLevel($dataset_group_node->getAttribute("xml:id")); | |
426 | + if ($dataset_place_holders['instrument_name'] == "IS IS EPI-Lo") { | |
427 | + $dataset_place_holders['instrument_name'] = "ISOIS EPI-Lo"; | |
428 | + } | |
429 | + else if ($dataset_place_holders['instrument_name'] == "IS IS EPI-Hi") { | |
430 | + $dataset_place_holders['instrument_name'] = "ISOIS EPI-Hi"; | |
394 | 431 | } |
395 | 432 | } |
396 | 433 | |
... | ... | @@ -424,6 +461,16 @@ foreach ($dataset_nodes as $dataset_node) { |
424 | 461 | $granule_place_holders['granule_index'] = str_replace(".nc", "", $granule_info[2]); |
425 | 462 | $granule_place_holders['granule_start_time'] = timestampToJulianDay($granule_info[0]); |
426 | 463 | $granule_place_holders['granule_stop_time'] = timestampToJulianDay($granule_info[1]); |
464 | + if ($granule_place_holders['granule_start_time'] > $granule_place_holders['granule_stop_time']) { | |
465 | + echo "[ERROR] Bad start/stop definition for granule ".$granule_place_holders['granule_index']." of ".$datasetId.PHP_EOL; | |
466 | + continue; | |
467 | + } | |
468 | + if (!empty($time_restriction)) { | |
469 | + // Exclude restricted granules | |
470 | + if (intval($granule_info[1]) > $time_restriction) { | |
471 | + continue; | |
472 | + } | |
473 | + } | |
427 | 474 | $granule_place_holders['modification_date'] = timestampToISO($granule_info[3]); |
428 | 475 | $granule_place_holders['granule_start_time_timestamp'] = $granule_info[0]; |
429 | 476 | $granule_place_holders['granule_stop_time_timestamp'] = $granule_info[1]; | ... | ... |
update_amda/makeHAPIMetadata.php
... | ... | @@ -9,10 +9,9 @@ $output_file = getenv('HAPIData')."/metadata/amda-catalog.json"; |
9 | 9 | $doc = new DOMDocument(); |
10 | 10 | @$doc->load($localparams_tree); |
11 | 11 | |
12 | - | |
13 | 12 | $xpath = new DOMXpath($doc); |
14 | 13 | |
15 | -$dataset_nodes = $xpath->query("/dataRoot/dataCenter/mission/instrument/dataset | /dataRoot/dataCenter/mission/observatory/instrument/dataset | /dataRoot/dataCenter/mission/instrument/datasetGroup/dataset"); | |
14 | +$dataset_nodes = $xpath->query("/dataRoot/dataCenter/mission/instrument/dataset | /dataRoot/dataCenter/mission/observatory/instrument/dataset | /dataRoot/dataCenter/mission/instrument/datasetGroup/dataset | /dataRoot/dataCenter/mission/observatory/instrument/datasetGroup/dataset"); | |
16 | 15 | $datasets = array(); |
17 | 16 | foreach ($dataset_nodes as $dataset_node) { |
18 | 17 | //Dataset id | ... | ... |