remakeInfo.php
1.89 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
<?php
function remove_children(&$node) {
while ($node->firstChild) {
while ($node->firstChild->firstChild) {
remove_children($node->firstChild);
}
$node->removeChild($node->firstChild);
}
}
define("NEWMETA",getenv("NEWMETA"));
define("AMDA_INTERNAL_METADATA",getenv("AMDAINTERNALDIR"));
$pattern = "info_psp_om*.xml";
$info = new DomDocument("1.0");
// $infoName = $argv[1];
foreach (glob(NEWMETA."/ParamInfo/".$pattern) as $infoName) {
$info->load($infoName);
$dimensions = $info->getElementsByTagName("dimensions")->item(0);
if ($dimensions->hasAttribute("dim_2") && $dimensions->getAttribute("dim_2") == "1")
$dimensions->removeAttribute("dim_2");
$components = $info->getElementsByTagName("components");
if ($components->length == 0) continue;
if ( !$components->item(0)->hasChildNodes() ) continue; // has been already processed
$a=$components->item(0);
remove_children($a);
$channels = $info->getElementsByTagName("channel");
foreach ($channels as $channel) {
$min = $channel->getAttribute("min");
$max = $channel->getAttribute("max");
if ( $min == "nan" ) {
$channel->setAttribute("min", "-");
}
if ( $max== "nan" ) {
$channel->setAttribute("max", "-");
}
if (is_numeric($min))
$channel->setAttribute("min",number_format($min,1,".",""));
if (is_numeric($max))
$channel->setAttribute("max",number_format($max,1,".",""));
}
echo basename($infoName).PHP_EOL;
$info->save(AMDA_INTERNAL_METADATA."/PARAM_INFO_PREDEFINED/".basename($infoName));
}
?>