Ignore:
Timestamp:
09/29/15 14:17:42 (9 years ago)
Author:
rlacroix
Message:

Support creating the timeseries automatically.

Fields which should be outputted as timeseries must have the ts_enabled attribute set to true.

Files have a new attribute timeseries which must be one of:

  • none: no timeseries are outputted, only the regular file (default behavior when the attribute is ommited).
  • only: only the timeseries are outputted, the regular file is not created.
  • both: both the timeseries and the regular files are outputted.
  • exclusive: the timeseries are outputted and a regular file is created with only the fields which were not marked for output as a timeserie (if any).

The name of the files created for the timeseries is composed of a prefix followed by the name of the variable. The file attribute ts_prefix can be used to control the prefix used (by default, the name of the regular file is used).

All the attributes of the regular file are inherited by the files created for the timeseries. The field attribute ts_split_freq can be used to configure the splitting for each timeseries (by default, the splitting frequency of the regular file is used).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/context.cpp

    r697 r711  
    771771      // Warning: This must be done after solving the inheritance and before the rest of post-processing 
    772772      checkAxisDomainsGridsEligibilityForCompressedOutput(); 
     773 
     774      // Check if some automatic time series should be generated 
     775      // Warning: This must be done after solving the inheritance and before the rest of post-processing 
     776      prepareTimeseries(); 
    773777 
    774778      //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 
     
    895899   } 
    896900 
     901   //! Client side: Prepare the timeseries by adding the necessary files 
     902   void CContext::prepareTimeseries() 
     903   { 
     904     if (!hasClient) return; 
     905 
     906     const std::vector<CFile*> allFiles = CFile::getAll(); 
     907     for (size_t i = 0; i < allFiles.size(); i++) 
     908     { 
     909       CFile* file = allFiles[i]; 
     910 
     911       if (!file->timeseries.isEmpty() && file->timeseries != CFile::timeseries_attr::none) 
     912       { 
     913         StdString tsPrefix = !file->ts_prefix.isEmpty() ? file->ts_prefix : (!file->name.isEmpty() ? file->name : file->getId()); 
     914 
     915         const std::vector<CField*> allFields = file->getAllFields(); 
     916         for (size_t j = 0; j < allFields.size(); j++) 
     917         { 
     918           CField* field = allFields[j]; 
     919 
     920           if (!field->ts_enabled.isEmpty() && field->ts_enabled) 
     921           { 
     922             CFile* tsFile = CFile::create(); 
     923             tsFile->duplicateAttributes(file); 
     924 
     925             tsFile->name = tsPrefix + "_"; 
     926             if (!field->name.isEmpty()) 
     927               tsFile->name.get() += field->name; 
     928             else if (field->hasDirectFieldReference()) // We cannot use getBaseFieldReference() just yet 
     929               tsFile->name.get() += field->field_ref; 
     930             else 
     931               tsFile->name.get() += field->getId(); 
     932 
     933             if (!field->ts_split_freq.isEmpty()) 
     934               tsFile->split_freq = field->ts_split_freq; 
     935 
     936             CField* tsField = tsFile->addField(); 
     937             tsField->field_ref = field->getId(); 
     938 
     939             tsFile->solveFieldRefInheritance(true); 
     940 
     941             if (file->timeseries == CFile::timeseries_attr::exclusive) 
     942               field->enabled = false; 
     943           } 
     944         } 
     945 
     946         // Finally disable the original file is need be 
     947         if (file->timeseries == CFile::timeseries_attr::only) 
     948          file->enabled = false; 
     949       } 
     950     } 
     951   } 
     952 
    897953   //! Client side: Send information of reference grid of active fields 
    898954   void CContext::sendRefGrid() 
Note: See TracChangeset for help on using the changeset viewer.