Commit a8bb25b838bb6c6ae0ff1aba2b391271474a60f7
1 parent
f3004c4a
Exists in
master
and in
96 other branches
tools to correct args
Showing
2 changed files
with
87 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,28 @@ |
1 | +<?php | |
2 | + | |
3 | + define("AMDA_INTERNAL_METADATA",getenv("AMDAINTERNALDIR")); | |
4 | + | |
5 | + $info = new DomDocument("1.0"); | |
6 | + // $infoName = $argv[1]; | |
7 | + $pattern = "info_psp_om*.xml"; | |
8 | + foreach (glob(AMDA_INTERNAL_METADATA."/PARAM_INFO_PREDEFINED/".$pattern) as $infoName) { | |
9 | + $info->load($infoName); | |
10 | + | |
11 | + $dimensions = $info->getElementsByTagName("dimensions")->item(0); | |
12 | + | |
13 | + $dim_1 = $dimensions->getAttribute("dim_1"); | |
14 | + $channels = $info->getElementsByTagName("channel"); | |
15 | + | |
16 | + if ($dim_1 != $channels->length) { | |
17 | + $dimensions->setAttribute("dim_1", $channels->length); | |
18 | + echo $infoName.PHP_EOL; | |
19 | + echo $dim_1." ".$channels->length.PHP_EOL; | |
20 | + } | |
21 | + | |
22 | + $info->save($infoName); | |
23 | + } | |
24 | + | |
25 | +?> | |
26 | + | |
27 | + | |
28 | + | ... | ... |
... | ... | @@ -0,0 +1,59 @@ |
1 | +<?php | |
2 | + | |
3 | + function remove_children(&$node) { | |
4 | + while ($node->firstChild) { | |
5 | + while ($node->firstChild->firstChild) { | |
6 | + remove_children($node->firstChild); | |
7 | + } | |
8 | + $node->removeChild($node->firstChild); | |
9 | + } | |
10 | + } | |
11 | + | |
12 | + define("NEWMETA",getenv("NEWMETA")); | |
13 | + define("AMDA_INTERNAL_METADATA",getenv("AMDAINTERNALDIR")); | |
14 | + | |
15 | + $pattern = "info_psp_om*.xml"; | |
16 | + $info = new DomDocument("1.0"); | |
17 | + | |
18 | + // $infoName = $argv[1]; | |
19 | + foreach (glob(NEWMETA."/ParamInfo/".$pattern) as $infoName) { | |
20 | + | |
21 | + $info->load($infoName); | |
22 | + $dimensions = $info->getElementsByTagName("dimensions")->item(0); | |
23 | + | |
24 | + if ($dimensions->hasAttribute("dim_2") && $dimensions->getAttribute("dim_2") == "1") | |
25 | + $dimensions->removeAttribute("dim_2"); | |
26 | + | |
27 | + $components = $info->getElementsByTagName("components"); | |
28 | + if ($components->length == 0) continue; | |
29 | + if ( !$components->item(0)->hasChildNodes() ) continue; // has been already processed | |
30 | + $a=$components->item(0); | |
31 | + remove_children($a); | |
32 | + | |
33 | + $channels = $info->getElementsByTagName("channel"); | |
34 | + foreach ($channels as $channel) { | |
35 | + $min = $channel->getAttribute("min"); | |
36 | + $max = $channel->getAttribute("max"); | |
37 | + | |
38 | + if ( $min == "nan" ) { | |
39 | + $channel->setAttribute("min", "-"); | |
40 | + } | |
41 | + if ( $max== "nan" ) { | |
42 | + $channel->setAttribute("max", "-"); | |
43 | + } | |
44 | + if (is_numeric($min)) | |
45 | + $channel->setAttribute("min",number_format($min,1,".","")); | |
46 | + if (is_numeric($max)) | |
47 | + $channel->setAttribute("max",number_format($max,1,".","")); | |
48 | + | |
49 | + } | |
50 | + echo basename($infoName).PHP_EOL; | |
51 | + $info->save(AMDA_INTERNAL_METADATA."/PARAM_INFO_PREDEFINED/".basename($infoName)); | |
52 | + } | |
53 | + | |
54 | +?> | |
55 | + | |
56 | + | |
57 | + | |
58 | + | |
59 | + | ... | ... |