From 945a4cea9d31706906ab9758d6ea9a240ea8966e Mon Sep 17 00:00:00 2001 From: Edward Givelberg Date: Tue, 25 Mar 2025 12:51:57 -0500 Subject: [PATCH] added original date --- utils/obsproc/NetCDFToIodaConverter.h | 7 +++++++ utils/obsproc/util.h | 17 +++++++++++++++++ utils/test/testref/insituall2ioda.test | 4 ++++ utils/test/testref/rads2ioda.test | 4 ++++ 4 files changed, 32 insertions(+) diff --git a/utils/obsproc/NetCDFToIodaConverter.h b/utils/obsproc/NetCDFToIodaConverter.h index 214fa25bf..7a2cbbdae 100644 --- a/utils/obsproc/NetCDFToIodaConverter.h +++ b/utils/obsproc/NetCDFToIodaConverter.h @@ -191,6 +191,13 @@ namespace gdasapp { count++; } + if (iodaVars.originalDatetime_.size() != 0) { + ioda::Variable iodaOriginalDatetime = + ogrp.vars.createWithScales("MetaData/originalDateTime", + {ogrp.vars["Location"]}, long_params); + iodaOriginalDatetime.writeWithEigenRegular(iodaVars.originalDatetime_); + } + // Test output iodaVars.testOutput(); diff --git a/utils/obsproc/util.h b/utils/obsproc/util.h index 0d19e8dde..f6d01a90a 100644 --- a/utils/obsproc/util.h +++ b/utils/obsproc/util.h @@ -116,6 +116,7 @@ namespace gdasapp { std::vector floatMetadataName_; // String descriptor of the float metadata Eigen::ArrayXXi intMetadata_; // Optional array of integer metadata std::vector intMetadataName_; // String descriptor of the integer metadata + Eigen::Array originalDatetime_; // Optional global attributes std::map strGlobalAttr_; @@ -133,6 +134,7 @@ namespace gdasapp { floatMetadataName_(fmnames), intMetadata_(location_, imnames.size()), intMetadataName_(imnames), + originalDatetime_(), // initialized as empty channel_(1), channelValues_(Eigen::ArrayXi::Constant(channel_, -1)) { @@ -157,6 +159,9 @@ namespace gdasapp { preQc_.conservativeResize(location_ * channel_ + other.location_ * other.channel_); floatMetadata_.conservativeResize(location_ + other.location_, nfMetadata_); intMetadata_.conservativeResize(location_ + other.location_, niMetadata_); + if (originalDatetime_.size() != 0) { + originalDatetime_.conservativeResize(location_ + other.location_); + } // Copy data from the 'other' object to this object longitude_.tail(other.location_) = other.longitude_; @@ -167,6 +172,9 @@ namespace gdasapp { preQc_.tail(other.location_) = other.preQc_; floatMetadata_.bottomRows(other.location_) = other.floatMetadata_; intMetadata_.bottomRows(other.location_) = other.intMetadata_; + if (originalDatetime_.size() != 0) { + originalDatetime_.tail(other.location_) = other.originalDatetime_; + } // Update obs count location_ += other.location_; @@ -194,6 +202,9 @@ namespace gdasapp { for (int k = 0; k < niMetadata_; k++) { iodaVarsMasked.intMetadata_(j, k) = intMetadata_(i, k); } + if (originalDatetime_.size() != 0) { + iodaVarsMasked.originalDatetime_(j) = originalDatetime_(i); + } j++; } // end if (mask(i)) } @@ -206,6 +217,7 @@ namespace gdasapp { preQc_ = iodaVarsMasked.preQc_; floatMetadata_ = iodaVarsMasked.floatMetadata_; intMetadata_ = iodaVarsMasked.intMetadata_; + originalDatetime_ = iodaVarsMasked.originalDatetime_; // Update obs count location_ = iodaVarsMasked.location_; @@ -221,11 +233,16 @@ namespace gdasapp { oops::Log::test() << checksum(longitude_, "longitude") << std::endl; oops::Log::test() << checksum(latitude_, "latitude") << std::endl; oops::Log::test() << checksum(datetime_, "datetime") << std::endl; + if (originalDatetime_.size() != 0) { + oops::Log::test() << checksum(originalDatetime_, "originalDatetime") << std::endl; + } } // Changing the date and Adjusting Errors void reDate(const util::DateTime & windowBegin, const util::DateTime & windowEnd, const std::string &epochDate, float errRatio) { + // save the original + originalDatetime_ = datetime_; // windowBegin and End into DAwindowTimes std::vector DAwindowTimes = {windowBegin, windowEnd}; // Epoch DateTime from Provider diff --git a/utils/test/testref/insituall2ioda.test b/utils/test/testref/insituall2ioda.test index d42358f31..9575598c9 100644 --- a/utils/test/testref/insituall2ioda.test +++ b/utils/test/testref/insituall2ioda.test @@ -24,3 +24,7 @@ datetime: Min: 1616619601 Max: 1616641199 Sum: 51732172800 +originalDatetime: + Min: 1616598720 + Max: 1616645340 + Sum: 51731904960 diff --git a/utils/test/testref/rads2ioda.test b/utils/test/testref/rads2ioda.test index bf41430ce..04bf57e60 100644 --- a/utils/test/testref/rads2ioda.test +++ b/utils/test/testref/rads2ioda.test @@ -24,3 +24,7 @@ datetime: Min: 5131805184 Max: 5131807744 Sum: 112899742208 +originalDatetime: + Min: 5131805184 + Max: 5131807744 + Sum: 112899742208