IPIM.php 3.82 KB
<?php
/**
 * @class IPIM 
 * @brief  
 * @details
 */
class IPIM extends SimulationDataCenterClass
{
	protected $url = "http://transplanet.irap.omp.eu";
	protected $treeXML = "impex.xml";
	
	public $alongOrbit = false;
	
	protected $hasAccessUrl = true;
	
	public $outputFormat = 'CDF';
	// altitude curvilinear_abscissa surface volume
	public $energyTableName = "curvilinear_abscissa";
	protected $energyTableWidth = 200;
	
	
	protected function addSimulatedRegionToTargetsFile($reg=null,$reg=null){}
	
	protected function getDatasetName($no) 
	{
		$name = explode("/",trim($no->ResourceID));	  
		return end($name);	
	}
	
	protected function setHelpAttribute($node, $helpFile)
	 {
		$node->setAttribute('att', "");	  
	 }
	 
	protected function setSimulationRunNodeDescription($runNode,$sr)
	{
		$coords = $this->getCoordinateSystem($sr->SimulationDomain->CoordinateSystem);
		$domain = $this->getRegionBoundaries($sr->SimulationDomain, null);
		$properties = $this->getProperties($sr);
	 	   
		$runNode->setAttribute('desc', $coords.$domain.$properties);		 
	} 
	
	protected function getAccessUrl($no)
	{
		$url = $no->AccessInformation->AccessURL->URL;
		$resourceID = $no->ResourceID;
		
		if ($url == '')
		{	
			foreach ($this->tree->Granule as $granule)
			{
			   $granuleID = $granule->ParentID;
			   
				if ("$granuleID" == "$resourceID")
				{					
					$url = $granule->Source->URL;						
					break;
				}
			}
		}
		
		return $url;	
	}
	
	protected function getStartTime($no)
	{
		$start = $no->TemporalDescription->TimeSpan->StartDate;
		$stpos = strpos($start, '+');
		if ($stpos > 0) 
			$start = substr($start,0,$stpos);
			
		return $start."Z";	
	}
	
	protected function getStopTime($no)
	{
		$stop = $no->TemporalDescription->TimeSpan->StopDate;
		$stpos = strpos($stop, '+');
		if ($stpos > 0) 
			$stop = substr($stop,0,$stpos);
			
		return $stop."Z";	
	}
	
	protected function getProperties($sr)
	{		
		$descInternal = "<b><br/>Internal Magnetic Field : </b> : ";				
		$inputFields = $sr->InputField;

		foreach ($inputFields as $field)		
		{			
				$descInternal .= $field->Name."<br/>";							 			
		}		
		$descInternal .= "<b>Input Neutrals : </b>";				
		$inputPopulations = $sr->InputPopulation; 
		foreach ($inputPopulations as $population)		
		{			
				$descInternal .= $population->Name.";";							 			
		}		
		return $descInternal;
	}
	
	protected function getRegionBoundaries($domain, $region = null)
	{		  
	   $desc = "<b><br/>Domain: </b><br/>";
	   
		$spatialDimension = $domain->SpatialDimension;  

		$ValidMinsDom = preg_split ("/\s+/", $domain->ValidMin);
		$ValidMaxsDom = preg_split ("/\s+/", $domain->ValidMax);
		$unitsDomain  = preg_split ("/\s+/", $domain->Units);
		$coordLabel = preg_split ("/\s+/",$domain->CoordinatesLabel);

		for($j=0; $j< $spatialDimension; $j++)
		{			
			$desc .= $coordLabel[$j]." : [ ".$ValidMinsDom[$j].", ".$ValidMaxsDom[$j]."] ".$unitsDomain[$j]."<br/>";			
		}		
		return $desc;
	}
	
	public function getFileName($resourceID, $templateArgs = null, $start = null)
	{	 
			$strpos = strrpos($resourceID, "/");
			
			if ($strpos > 0)
				$fileName = substr(strtr($resourceID, $this->impex_pairs),0,$strpos);
				
			$fileName .= ".cdf";

		return $fileName;
	}
	
	public function getMask($resourceID, $templateArgs = null)
	{			
		return  $this->getFileName($resourceID);     
	}
	
	public function getData($params)
	{
// 		$r = print_r($params,true);
 //   	error_log($params['accessUrl'],3,'/home/budnik/LOG');
   	  
		return $params['accessUrl'];
	}	
	
	public function getTableDefinition($viID = null)
	{
		$res = array();
		if ($viID)
		{
		  // amdaParam (like EISCAT)
		}
		else
		{
			$res["tableDefType"] = "SELECT"; 
			$res["channelsDefType"] = "CENTER";
			$res["data"] = array();
			$res["data"]["center"] = $this->energyTableName;
 			$res["data"]["width"] = $this->energyTableWidth;			
		}
		
		return $res;
	}
}
?>