Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
213 commits
Select commit Hold shift + click to select a range
2c9a19a
First cut at calling the new nceplibs bufr query interface.
rmclaren Jul 14, 2021
911ab75
Updated to handle multi-dimensional data. Fixed DatetimeVariable. Got…
rmclaren Jul 16, 2021
7292097
Added support for CCITT IA5 string fields. Fixed many other fields th…
rmclaren Jul 26, 2021
4197505
Added support for forfield. Cleaned up some uneccesarrily complicated…
rmclaren Jul 26, 2021
63ccb24
Removed split map in favor of a list of splits to make code more read…
rmclaren Jul 27, 2021
0267205
Fixed bug with transforms. Updated some YAML files.
rmclaren Jul 28, 2021
2fe07fc
Updated the README file.
rmclaren Jul 28, 2021
e6a57ed
Fixed bug were CCITT IA5 fields would fail because of a silly mistake…
rmclaren Aug 5, 2021
0bcdf01
Merge branch 'develop' into feature/query
emilyhcliu Aug 14, 2021
569c0d4
Renamed for field to group_by field.
rmclaren Aug 18, 2021
a28c35c
Merge branch 'feature/query' of https://github.com/JCSDA-internal/iod…
rmclaren Aug 18, 2021
0c2dd81
Removed duplicate directory for transforms.
rmclaren Aug 20, 2021
9bf4a30
Merge branch 'feature/query' of https://github.com/JCSDA-internal/iod…
rmclaren Sep 23, 2021
be4c663
incremental checkin, getting higher dimensional data working
rmclaren Sep 30, 2021
df685f0
Added DataObject cpp
rmclaren Oct 1, 2021
5c40747
Finished major code revisions and got things to compile for automatic…
rmclaren Oct 15, 2021
2ef38f9
Some bug fixes to get simple radiance data working.
rmclaren Oct 18, 2021
a30979d
Enhanced the reading of th dimensions field.
rmclaren Oct 18, 2021
3aad615
Got filtering and splitting to work again. Might need to be a little …
rmclaren Oct 18, 2021
80dbe6e
Fixed a dimension naming issue with the way group_by location dimensi…
rmclaren Oct 19, 2021
129fb53
Added arguments to bufr2ioda so you can limit the amount of messages …
rmclaren Oct 20, 2021
4c37c3b
Changed dimensions attribute to list or single string.
rmclaren Oct 21, 2021
ec23950
Fixed transforms.
rmclaren Nov 4, 2021
6de09ed
Fixed transfoms so they will not affect missing values.
rmclaren Nov 4, 2021
9f7b8fa
Fixed bug that happened when we tried to export an empty category.
rmclaren Nov 5, 2021
b165236
Fixed strange issue that happened while applying filters. Removed som…
rmclaren Nov 9, 2021
0051a0e
Updated a bunch of unit tests so that they would work with the latest…
rmclaren Nov 16, 2021
c655f4a
updated test output files to work with latest version of ioda
rmclaren Nov 18, 2021
8644963
Added unit test and now time the runtime.
rmclaren Dec 17, 2021
25982ab
Fixed a couple more unit tests.
rmclaren Dec 21, 2021
2b81f86
Added .dump files to gitlfs
rmclaren Dec 22, 2021
0dabeb8
removed uneeded file
rmclaren Dec 22, 2021
9eb5f62
BUFR2IODA conversion for AMSU-A and MHS Radiance data (#713)
emilyhcliu Dec 22, 2021
1679444
Update README.md
rmclaren Dec 28, 2021
ef43b58
Test and enhance two yaml files for adpsfc snow and sevcrs data (#736)
YoulongXia-NOAA Dec 29, 2021
7dfe9ef
Reduce the size of test files for amsua, mhs and iasi. Update the co…
emilyhcliu Jan 27, 2022
92aedb7
Merged in latest changes from develop.
rmclaren Jan 31, 2022
a48e36a
Removed uneeded files I missed during merge.
rmclaren Jan 31, 2022
aa1f4ff
Initial checkin of query classes with a lot of placeholder code
rmclaren Feb 2, 2022
a723efc
Got data collection mostly working.
rmclaren Feb 8, 2022
f655842
Starting to work end to end. Need to fix exportdims and revisit code …
rmclaren Feb 9, 2022
a815020
Merge branch 'feature/query' of https://github.com/JCSDA-internal/iod…
rmclaren Feb 10, 2022
a9983fc
Fixed issue where targets and masks were being copied unecessarily.
rmclaren Feb 10, 2022
af1304a
Feature/adpupa prepbufr (#794)
PraveenKumar-NOAA Feb 11, 2022
48f5189
Got a bunch of unit tests working.
rmclaren Feb 11, 2022
eebbf26
add aircft profiles to feature/query
nicholasesposito Feb 16, 2022
81a63a1
Fixed non-working functional unit tests.
rmclaren Mar 4, 2022
3432e9c
Merge branch 'feature/query' of https://github.com/JCSDA-internal/iod…
rmclaren Mar 4, 2022
6402f03
Merge branch 'feature/query' into feature/query_cxx
rmclaren Mar 4, 2022
2159242
Added unit test for simple groupby example.
rmclaren Mar 8, 2022
ee81939
Merge branch 'feature/query' of https://github.com/JCSDA-internal/iod…
rmclaren Mar 8, 2022
69a2f72
Merge branch 'feature/query' of https://github.com/JCSDA-internal/iod…
rmclaren Mar 9, 2022
7378b39
Merge branch 'feature/query' into feature/query_cxx
rmclaren Mar 9, 2022
598ebf6
Made simple groupby test work. Fixed related bugs.
rmclaren Mar 10, 2022
2406042
Added unit test for bufr files with missing fields.
rmclaren Mar 11, 2022
d8240c0
Added unit test for sfcshp data
rmclaren Mar 13, 2022
81931e3
accidentaly messed up the bufr-mhs test. this fixes it
rmclaren Mar 14, 2022
430850c
Integrated latest bug fixes from the feature/query branch.
rmclaren Mar 14, 2022
f083af6
Merge branch 'feature/query' of https://github.com/JCSDA-internal/iod…
rmclaren Mar 14, 2022
85c1a3e
Merge branch 'feature/query' into feature/query_cxx
rmclaren Mar 14, 2022
d16bf12
Fixed bug were we weren't checking for empty sequence counts.
rmclaren Mar 14, 2022
6e158c7
added adpupa tests
rmclaren Mar 14, 2022
68bc140
Merge branch 'feature/query' of https://github.com/JCSDA-internal/iod…
rmclaren Mar 14, 2022
6c9f1d6
Merge branch 'feature/query' into feature/query_cxx
rmclaren Mar 14, 2022
eeb0896
Fixed bugs that prevented adpupa from working.
rmclaren Mar 15, 2022
552aceb
Getting much closer to having adpupa groupby example working.
rmclaren Mar 22, 2022
d74796c
fixed final bug to get adpupa groupby case to work the same way.
rmclaren Mar 22, 2022
26ab396
Removed some uneeded code.
rmclaren Mar 22, 2022
56a452c
Merged latest from develop, and made it work with the latest from NCE…
rmclaren Mar 23, 2022
b86c4da
Reduce the size of the ADPUPA test input furrther
emilyhcliu Mar 23, 2022
9da4fb3
Merge branch 'feature/query_cxx' of https://github.com/JCSDA-internal…
rmclaren Mar 30, 2022
da9c483
Removed undesired include from legacy bufr code.
rmclaren Mar 31, 2022
5153474
Removed undesired include from legacy bufr code.
rmclaren Mar 31, 2022
8300c35
Removed undesired include from legacy bufr code.
rmclaren Mar 31, 2022
a052afb
Removed undesired include from legacy bufr code.
rmclaren Mar 31, 2022
418b1f4
Removed undesired include from legacy bufr code.
rmclaren Mar 31, 2022
e83ff00
Removed undesired include from legacy bufr code. Fixed some copyright…
rmclaren Mar 31, 2022
6a892fd
Changed the way data provider works (no longer a singleton). Minor cl…
rmclaren Apr 4, 2022
c683b4b
Added print_queries tool to the ioda-converter project.
rmclaren Apr 5, 2022
fb5f07f
Improved situation arrising from missing string fields.
rmclaren Apr 6, 2022
067390d
Improved detection of string fields.
rmclaren Apr 6, 2022
efa2763
Moved table logic out of the print_quiries function. Fixed bug were i…
rmclaren Apr 8, 2022
0a79cb3
Merge branch 'develop' into feature/query_cxx
rmclaren Apr 11, 2022
ccbbeb6
Replace nlocs with Location, reduce the size of ADPUPA.prepbufr and ……
emilyhcliu Apr 11, 2022
f09a98c
Merge branch 'feature/query_cxx' of https://github.com/JCSDA-internal…
rmclaren Apr 11, 2022
d403b75
Reverted ADPUPA bufr file to smaller one.
rmclaren Apr 11, 2022
dff7251
Fixed compiler warnings
rmclaren Apr 11, 2022
eca2524
Fixed code style (norm) issues.
rmclaren Apr 11, 2022
d723ac0
Added doc strings to query code.
rmclaren Apr 12, 2022
20eb76b
Feature/query cxx praveen (#893)
PraveenKumar-NOAA Apr 13, 2022
6fe7e43
Added white space
rmclaren Apr 13, 2022
664c2bf
Change dimension name to following unified IODA naming convention (#…
emilyhcliu Apr 13, 2022
394ae09
Merge branch 'feature/query_cxx' of https://github.com/JCSDA-internal…
rmclaren Apr 13, 2022
b5d4cdc
Fixed bug when there were more than one subset in the file. Added abi…
rmclaren Apr 18, 2022
b55c75d
Updated print queries so it no longer uses colors but prints the dime…
rmclaren Apr 25, 2022
b98c09d
Chenged some maps to unordered_maps as they are better performance wise.
rmclaren Apr 26, 2022
3122f9a
Feature/query cxx as (#914)
AshleyStanfield-NOAA May 6, 2022
da75624
Modify unit attribute in BUFR2IODA converter and bug fix for satellit…
emilyhcliu May 9, 2022
24d6a3e
Fixed issue where non-existing query with index would cause a crash. …
rmclaren May 17, 2022
68e94ec
Fixed some norm test failures.
rmclaren May 17, 2022
6a5043e
Fixed all the unit tests
rmclaren May 18, 2022
724b104
Made change so that there is always one group_by field whcih applies …
rmclaren May 23, 2022
9657fb2
Removed uneeded test
rmclaren May 23, 2022
107376f
Merge branch 'develop' into feature/query_cxx
emilyhcliu May 24, 2022
f76dbc8
Improved some of the code to do with finding the data object to group…
rmclaren May 24, 2022
bcda337
Merge branch 'feature/query_cxx' of https://github.com/JCSDA-internal…
rmclaren May 24, 2022
c80d02c
Fixed bug in print queries were fixed repeats were being missed.
rmclaren May 25, 2022
29a65b3
update two yaml files via query_cxx (#906)
YoulongXia-NOAA May 26, 2022
9325c5b
Feature/query cxx mhs (#960)
emilyhcliu Jun 2, 2022
a0dd8e1
Feature/query cxx amsua (#958)
emilyhcliu Jun 2, 2022
4bd2e8c
Feature/query cxx iasi (#966)
emilyhcliu Jun 7, 2022
ac14e75
Feature/query cxx nick e adpsfc (#904)
nicholasesposito Jun 7, 2022
f611e3a
Feature/query cxx atovs (#963)
emilyhcliu Jun 14, 2022
4adeaef
Added code for automated type selection.
rmclaren Jun 15, 2022
afbcb8f
Merge branch 'develop' into feature/query_cxx
srherbener Jun 17, 2022
a518afe
Removed check for unit type mismatch.
rmclaren Jun 24, 2022
9bba0bf
Fixed bug with string fields.
rmclaren Jun 27, 2022
b8165a7
Missing values now depend directly on the types (always max value for…
rmclaren Jun 28, 2022
297b19a
Updated DatetimeVariable.cpp code for optional value of Minute (#949)
PraveenKumar-NOAA Jul 12, 2022
b4a32e4
Automatic type selection based on NCEPLIB-bufr refernece, scale and u…
rmclaren Jul 25, 2022
65ffefb
Added target.h and updated cmakelists.txt
rmclaren Jul 25, 2022
3aecf36
updated mhs test file
rmclaren Jul 25, 2022
53b6e41
Merge branch 'feature/query_cxx' into feature/query_cxx_types
rmclaren Jul 25, 2022
92e46f3
Added way to manually override the type.
rmclaren Jul 27, 2022
230ad33
Print queries now displays type information.
rmclaren Jul 27, 2022
bf8606e
Fixed issue with discovering if field is an integer.
rmclaren Jul 27, 2022
c2fc683
Added some doc strings. Fixed readme.
rmclaren Jul 28, 2022
a6e38a2
Improved the handling of data types when doing transforms.
rmclaren Jul 28, 2022
2bd39d0
Fixed issue where transforms were being applied to missing value values.
rmclaren Aug 4, 2022
8de9b84
Got it kinda working.
rmclaren Aug 4, 2022
a92d54b
slight improvemetn
rmclaren Aug 4, 2022
b1d0647
slight improvement
rmclaren Aug 4, 2022
2be7961
Merged latest from develop branch
rmclaren Aug 8, 2022
36419c6
Added support for the latest changes to NCEPLIB bufr
rmclaren Aug 8, 2022
d7d3f91
Merge branch 'develop' into feature/query_cxx
srherbener Aug 9, 2022
3ec5043
Updated calls to NCEPLIB-bufr
rmclaren Aug 10, 2022
aafc721
Now uses OOPS logging.
rmclaren Aug 12, 2022
df7d5c8
Merge branch 'feature/query_cxx' of https://github.com/JCSDA-internal…
rmclaren Aug 12, 2022
4fb7bae
merged from feature/query_cxx
rmclaren Aug 12, 2022
22c73b6
Changed things back to using a NCEPLIB function to get table b data i…
rmclaren Aug 12, 2022
27a670a
Updated for latest NCEPLIB-bufr enhancements branch. It removed get_t…
rmclaren Aug 19, 2022
a53f0e1
Fixed some comments
rmclaren Aug 22, 2022
03bbffd
cast time to seconds instead of dividing by 1000
rmclaren Aug 22, 2022
dccf5a4
fixed norm test failure
rmclaren Aug 22, 2022
a76894e
made exit into exception
rmclaren Aug 22, 2022
dfc55d7
using back inserter to append to sequence path
rmclaren Aug 22, 2022
fbadda3
fixed error message.
rmclaren Aug 22, 2022
703b087
fixed error message.
rmclaren Aug 22, 2022
482f684
added prepbufr to git lfs
rmclaren Aug 22, 2022
aff8124
removed line continuation characters.
rmclaren Aug 22, 2022
bdd5c9b
replaced 10e10 with missing value
rmclaren Aug 22, 2022
f3fe27e
accidentally deleted line of code. added it back
rmclaren Aug 22, 2022
adf9c7e
changed print time function back tot he original.
rmclaren Aug 22, 2022
a2f7e65
using gsl::narrow instead of simpoe static cast
rmclaren Aug 22, 2022
39bfe36
Enhanced vector product function
rmclaren Aug 22, 2022
ec02de9
Pulled out missing value into a Constants.h file to avoid duplication.
rmclaren Aug 22, 2022
d4905fe
fixed some comments
rmclaren Aug 22, 2022
509af0f
fixed file permissions
rmclaren Aug 22, 2022
03dadc4
Added try catch statements to main functions. Fixed warning.
rmclaren Aug 22, 2022
06fb678
pre reserve some memory
rmclaren Aug 23, 2022
79ad913
removed unused test from CMakeLists.txt file.
rmclaren Aug 23, 2022
1360fd9
fixed norm check issues
rmclaren Aug 23, 2022
8dff03a
Added include of unordered map as some compilers were not finding it.
rmclaren Aug 29, 2022
d823c86
merged latest from develop
rmclaren Aug 31, 2022
a5a1b1b
Reverted unintended changes to files in ncar-bufr2nc-fortran and lib-…
rmclaren Aug 31, 2022
4c43af3
Fixed bug that invovled parsing the bufr table data incorrectly. Basi…
rmclaren Sep 1, 2022
f4477bf
Fixed bug in print queries as it was not trimming subset trims proper…
rmclaren Sep 1, 2022
37c0e49
merged latest from query_cxx. fixed issue in print queries where it w…
rmclaren Sep 1, 2022
71f2046
Fixed some warnings and errors that happen with the CLANG compiler.
rmclaren Sep 1, 2022
5281c18
Merge branch 'develop' into feature/query_cxx
srherbener Sep 1, 2022
ba1b34b
Enable the C++14 standard for C++ compiles. (#1036)
srherbener Sep 1, 2022
2cf589b
Fixed some code review issues that Cory Martin broght up.
rmclaren Sep 2, 2022
e49879a
Merge branch 'feature/query_cxx' of https://github.com/JCSDA-internal…
rmclaren Sep 2, 2022
71d2c26
updated docs for DataObject::print function
rmclaren Sep 2, 2022
c78b93e
commented in line that was accidentally commented out
rmclaren Sep 2, 2022
6c29f1f
Revert "commented in line that was accidentally commented out"
rmclaren Sep 2, 2022
f92e4e5
Added back missing tests from the develop branch.
rmclaren Sep 2, 2022
cdecff3
Moved test_iodaconv_generic_gnssro_bufr back to where it was before (…
rmclaren Sep 2, 2022
0327d35
merged latest from feature/query_cxx
rmclaren Sep 6, 2022
25b31d9
Merge branch 'develop' into feature/query_cxx
CoryMartin-NOAA Sep 8, 2022
66ee993
Fixed failing unit tests
rmclaren Sep 8, 2022
f396537
updated mhs unit test with dimension source to test this feature.
rmclaren Sep 8, 2022
6a563eb
Moved applicable create dimension functions to be private scope.
rmclaren Sep 8, 2022
cb80b94
Update unit tests files and fixed some bugs so everything passes now.
rmclaren Sep 9, 2022
09c01c7
Fixed issue caused by code review comment fix that caused bufr2ioda.x…
rmclaren Sep 9, 2022
4e14eb9
Fixed exception handler in print_queries.x.
rmclaren Sep 12, 2022
8d5d8e4
Merged latest from feature/query_cxx
rmclaren Sep 12, 2022
5367711
Updated readme with a type example.
rmclaren Sep 12, 2022
12e8ab8
got the latest from feature/query_cxx
rmclaren Sep 12, 2022
eccc632
Merge branch 'feature/query_cxx_types' into feature/query_labeled_dims
rmclaren Sep 13, 2022
bc048c4
fixed test
rmclaren Sep 13, 2022
2f7d0c6
Updated code to take advantage of types branch
rmclaren Sep 13, 2022
905bd44
Updated docs strings for createDimension functions
rmclaren Sep 13, 2022
4d1e6be
Updated a unit test to check that dimesnion sourcing code is working.
rmclaren Sep 13, 2022
01f2e1f
Added some doc strings to ioda encoder.
rmclaren Sep 13, 2022
db27ad3
Pushing files onto git-lfs
rmclaren Sep 15, 2022
9c65f78
Removed support for unsigned types as Fortran does not support them.
rmclaren Sep 16, 2022
a3c82a3
pushing files into lfs
rmclaren Sep 16, 2022
09064f7
Updated with latest from feature/query_cxx_types
rmclaren Sep 16, 2022
a36a577
Added some validation for the dimension source fields.
rmclaren Sep 19, 2022
3cf0f98
Enhanced some doc strings
rmclaren Sep 19, 2022
96b30cc
Fixed norm test issue
rmclaren Sep 19, 2022
663a2ce
Updated the readme.
rmclaren Sep 19, 2022
5ae5209
resolved merge conflicts
rmclaren Sep 22, 2022
be80e19
Merge branch 'feature/query_cxx_types' into feature/query_labeled_dims
rmclaren Sep 22, 2022
40f0516
Updated adpsfc types (#1034)
nicholasesposito Sep 22, 2022
8f1e3fb
Merge branch 'develop' into feature/query_cxx_types
rmclaren Sep 26, 2022
598b003
Merge branch 'feature/query_cxx_types' into feature/query_labeled_dims
rmclaren Sep 26, 2022
b5e07a9
Fixed some minor code review comments.
rmclaren Sep 27, 2022
b5ef290
Feature/query datetime subset fix (#1059)
rmclaren Sep 28, 2022
a1dedcd
merged the latest from the develop branch
rmclaren Sep 28, 2022
51bbdfc
Merge branch 'develop' into feature/query_labeled_dims
BenjaminRuston Sep 28, 2022
7365dc8
Fixed indentation in CMakeLists.txt file
rmclaren Sep 29, 2022
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
3 changes: 2 additions & 1 deletion src/bufr/BufrParser/BufrParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ namespace Ingester {
{
auto startTime = std::chrono::steady_clock::now();

auto querySet = bufr::QuerySet();
auto querySet = bufr::QuerySet(description_.getExport().getSubsets());

for (const auto &var : description_.getExport().getVariables())
{
for (const auto &queryPair : var->getQueryList())
Expand Down
6 changes: 6 additions & 0 deletions src/bufr/BufrParser/Exports/Export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace
const char* Splits = "splits";
const char* Variables = "variables";
const char* GroupByVariable = "group_by_variable";
const char* Subsets = "subsets";

namespace Variable
{
Expand Down Expand Up @@ -75,6 +76,11 @@ namespace Ingester
groupByVariable = conf.getString(ConfKeys::GroupByVariable);
}

if (conf.has(ConfKeys::Subsets))
{
subsets_ = conf.getStringVector(ConfKeys::Subsets);
}

if (conf.has(ConfKeys::Variables))
{
addVariables(conf.getSubConfiguration(ConfKeys::Variables),
Expand Down
2 changes: 2 additions & 0 deletions src/bufr/BufrParser/Exports/Export.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ namespace Ingester
inline Splits getSplits() const { return splits_; }
inline Variables getVariables() const { return variables_; }
inline Filters getFilters() const { return filters_; }
inline std::vector<std::string> getSubsets() const { return subsets_; }

private:
Splits splits_;
Variables variables_;
Filters filters_;
std::vector<std::string> subsets_;

/// \brief Create Variables exports from config.
void addVariables(const eckit::Configuration &conf,
Expand Down
7 changes: 3 additions & 4 deletions src/bufr/BufrParser/Exports/Splits/CategorySplit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ namespace Ingester
auto location = Location(dataObject->getDims().size(), 0);
location[0] = rowIdx;

auto itemVal = dataObject->getAsFloat(location);
if (trunc(itemVal) == itemVal)
if (auto dat = std::dynamic_pointer_cast<DataObject<int>> (dataObject))
{
nameMap_.insert({static_cast<int> (itemVal),
std::to_string(static_cast<int> (itemVal))});
auto itemVal = dat->get(location);
nameMap_.insert({itemVal, std::to_string(itemVal)});
}
else
{
Expand Down
54 changes: 33 additions & 21 deletions src/bufr/BufrParser/Exports/Variables/DatetimeVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <climits>
#include <iostream>
#include <iomanip>
#include <unordered_map>

#include <ostream>
#include <time.h>
Expand Down Expand Up @@ -71,8 +72,7 @@ namespace Ingester
std::shared_ptr<DataObjectBase> DatetimeVariable::exportData(const BufrDataMap& map)
{
checkKeys(map);
static const float missing = 1.e+11;
static const int64_t missing_int = INT_MIN;
static const int missingInt = DataObject<int>::missingValue();

std::tm tm{}; // zero initialise
tm.tm_year = 1970-1900; // 1970
Expand All @@ -83,26 +83,38 @@ namespace Ingester
tm.tm_sec = 0;
tm.tm_isdst = 0; // Not daylight saving
std::time_t epochDt = std::mktime(&tm);
std::time_t this_time = std::mktime(&tm);
int64_t diff_time;

std::vector<int64_t> timeOffsets;
timeOffsets.reserve(map.at(getExportKey(ConfKeys::Year))->size());

// Validation
if (map.at(getExportKey(ConfKeys::Year))->getDims().size() != 1 ||
map.at(getExportKey(ConfKeys::Month))->getDims().size() != 1 ||
map.at(getExportKey(ConfKeys::Day))->getDims().size() != 1 ||
(!minuteQuery_.empty() &&
map.at(getExportKey(ConfKeys::Minute))->getDims().size() != 1) ||
(!secondQuery_.empty() &&
map.at(getExportKey(ConfKeys::Second))->getDims().size() != 1))
{
std::ostringstream errStr;
errStr << "Datetime variables must be 1 dimensional.";
throw eckit::BadParameter(errStr.str());
}

for (unsigned int idx = 0; idx < map.at(getExportKey(ConfKeys::Year))->size(); idx++)
{
int year = static_cast<int>(map.at(getExportKey(ConfKeys::Year))->getAsFloat(idx));
int month = static_cast<int>(map.at(getExportKey(ConfKeys::Month))->getAsFloat(idx));
int day = static_cast<int>(map.at(getExportKey(ConfKeys::Day))->getAsFloat(idx));
int hour = static_cast<int>(map.at(getExportKey(ConfKeys::Hour))->getAsFloat(idx));
int year = map.at(getExportKey(ConfKeys::Year))->getAsInt(idx);
int month = map.at(getExportKey(ConfKeys::Month))->getAsInt(idx);
int day = map.at(getExportKey(ConfKeys::Day))->getAsInt(idx);
int hour = map.at(getExportKey(ConfKeys::Hour))->getAsInt(idx);
int minutes = 0;
int seconds = 0;

diff_time = missing_int;
if (year != missing &&
month != missing &&
day != missing &&
hour != missing)
auto diff_time = DataObject<int64_t>::missingValue();
if (year != missingInt &&
month != missingInt &&
day != missingInt &&
hour != missingInt)
{
tm.tm_year = year - 1900;
tm.tm_mon = month - 1;
Expand All @@ -114,8 +126,7 @@ namespace Ingester

if (!minuteQuery_.empty())
{
minutes =
static_cast<int>(map.at(getExportKey(ConfKeys::Minute))->getAsFloat(idx));
minutes = map.at(getExportKey(ConfKeys::Minute))->getAsInt(idx);

if (minutes >= 0 && minutes < 60)
{
Expand All @@ -125,25 +136,26 @@ namespace Ingester

if (!secondQuery_.empty())
{
seconds =
static_cast<int>(map.at(getExportKey(ConfKeys::Second))->getAsFloat(idx));
seconds = map.at(getExportKey(ConfKeys::Second))->getAsInt(idx);

if (seconds >= 0 && seconds < 60)
{
tm.tm_sec = seconds;
}
}

this_time = std::mktime(&tm);
if (this_time < 0)
// Be careful with mktime as it can be very slow.
auto thisTime = std::mktime(&tm);
if (thisTime < 0)
{
oops::Log::warning() << "Caution, date suspicious date (year, month, day): "
<< year << ", "
<< month << ", "
<< day << std::endl;
}
diff_time = static_cast<std::int64_t>(difftime(this_time, epochDt)
+ hoursFromUtc_*3600);

diff_time = static_cast<int64_t>(difftime(thisTime, epochDt)
+ hoursFromUtc_ * 3600);
}

timeOffsets.push_back(diff_time);
Expand Down
30 changes: 19 additions & 11 deletions src/bufr/BufrParser/Query/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

#include "File.h"

#include <algorithm>

#include "bufr_interface.h"

#include "Query.h"
#include "QueryRunner.h"
#include "QuerySet.h"
#include "DataProvider.h"

Expand Down Expand Up @@ -61,7 +63,7 @@ namespace bufr {
{
static int SubsetLen = 9;
unsigned int messageNum = 0;
char subset[SubsetLen];
char subsetChars[SubsetLen];
int iddate;

int bufrLoc;
Expand All @@ -70,21 +72,27 @@ namespace bufr {
auto dataProvider = DataProvider(fileUnit_);

auto resultSet = ResultSet(querySet.names());
auto query = Query(querySet, resultSet, dataProvider);
auto queryRunner = QueryRunner(querySet, resultSet, dataProvider);

while (ireadmg_f(fileUnit_, subset, &iddate, SubsetLen) == 0)
while (ireadmg_f(fileUnit_, subsetChars, &iddate, SubsetLen) == 0)
{
while (ireadsb_f(fileUnit_) == 0)
auto subset = std::string(subsetChars);
subset.erase(std::remove_if(subset.begin(), subset.end(), isspace), subset.end());

if (querySet.includesSubset(subset))
{
status_f(fileUnit_, &bufrLoc, &il, &im);
dataProvider.updateData(bufrLoc);
query.query();
while (ireadsb_f(fileUnit_) == 0)
{
status_f(fileUnit_, &bufrLoc, &il, &im);
dataProvider.updateData(bufrLoc);
queryRunner.accumulate();
}

if (next > 0 && ++messageNum >= next) break;
}

if (next > 0 && ++messageNum >= next) break;
}

resultSet.setTargets(query.getTargets());
resultSet.setTargets(queryRunner.getTargets());

dataProvider.deleteData();

Expand Down
33 changes: 24 additions & 9 deletions src/bufr/BufrParser/Query/QueryParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@

namespace Ingester {
namespace bufr {
std::vector<std::string> QueryParser::splitMultiquery(const std::string &query) {
std::vector<Query> QueryParser::parse(const std::string& queryStr)
{
std::vector<Query> queries;
for (auto& subStr : QueryParser::splitMultiquery(queryStr))
{
queries.emplace_back(QueryParser::splitQueryStr(subStr));
}

return queries;
}

std::vector<std::string> QueryParser::splitMultiquery(const std::string &query)
{
std::vector<std::string> subqueries;

// Remove whitespace from query and assign to working_str
Expand Down Expand Up @@ -66,11 +78,8 @@ namespace bufr {
return subqueries;
}


void QueryParser::splitQueryStr(const std::string& query,
std::string& subset,
std::vector<std::string>& mnemonics,
int& index) {
Query QueryParser::splitQueryStr(const std::string& query)
{
// Find positions of slashes
std::vector<size_t> slashPositions;
size_t slashIdx = 0;
Expand All @@ -89,7 +98,7 @@ namespace bufr {
}

// Capture the subset string
subset = query.substr(0, slashPositions[0]);
auto subset = query.substr(0, slashPositions[0]);

std::vector<std::string> mnemonicStrings(slashPositions.size());

Expand All @@ -105,7 +114,7 @@ namespace bufr {
std::string lastElement = query.substr(slashPositions[slashPositions.size() - 1] + 1);

// Parse last element
index = -1;
int index = -1;
size_t startSubscript = lastElement.find_first_of("[");
size_t endSubscript = lastElement.find_first_of("]");
if (startSubscript != std::string::npos && endSubscript != std::string::npos)
Expand All @@ -126,7 +135,13 @@ namespace bufr {
mnemonicStrings.back() = lastElement;
}

mnemonics = mnemonicStrings;
auto queryObj = Query();
queryObj.queryStr = query;
queryObj.subset = subset;
queryObj.mnemonics = mnemonicStrings;
queryObj.index = index;

return queryObj;
}
} // namespace bufr
} // namespace Ingester
19 changes: 12 additions & 7 deletions src/bufr/BufrParser/Query/QueryParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,29 @@
namespace Ingester {
namespace bufr {

struct Query
{
std::string queryStr;
std::string subset;
std::vector<std::string> mnemonics;
int index;
};

/// \brief Parses a user supplied query string into its component parts.
/// \note Will be refactored to properly tokenize the query string.
class QueryParser
{
public:
static std::vector<Query> parse(const std::string& queryStr);

private:
/// \brief Split a multi query (ex: ["*/CLONH", "*/CLON"]) into a vector of single queries.
/// \param query The query to split.
static std::vector<std::string> splitMultiquery(const std::string& query);

/// \brief Split a single query (ex: "*/ROSEQ1/ROSEQ2/PCCF[2]") into its component parts.
/// \param query The query to split.
/// \param[out] subset The subset part of the query (ex: *).
/// \param[out] mnemonics Query path components (ex: ["ROSEQ1", "ROSEQ2", "PCCF"]).
/// \param[out] index The index associated with this query (ex: 2).
static void splitQueryStr(const std::string& query,
std::string& subset,
std::vector<std::string>& mnemonics,
int& index);
static Query splitQueryStr(const std::string& query);

private:
/// \brief Private constructor.
Expand Down
Loading