From bc0f89a8f31cef0235dd55151347662ff75abc0b Mon Sep 17 00:00:00 2001 From: Elena.Budnik Date: Mon, 6 Apr 2020 11:36:10 +0200 Subject: [PATCH] correctNan for 2 dims --- update_amda/correctNan.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/update_amda/correctNan.php b/update_amda/correctNan.php index 04a1b7f..01f4edb 100644 --- a/update_amda/correctNan.php +++ b/update_amda/correctNan.php @@ -4,21 +4,31 @@ $info = new DomDocument("1.0"); // $infoName = $argv[1]; - $pattern = "info_psp_om*.xml"; + $pattern = "info_psp_loic_*.xml"; foreach (glob(AMDA_INTERNAL_METADATA."/PARAM_INFO_PREDEFINED/".$pattern) as $infoName) { $info->load($infoName); $dimensions = $info->getElementsByTagName("dimensions")->item(0); $dim_1 = $dimensions->getAttribute("dim_1"); - $channels = $info->getElementsByTagName("channel"); + $dim_2 = null; + if ($dimensions->hasAttribute("dim_2")) + $dim_2 = $dimensions->getAttribute("dim_2"); - if ($dim_1 != $channels->length) { - $dimensions->setAttribute("dim_1", $channels->length); - echo $infoName.PHP_EOL; - echo $dim_1." ".$channels->length.PHP_EOL; - } + + $tables = $info->getElementsByTagName("table"); + foreach ($tables as $table) { + $channels = $table->getElementsByTagName("channel"); + $dim = $table->getAttribute("relatedDim"); + if ( $dim == "dim_1" ) $dim_ = $dim_1; + if ( $dim == "dim_2" ) $dim_ = $dim_2; + if ($dim_ != $channels->length) { + $dimensions->setAttribute($dim, $channels->length); + echo $infoName.PHP_EOL; + echo $dim_." ".$channels->length.PHP_EOL; + } + } $info->save($infoName); } -- libgit2 0.21.2