Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion utils/preproc/NetCDFToIodaConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ namespace obsforge {
int count = 0;
for (const std::string& strMeta : iodaVars.intMetadataName_) {
tmpIntMeta = ogrp.vars.createWithScales<int>("MetaData/"+strMeta,
{ogrp.vars["Location"]}, int_params);
Comment thread
givelberg marked this conversation as resolved.
{ogrp.vars["Location"]}, long_params);
// get ocean basin masks if asked in the config
preproc::oceanmask::OceanMask* oceanMask = nullptr;
if (fullConfig_.has("ocean basin")) {
Expand Down
46 changes: 42 additions & 4 deletions utils/preproc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace obsforge {
// Optional metadata
Eigen::ArrayXXf floatMetadata_; // Optional array of float metadata
std::vector<std::string> floatMetadataName_; // String descriptor of the float metadata
Eigen::ArrayXXi intMetadata_; // Optional array of integer metadata
Comment thread
givelberg marked this conversation as resolved.
Eigen::Array<int64_t, Eigen::Dynamic, Eigen::Dynamic> intMetadata_;
std::vector<std::string> intMetadataName_; // String descriptor of the integer metadata

// Optional global attributes
Expand Down Expand Up @@ -145,9 +145,6 @@ namespace obsforge {
ASSERT(nVars_ == other.nVars_);
ASSERT(nfMetadata_ == other.nfMetadata_);
ASSERT(niMetadata_ == other.niMetadata_);
ASSERT(floatMetadataName_ == floatMetadataName_);
ASSERT(intMetadataName_ == intMetadataName_);
Comment thread
givelberg marked this conversation as resolved.

// Concatenate Eigen arrays and vectors
longitude_.conservativeResize(location_ + other.location_);
latitude_.conservativeResize(location_ + other.location_);
Expand Down Expand Up @@ -221,11 +218,52 @@ namespace obsforge {
oops::Log::test() << checksum(longitude_, "longitude") << std::endl;
oops::Log::test() << checksum(latitude_, "latitude") << std::endl;
oops::Log::test() << checksum(datetime_, "datetime") << std::endl;

add_originalDatetime_test();
}


void add_originalDatetime_test() {
// Find the index of "originalDatetime" in intMetadataName_
int colIndex = -1;
for (size_t i = 0; i < intMetadataName_.size(); ++i) {
if (intMetadataName_[i] == "originalDatetime") {
colIndex = static_cast<int>(i);
break;
}
}

// Check if "originalDatetime" was found
if (colIndex == -1) {
return;
}

Eigen::Array<int64_t, Eigen::Dynamic, 1> od;
// Ensure od has the correct size (same as intMetadata_ rows)
if (od.size() != intMetadata_.rows()) {
od.resize(intMetadata_.rows());
}

// Copy the corresponding column from intMetadata_ to od
od = intMetadata_.col(colIndex);

oops::Log::test() << checksum(od, "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) {
// Preserve original datetime_ values in a new column
int nCols = intMetadata_.cols(); // Current number of columns
intMetadata_.conservativeResize(location_, nCols + 1); // Add 1 column, preserve data
int newColIdx = nCols; // Index of the new column
for (int i = 0; i < location_; i++) {
intMetadata_(i, newColIdx) = datetime_(i, 0); // Store original datetime_
}
intMetadataName_.push_back("originalDatetime");
niMetadata_++;

// windowBegin and End into DAwindowTimes
std::vector<util::DateTime> DAwindowTimes = {windowBegin, windowEnd};
// Epoch DateTime from Provider
Expand Down
4 changes: 4 additions & 0 deletions utils/test/testref/insituall2ioda.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ datetime:
Min: 1616619601
Max: 1616641199
Sum: 51732172800
originalDatetime:
Min: 1616598720
Max: 1616645340
Sum: 51731904960
4 changes: 4 additions & 0 deletions utils/test/testref/rads2ioda.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ datetime:
Min: 5131805184
Max: 5131807744
Sum: 112899742208
originalDatetime:
Min: 5131805184
Max: 5131807744
Sum: 112899742208