From a8bb25b838bb6c6ae0ff1aba2b391271474a60f7 Mon Sep 17 00:00:00 2001 From: Elena.Budnik Date: Fri, 3 Apr 2020 13:26:05 +0200 Subject: [PATCH] tools to correct args --- update_amda/correctNan.php | 28 ++++++++++++++++++++++++++++ update_amda/remakeInfo.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 0 deletions(-) create mode 100644 update_amda/correctNan.php create mode 100644 update_amda/remakeInfo.php diff --git a/update_amda/correctNan.php b/update_amda/correctNan.php new file mode 100644 index 0000000..04a1b7f --- /dev/null +++ b/update_amda/correctNan.php @@ -0,0 +1,28 @@ +load($infoName); + + $dimensions = $info->getElementsByTagName("dimensions")->item(0); + + $dim_1 = $dimensions->getAttribute("dim_1"); + $channels = $info->getElementsByTagName("channel"); + + if ($dim_1 != $channels->length) { + $dimensions->setAttribute("dim_1", $channels->length); + echo $infoName.PHP_EOL; + echo $dim_1." ".$channels->length.PHP_EOL; + } + + $info->save($infoName); + } + +?> + + + diff --git a/update_amda/remakeInfo.php b/update_amda/remakeInfo.php new file mode 100644 index 0000000..e4d13b8 --- /dev/null +++ b/update_amda/remakeInfo.php @@ -0,0 +1,59 @@ +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)); + } + +?> + + + + + -- libgit2 0.21.2