Changeset 130
- Timestamp:
- 10/12/10 11:42:58 (14 years ago)
- Location:
- XMLIO_V2/dev/dev_rv/src/XMLIO
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/NetCDF4_data_output.hpp
r128 r130 2 2 #define __NETCDF4_DATA_OUTPUT__ 3 3 4 // Entête NetCDF pour le C++. 4 5 #include <netcdfcpp.h> 5 6 … … 82 83 83 84 if (!cVar->put(cdata.dataFirst(), cdata.size())) 84 throw XMLIOUndefinedValueException("Impossible d'écrire les valeurs de coordonnées "+ id +" !"); 85 throw XMLIOUndefinedValueException 86 ("Impossible d'écrire les valeurs de coordonnées "+ id +" !"); 87 } 88 89 void setTimeCoords(void) 90 { 91 NcVar *oVar = NULL; 92 Poco::HashMap<string, string> hm; 93 AbstractCalendar * ccal = Context::GetCurrentContext()->getCalendar(); 94 const std::set<const FieldOperation*> sfo = this->getRelFile()->getEnabledOperation(); 95 std::set<const FieldOperation*>::const_iterator it; 96 97 //std::cout << "Nombre d'opération disponibles pour le fichier : " << sfo.size() << std::endl; 98 99 for ( it = sfo.begin() ; it != sfo.end(); it++ ) 100 { 101 const FieldOperation * const fope = (*it); 102 const Duration& ffope = (*it)->getFreqOp(); 103 ostringstream oss; oss << "t_" << *fope << "_" << ffope; 104 const std::string cid(oss.str()); 105 106 if (!(oVar = dataFile->add_var(cid.c_str(), ncDouble, dataFile->get_dim(TimeName)))) 107 throw XMLIOUndefinedValueException 108 ("Impossible d'ajouter la coordonnée temporelle "+cid+" !"); 109 110 hm ["standard_name"] = "time"; 111 hm ["title"] = "Time"; 112 hm ["long_name"] = "Time axis"; 113 hm ["units"] = string("seconds since ").append(ccal->getInitDate().toString()); //"seconds since 1979-01-01 00:00:00" 114 hm ["calendar"] = ccal->getType(); //"360d" 115 hm ["time_origin"] = ccal->getInitDate().toString();//" 1979-JAN-01 00:00:00" ; 116 this->addStringAttributesToVar_str(oVar, hm); 117 hm.clear(); 118 } 85 119 } 86 120 … … 94 128 dataFile = new NcFile(filename.c_str(), NcFile::Replace); 95 129 if(!dataFile->is_valid()) 96 throw XMLIOUndefinedValueException("Impossible d'ouvrir le fichier '"+ filename +"' pour l'écriture des données' !"); 130 throw XMLIOUndefinedValueException 131 ("Impossible d'ouvrir le fichier '"+ filename +"' pour l'écriture des données' !"); 97 132 98 133 // Ajout de quelques attributs globaux. … … 181 216 if ((*itt)->yvalue.hasValue()) 182 217 this->writeCoords(lonid, (*itt)->xvalue); 183 else throw XMLIOUndefinedValueException("Les coordonnées de longitude (xvalue) ne sont pas définies pour le domaine \""+domid+"\"."); 218 else throw XMLIOUndefinedValueException 219 ("Les coordonnées de longitude (xvalue) ne sont pas définies pour le domaine \""+domid+"\"."); 184 220 185 221 if ((*itt)->xvalue.hasValue()) 186 222 this->writeCoords(latid, (*itt)->yvalue); 187 else throw XMLIOUndefinedValueException("Les coordonnées de latitude (yvalue) ne sont pas définies pour le domaine \""+domid+"\"."); 223 else throw XMLIOUndefinedValueException 224 ("Les coordonnées de latitude (yvalue) ne sont pas définies pour le domaine \""+domid+"\"."); 188 225 } 189 226 … … 215 252 if ((*it)->value.hasValue()) 216 253 this->writeCoords(axisid, (*it)->value); 217 else throw XMLIOUndefinedValueException("Les coordonnées de l'axe \""+axisid+"\" (value) ne sont pas définies."); 218 } 254 else throw XMLIOUndefinedValueException 255 ("Les coordonnées de l'axe \""+axisid+"\" (value) ne sont pas définies."); 256 } 257 258 this->setTimeCoords(); 219 259 } 220 260 … … 233 273 for ( it = enabledFields.begin() ; it != enabledFields.end(); it++ ) 234 274 { 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();275 CField * const field = (*it); 276 const CField * const bfield = (*it)->getBaseObject(); 277 const CDomain * const rdom = field->getGrid()->getRelDomain(); 278 const CAxis * const raxis = field->getGrid()->getRelAxis(); 279 FieldOperation* const fope = field->operation.getValue(); 280 //Duration * const ffope = field->freq_op.getValue(); 241 281 242 282 string fieldid = (field->name.hasValue()) ? (string)field->name : bfield->getId(); … … 244 284 string axisid = (raxis->name.hasValue()) ? (string)raxis->name : raxis ->getId(); 245 285 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. 286 string lonid = (sdom.size() == 1)? string("lon") 287 : string("lon_").append(domid); // Nom de la coordonnée longitudinale associée. 288 string latid = (sdom.size() == 1)? string("lat") 289 : string("lat_").append(domid); // Nom de la coordonnée latitudinale associée. 248 290 249 291 lonlat = !field->getGrid()->_hasAxis(); 250 292 251 252 ////////////////////////////////////// A DEPLACER253 293 if (fope != NULL) 254 { // Si une opération sur le champ est définie ...255 294 if (fope->getId().compare("once") == 0) 256 { wtime = false; field->freq_op.setValue(NoneDu); } 257 } 258 else 259 { // Si aucune opération sur le champ n'est définie ... 260 FieldOperation ope("inst"); 261 field->operation.setValue(ope); 262 } 263 264 // Si la fréquence d'opération n'est pas définie, on l'initialise à 0s. 265 // Une fréquence à 0s signifie que l'opération se fera à chaque écriture de données depuis la simulation. 266 if (ffope == NULL) 267 field->freq_op.setValue(NoneDu); 268 269 field->operation.getValue()->setFreqOp(field->freq_op); 270 ///////////////////////////////////////////// 295 wtime = false; 271 296 272 297 tvar = ncFloat; 273 298 if (field->prec.hasValue()) 274 if (field->prec == 8) tvar = ncDouble; 299 if (field->prec == 8) 300 tvar = ncDouble; 275 301 276 302 if (wtime) -
XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_calendar.hpp
r127 r130 19 19 return (out); 20 20 } 21 22 virtual string getType(void) const { return (string(this->getId())); } 21 23 22 24 const Date& getInitDate(void) const { return(initDate); } -
XMLIO_V2/dev/dev_rv/src/XMLIO/calendar.hpp
r127 r130 27 27 return (AbstractCalendar::getMonthLength(_d)); 28 28 } 29 30 virtual string getType(void) const { return (string("julian")); } 29 31 30 32 virtual ~JulianCalendar() … … 63 65 } 64 66 67 virtual string getType(void) const { return (string("gregorian")); } 68 65 69 virtual ~GregorianCalendar() 66 70 {/* Ne rien faire de plus */} … … 76 80 NoLeapCalendar(const string& dateStr) : AbstractCalendar("NoLeap", dateStr) 77 81 {/* Ne rien faire de plus */} 82 83 virtual string getType(void) const { return (string("noleap")); } 78 84 79 85 virtual ~NoLeapCalendar() … … 98 104 virtual int getYearTotalLength(const Date& d) const { return (366 * 86400); } 99 105 106 virtual string getType(void) const { return (string("allleap")); } 107 100 108 virtual ~AllLeapCalendar() 101 109 {/* Ne rien faire de plus */} … … 117 125 virtual int getMonthLength(const Date& d) const { return (30); } 118 126 127 virtual string getType(void) const { return (string("360d")); } 128 119 129 virtual ~D360Calendar() 120 130 {/* Ne rien faire de plus */} -
XMLIO_V2/dev/dev_rv/src/XMLIO/data_treatment.hpp
r128 r130 97 97 this->solveAllGridRef(); 98 98 99 // Traitement des opérations. 100 this->solveAllOperation(); 101 99 102 //std::cout << "(Message temporaire) fin traitement sorties ..." << std::endl; 100 103 } … … 114 117 for (unsigned int i = 0; i < enabledFiles.size(); i++) 115 118 enabledFiles[i]->solveEFGridRef(); 119 } 120 121 void solveAllOperation(void) 122 { 123 for (unsigned int i = 0; i < enabledFiles.size(); i++) 124 enabledFiles[i]->solveEFOperation(); 116 125 } 117 126 -
XMLIO_V2/dev/dev_rv/src/XMLIO/date.hpp
r127 r130 32 32 } 33 33 34 operator Time(void); // Retourne le nombre de secondes écoulées depuis la date initiale définie dans le calendrier.34 operator Time(void); // Retourne le nombre de secondes écoulées depuis la date initiale définie dans le calendrier. 35 35 bool checkDate(void); // Vérifie la validité de la date. 36 37 std::string toString(void) const 38 { std::ostringstream oss; oss << (*this); return (string(oss.str())); } 36 39 37 40 friend std::ostream& operator<<(std::ostream& out, const Date& d) … … 72 75 const AbstractCalendar& getRelCalendar(void) const { return (relCalendar); } 73 76 74 ~Date( )77 ~Date(void) 75 78 {/* Ne rien faire de plus */} 76 79 -
XMLIO_V2/dev/dev_rv/src/XMLIO/duration.hpp
r128 r130 19 19 } 20 20 21 friend std::ostream& operator<<(std::ostream& out, const struct _duration& d)21 friend std::ostream& operator<<(std::ostream& _out, const struct _duration& d) 22 22 { 23 std::ostringstream out; 23 24 bool testValue = true; 24 25 if(d.year != 0.0) { testValue = false; out << d.year << "y " ; } … … 28 29 if(d.minute != 0.0) { testValue = false; out << d.minute << "mi "; } 29 30 if(d.second != 0.0 || testValue) { out << d.second << "s " ; } 30 return (out); 31 32 _out << (out.str().substr(0, out.str().size()-1)); // << suppression de l'espace en fin de chaîne. 33 return (_out); 31 34 } 32 35 -
XMLIO_V2/dev/dev_rv/src/XMLIO/field.hpp
r128 r130 40 40 data.resize(shape(arr.size())) ; 41 41 data = arr; 42 } 43 44 void solveOperation(void) 45 { 46 FieldOperation* fope = this->operation.getValue(); 47 Duration * ffope = this->freq_op.getValue(); 48 49 if (fope != NULL) 50 { // Si une opération sur le champ est définie ... 51 if (fope->getId().compare("once") == 0) 52 this->freq_op.setValue(NoneDu); 53 } 54 else 55 { // Si aucune opération sur le champ n'est définie ... 56 FieldOperation ope("inst"); 57 this->operation.setValue(ope); 58 } 59 60 // Si la fréquence d'opération n'est pas définie, on l'initialise à 0s. 61 // Une fréquence à 0s signifie que l'opération se fera à chaque écriture de données depuis la simulation. 62 if (ffope == NULL) 63 this->freq_op.setValue(NoneDu); 64 65 this->operation.getValue()->setFreqOp(this->freq_op); 42 66 } 43 67 -
XMLIO_V2/dev/dev_rv/src/XMLIO/file.hpp
r128 r130 11 11 public: 12 12 13 CFile(void) : ObjectTemplate<CFile>(), FileAttribut(), vfieldGroup(NULL), enabledFields(), output(NULL)14 {/* Ne rien faire de plus */}15 CFile(const string& _id) : ObjectTemplate<CFile>(_id), FileAttribut(),vfieldGroup(NULL), enabledFields(), output(NULL)16 { /* Ne rien faire de plus */}13 CFile(void) 14 : ObjectTemplate<CFile>(), FileAttribut(), 15 vfieldGroup(NULL), enabledFields(), output(NULL) 16 { /* Ne rien faire de plus */ } 17 17 18 AbstractDataOutput* getDataOutput(void) const { return (output); } 18 CFile(const string& _id) 19 : ObjectTemplate<CFile>(_id), FileAttribut(), 20 vfieldGroup(NULL), enabledFields(), output(NULL) 21 { /* Ne rien faire de plus */ } 22 23 AbstractDataOutput* getDataOutput (void) const { return (output); } 24 FieldGroup* getVirtualFieldGroup(void) const { return (vfieldGroup); } 25 const std::vector<CField*>& getEnabledFields (void) const { return (enabledFields); } 26 19 27 void initializeDataOutput(AbstractDataOutput* _output) 20 28 { 21 29 if (_output != NULL) output = _output; 22 else throw XMLIOSERVER::XMLIOUndefinedValueException("Impossible d'initialiser la sortie de données pour le fichier nommé '"+ getId() +"'.") ; 30 else throw XMLIOSERVER::XMLIOUndefinedValueException 31 ("Impossible d'initialiser la sortie de données pour le fichier nommé '"+ getId() +"'.") ; 23 32 } 24 33 25 void getAllFields(std::vector<CField*>& _allF) const { if (vfieldGroup!=NULL) vfieldGroup->getAllChildren(_allF); }26 const std::vector<CField*>& getEnabledFields(void) const { return (enabledFields); }34 void getAllFields(std::vector<CField*>& _allF) const 35 { if (vfieldGroup!=NULL) vfieldGroup->getAllChildren(_allF); } 27 36 28 37 const std::set<const CGrid*> getEnabledGrids(void) const … … 46 55 for ( it = enabledFields.begin() ; it != enabledFields.end(); it++ ) 47 56 if ((*it)->operation.hasValue()) 48 sope.insert(( FieldOperation*)&(*it)->operation);57 sope.insert((*it)->operation.getValue()); 49 58 50 59 return (sope); … … 55 64 const std::set<const CGrid*> sgrid = this->getEnabledGrids(); 56 65 std::set<const CDomain*> sdomain; 57 58 66 std::set<const CGrid*>::const_iterator it; 59 67 … … 68 76 const std::set<const CGrid*> sgrid = this->getEnabledGrids(); 69 77 std::set<const CAxis*> saxis; 70 71 78 std::set<const CGrid*>::const_iterator it; 72 79 … … 80 87 { // Résolution des héritages par référence de chacun des champs contenus dans le fichier. 81 88 std::vector<CField*> allF; this->getAllFields(allF); 82 for (unsigned int i = 0; i < allF.size(); i++) allF[i]->solveRefInheritance(); 89 for (unsigned int i = 0; i < allF.size(); i++) 90 allF[i]->solveRefInheritance(); 83 91 } 84 92 85 FieldGroup* getVirtualFieldGroup(void) const { return (vfieldGroup); } 86 87 void findEnabledFields(const Date& inidate, int default_outputlevel = 5, int default_level = 1, bool default_enabled = true ) 93 void findEnabledFields(const Date& inidate, 94 int default_outputlevel = 5, int default_level = 1, bool default_enabled = true ) 88 95 { 89 96 const int _outputlevel = (output_level.hasValue()) ? (int)output_level : default_outputlevel; … … 128 135 for (unsigned int i = 0; i < enabledFields.size(); i++) 129 136 enabledFields[i]->solveGridRef(); 137 } 138 139 void solveEFOperation(void) 140 { 141 for (unsigned int i = 0; i < enabledFields.size(); i++) 142 enabledFields[i]->solveOperation(); 130 143 } 131 144
Note: See TracChangeset
for help on using the changeset viewer.