Commit 1b0e06315b034208de6f14c271ab6ac033a9c142

Authored by Elena.Budnik
1 parent 893d690d

unique name for obs

Showing 1 changed file with 51 additions and 34 deletions   Show diff stats
src/REMOTEDATA/CDAWEB.php
... ... @@ -14,10 +14,10 @@ class CDAWEB extends RemoteDataCenterClass
14 14 private $CDAWEB = array(), $masterCDF = array();
15 15  
16 16 // https://cdaweb.gsfc.nasa.gov/WS/cdasr/1/dataviews/sp_phys/instrumentTypes
17   - /*private $validInstrumentTypes = [ "Activity%20Indices", "Electric%20Fields%20(space)","Gamma%20and%20X-Rays",
  17 + private $validInstrumentTypes = [ "Activity%20Indices", "Electric%20Fields%20(space)","Gamma%20and%20X-Rays",
18 18 "Magnetic%20Fields%20(space)", "Particles%20(space)", "Plasma%20and%20Solar%20Wind",
19   - "Radio%20and%20Plasma%20Waves%20(space)" ]; */
20   - private $validInstrumentTypes = [ "Magnetic%20Fields%20(space)" ];
  19 + "Radio%20and%20Plasma%20Waves%20(space)" ];
  20 + // private $validInstrumentTypes = [ "Magnetic%20Fields%20(space)", "Radio%20and%20Plasma%20Waves%20(space)" ];
21 21  
22 22 // not used : $validInstrumentTypes = ["Ephemeris"];
23 23  
... ... @@ -125,7 +125,7 @@ class CDAWEB extends RemoteDataCenterClass
125 125 $obsIds[$obsId] = $insIds;
126 126 }
127 127  
128   - $this->obsGroupsIds[$obsGroupId][$insType] = $obsIds;
  128 + $this->obsGroupsIds[$insType][$obsGroupId] = $obsIds;
129 129 }
130 130 }
131 131  
... ... @@ -330,7 +330,7 @@ class CDAWEB extends RemoteDataCenterClass
330 330 $sampling = $this->getDatasetSpaseDescription($dsId);
331 331 $this->updateDDServerXml("GlobalStart",$startTime);
332 332 $this->updateDDServerXml("GlobalStop",$endTime);
333   -
  333 +
334 334 // no general description - strange dataset
335 335 if ($sampling == -1)
336 336 return null;
... ... @@ -339,7 +339,7 @@ class CDAWEB extends RemoteDataCenterClass
339 339 echo " !!! $dsId $sampling".PHP_EOL;
340 340 else
341 341 $this->updateDDServerXml("MinSampling",$sampling);
342   -
  342 +
343 343 $dsNode->setAttribute('spaseUrl',$this->CDAWEB[$dsId]);
344 344 // $dsNode->setAttribute('masterCdf',$this->existsMasterCdf($dsId));
345 345 $dsNode->setAttribute("desc", "$label; $startTime - $endTime");
... ... @@ -462,7 +462,9 @@ class CDAWEB extends RemoteDataCenterClass
462 462 $rootNode->appendChild($this->DDserverXml->createElement("DataSetID", $ds));
463 463 $rootNode->appendChild($this->DDserverXml->createElement("GlobalStart"));
464 464 $rootNode->appendChild($this->DDserverXml->createElement("GlobalStop"));
465   - $rootNode->appendChild($this->DDserverXml->createElement("MinSampling"));
  465 + $rootNode->appendChild($this->DDserverXml->createElement("MinSampling"));
  466 + // fill value by default - if different - add into param description
  467 + $rootNode->appendChild($this->DDserverXml->createElement("FillValue"), -1.0E31);
466 468 }
467 469  
468 470 protected function updateDDServerXml($target, $value)
... ... @@ -607,11 +609,25 @@ class CDAWEB extends RemoteDataCenterClass
607 609 $dataRoot->appendChild($this->dataCenter);
608 610  
609 611 $this->setDataCenterAttributes();
610   -
611   - foreach ($this->obsGroupsIds as $groupId => $insTypes){
612   - foreach ($insTypes as $insType => $obss){
  612 + $first = true;
  613 +
  614 + foreach ($this->obsGroupsIds as $insType => $groupIds){
  615 + // getElementByID doesn't work on newly created Document
  616 + if (!$first) {
  617 + $this->domAmda->loadXML($this->domAmda->saveXML());
  618 + $this->dataCenter = $this->domAmda->getElementById($this->baseID);
  619 + }
  620 + foreach ($groupIds as $groupId => $obss){
  621 +
613 622 $obsNodes = array();
614   - foreach ($obss as $obs => $inss){
  623 +
  624 + foreach ($obss as $obs => $inss)
  625 + {
  626 + if (substr($obs,0,4) == "OMNI" && substr($groupId,0,4) != "OMNI"){
  627 + echo 'OMNI '.$obs.' '.$missionId.PHP_EOL;
  628 + continue;
  629 + }
  630 +
615 631 $insNodes = array();
616 632 // Create instrument nodes
617 633 foreach ($inss as $ins => $dss){
... ... @@ -653,8 +669,12 @@ class CDAWEB extends RemoteDataCenterClass
653 669  
654 670 $obsId = $this->baseID.":".$this->param2dd($groupId).":".$this->param2dd($obsSpaseId);
655 671  
656   - if (!($obsNode = $this->domAmda->getElementById($obsId))){
  672 + if (!($obsNode = $this->domAmda->getElementById($obsId))){
657 673 $obsNode = $this->createObservatoryNode($obsSpaseId, $groupId);
  674 +
  675 +// if (!$first){
  676 +// echo "NEW OBS ".$obsId.PHP_EOL;
  677 +// }
658 678 $obsNodes[] = $obsNode;
659 679 }
660 680  
... ... @@ -663,31 +683,28 @@ class CDAWEB extends RemoteDataCenterClass
663 683 }
664 684 }
665 685 } // foreach ($obss as $obs => $inss)
666   - }
667   - if ($obsNodes){
668   - $missionId = $this->baseID.":".$this->param2dd($groupId);
669   -
670   - if (!($missionNode = $this->domAmda->getElementById($missionId))){
671   - $missionNode = $this->createMissionNode($groupId);
672   - $this->dataCenter->appendChild($missionNode);
673   - }
674 686  
675   - foreach ($obsNodes as $obsNode){
676   - // observatory == mission
677   - if ($obsNode->getAttribute('name') == $missionNode->getAttribute('name')) {
678   - $insNodes = $obsNode->getElementsByTagName("instrument");
679   - foreach ($insNodes as $insNode)
680   - $missionNode->appendChild($insNode);
  687 + if ($obsNodes){
  688 + $missionId = $this->baseID.":".$this->param2dd($groupId);
  689 +
  690 + if (!($missionNode = $this->domAmda->getElementById($missionId))){
  691 + $missionNode = $this->createMissionNode($groupId);
  692 + $this->dataCenter->appendChild($missionNode);
681 693 }
682   - else
683   - $missionNode->appendChild($obsNode);
  694 +
  695 + foreach ($obsNodes as $obsNode){
  696 + // observatory == mission
  697 + if ($obsNode->getAttribute('name') == $missionNode->getAttribute('name')) {
  698 + $insNodes = $obsNode->getElementsByTagName("instrument");
  699 + foreach ($insNodes as $insNode)
  700 + $missionNode->appendChild($insNode);
  701 + }
  702 + else
  703 + $missionNode->appendChild($obsNode);
  704 + }
684 705 }
685   - }
686   - // getElemetByID doesn't work on newly created Document
687   - $this->domAmda->save('temp.xml');
688   - $this->domAmda->load('temp.xml');
689   -
690   - $this->dataCenter = $this->domAmda->getElementById($this->baseID);
  706 + }
  707 + $first = false;
691 708 }
692 709 }
693 710  
... ...