Blame view

php/RemoteDataCenter/IPIM.php 4.35 KB
bf74fc2d   Elena.Budnik   IMPEX
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?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;
	}
46ac3264   Elena.Budnik   redmine #6005 : b...
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
	
	public function validateStartStop($fileName, $startTime, $stopTime)
	{
			$res = array();
			exec('cdfstartstopfromdata '.IHMConfigClass::getLocalBasePath().$fileName, $start_stop);
			$tempArr = explode(' ', $start_stop[0]);
			
			$res["start"] = date("Y-m-d\TH:i:s",(int)$tempArr[0]);
			$res["stop"] = date("Y-m-d\TH:i:s",(int)$tempArr[1]);
			
			if ( strtotime($startTime) >= (int)$tempArr[1] || strtotime($stopTime) <= (int)$tempArr[0] ) 
					$res["success"] = false;
			else
					$res["success"] = true;
		   
			return $res;
	}
bf74fc2d   Elena.Budnik   IMPEX
182
183
}
?>