Skip to content

Commit

Permalink
Per #2701, even though we're mapping obs data to GRIB code names and …
Browse files Browse the repository at this point in the history
…units, we want to encode them with use_var_id = true and so we need to keep track of those var_id values.
  • Loading branch information
JohnHalleyGotway committed Dec 6, 2023
1 parent d4c5690 commit 9326888
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/tools/other/ascii2nc/ismn_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ bool IsmnHandler::_readObservations(LineDataFile &ascii_file) {
// Read and save the header information
if(!_readHeaderInfo(ascii_file)) return(false);

// Get the var_id to use
int var_id = bad_data_int;
if(!_varNames.has(_obsVarInfo._varName, var_id)) return(false);

// Process the observation lines
DataLine dl;
while(ascii_file >> dl) {
Expand Down Expand Up @@ -144,7 +148,7 @@ bool IsmnHandler::_readObservations(LineDataFile &ascii_file) {
_addObservations(Observation(
_networkName, _stationId, valid_time,
_stationLat, _stationLon, _stationElv,
dl[3], _obsVarInfo._gribCode, bad_data_double,
dl[3], var_id, bad_data_double,
_depth, obs_value, _obsVarInfo._varName));

} // end while
Expand Down Expand Up @@ -212,6 +216,9 @@ bool IsmnHandler::_readHeaderInfo(LineDataFile &ascii_file) {
// Store the observation variable info
_obsVarInfo = IsmnObsVarMap[sa[3]];

// Store the output variable name
_varNames.add_uniq(_obsVarInfo._varName);

// Read the header line
DataLine dl;
while(dl.n_items() == 0) ascii_file >> dl;
Expand Down
3 changes: 3 additions & 0 deletions src/tools/other/ascii2nc/ismn_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class IsmnHandler : public FileHandler {
// Unchanging file name information
obsVarInfo _obsVarInfo;

// Store list of unqiue output variable names
StringArray _varNames;

// Unchanging header information
string _networkName;
string _stationId;
Expand Down

0 comments on commit 9326888

Please sign in to comment.