//
// imf
// b_gse
// bx,by,bz
// nT
// GSE
//
// 1e-9>T
// -1.0E31
// phys.magField
// ace-imf-all
// ACE_MAG
//
//
//
//
//
//
//
//
//
protected function makeInternalParamXml($param)
{
$xml = new DomDocument("1.0");
$paramNode = $xml->createElement("param");
$xml->appendChild($paramNode);
$paramId = $param->getAttribute('xml:id');
$paramNode->setAttribute("xml:id", $paramId);
$ViId = substr($param->parentNode->getAttribute('xml:id'), strlen($this->baseID)+1);
$infoNode = $xml->createElement("info");
$infoNode->appendChild($xml->createElement("name",$paramId));
$infoNode->appendChild($xml->createElement("short_name",$param->getAttribute('name')));
$size = $param->getAttribute('size');
//TODO spectra components
if ($size > 1 && $param->hasAttribute('labels'))
{
$components = $param->getAttribute('labels');
}
else {
$components = null;
}
$infoNode->appendChild($xml->createElement("components",$components));
$infoNode->appendChild($xml->createElement("units",$param->getAttribute('units')));
$infoNode->appendChild($xml->createElement("coordinates_system"));
$infoNode->appendChild($xml->createElement("tensor_order"));
$infoNode->appendChild($xml->createElement("si_conversion"));
$infoNode->appendChild($xml->createElement("fill_value", $this->fillValue));
$infoNode->appendChild($xml->createElement("ucd"));
$infoNode->appendChild($xml->createElement("dataset_id",strtolower($ViId)));
$infoNode->appendChild($xml->createElement("instrument_id",strtolower($this->baseID." ".$ViId)));
$getNode = $xml->createElement("get");
$viNode = $xml->createElement("vi");
$baseParamNode = $xml->createElement("baseParam");
$arr = explode("_",$paramId); // tha_peif_density -> only last part
$baseParamName = $arr[2];
if ( count($arr) > 3 ) {
for ($i = 3; $i < count($arr); $i++)
$baseParamName .= "_".$arr[$i];
}
$baseParamNode->setAttribute("name", $baseParamName);
$viNode->setAttribute("name", strtolower(strtr($ViId,"_", ":")));
$viNode->appendChild($baseParamNode);
$getNode->appendChild($viNode);
$paramNode->appendChild($infoNode);
$paramNode->appendChild($getNode);
$paramNode->appendChild($xml->createElement("process"));
$paramNode->appendChild($xml->createElement("output"));
$xmlNameRemote = RemoteData."/PARAMS/".$paramId.".xml";
if (!is_dir(RemoteData."/PARAMS"))
mkdir(RemoteData."/PARAMS", 0775, true);
chmod(RemoteData."/PARAMS", 0775);
return $xml->save($xmlNameRemote);
}
public function makeAllParams()
{
$params = $this->baseDom->getElementsByTagName('parameter');
foreach ($params as $param)
{
if (!$this->makeInternalParamXml($param))
echo 'Error while making '.$param->getAttribute('xml:id').PHP_EOL;
}
}
// make components description from base.xml
public function makeCenterNode($xmlDom)
{
$nodeBase = $this->baseDom->getElementsByTagName('dataCenter')->item(0);
$node = $xmlDom->importNode($nodeBase, true);
$parameters = $node->getElementsByTagName('parameter');
foreach ($parameters as $param) {
if ($param->hasAttribute("labels"))
{
$labels = $param->getAttribute('labels');
$id = $param->getAttribute('xml:id');
$name = $param->getAttribute('name');
// if (!$labels) {
// $param->setAttribute('needsArgs', true);
// return true;
$labelArr = explode(",",$labels);
for ($i = 0; $i < count($labelArr); $i++)
{
$component = $xmlDom->createElement('component');
$component->setAttribute('xml:id',$id.'('.$i.')');
$component->setAttribute('name',$labelArr[$i]);
$param->appendChild($component);
}
}
}
return $node;
}
}
?>