Ignore:
Timestamp:
10/11/10 16:10: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

    r127 r128  
    4545            { 
    4646               string domid = ((*itt)->name.hasValue()) ? (string)(*itt)->name : (*itt)->getId(); 
    47                string lonid = string("lon_").append(domid); 
    48                string latid = string("lat_").append(domid); 
     47               string lonid = (sdom.size() == 1)? string("lon"): string("lon_").append(domid); 
     48               string latid = (sdom.size() == 1)? string("lat"): string("lat_").append(domid); 
    4949               dims[lonid]  = (*itt)->ni; 
    5050               dims[latid]  = (*itt)->nj; 
     
    129129 
    130130            Poco::HashMap<string, string> hm; 
     131            Poco::HashMap<string, float>  hmf; 
    131132 
    132133            const std::set<const CDomain*> sdom = this->getRelFile()->getEnabledDomains(); 
     
    137138            { 
    138139               string domid = ((*itt)->name.hasValue()) ? (string)(*itt)->name : (*itt)->getId(); 
    139                string lonid = string("lon_").append(domid); 
    140                string latid = string("lat_").append(domid); 
     140               string lonid = (sdom.size() == 1)? string("lon"): string("lon_").append(domid); 
     141               string latid = (sdom.size() == 1)? string("lat"): string("lat_").append(domid); 
    141142 
    142143               if (!(latVar = dataFile->add_var(latid.c_str(), ncFloat, dataFile->get_dim(latid.c_str())))) 
     
    151152               hm["units"]         = "degrees_north"; 
    152153               hm["long_name"]     = "Latitude" ; 
    153                this->addStringAttributesToVar(latVar, hm); 
     154               hm["nav_model"]     = domid ; 
     155               if ((*itt)->yvalue.hasValue()) 
     156               { 
     157                  hmf["valid_min"] = ((Array<double, 1>)(*itt)->yvalue)(0); 
     158                  hmf["valid_max"] = ((Array<double, 1>)(*itt)->yvalue)(((Array<double, 1>)(*itt)->yvalue).size()-1); 
     159                  this->addStringAttributesToVar(latVar, hmf); 
     160                  hmf.clear(); 
     161               } 
     162               this->addStringAttributesToVar_str(latVar, hm); 
    154163               hm.clear(); 
    155164 
    156165               // Attribut de longitude. 
    157                hm["axis"]           = "X" ; 
    158                hm["standard_name"]  = "longitude" ; 
    159                hm["units"]          = "degrees_east"; 
    160                hm["long_name"]      = "Longitude" ; 
    161                this->addStringAttributesToVar(lonVar, hm); 
     166               hm["axis"]          = "X" ; 
     167               hm["standard_name"] = "longitude" ; 
     168               hm["units"]         = "degrees_east"; 
     169               hm["long_name"]     = "Longitude" ; 
     170               hm["nav_model"]     = domid ; 
     171               if ((*itt)->xvalue.hasValue()) 
     172               { 
     173                  hmf["valid_min"] = ((Array<double, 1>)(*itt)->xvalue)(0); 
     174                  hmf["valid_max"] = ((Array<double, 1>)(*itt)->xvalue)(((Array<double, 1>)(*itt)->xvalue).size()-1); 
     175                  this->addStringAttributesToVar(lonVar, hmf); 
     176                  hmf.clear(); 
     177               } 
     178               this->addStringAttributesToVar_str(lonVar, hm); 
    162179               hm.clear(); 
    163180 
     
    179196                  throw XMLIOUndefinedValueException("Impossible d'ajouter la variable "+ (*it)->getId() +" !"); 
    180197 
    181                hm["axis"] = "Z" ; 
     198               hm["axis"]     = "Z" ; 
     199               hm["title"]    = axisid ; 
     200               hm["positive"] = "unknown" ; 
     201 
    182202               if ((*it)->standard_name.hasValue())hm["standard_name"] = (*it)->standard_name ; 
    183203               if ((*it)->long_name.hasValue())    hm["long_name"]     = (*it)->long_name ; 
    184204               if ((*it)->unit.hasValue())         hm["units"]         = (*it)->unit; 
    185                this->addStringAttributesToVar(othvar, hm); 
     205               if ((*it)->value.hasValue()) 
     206               { 
     207                  hmf["valid_min"] = ((Array<double, 1>)(*it)->value)(0); 
     208                  hmf["valid_max"] = ((Array<double, 1>)(*it)->value)(((Array<double, 1>)(*it)->value).size()-1); 
     209                  this->addStringAttributesToVar(othvar, hmf); 
     210                  hmf.clear(); 
     211               } 
     212               this->addStringAttributesToVar_str(othvar, hm); 
    186213               hm.clear(); 
    187214 
     
    197224            NcVar *var  = NULL; 
    198225            Poco::HashMap<string, string> hm; 
     226            Poco::HashMap<string, float>  hmf; 
    199227            bool lonlat = false, wtime = true; 
    200228            const std::vector<CField*>& enabledFields = getRelFile()->getEnabledFields(); 
     229            const std::set<const CDomain*> sdom = this->getRelFile()->getEnabledDomains(); 
    201230 
    202231            std::vector<CField*>::const_iterator it; 
     
    204233            for ( it = enabledFields.begin() ; it != enabledFields.end(); it++ ) 
    205234            { 
    206                      CField*  field = (*it); 
    207                const CField* bfield = (*it)->getBaseObject(); 
    208                const CDomain*  rdom = field->getGrid()->getRelDomain(); 
    209                const CAxis*   raxis = field->getGrid()->getRelAxis(); 
     235                     CField  *  field = (*it); 
     236               const CField  * bfield = (*it)->getBaseObject(); 
     237               const CDomain *   rdom = field->getGrid()->getRelDomain(); 
     238               const CAxis   *  raxis = field->getGrid()->getRelAxis(); 
     239               FieldOperation*   fope = field->operation.getValue(); 
     240               Duration      *  ffope = field->freq_op.getValue(); 
    210241 
    211242               string fieldid = (field->name.hasValue()) ? (string)field->name : bfield->getId(); 
     
    213244               string axisid  = (raxis->name.hasValue()) ? (string)raxis->name : raxis ->getId(); 
    214245 
    215                string lonid = string("lon_").append(domid); // Nom de la coordonnée longitudinale associée. 
    216                string latid = string("lat_").append(domid); // Nom de la coordonnée latitudinale  associée. 
     246               string lonid = (sdom.size() == 1)? string("lon"): string("lon_").append(domid); // Nom de la coordonnée longitudinale associée. 
     247               string latid = (sdom.size() == 1)? string("lat"): string("lat_").append(domid); // Nom de la coordonnée latitudinale  associée. 
    217248 
    218249               lonlat = !field->getGrid()->_hasAxis(); 
    219250 
    220                if (field->operation.hasValue()) 
     251 
     252               ////////////////////////////////////// A DEPLACER 
     253               if (fope != NULL) 
    221254               { // Si une opération sur le champ est définie ... 
    222                   if (field->operation.getId().compare("once") == 0) 
     255                  if (fope->getId().compare("once") == 0) 
    223256                  { wtime = false; field->freq_op.setValue(NoneDu); } 
    224257               } 
     
    231264               // Si la fréquence d'opération n'est pas définie, on l'initialise à 0s. 
    232265               // Une fréquence à 0s signifie que l'opération se fera à chaque écriture de données depuis la simulation. 
    233                if (!field->freq_op.hasValue()) 
     266               if (ffope == NULL) 
    234267                  field->freq_op.setValue(NoneDu); 
    235                ((FieldOperation)field->operation).setFreqOp(Duration(field->freq_op)); 
     268 
     269               field->operation.getValue()->setFreqOp(field->freq_op); 
     270               ///////////////////////////////////////////// 
    236271 
    237272               tvar = ncFloat; 
     
    271306               } 
    272307 
    273                if (field->standard_name.hasValue())hm["standard_name"] = field->standard_name ; 
    274                if (field->long_name.hasValue())    hm["long_name"]     = field->long_name ; 
    275                if (field->unit.hasValue())         hm["units"]         = field->unit; 
    276                this->addStringAttributesToVar(var, hm); 
     308               if (field->standard_name.hasValue())hm["standard_name"]     = field->standard_name ; 
     309               if (field->long_name.hasValue())    hm["long_name"]         = field->long_name ; 
     310               if (field->unit.hasValue())         hm["units"]             = field->unit; 
     311 
     312               if (field->operation.hasValue()) 
     313               { 
     314                  hm["online_operation"]   = field->operation.getValue()->getId(); 
     315 
     316                  if (!field->operation.getValue()->getFreqOp().isNone()) 
     317                     hm["interval_operation"] = field->operation.getValue()->getFreqOp().toString(); 
     318                  else 
     319                     hm["interval_operation"] = ((Duration)this->getRelFile()->output_freq).toString(); 
     320               } 
     321               hm["interval_write"] = ((Duration)this->getRelFile()->output_freq).toString(); 
     322 
     323               this->addStringAttributesToVar_str(var, hm); 
    277324               hm.clear(); 
    278325            } 
     
    281328      private : 
    282329 
    283          void addStringAttributesToVar(NcVar * const var, const Poco::HashMap<string, string>& attr) 
     330         template <class U> 
     331            void addStringAttributesToVar(NcVar * const var, const Poco::HashMap<string, U>& attr) 
     332         { 
     333            typename Poco::HashMap<string, U>::ConstIterator it; 
     334 
     335            for ( it = attr.begin() ; it != attr.end(); it++ ) 
     336               if (!var->add_att((*it).first.c_str(), (*it).second)) 
     337                  throw XMLIOUndefinedValueException("Impossible d'ajouter l'attribut' "+ (*it).first +" à la variable "+ var->name() +" !"); 
     338         } 
     339 
     340         void addStringAttributesToVar_str(NcVar * const var, const Poco::HashMap<string, string>& attr) 
    284341         { 
    285342            Poco::HashMap<string, string>::ConstIterator it; 
Note: See TracChangeset for help on using the changeset viewer.