Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature_2924_parse…
Browse files Browse the repository at this point in the history
…_config
  • Loading branch information
JohnHalleyGotway committed Sep 12, 2024
2 parents 7849d5d + 095cd8e commit 6edd245
Show file tree
Hide file tree
Showing 18 changed files with 1,263 additions and 3,134 deletions.
2 changes: 1 addition & 1 deletion docs/Users_Guide/reformat_point.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ Only 4 interpolation methods are applied to the field variables; MIN/MAX/MEDIAN/
For the GOES-16 and GOES-17 data, the computing lat/long is time consuming. The computed coordinate (lat/long) is saved to a temporary NetCDF file, as described in :numref:`Contributor's Guide Section %s <tmp_files_point2grid>`. The computing lat/long step can be skipped if the coordinate file is given through the environment variable MET_GEOSTATIONARY_DATA. The grid mapping to the target grid is saved to MET_TMP_DIR to save the execution time. Once this file is created, the MET_GEOSTATIONARY_DATA is ignored. The grid mapping file should be deleted manually in order to apply a new MET_GEOSTATIONARY_DATA environment variable or to re-generate the grid mapping file. An example of call point2grid to process GOES-16 AOD data is shown below:


The grid name or the grid definition can be given with the -field option when the grid information is missing from the input NetCDF file for the latitude_longitude projection. The latitude and longitude variable names should be defined by the user, and the grid information from the set_attr_grid is ignored in this case
The grid name or the grid definition can be given with the -field option when the grid information is missing from the input NetCDF file for the latitude_longitude projection. The latitude and longitude variable names should be defined by the user, and the grid information from the set_attr_grid is ignored in this case except nx and ny.

.. code-block:: none
Expand Down
2 changes: 1 addition & 1 deletion internal/scripts/docker/Dockerfile.sonarqube
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MAINTAINER John Halley Gotway <johnhg@ucar.edu>
# SonarQube static code analysis on the specified branch or tag.
# https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/
#
ARG SONAR_SCANNER_VERSION=5.0.1.3006
ARG SONAR_SCANNER_VERSION=6.1.0.4477
ARG SONAR_HOST_URL
ARG SONAR_TOKEN
ARG SOURCE_BRANCH
Expand Down
1 change: 1 addition & 0 deletions internal/scripts/docker/build_met_sonarqube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ time_command ./configure \
BUFRLIB_NAME=${BUFRLIB_NAME} \
GRIB2CLIB_NAME=${GRIB2CLIB_NAME} \
--enable-all \
MET_CXX_STANDARD=11 \
CPPFLAGS="-I/usr/local/include -I/usr/local/include/freetype2 -I/usr/local/include/cairo" \
LIBS="-ltirpc"

Expand Down
5 changes: 3 additions & 2 deletions internal/scripts/sonarqube/run_sonarqube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ run_command "git checkout ${1}"
# Otherwise, the SonarQube logic does not work.
export MET_DEVELOPMENT=true

# Run the configure script
run_command "./configure --prefix=`pwd` --enable-all"
# Run the configure script.
# Specify the C++ standard to limit the scope of the findings.
run_command "./configure --prefix=`pwd` --enable-all MET_CXX_STANDARD=11"

# Define the version string
SONAR_PROJECT_VERSION=$(grep "^version" docs/conf.py | cut -d'=' -f2 | tr -d "\'\" ")
Expand Down
11 changes: 9 additions & 2 deletions internal/test_unit/python/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def unit(test_xml, file_log=None, cmd_only=False, noexit=False, memchk=False, ca
if cmd_only:
if 'env' in test.keys():
for key, val in sorted(test['env'].items()):
print(f"export {key}={val}")
print(f"export '{key}={val}'")
print(f"{cmd}")
if 'env' in test.keys():
for key, val in sorted(test['env'].items()):
Expand All @@ -143,7 +143,7 @@ def unit(test_xml, file_log=None, cmd_only=False, noexit=False, memchk=False, ca
logger.debug(f"Return code: {cmd_return.returncode}")

# # check the return status and output files
ret_ok = not cmd_return.returncode
ret_ok = (cmd_return.returncode == test['retval'])
if ret_ok:
out_ok = True

Expand Down Expand Up @@ -279,9 +279,16 @@ def build_tests(test_root):
logger.error("ERROR: name attribute not found for test")
raise

test['retval'] = 0
for el in test_el:
if (el.tag=='exec' or el.tag=='param'):
test[el.tag] = repl_env(el.text)
elif el.tag=='retval':
try:
test['retval'] = int(el.text)
except ValueError:
logger.error("ERROR: retval must be an integer value")
raise
elif el.tag=='output':
test['out_pnc'] = []
test['out_gnc'] = []
Expand Down
12 changes: 12 additions & 0 deletions internal/test_unit/xml/unit_ascii2nc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@
</output>
</test>

<test name="ascii2nc_GAGE_24hr_badfile">
<exec>&MET_BIN;/ascii2nc</exec>
<retval>1</retval>
<param> \
&DATA_DIR_OBS;/gauge/2012041012.badfile.ascii \
&OUTPUT_DIR;/ascii2nc/gauge_2012041012_24hr.nc \
-v 1
</param>
<output>
</output>
</test>

<test name="ascii2nc_duplicates">
<exec>&MET_BIN;/ascii2nc</exec>
<param> \
Expand Down
2 changes: 1 addition & 1 deletion internal/test_unit/xml/unit_point2grid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@
G231 \
&OUTPUT_DIR;/point2grid/point2grid_cice_to_G231.nc \
-config &CONFIG_DIR;/Point2GridConfig_tlat_tlon \
-field 'name="hi_d"; level="(0,*,*)"; set_attr_grid="latlon 180 360 -80 -180 1 1";' \
-field 'name="hi_d"; level="(0,*,*)"; set_attr_grid="latlon 1440 1080 -80 -180 0.1 0.1";' \
-v 1
</param>
<output>
Expand Down
15 changes: 8 additions & 7 deletions src/basic/vx_util/num_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class NumArray {

double operator[](int) const;

const double * vals() const;
const std::vector<double> & vals() const;
double * buf();

int has(int, bool forward=true) const;
Expand Down Expand Up @@ -127,12 +127,13 @@ class NumArray {
////////////////////////////////////////////////////////////////////////


inline int NumArray::n_elements() const { return ( e.size() ); }
inline int NumArray::n () const { return ( e.size() ); }
inline const double * NumArray::vals() const { return ( e.data() ); }
inline double * NumArray::buf() { return ( e.data() ); }
inline void NumArray::inc(int i, int v) { e[i] += v; return; }
inline void NumArray::inc(int i, double v) { e[i] += v; return; }
inline int NumArray::n_elements() const { return e.size(); }
inline int NumArray::n() const { return e.size(); }
inline const std::vector<double> &
NumArray::vals() const { return e; }
inline double * NumArray::buf() { return e.data(); }
inline void NumArray::inc(int i, int v) { e[i] += v; return; }
inline void NumArray::inc(int i, double v) { e[i] += v; return; }


////////////////////////////////////////////////////////////////////////
Expand Down
7 changes: 7 additions & 0 deletions src/basic/vx_util/thresh_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,13 @@ ThreshArray define_prob_bins(double beg, double end, double inc, int prec) {
v += inc;
}

// Add final 1.0 threshold, if needed
v = ta[(ta.n() - 1)].get_value();
if(v < 1.0 && !is_eq(v, 1.0)) {
cs << cs_erase << ">=1.0";
ta.add(cs.c_str());
}

return ta;
}

Expand Down
12 changes: 12 additions & 0 deletions src/libcode/vx_data2d_nc_cf/nc_cf_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,18 @@ bool NcCfFile::getData(NcVar * v, const LongArray & a, DataPlane & plane) const
const int nx = grid.nx();
const int ny = grid.ny();

size_t data_size = 1;
for (int k=0; k<dim_count; k++) {
if (a[k] == vx_data2d_star) data_size *= v->getDim(k).getSize();
}
if (data_size == 1) data_size = v->getDim(x_slot).getSize() * v->getDim(y_slot).getSize();
if (!is_eq(data_size, (size_t)nx*ny)) {
mlog << Error << "\n" << method_name
<< "Allocated DataPlane from Grid (" << nx*ny << ") does not match with the variable size ("
<< data_size << "). Please check set_attr_grid settings (nx and ny) if applied.\n\n";
exit(1);
}

plane.clear();
plane.set_size(nx, ny);

Expand Down
36 changes: 16 additions & 20 deletions src/libcode/vx_statistics/compute_ci.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,8 @@ void compute_wilson_ci(double p, int n_int, double alpha, double vif,
////////////////////////////////////////////////////////////////////////

void compute_woolf_ci(double odds, double alpha,
int fy_oy, int fy_on, int fn_oy, int fn_on,
double fy_oy, double fy_on, double fn_oy, double fn_on,
double &odds_cl, double &odds_cu) {
double cv_normal_l, cv_normal_u, a, b;

if(is_bad_data(odds) ||
fy_oy == 0 || fy_on == 0 || fn_oy == 0 || fn_on == 0) {
Expand All @@ -185,14 +184,14 @@ void compute_woolf_ci(double odds, double alpha,
// Compute the upper and lower critical values from the
// normal distribution.
//
cv_normal_l = normal_cdf_inv(alpha/2.0, 0.0, 1.0);
cv_normal_u = normal_cdf_inv(1.0 - (alpha/2.0), 0.0, 1.0);
double cv_normal_l = normal_cdf_inv(alpha/2.0, 0.0, 1.0);
double cv_normal_u = normal_cdf_inv(1.0 - (alpha/2.0), 0.0, 1.0);

//
// Compute the upper and lower bounds of the confidence interval
//
a = exp(cv_normal_l*sqrt(1.0/fy_oy + 1.0/fy_on + 1.0/fn_oy + 1.0/fn_on));
b = exp(cv_normal_u*sqrt(1.0/fy_oy + 1.0/fy_on + 1.0/fn_oy + 1.0/fn_on));
double a = exp(cv_normal_l*sqrt(1.0/fy_oy + 1.0/fy_on + 1.0/fn_oy + 1.0/fn_on));
double b = exp(cv_normal_u*sqrt(1.0/fy_oy + 1.0/fy_on + 1.0/fn_oy + 1.0/fn_on));

odds_cl = odds * a;
odds_cu = odds * b;
Expand All @@ -210,19 +209,16 @@ void compute_woolf_ci(double odds, double alpha,
////////////////////////////////////////////////////////////////////////

void compute_hk_ci(double hk, double alpha, double vif,
int fy_oy, int fy_on, int fn_oy, int fn_on,
double fy_oy, double fy_on, double fn_oy, double fn_on,
double &hk_cl, double &hk_cu) {
double cv_normal, stdev;
double h, h_var, f_var;
int h_n, f_n;

//
// Get the counts
//
h_n = fy_oy + fn_oy;
f_n = fn_on + fy_on;
double h_n = fy_oy + fn_oy;
double f_n = fn_on + fy_on;

if(is_bad_data(hk) || h_n == 0 || f_n == 0) {
if(is_bad_data(hk) || is_eq(h_n, 0.0) || is_eq(f_n, 0.0)) {
hk_cl = hk_cu = bad_data_double;
return;
}
Expand All @@ -231,26 +227,26 @@ void compute_hk_ci(double hk, double alpha, double vif,
// Compute the critical value for the normal distribution based
// on the sample size
//
cv_normal = normal_cdf_inv(alpha/2.0, 0.0, 1.0);
double cv_normal = normal_cdf_inv(alpha/2.0, 0.0, 1.0);

//
// Compute the hit rate and false alarm rate
//
h = (double) fy_oy/h_n;
double h = fy_oy/h_n;

//
// Compute a variance for H and F
//
h_var = sqrt(h*(1.0-h)/h_n + cv_normal*cv_normal/(4.0*h_n*h_n))
/ (1.0 + cv_normal*cv_normal/h_n);
double h_var = sqrt(h*(1.0-h)/h_n + cv_normal*cv_normal/(4.0*h_n*h_n))
/ (1.0 + cv_normal*cv_normal/h_n);

f_var = sqrt(h*(1.0-h)/f_n + cv_normal*cv_normal/(4.0*f_n*f_n))
/ (1.0 + cv_normal*cv_normal/f_n);
double f_var = sqrt(h*(1.0-h)/f_n + cv_normal*cv_normal/(4.0*f_n*f_n))
/ (1.0 + cv_normal*cv_normal/f_n);

//
// Compute the standard deviation for HK
//
stdev = sqrt(vif*(h_var*h_var + f_var*f_var));
double stdev = sqrt(vif*(h_var*h_var + f_var*f_var));

//
// Compute the upper and lower bounds of the confidence interval
Expand Down
4 changes: 2 additions & 2 deletions src/libcode/vx_statistics/compute_ci.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ extern void compute_wilson_ci(double p, int n, double alpha,
double vif, double &p_cl, double &p_cu);

extern void compute_woolf_ci(double odds, double alpha,
int fy_oy, int fy_on, int fn_oy, int fn_on,
double fy_oy, double fy_on, double fn_oy, double fn_on,
double &odds_cl, double &odds_cu);

extern void compute_hk_ci(double hk, double alpha, double vif,
int fy_oy, int fy_on, int fn_oy, int fn_on,
double fy_oy, double fy_on, double fn_oy, double fn_on,
double &hk_cl, double &hk_cu);

extern void compute_cts_stats_ci_bca(const gsl_rng *,
Expand Down
Loading

0 comments on commit 6edd245

Please sign in to comment.