Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #1019 USCRN #3049

Merged
merged 25 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
30bf0b7
Per #1019, initial setup for supporting -format uscrn. It compiles bu…
JohnHalleyGotway Jan 7, 2025
834b5d7
Per #1019, add NumArray constructor using a vector of doubles.
JohnHalleyGotway Jan 7, 2025
df6211a
Per #1019, saving progress after handling monthly, daily, and hourly …
JohnHalleyGotway Jan 7, 2025
ea54503
Per #1019, consistent spacing.
JohnHalleyGotway Jan 10, 2025
a9530a1
Per #1019, tweak log messages so that the file being read is logged b…
JohnHalleyGotway Jan 10, 2025
64a6f23
Per #1019, update DataLine and LineDataFile classes to support parsin…
JohnHalleyGotway Jan 10, 2025
0ebace0
Per #1019, update USCRN handler code to support all 7 input variants,…
JohnHalleyGotway Jan 10, 2025
4674e98
Per #1019, add units to the Observation class.
JohnHalleyGotway Jan 11, 2025
285804b
Per #1019, add units string to the SummaryObs and SummaryKey classes.
JohnHalleyGotway Jan 11, 2025
302e4d5
Per #1019, update USCRN format to write units. Consider defining unit…
JohnHalleyGotway Jan 11, 2025
ef4d982
Per #1019, add StringArray::all_empty() member function to check for …
JohnHalleyGotway Jan 13, 2025
6202314
Per #1019, update library code to handle the independent writing of p…
JohnHalleyGotway Jan 13, 2025
07dd0a8
Per #1019, add descriptions for all USCRN observations, pulled from t…
JohnHalleyGotway Jan 13, 2025
8f5bedc
Merge remote-tracking branch 'origin/develop' into feature_1019_USCRN
JohnHalleyGotway Jan 13, 2025
add3aef
Per #1019, need to subtract 1900 from the year and 1 from the month t…
JohnHalleyGotway Jan 13, 2025
a92047f
Per #1019, get rid of USCRNHandler::_readHeaderInfo() since it compil…
JohnHalleyGotway Jan 13, 2025
4012a65
Per #1019, rather than always skipping the first line of USCRN csv fi…
JohnHalleyGotway Jan 13, 2025
aa1be48
Per #1019, add an ascii2nc unit test for USCRN point observations.
JohnHalleyGotway Jan 13, 2025
e38af93
Per #1019, doc-only change to indicate the prefix/suffix of the input…
JohnHalleyGotway Jan 13, 2025
d04d83e
Per #1019, update USCRN code to no longer specify a default _qcOffset…
JohnHalleyGotway Jan 14, 2025
c02f1c9
Per #1019, for SonarQube replace ALL instances of push_back() with em…
JohnHalleyGotway Jan 14, 2025
8a9b02a
Per #1019, more changes to address SonarQube code smells and reduce t…
JohnHalleyGotway Jan 14, 2025
65dd8ec
Per #1019, second pass through to further reduce SonarQube findings.
JohnHalleyGotway Jan 15, 2025
de71c6d
Per #1019, revert back to protected members in file_handler.h
JohnHalleyGotway Jan 15, 2025
aca605b
Per #1019, one last round of minor SonarQube code smell remediation.
JohnHalleyGotway Jan 15, 2025
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
8 changes: 5 additions & 3 deletions docs/Users_Guide/reformat_point.rst
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,9 @@ While initial versions of the ASCII2NC tool only supported a simple 11 column AS

• `International Arctic Buoy Programme (IABP) Data format <https://iabp.apl.uw.edu/>`_.

• `AErosol RObotic NEtwork (AERONET) versions 2 and 3 format <http://aeronet.gsfc.nasa.gov/>`_
• `AErosol RObotic NEtwork (AERONET) versions 2 and 3 format <http://aeronet.gsfc.nasa.gov/>`_.

• `U.S. Climate Reference Network (USCRN) Quality Controlled Datasets <https://www.ncei.noaa.gov/access/crn/qcdatasets.html>`_, where the specific data format is determined by the prefix and suffix of the input file name.

• Python embedding of point observations, as described in :numref:`pyembed-point-obs-data`. See example below in :numref:`ascii2nc-pyembed`.

Expand Down Expand Up @@ -507,7 +509,7 @@ Once the ASCII point observations have been formatted as expected, the ASCII fil
Usage: ascii2nc
ascii_file1 [ascii_file2 ... ascii_filen]
netcdf_file
[-format ASCII_format]
[-format type]
[-config file]
[-valid_beg time]
[-valid_end time]
Expand All @@ -530,7 +532,7 @@ Required Arguments for ascii2nc
Optional Arguments for ascii2nc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

3. The **-format ASCII_format** option may be set to "met_point", "little_r", "surfrad", "wwsis", "airnowhourlyaqobs", "airnowhourly", "airnowdaily_v2", "ndbc_standard", "ismn", "iabp", "aeronet", "aeronetv2", "aeronetv3", or "python". If passing in ISIS data, use the "surfrad" format flag.
3. The **-format type** option may be set to "met_point", "little_r", "surfrad", "wwsis", "airnowhourlyaqobs", "airnowhourly", "airnowdaily_v2", "ndbc_standard", "ismn", "iabp", "aeronet", "aeronetv2", "aeronetv3", "uscrn", or "python". If passing in ISIS data, use the "surfrad" format flag.

4. The **-config file** option is the configuration file for generating time summaries.

Expand Down
21 changes: 20 additions & 1 deletion internal/test_unit/xml/unit_ascii2nc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
<test name="ascii2nc_iabp">
<exec>&MET_BIN;/ascii2nc</exec>
<param> \
-format iabp \
-format iabp \
-valid_beg 20140101 -valid_end 20140201 \
&DATA_DIR_OBS;/iabp/090629.dat \
&DATA_DIR_OBS;/iabp/109320.dat \
Expand All @@ -238,4 +238,23 @@
</output>
</test>

<test name="ascii2nc_uscrn">
<exec>&MET_BIN;/ascii2nc</exec>
<param> \
-format uscrn \
-valid_beg 20240801 -valid_end 20240801 \
&DATA_DIR_OBS;/uscrn/monthly01/CRNM0102-CO_Boulder_14_W.txt \
&DATA_DIR_OBS;/uscrn/daily01/2024/CRND0103-2024-CO_Boulder_14_W.txt \
&DATA_DIR_OBS;/uscrn/hourly02/2024/CRNH0203-2024-CO_Boulder_14_W.txt \
&DATA_DIR_OBS;/uscrn/subhourly01/2024/CRNS0101-05-2024-CO_Boulder_14_W.txt \
&DATA_DIR_OBS;/uscrn/soil/soilanom01/CRNSSM0101-CO_Boulder_14_W.csv \
&DATA_DIR_OBS;/uscrn/drought01/CRNDI0101-CO_Boulder_14_W.csv \
&DATA_DIR_OBS;/uscrn/heat01/CRNHE0101-CO_Boulder_14_W.csv \
&OUTPUT_DIR;/ascii2nc/USCRN_Boulder_20240801.nc
</param>
<output>
<point_nc>&OUTPUT_DIR;/ascii2nc/USCRN_Boulder_20240801.nc</point_nc>
</output>
</test>

</met_test>
22 changes: 11 additions & 11 deletions internal/test_util/libcode/vx_nc_util/test_pressure_levels.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ int main(int argc, char *argv[]) {
map<string, vector<string> > variable_levels;

vector<string> u_levels;
u_levels.push_back("P1000");
u_levels.push_back("P800");
u_levels.push_back("P500");
u_levels.emplace_back("P1000");
u_levels.emplace_back("P800");
u_levels.emplace_back("P500");
variable_levels["U"] = u_levels;

vector<string> v_levels;
v_levels.push_back("P1000");
v_levels.push_back("P900");
v_levels.push_back("P700");
v_levels.push_back("P500");
v_levels.push_back("P300");
v_levels.push_back("P100");
v_levels.push_back("P50");
v_levels.push_back("P10");
v_levels.emplace_back("P1000");
v_levels.emplace_back("P900");
v_levels.emplace_back("P700");
v_levels.emplace_back("P500");
v_levels.emplace_back("P300");
v_levels.emplace_back("P100");
v_levels.emplace_back("P50");
v_levels.emplace_back("P10");
variable_levels["V"] = v_levels;

for (map<string, vector<string> >::iterator i = variable_levels.begin();
Expand Down
2 changes: 1 addition & 1 deletion src/basic/vx_config/config_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ vector<MaskLatLon> parse_conf_llpnt_mask(Dictionary *dict) {
}

// Add current MaskLatLon to the vector
v.push_back(m);
v.emplace_back(m);
}

return v;
Expand Down
2 changes: 1 addition & 1 deletion src/basic/vx_config/threshold.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ void Simple_Node::get_simple_nodes(vector<Simple_Node> &v) const

{

v.push_back(*this);
v.emplace_back(*this);

return;

Expand Down
37 changes: 31 additions & 6 deletions src/basic/vx_log/string_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void StringArray::add(const std::string text)

{

s.push_back(text);
s.emplace_back(text);

Sorted = false;

Expand All @@ -277,7 +277,7 @@ void StringArray::add_uniq(const std::string text)

if(!has(text)) {

s.push_back(text);
s.emplace_back(text);

Sorted = false;

Expand Down Expand Up @@ -323,7 +323,7 @@ for(int i=0; i<a.n(); i++) {

if(!has(a[i])) {

s.push_back(a[i]);
s.emplace_back(a[i]);

Sorted = false;

Expand Down Expand Up @@ -378,7 +378,7 @@ void StringArray::set(const std::string text)

s.clear();

s.push_back(text);
s.emplace_back(text);

// Setting to a single value, by nature it is Sorted
Sorted = true;
Expand Down Expand Up @@ -560,6 +560,31 @@ bool StringArray::has(const std::string text, int & index, bool forward) const
////////////////////////////////////////////////////////////////////////


bool StringArray::all_empty() const

{

bool all_empty = true;

//
// Search for non-empty string
//

for(auto &x : s) {
if(!x.size() == 0) {
all_empty = false;
break;
}
}

return all_empty;

}


////////////////////////////////////////////////////////////////////////


void StringArray::parse_wsss(const std::string text)

{
Expand Down Expand Up @@ -600,12 +625,12 @@ void StringArray::parse_delim(const std::string text, const char *delim)
size_t end = str.find_first_of(delim);
while (end != string::npos) {
if (start != end)
s.push_back(str.substr(start, end-start).c_str());
s.emplace_back(str.substr(start, end-start).c_str());
start = end + 1;
end = str.find_first_of(delim, start);
}
if (start < str.length())
s.push_back(str.substr(start).c_str());
s.emplace_back(str.substr(start).c_str());

Sorted = false;

Expand Down
2 changes: 2 additions & 0 deletions src/basic/vx_log/string_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class StringArray {

bool has(const std::string, int & index, bool forward=true) const;

bool all_empty() const;

//
// parse delimited strings
//
Expand Down
8 changes: 4 additions & 4 deletions src/basic/vx_math/pwl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ Name = NAME;

for (int j=0; j<Npoints; ++j) {

X.push_back(XX[j]);
Y.push_back(YY[j]);
X.emplace_back(XX[j]);
Y.emplace_back(YY[j]);

}

Expand Down Expand Up @@ -266,8 +266,8 @@ void PiecewiseLinear::add_point(double xx, double yy)

{

X.push_back(xx);
Y.push_back(yy);
X.emplace_back(xx);
Y.emplace_back(yy);

return;

Expand Down
12 changes: 6 additions & 6 deletions src/basic/vx_util/GridTemplate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ GridTemplate::GridTemplate(const GridTemplate& rhs) {

for (offset_iter = rhs._offsetList.begin();
offset_iter != rhs._offsetList.end(); ++offset_iter)
_offsetList.push_back(new GridOffset(*offset_iter));
_offsetList.emplace_back(new GridOffset(*offset_iter));

_pointInGridBase = rhs._pointInGridBase;
_pointInGridNumX = rhs._pointInGridNumX;
Expand Down Expand Up @@ -506,7 +506,7 @@ void GridTemplate::printOffsetList(FILE *stream) {
void GridTemplate::_addOffset(int x_offset, int y_offset) {
GridOffset *offset = new GridOffset(x_offset, y_offset);

_offsetList.push_back(offset);
_offsetList.emplace_back(offset);

return;
}
Expand Down Expand Up @@ -558,28 +558,28 @@ void GridTemplate::_setEdgeOffsets() {
for(m_iterator = min_x_by_y.begin();
m_iterator != min_x_by_y.end();
m_iterator++) {
_offsetLftEdge.push_back(m_iterator->second);
_offsetLftEdge.emplace_back(m_iterator->second);
}

// Store max_x_by_y map as _offsetRgtEdge vector
for(m_iterator = max_x_by_y.begin();
m_iterator != max_x_by_y.end();
m_iterator++) {
_offsetRgtEdge.push_back(m_iterator->second);
_offsetRgtEdge.emplace_back(m_iterator->second);
}

// Store max_y_by_x map as _offsetTopEdge vector
for(m_iterator = max_y_by_x.begin();
m_iterator != max_y_by_x.end();
m_iterator++) {
_offsetTopEdge.push_back(m_iterator->second);
_offsetTopEdge.emplace_back(m_iterator->second);
}

// Store min_y_by_x map as _offsetBotEdge vector
for(m_iterator = min_y_by_x.begin();
m_iterator != min_y_by_x.end();
m_iterator++) {
_offsetBotEdge.push_back(m_iterator->second);
_offsetBotEdge.emplace_back(m_iterator->second);
}

return;
Expand Down
4 changes: 2 additions & 2 deletions src/basic/vx_util/GridTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ class GridTemplate {
// Access methods

inline void addOffset(const GridOffset &offset) {
_offsetList.push_back(new GridOffset(offset.x_offset,
_offsetList.emplace_back(new GridOffset(offset.x_offset,
offset.y_offset));
}

inline void addOffset(const int x_offset, const int y_offset) {
_offsetList.push_back(new GridOffset(x_offset, y_offset));
_offsetList.emplace_back(new GridOffset(x_offset, y_offset));
}

int size(void) const {
Expand Down
2 changes: 1 addition & 1 deletion src/basic/vx_util/ascii_header.cc
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ void AsciiHeader::read(const char *version) {
header_line.set_col_names(line[3]);

// Store the current line
Headers.push_back(header_line);
Headers.emplace_back(header_line);
}

// Store the version we just loaded
Expand Down
4 changes: 2 additions & 2 deletions src/basic/vx_util/crc_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ void CRC_Array<T>::add(const T & k)

extend(Nelements + 1, false);

e.push_back(k);
e.emplace_back(k);

Nelements++;

Expand All @@ -494,7 +494,7 @@ int j;

for (j=0; j<(a.Nelements); ++j) {

e.push_back(a.e[j]);
e.emplace_back(a.e[j]);

Nelements++;

Expand Down
Loading
Loading