Skip to content

Commit

Permalink
BUFR: skip values when period is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
istvans-mn committed Oct 17, 2024
1 parent 687d77f commit c2aa501
Showing 1 changed file with 47 additions and 36 deletions.
83 changes: 47 additions & 36 deletions ingest/src/ingest/bufr/ESOHBufr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <list>
#include <sstream>
Expand Down Expand Up @@ -425,45 +426,50 @@ std::list<std::string> ESOHBufr::msg() const {
}
}
if (period_update) {
bool valid_period = true;
if (data_category != 2 ||
(int_data_subcategory < 4 || int_data_subcategory > 7)) {
int time_period = 0;
time_period = getValue(v, time_period);

if (data_category == 2 && int_data_subcategory == 1) {
time_period = -time_period;
if (period_beg == "PT") {
if (period_end == "S") {
time_disp += time_period;
} else {
if (period_end == "M") {
time_disp += time_period * 60;
if (time_period == std::numeric_limits<int>::max())
valid_period = false;
if (valid_period) {
if (data_category == 2 && int_data_subcategory == 1) {
time_period = -time_period;
if (period_beg == "PT") {
if (period_end == "S") {
time_disp += time_period;
} else {
if (period_end == "H") {
time_disp += time_period * 60 * 60;
if (period_end == "M") {
time_disp += time_period * 60;
} else {
lb.addLogEntry(LogEntry(
"Profile datetime is the start of measure!",
LogLevel::WARN, __func__, bufr_id));
if (period_end == "H") {
time_disp += time_period * 60 * 60;
} else {
lb.addLogEntry(LogEntry(
"Profile datetime is the start of measure!",
LogLevel::WARN, __func__, bufr_id));
}
}
}
}
} else {
if (time_period > 0) {
time_period = -time_period;
lb.addLogEntry(LogEntry("Positive BUFR time period: " +
std::to_string(time_period) +
", at: " + v.toString(),
LogLevel::WARN, __func__, bufr_id));
}
}
} else {
if (time_period > 0) {
time_period = -time_period;
lb.addLogEntry(LogEntry("Positive BUFR time period: " +
std::to_string(time_period) +
", at: " + v.toString(),
LogLevel::WARN, __func__, bufr_id));
}
dateupdate = true;
std::stringstream ss;
ss << period_beg << -time_period << period_end;
period_str = ss.str();
}
dateupdate = true;
std::stringstream ss;
ss << period_beg << -time_period << period_end;
period_str = ss.str();
}
dateupdate = true;
if (valid_period)
dateupdate = true;
}
if (dateupdate) {
if (v.y() == 86 || (v.y() >= 21 && v.y() <= 26) ||
Expand Down Expand Up @@ -527,7 +533,7 @@ std::list<std::string> ESOHBufr::msg() const {
// 33: // Height of sensor above water
if (v.y() == 31 || v.y() == 32 || v.y() == 33) {
sensor_level = getValue(v, sensor_level);
if (getDataCategory() <= 1) {
if (getDataCategory() <= 1 && !std::isnan(sensor_level)) {
sensor_level_active = 2;
}
}
Expand Down Expand Up @@ -660,20 +666,25 @@ std::list<std::string> ESOHBufr::msg() const {
++ci;
double precip = 0.0;
int period = 0;
bool valid_period = true;
time_t start_datetime = 0;
if (*ci == DescriptorId(4024, true)) {
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();
if (period == std::numeric_limits<int>::max())
valid_period = false;
if (valid_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;
if (*ci == DescriptorId(13011, true)) {
if (valid_period && *ci == DescriptorId(13011, true)) {
precip = getValue(*ci, precip);
if (precip !=
static_cast<double>(std::numeric_limits<uint64_t>::max())) {
Expand Down

1 comment on commit c2aa501

@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.py614821%34–81
datastore_pb2_grpc.py542750%15–16, 19, 65–80, 121–123, 128–130, 135–137, 142–144, 148–173, 219, 246, 273, 300
export_metrics.py100100% 
grpc_getter.py201145%15–19, 23–26, 30–32, 36–38
locustfile.py15150%1–31
main.py43784%45, 50, 60, 70–71, 81–82
metadata_endpoints.py653152%45–54, 58, 85, 100–219, 223
response_classes.py50100% 
utilities.py1744674%20, 38, 45, 67–70, 78–89, 94–101, 121, 125, 127, 155, 161, 179, 193–194, 198, 214–218, 222–228, 232–234, 264, 268, 290, 295
custom_geo_json
   edr_feature_collection.py60100% 
formatters
   \_\_init\_\_.py110100% 
   covjson.py59198%91
   geojson.py21290%27, 52
openapi
   custom_dimension_examples.py40100% 
   edr_query_parameter_descriptions.py110100% 
   openapi_examples.py130100% 
routers
   \_\_init\_\_.py00100% 
   edr.py101496%348–349, 438–439
   feature.py471960%99–132, 148–153, 159–181
TOTAL72021171% 

API Unit Test Coverage Summary

Tests Skipped Failures Errors Time
30 0 💤 0 ❌ 0 🔥 1.914s ⏱️

Please sign in to comment.