From 4f089c4d72483dd2f88bca69df11143db8f2ee72 Mon Sep 17 00:00:00 2001 From: Mindo Choi <141867620+apchoiCMD@users.noreply.github.com> Date: Mon, 20 Nov 2023 16:54:39 -0500 Subject: [PATCH] Fix a bug for dateTime in IcecAmsr2Ioda.h (#756) ### Description - Implemented an additional trim function to ensure that the Obs.Values align with their respective dTime entries - Minor changes within for loop and removed unnecessary function - Only applied to amsr2_icec --------- Co-authored-by: Guillaume Vernieres --- utils/obsproc/IcecAmsr2Ioda.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/utils/obsproc/IcecAmsr2Ioda.h b/utils/obsproc/IcecAmsr2Ioda.h index 414d25017..0295b6e37 100644 --- a/utils/obsproc/IcecAmsr2Ioda.h +++ b/utils/obsproc/IcecAmsr2Ioda.h @@ -64,10 +64,9 @@ namespace gdasapp { ncFile.getVar("Scan_Time").getVar(oneTmpdateTimeVal.data()); iodaVars.referenceDate_ = "seconds since 1970-01-01T00:00:00Z"; + size_t index = 0; std::tm timeinfo = {}; for (int i = 0; i < ntimes; i += dimTimeSize) { - for (int j = 0; j < dimTimeSize && i + j < ntimes; j++) { - } timeinfo.tm_year = oneTmpdateTimeVal[i] - 1900; // Year since 1900 timeinfo.tm_mon = oneTmpdateTimeVal[i + 1] - 1; // 0-based; 8 represents Sep timeinfo.tm_mday = oneTmpdateTimeVal[i + 2]; @@ -77,20 +76,22 @@ namespace gdasapp { // Calculate and store the seconds since the Unix epoch time_t epochtime = std::mktime(&timeinfo); - iodaVars.datetime_(i/6) = static_cast(epochtime); + iodaVars.datetime_(index) = static_cast(epochtime); + index++; } // Update non-optional Eigen arrays for (int i = 0; i < iodaVars.location_; i++) { iodaVars.longitude_(i) = oneDimLonVal[i]; iodaVars.latitude_(i) = oneDimLatVal[i]; - iodaVars.obsVal_(i) = static_cast(oneDimObsVal[i]*0.01); + iodaVars.obsVal_(i) = static_cast(oneDimObsVal[i]*0.01f); iodaVars.obsError_(i) = 0.1; // Do something for obs error iodaVars.preQc_(i) = oneDimFlagsVal[i]; } // basic test for iodaVars.trim - Eigen::Array mask = (iodaVars.obsVal_ >= 0.0); + Eigen::Array mask = (iodaVars.obsVal_ >= 0.0 + && iodaVars.datetime_ > 0.0); iodaVars.trim(mask); return iodaVars;