Ignore:
Timestamp:
06/11/15 10:30:11 (7 years ago)
Author:
rlacroix
Message:

Improve CF compliance: Minor tweaks and improvements.

  • Bump the CF version to 1.5.
  • Use the same bounds dimension for all axis, including time axis.
  • Add a standard_name attribute for cell area variables.
  • Set the interval part of cell_methods attribute only when the write interval and the operation interval are different.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/output/nc4_data_output.cpp

    r613 r614  
    215215                 { 
    216216                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0); 
     217                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); 
    217218                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); 
    218219                 } 
     
    271272                   dim0.push_back(dimYid); dim0.push_back(dimXid); 
    272273                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0); 
     274                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); 
    273275                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); 
    274276                   dim0.clear(); 
     
    433435                 { 
    434436                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0); 
     437                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); 
    435438                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); 
    436439                 } 
     
    484487                   dim0.push_back(dimXid); 
    485488                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0); 
     489                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); 
    486490                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); 
    487491                 } 
     
    640644       { 
    641645        SuperClassWriter::addDimension("time_counter"); 
    642         SuperClassWriter::addDimension("time_bounds", 2); 
    643646       } 
    644647       catch (CNetCdfException& e) 
    645648       { 
    646          StdString msg("On writing time dimension : time_couter, time_bounds \n"); 
     649         StdString msg("On writing time dimension : time_couter\n"); 
    647650         msg.append("In the context : "); 
    648651         CContext* context = CContext::getCurrent() ; 
     
    818821           if (wtime) 
    819822           { 
    820               CDuration duration = field->freq_op.getValue(); 
    821               duration.solveTimeStep(*context->calendar); 
    822               StdString freqOpStr = duration.toStringUDUnits(); 
     823              CDuration freqOp = field->freq_op.getValue(); 
     824              freqOp.solveTimeStep(*context->calendar); 
     825              StdString freqOpStr = freqOp.toStringUDUnits(); 
    823826              SuperClassWriter::addAttribute("interval_operation", freqOpStr, &fieldid); 
    824827 
    825               duration = field->getRelFile()->output_freq.getValue(); 
    826               duration.solveTimeStep(*context->calendar); 
    827               SuperClassWriter::addAttribute("interval_write", duration.toStringUDUnits(), &fieldid); 
     828              CDuration freqOut = field->getRelFile()->output_freq.getValue(); 
     829              freqOut.solveTimeStep(*context->calendar); 
     830              SuperClassWriter::addAttribute("interval_write", freqOut.toStringUDUnits(), &fieldid); 
    828831 
    829832              StdString cellMethods = coodinates.front() + ": "; 
     
    832835              else if (field->operation.getValue() == "accumulate") cellMethods += "sum"; 
    833836              else cellMethods += field->operation; 
    834               cellMethods += " (interval: " + freqOpStr + ")"; 
     837              if (freqOp.resolve(*context->calendar) != freqOut.resolve(*context->calendar)) 
     838                cellMethods += " (interval: " + freqOpStr + ")"; 
    835839              SuperClassWriter::addAttribute("cell_methods", cellMethods, &fieldid); 
    836840           } 
     
    11001104         { 
    11011105           this->writeFileAttributes(filename, description, 
    1102                                      StdString("CF-1.1"), 
     1106                                     StdString("CF-1.5"), 
    11031107                                     StdString("An IPSL model"), 
    11041108                                     this->getTimeStamp()); 
    11051109 
    1106            if (file->nbAxis >= 1) 
    1107              SuperClassWriter::addDimension("axis_nbounds", 2); 
     1110           SuperClassWriter::addDimension("axis_nbounds", 2); 
    11081111         } 
    11091112         catch (CNetCdfException& e) 
     
    15691572         StdString axisBoundId("time_centered_bounds"); 
    15701573         StdString timeid("time_counter"); 
    1571          StdString timeBoundId("time_bounds"); 
     1574         StdString timeBoundId("axis_nbounds"); 
    15721575 
    15731576         if (field->foperation->timeType() == func::CFunctor::instant) 
Note: See TracChangeset for help on using the changeset viewer.