Skip to content

Commit

Permalink
Keep datetime, and fix period property
Browse files Browse the repository at this point in the history
  • Loading branch information
istvans-mn committed Apr 11, 2024
1 parent 6634fed commit 9af67ca
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
31 changes: 24 additions & 7 deletions ingest/src/ingest/bufr/ESOHBufr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,11 @@ std::list<std::string> ESOHBufr::msg() const {
time_t start_datetime = 0;
start_datetime = mktime(&meas_datetime);
start_datetime -= 60 * 60 * 24;
period_str = "PT24H";

ret.push_back(addMessage(ci, subset_message,
sensor_level_active, sensor_level,
"sum", &start_datetime));
"sum", &start_datetime, period_str));
}
}

Expand All @@ -604,6 +605,11 @@ std::list<std::string> ESOHBufr::msg() const {
period = getValue(*ci, period);
start_datetime = mktime(&meas_datetime);
start_datetime += period * 60 * 60;
period_beg = "PT";
period_end = "H";
std::stringstream ss;
ss << period_beg << -period << period_end;
period_str = ss.str();
}

++ci;
Expand All @@ -613,7 +619,7 @@ std::list<std::string> ESOHBufr::msg() const {
static_cast<double>(std::numeric_limits<uint64_t>::max())) {
ret.push_back(addMessage(ci, subset_message,
sensor_level_active, sensor_level,
"sum", &start_datetime));
"sum", &start_datetime, period_str));
}
}
}
Expand All @@ -630,6 +636,11 @@ std::list<std::string> ESOHBufr::msg() const {
period = getValue(*ci, period);
start_datetime = mktime(&meas_datetime);
start_datetime += period * 60 * 60;
period_beg = "PT";
period_end = "H";
std::stringstream ss;
ss << period_beg << -period << period_end;
period_str = ss.str();
}

++ci;
Expand All @@ -643,7 +654,7 @@ std::list<std::string> ESOHBufr::msg() const {
static_cast<double>(std::numeric_limits<uint64_t>::max())) {
ret.push_back(addMessage(ci, subset_message,
sensor_level_active, sensor_level,
"sun", &start_datetime));
"sum", &start_datetime, period_str));
}
}

Expand Down Expand Up @@ -873,7 +884,8 @@ bool ESOHBufr::setDateTime(struct tm *meas_datetime,
}

bool ESOHBufr::setStartDateTime(struct tm *start_meas_datetime,
rapidjson::Document &message) const {
rapidjson::Document &message,
std::string period_str) const {
rapidjson::Document::AllocatorType &message_allocator =
message.GetAllocator();
rapidjson::Value &properties = message["properties"];
Expand All @@ -893,16 +905,21 @@ bool ESOHBufr::setStartDateTime(struct tm *start_meas_datetime,

// datetime.SetString(date_str,static_cast<rapidjson::SizeType>(dl),message_allocator);
end_datetime.CopyFrom(datetime, message_allocator);
properties.RemoveMember("datetime");
// properties.RemoveMember("datetime");
properties.AddMember("end_datetime", end_datetime, message_allocator);

if (period_str.size()) {
properties["period"].SetString(period_str.c_str(), message_allocator);
}

return true;
}

std::string ESOHBufr::addMessage(std::list<Descriptor>::const_iterator ci,
rapidjson::Document &message,
char sensor_level_active, double sensor_level,
std::string fn, time_t *start_datetime) const {
std::string fn, time_t *start_datetime,
std::string period_str) const {
std::string ret;

rapidjson::Document new_message;
Expand All @@ -911,7 +928,7 @@ std::string ESOHBufr::addMessage(std::list<Descriptor>::const_iterator ci,
new_message.CopyFrom(message, new_message_allocator);

if (start_datetime)
setStartDateTime(gmtime(start_datetime), new_message);
setStartDateTime(gmtime(start_datetime), new_message, period_str);

addContent(*ci, cf_names[*ci].first, sensor_level_active, sensor_level, fn,
new_message);
Expand Down
6 changes: 4 additions & 2 deletions ingest/src/ingest/bufr/ESOHBufr.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class ESOHBufr : public NorBufr {
std::string addMessage(std::list<Descriptor>::const_iterator ci,
rapidjson::Document &message, char sensor_level_active,
double sensor_level, std::string fn = "",
time_t *start_datetime = 0) const;
time_t *start_datetime = 0,
std::string period_str = "") const;
bool addDescriptor(Descriptor &D, rapidjson::Value &dest,
rapidjson::Document::AllocatorType &) const;
bool addContent(const Descriptor &D, std::string cf_name,
Expand All @@ -88,7 +89,8 @@ class ESOHBufr : public NorBufr {

bool setDateTime(struct tm *, rapidjson::Document &,
std::string period_str = "") const;
bool setStartDateTime(struct tm *, rapidjson::Document &) const;
bool setStartDateTime(struct tm *, rapidjson::Document &,
std::string period_str = "") const;
Oscar *oscar;
std::string msg_template;
};
Expand Down

1 comment on commit 9af67ca

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API Unit Test Coverage Report
FileStmtsMissCoverMissing
\_\_init\_\_.py00100% 
datastore_pb2.py584621%24–69
datastore_pb2_grpc.py432347%37–52, 85–87, 92–94, 99–101, 106–108, 112–136, 174, 191, 208, 225
grpc_getter.py201145%15–16, 20–23, 27–29, 33–35
locustfile.py15150%1–31
main.py34585%41, 51–52, 62–63
metadata_endpoints.py552555%42–51, 55, 72–151, 155
response_classes.py50100% 
utilities.py681972%15, 33, 40, 62–65, 73–80, 85–92, 112, 116, 118
custom_geo_json
   edr_feature_collection.py60100% 
formatters
   \_\_init\_\_.py110100% 
   covjson.py53198%75
   geojson.py15287%17, 42
routers
   \_\_init\_\_.py00100% 
   edr.py121794%131, 143, 151, 264–265, 310–311
   feature.py461959%75–108, 124–129, 135–157
TOTAL55017369% 

API Unit Test Coverage Summary

Tests Skipped Failures Errors Time
23 0 💤 0 ❌ 0 🔥 2.028s ⏱️

Please sign in to comment.