correctNan.php
1.17 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
<?php
define("AMDA_INTERNAL_METADATA",getenv("AMDAINTERNALDIR"));
$info = new DomDocument("1.0");
// $infoName = $argv[1];
$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");
$dim_2 = null;
if ($dimensions->hasAttribute("dim_2"))
$dim_2 = $dimensions->getAttribute("dim_2");
$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);
}
?>