Changeset 128 for XMLIO_V2/dev/dev_rv/src/XMLIO/NetCDF4_data_output.hpp
- Timestamp:
- 10/11/10 16:10:10 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/NetCDF4_data_output.hpp
r127 r128 45 45 { 46 46 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); 49 49 dims[lonid] = (*itt)->ni; 50 50 dims[latid] = (*itt)->nj; … … 129 129 130 130 Poco::HashMap<string, string> hm; 131 Poco::HashMap<string, float> hmf; 131 132 132 133 const std::set<const CDomain*> sdom = this->getRelFile()->getEnabledDomains(); … … 137 138 { 138 139 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); 141 142 142 143 if (!(latVar = dataFile->add_var(latid.c_str(), ncFloat, dataFile->get_dim(latid.c_str())))) … … 151 152 hm["units"] = "degrees_north"; 152 153 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); 154 163 hm.clear(); 155 164 156 165 // 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); 162 179 hm.clear(); 163 180 … … 179 196 throw XMLIOUndefinedValueException("Impossible d'ajouter la variable "+ (*it)->getId() +" !"); 180 197 181 hm["axis"] = "Z" ; 198 hm["axis"] = "Z" ; 199 hm["title"] = axisid ; 200 hm["positive"] = "unknown" ; 201 182 202 if ((*it)->standard_name.hasValue())hm["standard_name"] = (*it)->standard_name ; 183 203 if ((*it)->long_name.hasValue()) hm["long_name"] = (*it)->long_name ; 184 204 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); 186 213 hm.clear(); 187 214 … … 197 224 NcVar *var = NULL; 198 225 Poco::HashMap<string, string> hm; 226 Poco::HashMap<string, float> hmf; 199 227 bool lonlat = false, wtime = true; 200 228 const std::vector<CField*>& enabledFields = getRelFile()->getEnabledFields(); 229 const std::set<const CDomain*> sdom = this->getRelFile()->getEnabledDomains(); 201 230 202 231 std::vector<CField*>::const_iterator it; … … 204 233 for ( it = enabledFields.begin() ; it != enabledFields.end(); it++ ) 205 234 { 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(); 210 241 211 242 string fieldid = (field->name.hasValue()) ? (string)field->name : bfield->getId(); … … 213 244 string axisid = (raxis->name.hasValue()) ? (string)raxis->name : raxis ->getId(); 214 245 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. 217 248 218 249 lonlat = !field->getGrid()->_hasAxis(); 219 250 220 if (field->operation.hasValue()) 251 252 ////////////////////////////////////// A DEPLACER 253 if (fope != NULL) 221 254 { // Si une opération sur le champ est définie ... 222 if (f ield->operation.getId().compare("once") == 0)255 if (fope->getId().compare("once") == 0) 223 256 { wtime = false; field->freq_op.setValue(NoneDu); } 224 257 } … … 231 264 // Si la fréquence d'opération n'est pas définie, on l'initialise à 0s. 232 265 // 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) 234 267 field->freq_op.setValue(NoneDu); 235 ((FieldOperation)field->operation).setFreqOp(Duration(field->freq_op)); 268 269 field->operation.getValue()->setFreqOp(field->freq_op); 270 ///////////////////////////////////////////// 236 271 237 272 tvar = ncFloat; … … 271 306 } 272 307 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); 277 324 hm.clear(); 278 325 } … … 281 328 private : 282 329 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) 284 341 { 285 342 Poco::HashMap<string, string>::ConstIterator it;
Note: See TracChangeset
for help on using the changeset viewer.