correctNan.php 1.17 KB
<?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);
    }

?>