Commit c2e1eb0f361629f2ee4007993f26486cb4b8223b

Authored by Erdogan Furkan
1 parent 5631534a

More compliant now

src/Info/ParamTable.cc
... ... @@ -396,6 +396,7 @@ namespace AMDA {
396 396 }
397 397 bound.min = std::min(boundsValues[index], boundsValues[index + 1]);
398 398 bound.max = std::max(boundsValues[index], boundsValues[index + 1]);
  399 + bound.center = (bound.min + bound.max) /2.;
399 400  
400 401 return bound;
401 402 }
... ... @@ -445,7 +446,7 @@ namespace AMDA {
445 446 bound.min = NAN;
446 447 bound.max = NAN;
447 448 }
448   -
  449 + bound.center = centersValues[index];
449 450 return bound;
450 451 }
451 452  
... ... @@ -496,7 +497,7 @@ namespace AMDA {
496 497 bound.min = NAN;
497 498 bound.max = NAN;
498 499 }
499   -
  500 + bound.center = centersValues[index];
500 501 return bound;
501 502 }
502 503  
... ... @@ -544,6 +545,7 @@ namespace AMDA {
544 545 bound.min = 1.0/((1.0/_centersValues[index]+ 1.0/_centersValues[index+1])/2);
545 546 bound.max = 1.0/((1.0/_centersValues[index]+ 1.0/_centersValues[index-1])/2);
546 547 }
  548 + bound.center = _centersValues[index];
547 549 return bound;
548 550 }
549 551  
... ... @@ -655,6 +657,7 @@ namespace AMDA {
655 657 bound.min = pow(10,bound.min);
656 658 bound.max = pow(10,bound.max);
657 659 }
  660 + bound.center = centersValues[index];
658 661  
659 662 return bound;
660 663 }
... ... @@ -698,6 +701,8 @@ namespace AMDA {
698 701 bound.min = std::min(minValues[index], maxValues[index]);
699 702 bound.max = std::max(minValues[index], maxValues[index]);
700 703  
  704 + bound.center = (bound.min + bound.max)/2.;
  705 +
701 706 return bound;
702 707 }
703 708  
... ...
src/Info/ParamTable.hh
... ... @@ -32,6 +32,7 @@ namespace AMDA {
32 32 int index;
33 33 double min;
34 34 double max;
  35 + double center;
35 36 } t_TableBound;
36 37  
37 38 /**
... ...
src/InternLib/ParamTableOperation.hh
... ... @@ -255,7 +255,7 @@ public:
255 255 std::vector<double> tab1DData(size);
256 256 for (int i = 0; i < size; ++i) {
257 257 AMDA::Info::t_TableBound bound = _processParamTable.getParamTable()->getBound(&_processParamTable.getParameterManager(), i, &paramsTableData);
258   - tab1DData[i] = (bound.min+bound.max)/2.;
  258 + tab1DData[i] = bound.center;
259 259 }
260 260 _paramOutput->pushTime(time);
261 261 _paramOutput->push(tab1DData);
... ...
src/ParamOutputImpl/Download/FileWriterCDF.cc
... ... @@ -20,6 +20,7 @@
20 20 #include <limits.h>
21 21 #include <float.h>
22 22 #include <boost/cast.hpp>
  23 +#include <boost/filesystem.hpp>
23 24  
24 25 namespace AMDA
25 26 {
... ... @@ -79,6 +80,11 @@ namespace AMDA
79 80 // remove old file if exist
80 81 remove(filePath.c_str());
81 82  
  83 + // get File Name for Global attributes
  84 +
  85 + boost::filesystem::path p(filePath);
  86 + _fileName = p.filename().c_str() ;
  87 +
82 88 // CDFcreateCDF add automatically ".cdf" extension
83 89 status = CDFcreateCDF((char *)filePath.c_str(), &_cdfid);
84 90  
... ... @@ -92,6 +98,7 @@ namespace AMDA
92 98 {
93 99 if (!createCDFVar(CDF_TIME_VAR, DT_TIME, 1, 1, _cdfVarMap[CDF_TIME_VAR]))
94 100 return false;
  101 + writeTimeInfo();
95 102 }
96 103  
97 104 return addCDFParameter(paramProp->getOutputId(), indexList, type, dim1Size, dim2Size, isTableParam);
... ... @@ -433,6 +440,34 @@ namespace AMDA
433 440 return (status == CDF_OK);
434 441 }
435 442  
  443 + bool FileWriterCDF::addAttribute(std::string attName, double attVal,
  444 + long scope, long varNum)
  445 + {
  446 + boost::mutex::scoped_lock scoped_lock(ParameterManager::mutexCDFLib);
  447 + if (_cdfid == NULL)
  448 + return false;
  449 +
  450 + CDFstatus status;
  451 +
  452 + long attNum = CDFgetAttrNum(_cdfid, (char *)attName.c_str());
  453 +
  454 + if (attNum < 0)
  455 + {
  456 + status = CDFcreateAttr(_cdfid, (char *)attName.c_str(), scope, &attNum);
  457 +
  458 + if (status != CDF_OK)
  459 + return false;
  460 + }
  461 +
  462 + if (scope == GLOBAL_SCOPE)
  463 + status = CDFputAttrgEntry(_cdfid, attNum, 0, CDF_DOUBLE, 1, (void *)&attVal);
  464 + else
  465 + status = CDFputAttrzEntry(_cdfid, attNum, varNum, CDF_DOUBLE, 1, (void *)&attVal);
  466 +
  467 + return (status == CDF_OK);
  468 + }
  469 +
  470 +
436 471 bool FileWriterCDF::writeTimeData(std::string /* paramId */, double data, OutputFormatTime /* timeFormat */, bool isFirstParam)
437 472 {
438 473 if (_cdfid == NULL)
... ... @@ -486,6 +521,7 @@ namespace AMDA
486 521 }
487 522 }
488 523 }
  524 + void FileWriterCDF::writeTimeInfo() {}
489 525  
490 526 bool FileWriterCDF::writeOneData(std::string paramId, int varIndex, void *data)
491 527 {
... ...
src/ParamOutputImpl/Download/FileWriterCDF.hh
... ... @@ -196,6 +196,12 @@ namespace AMDA
196 196 long scope, long varNum = 0);
197 197  
198 198 /*
  199 + * @brief Add an attribute in the CDF file
  200 + */
  201 + bool addAttribute(std::string attName, double attVal,
  202 + long scope, long varNum = 0);
  203 +
  204 + /*
199 205 * @brief Write mission info attributes in the CDF file
200 206 */
201 207 bool writeMissionInfo(MissionInfoSPtr missionInfo, long varNum);
... ... @@ -220,6 +226,8 @@ namespace AMDA
220 226 */
221 227 bool writeTableParamsInfo(std::vector<std::string> tableParams, int level);
222 228  
  229 + virtual void writeTimeInfo();
  230 +
223 231 /*
224 232 * @brief CDF identifier
225 233 */
... ... @@ -229,6 +237,9 @@ namespace AMDA
229 237 */
230 238 std::map<std::string, ParamCDFVar> _cdfVarMap;
231 239  
  240 +
  241 + std::string _fileName;
  242 +
232 243 private:
233 244  
234 245  
... ...
src/ParamOutputImpl/Download/FileWriterCDFISTP.cc
... ... @@ -42,6 +42,47 @@ namespace AMDA {
42 42 void FileWriterCDFISTP::addInfoInMap(std::string key, std::string value){
43 43 _infoMap.push_back(std::pair<std::string,std::string>(key,value));
44 44 }
  45 +
  46 + bool FileWriterCDFISTP::writeAMDAInfo(std::string version, std::string createdby, std::string acknowledgement)
  47 + {
  48 + addAttribute("Data_type", createdby, GLOBAL_SCOPE);
  49 + addAttribute("Data_version", version, GLOBAL_SCOPE);
  50 + addAttribute("Acknowledgement", acknowledgement, GLOBAL_SCOPE);
  51 + return true;
  52 + }
  53 +
  54 + bool FileWriterCDFISTP::writeRequestInfo(std::string structure, std::string /* timeFormat */,
  55 + int timeResolution, std::string outputParams, std::string ttName)
  56 + {
  57 +
  58 + addAttribute("Descriptor", outputParams, GLOBAL_SCOPE);
  59 + addAttribute("Instrument_type", "ToDo", GLOBAL_SCOPE);
  60 + addAttribute("Logical_file_id", _fileName, GLOBAL_SCOPE);
  61 + addAttribute("Logical_source", _fileName, GLOBAL_SCOPE);
  62 + addAttribute("Logical_source_description", _fileName, GLOBAL_SCOPE);
  63 + addAttribute("Mission_group", "ToDo", GLOBAL_SCOPE);
  64 + addAttribute("PI_affiliation", "CDPP", GLOBAL_SCOPE);
  65 + addAttribute("PI_name", "AMDA", GLOBAL_SCOPE);
  66 + addAttribute("Project", "AMDA", GLOBAL_SCOPE);
  67 + addAttribute("Source_name", "AMDA", GLOBAL_SCOPE);
  68 + addAttribute("TEXT", "ToDo", GLOBAL_SCOPE);
  69 +
  70 +
  71 + addAttribute(REQUEST_STRUCTURE, structure, GLOBAL_SCOPE);
  72 + return true;
  73 + }
  74 +
  75 + void FileWriterCDFISTP::writeTimeInfo()
  76 + {
  77 + int varNum = _cdfVarMap[CDF_TIME_VAR].varNum;
  78 +
  79 + addAttribute("CATDESC", "Time", VARIABLE_SCOPE, varNum);
  80 + addAttribute("FIELDNAM", "Time", VARIABLE_SCOPE, varNum);
  81 + addAttribute("FORMAT", "ToDo", VARIABLE_SCOPE, varNum);
  82 + addAttribute("VAR_TYPE", "support_data", VARIABLE_SCOPE, varNum);
  83 + addAttribute("UNITS", "ToDo", VARIABLE_SCOPE, varNum);
  84 + addAttribute("TIME_BASE", "ToDO", VARIABLE_SCOPE, varNum);
  85 + }
45 86 void FileWriterCDFISTP::writeParamVariableAttributes(ParamInfoSPtr paramInfo, std::string paramId)
46 87 {
47 88 int varNum = _cdfVarMap[paramId].varNum;
... ... @@ -54,8 +95,9 @@ namespace AMDA {
54 95  
55 96  
56 97 addInfoInMap("FIELDNAM", paramInfo->getShortName());
57   - addInfoInMap("FILLVAL", std::to_string(paramInfo->getFillValue()));
58   - //addInfoInMap("FORMAT", "ToDo");
  98 + addAttribute("FILLVAL", paramInfo->getFillValue(), VARIABLE_SCOPE, varNum);
  99 + //addInfoInMap("FILLVAL", std::to_string(paramInfo->getFillValue()));
  100 + addInfoInMap("FORMAT", "ToDo");
59 101 //addInfoInMap("FORM_PTR", "time_series");
60 102 addInfoInMap("LABLAXIS", paramInfo->getShortName());
61 103 //addInfoInMap("LABL_PTR_1", "ToDo");
... ... @@ -67,8 +109,8 @@ namespace AMDA {
67 109 addInfoInMap("TENSOR_FRAME", paramInfo->getCoordinatesSystem());
68 110 addInfoInMap("TENSOR_ORDER", std::to_string(paramInfo->getTensorOrder()));
69 111 addInfoInMap("UNITS", paramInfo->getUnits());
70   - addInfoInMap("VALID_MIN", _cdfVarMap[paramId].validMin);
71   - addInfoInMap("VALID_MAX", _cdfVarMap[paramId].validMax);
  112 + addInfoInMap("VALIDMIN", _cdfVarMap[paramId].validMin);
  113 + addInfoInMap("VALIDMAX", _cdfVarMap[paramId].validMax);
72 114 //addInfoInMap("VALUE_TYPE", "ToDo");
73 115 if (_cdfVarMap[paramId].isTableParam)
74 116 addInfoInMap("VAR_TYPE", "support_data");
... ...
src/ParamOutputImpl/Download/FileWriterCDFISTP.hh
... ... @@ -52,10 +52,10 @@ namespace AMDA {
52 52  
53 53  
54 54 bool writeTableParamsInfo(std::map<int, boost::shared_ptr<ParamTable>> &dependTables,std::string currentParamId);
55   - //bool writeAMDAInfo(std::string version, std::string createdby, std::string acknowledgement){return true;}
56   - //bool writeRequestInfo(std::string structure, std::string /* timeFormat */,
57   - // int timeResolution, std::string outputParams, std::string ttName)
58   - // {return true;}
  55 + bool writeAMDAInfo(std::string version, std::string createdby, std::string acknowledgement);
  56 + bool writeRequestInfo(std::string structure, std::string timeFormat,
  57 + int timeResolution, std::string outputParams, std::string ttName);
  58 +
59 59 bool writeParamsInfo(ParamPropertiesList &paramPropertiesList, OutputStructure outputStructure,
60 60 std::string currentParamId);
61 61  
... ... @@ -63,6 +63,8 @@ namespace AMDA {
63 63  
64 64 void writeParamVariableAttributes(ParamInfoSPtr ParamInfo, std::string paramId);
65 65  
  66 + void writeTimeInfo();
  67 +
66 68 protected:
67 69  
68 70 //bool addCDFParameter(std::string outputId, AMDA::Common::ParameterIndexComponentList &indexList,
... ...