Changeset 125 for XMLIO_V2/dev/dev_rv/src/XMLIO/NetCDF4_data_output.hpp
- Timestamp:
- 10/05/10 09:47:10 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/NetCDF4_data_output.hpp
r124 r125 20 20 protected : 21 21 22 Poco::HashMap<string, int> getAllLimitedDim(void) 22 Poco::HashMap<string, int> getAllLimitedDim(void) const 23 23 { 24 24 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 } 33 40 34 41 std::set<const CAxis*>::const_iterator it; 35 42 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 } 37 47 38 48 return (dims); … … 45 55 { 46 56 time_t rawtime; 47 struct tm * timeinfo ;57 struct tm * timeinfo = NULL; 48 58 char buffer [100]; 49 59 … … 77 87 { 78 88 bool withTime = true; 79 const Poco::HashMap<string, int>& allDim = getAllLimitedDim();89 const Poco::HashMap<string, int>& allDim = this->getAllLimitedDim(); 80 90 Poco::HashMap<string, int>::ConstIterator it; 81 91 … … 99 109 Poco::HashMap<string, string> hm; 100 110 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 } 124 142 125 143 // Attribut des autres coordonnées. … … 127 145 for ( it = saxis.begin() ; it != saxis.end(); it++ ) 128 146 { 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())))) 130 149 throw XMLIOUndefinedValueException("Impossible d'ajouter la variable "+ (*it)->getId() +" !"); 131 150 … … 150 169 for ( it = enabledFields.begin() ; it != enabledFields.end(); it++ ) 151 170 { 152 CField*field = (*it);171 CField* field = (*it); 153 172 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. 154 182 155 183 lonlat = !field->getGrid()->_hasAxis(); … … 158 186 { // Si une opération sur le champ est définie ... 159 187 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); } 164 189 } 165 190 else … … 175 200 ((FieldOperation)field->operation).setFreqOp(Duration(field->freq_op)); 176 201 177 178 202 tvar = ncFloat; 179 203 if (field->prec.hasValue()) … … 184 208 if (lonlat) // 2D spatio + temps 185 209 { 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())))) 188 212 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 189 213 } 190 214 else // 3D spatio + temps 191 215 { 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())))) 195 219 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 196 220 } … … 200 224 if (lonlat) // 2D spatio sans temps 201 225 { 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())))) 204 228 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 205 229 } 206 230 else // 3D spatio sans temps 207 231 { 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())))) 211 235 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 212 236 } … … 221 245 } 222 246 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 223 259 private : 224 260
Note: See TracChangeset
for help on using the changeset viewer.