Ignore:
Timestamp:
10/05/10 09:47:10 (14 years ago)
Author:
hozdoba
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/dev_rv/src/XMLIO/NetCDF4_data_output.hpp

    r124 r125  
    2020      protected : 
    2121 
    22          Poco::HashMap<string, int> getAllLimitedDim(void) 
     22         Poco::HashMap<string, int> getAllLimitedDim(void) const 
    2323         { 
    2424            Poco::HashMap<string, int> dims; 
    25             const std::set<const CDomain*> sdom = getRelFile()->getEnabledDomains(); 
    26             const std::set<const CAxis*> saxis = getRelFile()->getEnabledAxis(); 
    27  
    28             const CDomain* pdom = *sdom.begin(); 
    29  
    30             // TODO Améliorer ci-dessous -> un seul domaine pris en compte pour le moment 
    31             dims["lon"] = pdom->nj; 
    32             dims["lat"] = pdom->ni; 
     25            const std::set<const CDomain*> sdom = this->getRelFile()->getEnabledDomains(); 
     26            const std::set<const CAxis*>  saxis = this->getRelFile()->getEnabledAxis(); 
     27 
     28            // std::cout << "Nombre de domaines disponibles pour le fichier : " << sdom.size() << std::endl; 
     29            // std::cout << "Nombre d'axes disponibles pour le fichier : " << saxis.size() << std::endl; 
     30 
     31            std::set<const CDomain*>::const_iterator itt; 
     32            for ( itt = sdom.begin() ; itt != sdom.end(); itt++ ) 
     33            { 
     34               string domid = ((*itt)->name.hasValue()) ? (string)(*itt)->name : (*itt)->getId(); 
     35               string lonid = string("lon_").append(domid); 
     36               string latid = string("lat_").append(domid); 
     37               dims[lonid]  = (*itt)->ni; 
     38               dims[latid]  = (*itt)->nj; 
     39            } 
    3340 
    3441            std::set<const CAxis*>::const_iterator it; 
    3542            for ( it = saxis.begin() ; it != saxis.end(); it++ ) 
    36                dims[(*it)->getId()] = (*it)->size; 
     43            { 
     44               string axisid = ((*it)->name.hasValue()) ? (string)(*it)->name : (*it)->getId(); 
     45               dims[axisid]  = (*it)->size; 
     46            } 
    3747 
    3848            return (dims); 
     
    4555         { 
    4656              time_t rawtime; 
    47               struct tm * timeinfo; 
     57              struct tm * timeinfo = NULL; 
    4858              char buffer [100]; 
    4959 
     
    7787         { 
    7888            bool withTime = true; 
    79             const Poco::HashMap<string, int>& allDim = getAllLimitedDim(); 
     89            const Poco::HashMap<string, int>& allDim = this->getAllLimitedDim(); 
    8090            Poco::HashMap<string, int>::ConstIterator it; 
    8191 
     
    99109            Poco::HashMap<string, string> hm; 
    100110 
    101             const std::set<const CDomain*> sdom = getRelFile()->getEnabledDomains(); 
    102             const std::set<const CAxis*> saxis = getRelFile()->getEnabledAxis(); 
    103  
    104             if (!(latVar = dataFile->add_var("lat", ncFloat, dataFile->get_dim("lat")))) 
    105                throw XMLIOUndefinedValueException("Impossible d'ajouter la variable de latitude !"); 
    106             if (!(lonVar = dataFile->add_var("lon", ncFloat, dataFile->get_dim("lon")))) 
    107                throw XMLIOUndefinedValueException("Impossible d'ajouter la variable de longitude !"); 
    108  
    109             // Attribut de latitude. 
    110             hm["axis"]          = "Y" ; 
    111             hm["standard_name"] = "latitude" ; 
    112             hm["units"]         = "degrees_north"; 
    113             hm["long_name"]     = "Latitude" ; 
    114             addStringAttributesToVar(latVar, hm); 
    115             hm.clear(); 
    116  
    117             // Attribut de longitude. 
    118             hm["axis"]           = "X" ; 
    119             hm["standard_name"]  = "longitude" ; 
    120             hm["units"]          = "degrees_east"; 
    121             hm["long_name"]      = "Longitude" ; 
    122             addStringAttributesToVar(lonVar, hm); 
    123             hm.clear(); 
     111            const std::set<const CDomain*> sdom = this->getRelFile()->getEnabledDomains(); 
     112            const std::set<const CAxis*>  saxis = this->getRelFile()->getEnabledAxis(); 
     113 
     114            std::set<const CDomain*>::const_iterator itt; 
     115            for ( itt = sdom.begin() ; itt != sdom.end(); itt++ ) 
     116            { 
     117               string domid = ((*itt)->name.hasValue()) ? (string)(*itt)->name : (*itt)->getId(); 
     118               string lonid = string("lon_").append(domid); 
     119               string latid = string("lat_").append(domid); 
     120 
     121               if (!(latVar = dataFile->add_var(latid.c_str(), ncFloat, dataFile->get_dim(latid.c_str())))) 
     122                  throw XMLIOUndefinedValueException("Impossible d'ajouter la variable de latitude !"); 
     123               if (!(lonVar = dataFile->add_var(lonid.c_str(), ncFloat, dataFile->get_dim(lonid.c_str())))) 
     124                  throw XMLIOUndefinedValueException("Impossible d'ajouter la variable de longitude !"); 
     125 
     126               // Attribut de latitude. 
     127               hm["axis"]          = "Y" ; 
     128               hm["standard_name"] = "latitude" ; 
     129               hm["units"]         = "degrees_north"; 
     130               hm["long_name"]     = "Latitude" ; 
     131               addStringAttributesToVar(latVar, hm); 
     132               hm.clear(); 
     133 
     134               // Attribut de longitude. 
     135               hm["axis"]           = "X" ; 
     136               hm["standard_name"]  = "longitude" ; 
     137               hm["units"]          = "degrees_east"; 
     138               hm["long_name"]      = "Longitude" ; 
     139               addStringAttributesToVar(lonVar, hm); 
     140               hm.clear(); 
     141            } 
    124142 
    125143            // Attribut des autres coordonnées. 
     
    127145            for ( it = saxis.begin() ; it != saxis.end(); it++ ) 
    128146            { 
    129                if (!(othvar = dataFile->add_var((*it)->getId().c_str(), ncFloat, dataFile->get_dim((*it)->getId().c_str())))) 
     147               string axisid = ((*it)->name.hasValue()) ? (string)(*it)->name : (*it)->getId(); 
     148               if (!(othvar = dataFile->add_var(axisid.c_str(), ncFloat, dataFile->get_dim(axisid.c_str())))) 
    130149                  throw XMLIOUndefinedValueException("Impossible d'ajouter la variable "+ (*it)->getId() +" !"); 
    131150 
     
    150169            for ( it = enabledFields.begin() ; it != enabledFields.end(); it++ ) 
    151170            { 
    152                CField* field = (*it); 
     171                     CField* field = (*it); 
    153172               const CField* bfield = (*it)->getBaseObject(); 
     173               const CDomain*  rdom = field->getGrid()->getRelDomain(); 
     174               const CAxis*   raxis = field->getGrid()->getRelAxis(); 
     175 
     176               string fieldid = (field->name.hasValue()) ? (string)field->name : bfield->getId(); 
     177               string domid   = (rdom ->name.hasValue()) ? (string)rdom ->name : rdom  ->getId(); 
     178               string axisid  = (raxis->name.hasValue()) ? (string)raxis->name : raxis ->getId(); 
     179 
     180               string lonid = string("lon_").append(domid); // Nom de la coordonnée longitudinale associée. 
     181               string latid = string("lat_").append(domid); // Nom de la coordonnée latitudinale  associée. 
    154182 
    155183               lonlat = !field->getGrid()->_hasAxis(); 
     
    158186               { // Si une opération sur le champ est définie ... 
    159187                  if (field->operation.getId().compare("once") == 0) 
    160                   { 
    161                      wtime = false; 
    162                      field->freq_op.setValue(NoneDu); 
    163                   } 
     188                  { wtime = false; field->freq_op.setValue(NoneDu); } 
    164189               } 
    165190               else 
     
    175200               ((FieldOperation)field->operation).setFreqOp(Duration(field->freq_op)); 
    176201 
    177  
    178202               tvar = ncFloat; 
    179203               if (field->prec.hasValue()) 
     
    184208                  if (lonlat) // 2D spatio + temps 
    185209                  { 
    186                      if (!(var = dataFile->add_var(bfield->getId().c_str(), tvar, 
    187                         dataFile->get_dim("time"), dataFile->get_dim("lon"), dataFile->get_dim("lat")))) 
     210                     if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 
     211                        dataFile->get_dim("time"), dataFile->get_dim(lonid.c_str()), dataFile->get_dim(latid.c_str())))) 
    188212                        throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 
    189213                  } 
    190214                  else // 3D spatio + temps 
    191215                  { 
    192                      if (!(var = dataFile->add_var(bfield->getId().c_str(), tvar, 
    193                         dataFile->get_dim("time"), dataFile->get_dim("lon"), dataFile->get_dim("lat"), 
    194                         dataFile->get_dim(field->getGrid()->getRelAxis()->getId().c_str())))) 
     216                     if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 
     217                        dataFile->get_dim("time"), dataFile->get_dim(lonid.c_str()), dataFile->get_dim(latid.c_str()), 
     218                        dataFile->get_dim(axisid.c_str())))) 
    195219                        throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 
    196220                  } 
     
    200224                  if (lonlat) // 2D spatio sans temps 
    201225                  { 
    202                      if (!(var = dataFile->add_var(bfield->getId().c_str(), tvar, 
    203                         dataFile->get_dim("lon"), dataFile->get_dim("lat")))) 
     226                     if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 
     227                        dataFile->get_dim(lonid.c_str()), dataFile->get_dim(latid.c_str())))) 
    204228                        throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 
    205229                  } 
    206230                  else // 3D spatio sans temps 
    207231                  { 
    208                      if (!(var = dataFile->add_var(bfield->getId().c_str(), tvar, 
    209                         dataFile->get_dim("lon"), dataFile->get_dim("lat"), 
    210                         dataFile->get_dim(field->getGrid()->getRelAxis()->getId().c_str())))) 
     232                     if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 
     233                        dataFile->get_dim(lonid.c_str()), dataFile->get_dim(latid.c_str()), 
     234                        dataFile->get_dim(axisid.c_str())))) 
    211235                        throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 
    212236                  } 
     
    221245         } 
    222246 
     247         virtual void writeCoords(const string& id, const Array<float, 1>& cdata) 
     248         { 
     249            //if (!latVar->put(lats, NLAT)) 
     250            //   return NC_ERR; 
     251         } 
     252 
     253         virtual void writeVarData(const string& id, const Array<float, 1>& vdata) 
     254         { 
     255            //if (!latVar->put(lats, NLAT)) 
     256            //   return NC_ERR; 
     257         } 
     258 
    223259      private : 
    224260 
Note: See TracChangeset for help on using the changeset viewer.