Skip to content

Commit

Permalink
feature 1580 nccf (#1619)
Browse files Browse the repository at this point in the history
* #1580 Correct the precision at _apply_scale_factor

* #1580 Added unit test plot_data_plane_NCCF_time

* #1580 Changed argument type to double at _apply_scale_factor(double)
  • Loading branch information
hsoh-u authored Jan 14, 2021
1 parent 412cfcd commit ca49ffc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions met/src/libcode/vx_nc_util/nc_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ void _apply_scale_factor(float *data, const T *packed_data,
else {
if (raw_min_val > packed_data[idx]) raw_min_val = packed_data[idx];
if (raw_max_val < packed_data[idx]) raw_max_val = packed_data[idx];
data[idx] = (packed_data[idx] * scale_factor) + add_offset;
data[idx] = ((float)packed_data[idx] * scale_factor) + add_offset;
if (data[idx] > 0) positive_cnt++;
if (min_value > data[idx]) min_value = data[idx];
if (max_value < data[idx]) max_value = data[idx];
Expand Down Expand Up @@ -1667,7 +1667,7 @@ template <typename T>
int _apply_scale_factor(double *data, const T *packed_data,
const int cell_count, const T fill_value,
T &raw_min_val, T &raw_max_val, const char *data_type,
float add_offset, float scale_factor) {
double add_offset, double scale_factor) {
int positive_cnt = 0;
int unpacked_count = 0;
double min_value = 10e10;
Expand All @@ -1680,7 +1680,7 @@ int _apply_scale_factor(double *data, const T *packed_data,
else {
if (raw_min_val > packed_data[idx]) raw_min_val = packed_data[idx];
if (raw_max_val < packed_data[idx]) raw_max_val = packed_data[idx];
data[idx] = (packed_data[idx] * scale_factor) + add_offset;
data[idx] = ((double)packed_data[idx] * scale_factor) + add_offset;
if (data[idx] > 0) positive_cnt++;
if (min_value > data[idx]) min_value = data[idx];
if (max_value < data[idx]) max_value = data[idx];
Expand Down
14 changes: 14 additions & 0 deletions test/xml/unit_plot_data_plane.xml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,20 @@
</output>
</test>

<test name="plot_data_plane_NCCF_time">
<exec>&MET_BIN;/plot_data_plane</exec>
<param> \
&DATA_DIR_MODEL;/nccf/GloTEC_TEC_2015_03_17.nc \
&OUTPUT_DIR;/plot_data_plane/plot_data_plane_NCCF_time.ps \
'name="TEC"; level="(20150317_000500,*,*)"; file_type=NETCDF_NCCF;' \
-title "NCCF GloTEC - Total Electron Content" \
-v 1
</param>
<output>
<ps>&OUTPUT_DIR;/plot_data_plane/plot_data_plane_NCCF_time.ps</ps>
</output>
</test>

<test name="plot_data_plane_GRIB2_PROB">
<exec>&MET_BIN;/plot_data_plane</exec>
<param> \
Expand Down

0 comments on commit ca49ffc

Please sign in to comment.