Skip to content

Commit

Permalink
Code clean-up and a reference test for VIIRS AOD IODA converter (#808)
Browse files Browse the repository at this point in the history
### Description:

- Remove duplicate code (NetCDFToIodaConverter2d.h) and implement the
channel dimension to the original constructors.

- Update the VIIRS ioda converter ctest with reference test.

---------

Co-authored-by: ypwang19 <[email protected]>
  • Loading branch information
ypwang19 and ypwang19 authored Dec 18, 2023
1 parent 066dc81 commit ceedcce
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 336 deletions.
24 changes: 21 additions & 3 deletions utils/obsproc/NetCDFToIodaConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,26 @@ namespace gdasapp {
// Update the group with the location dimension
ioda::NewDimensionScales_t
newDims {ioda::NewDimensionScale<int>("Location", iodaVarsAll.location_)};

// Update the group with the location and channel dimension (if channel value is assigned)
if (iodaVars.channelValues_(0) > 0) {
newDims = {
ioda::NewDimensionScale<int>("Location", iodaVarsAll.location_),
ioda::NewDimensionScale<int>("Channel", iodaVarsAll.channel_)
};
}
ioda::ObsGroup ogrp = ioda::ObsGroup::generate(group, newDims);

// Create different dimensionScales for data w/wo channel info
std::vector<ioda::Variable> dimensionScales {
ogrp.vars["Location"]
};
if (iodaVars.channelValues_(0) > 0) {
dimensionScales = {ogrp.vars["Location"], ogrp.vars["Channel"]};
ogrp.vars["Channel"].writeWithEigenRegular(iodaVars.channelValues_);
}


// Set up the creation parameters
ioda::VariableCreationParameters float_params = createVariableParams<float>();
ioda::VariableCreationParameters int_params = createVariableParams<int>();
Expand All @@ -112,14 +130,14 @@ namespace gdasapp {

ioda::Variable iodaObsVal =
ogrp.vars.createWithScales<float>("ObsValue/"+variable_,
{ogrp.vars["Location"]}, float_params);
dimensionScales, float_params);
ioda::Variable iodaObsErr =
ogrp.vars.createWithScales<float>("ObsError/"+variable_,
{ogrp.vars["Location"]}, float_params);
dimensionScales, float_params);

ioda::Variable iodaPreQc =
ogrp.vars.createWithScales<int>("PreQC/"+variable_,
{ogrp.vars["Location"]}, int_params);
dimensionScales, int_params);

// add input filenames to IODA file global attributes
ogrp.atts.add<std::string>("obs_source_files", inputFilenames_);
Expand Down
318 changes: 0 additions & 318 deletions utils/obsproc/NetCDFToIodaConverter2D.h

This file was deleted.

Loading

0 comments on commit ceedcce

Please sign in to comment.