Ignore:
Timestamp:
06/10/15 15:11:22 (6 years ago)
Author:
rlacroix
Message:

Improve CF compliance: Write the "cell_methods" metadata.

Also try to use the time units defined by the UDUnits specification.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/branchs/xios-1.0/src/output/nc4_data_output.cpp

    r611 r612  
    794794           if (wtime) 
    795795           { 
    796               CDuration duration ; 
    797  
    798               duration=CDuration::FromString(field->freq_op) ; 
    799               duration.solveTimeStep(*(context->calendar)); 
    800               SuperClassWriter::addAttribute("interval_operation", duration.toString(), &fieldid); 
    801  
    802               duration=CDuration::FromString(field->getRelFile()->output_freq) ; 
    803               duration.solveTimeStep(*(context->calendar)); 
    804               SuperClassWriter::addAttribute("interval_write", duration.toString(), &fieldid); 
     796              CDuration duration = CDuration::FromString(field->freq_op); 
     797              duration.solveTimeStep(*context->calendar); 
     798              StdString freqOpStr = duration.toStringUDUnits(); 
     799              SuperClassWriter::addAttribute("interval_operation", freqOpStr, &fieldid); 
     800 
     801              duration = CDuration::FromString(field->getRelFile()->output_freq); 
     802              duration.solveTimeStep(*context->calendar); 
     803              SuperClassWriter::addAttribute("interval_write", duration.toStringUDUnits(), &fieldid); 
     804 
     805              StdString cellMethods = coodinates.front() + ": "; 
     806              if (field->operation.getValue() == "instant") cellMethods += "point"; 
     807              else if (field->operation.getValue() == "average") cellMethods += "mean"; 
     808              else if (field->operation.getValue() == "accumulate") cellMethods += "sum"; 
     809              else cellMethods += field->operation; 
     810              cellMethods += " (interval: " + freqOpStr + ")"; 
     811              SuperClassWriter::addAttribute("cell_methods", cellMethods, &fieldid); 
    805812           } 
    806813 
Note: See TracChangeset for help on using the changeset viewer.