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 2842 ugrid config #2852

Merged
merged 24 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
48b52e7
#2842 Removed UGrid related setting
Mar 27, 2024
9feae3d
#2842 Corrected vertical level for data_plane_array
Mar 27, 2024
01ae422
#2842 Do not allow the time range
Mar 27, 2024
1b43102
#2842 The UGridConfig file can be passed as ugrid_dataset
Mar 27, 2024
334b2a8
#2842 Changed -config option to -ugrid_config
Mar 27, 2024
b9ca329
#2842 Deleted UGrid configurations
Mar 28, 2024
7f25cf8
2842 Fix a compile error when UGrid is disabled
Apr 2, 2024
8293c53
#2842 Cleanup
Apr 2, 2024
816c12c
#2842 Added an unittest point_stat_ugrid_mpas_config
Apr 8, 2024
613035c
#2842 Added a PointStatConfig without UGrid dataset.
Apr 8, 2024
42f65bd
#2842 Corrected ty[po at the variable name
Apr 17, 2024
301a14b
Merge remote-tracking branch 'origin/develop' into feature_2842_ugrid…
Apr 17, 2024
0974159
Switched from time_centered to time_instant. I think time_centered is…
DanielAdriaansen Apr 18, 2024
7933a7e
#2842 Removed ugrid_max_distance_km and unused metadata names
Apr 19, 2024
faac20c
#2842 Restored time variable for LFric
Apr 19, 2024
a253d1e
#2842 Restored time variable time_instant for LFric
Apr 19, 2024
3c16852
#2842 Adjust lon between -180 and 180
Apr 23, 2024
2472b84
#2842 Adjust lon between -180 and 180
Apr 23, 2024
9dfc8bf
#2842 Adjust lon between -180 and 180
Apr 23, 2024
fd42640
#2842 Adjusted lon to between -180 to 180
Apr 23, 2024
50d6e4a
#2842 Changed variable names
Apr 23, 2024
f620206
Per #2842, switch from degrees east to west right when the longitudes…
JohnHalleyGotway Apr 24, 2024
f25dd19
#2842, switch from degrees east to west right when the longitudes are…
Apr 24, 2024
07e4209
#2842 Cleanup debug messages
Apr 25, 2024
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
6 changes: 0 additions & 6 deletions data/config/GridStatConfig_default
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,6 @@ nc_pairs_flag = {

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

ugrid_dataset = "";
ugrid_max_distance_km = 30;
ugrid_coordinates_file = "";

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

grid_weight_flag = NONE;
tmp_dir = "/tmp";
output_prefix = "";
Expand Down
6 changes: 0 additions & 6 deletions data/config/PointStatConfig_default
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,6 @@ output_flag = {

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

ugrid_dataset = "";
ugrid_max_distance_km = 30;
ugrid_coordinates_file = "";

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

tmp_dir = "/tmp";
output_prefix = "";
version = "V12.0.0";
Expand Down
167 changes: 167 additions & 0 deletions internal/test_unit/config/PointStatConfig_ugrid_no_dataset
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
////////////////////////////////////////////////////////////////////////////////
//
// Point-Stat configuration file.
//
// For additional information, please see the MET User's Guide.
//
////////////////////////////////////////////////////////////////////////////////

model = "WRF";

//
// Output description to be written
// May be set separately in each "obs.field" entry
//
desc = "NA";

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

regrid = {
to_grid = NONE;
method = NEAREST;
width = 1;
}

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

obs_window = {
beg = ${BEG_DS};
end = ${END_DS};
}

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

mpr_column = [];
mpr_thresh = [];
cnt_thresh = [ NA ];
cnt_logic = UNION;
wind_thresh = [ NA ];
wind_logic = UNION;
eclv_points = 0.05;


fcst = {
sid_inc = [];
sid_exc = [];
obs_quality_inc = [];
obs_quality_exc = [];

field = [
{ name = "theta"; level = "L2"; message_type = "ADPSFC"; }
];

}

obs = {
sid_inc = [];
sid_exc = [];
obs_quality_inc = [];
obs_quality_exc = [];

field = [
{ name = "TMP"; level = "P1000-500"; message_type = "ADPSFC"; }
];

}

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

climo_mean = obs;
climo_mean = {
file_name = [];
}

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

mask = {
grid = [];
poly = [];
sid = [];
llpnt = [{ name = "ALLLATLON"; lat_thresh = NA; lon_thresh = NA; }];
}

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

ci_alpha = [ 0.05 ];

boot = {
interval = PCTILE;
rep_prop = 1.0;
n_rep = 200;
rng = "mt19937";
seed = "1";
}

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

interp = {
vld_thresh = 1.0;

type = [
{
method = NEAREST;
width = 1;
}
];
}

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

hira = {
flag = FALSE;
width = [ 2, 3, 4, 5 ];
vld_thresh = 1.0;
cov_thresh = [ ==0.25 ];
shape = SQUARE;
prob_cat_thresh = [];
}

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

output_flag = {
fho = BOTH;
ctc = BOTH;
cts = BOTH;
mctc = NONE;
mcts = NONE;
cnt = BOTH;
sl1l2 = NONE;
sal1l2 = NONE;
vl1l2 = NONE;
val1l2 = NONE;
vcnt = BOTH;
pct = NONE;
pstd = NONE;
pjc = NONE;
prc = NONE;
ecnt = NONE;
orank = NONE;
rps = NONE;
eclv = BOTH;
mpr = BOTH;
seeps = NONE;
seeps_mpr = NONE;
}

////////////////////////////////////////////////////////////////////////////////
// Threshold for SEEPS p1 (Probability of being dry)

seeps_p1_thresh = NA;

////////////////////////////////////////////////////////////////////////////////
// Unstructured Grid (optional ecept ugrid_dataset)

//ugrid_dataset = "mpas";
ugrid_max_distance_km = 35;
//ugrid_map_config = "";
ugrid_coordinates_file = "${MET_TEST_INPUT}/ugrid_data/mpas/static.40962_reduced.nc";

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

duplicate_flag = NONE;
rank_corr_flag = TRUE;
tmp_dir = "/tmp";
output_prefix = "${OUTPUT_PREFIX}";
version = "V12.0.0";

////////////////////////////////////////////////////////////////////////////////
26 changes: 26 additions & 0 deletions internal/test_unit/xml/unit_ugrid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,30 @@
</output>
</test>

<test name="point_stat_ugrid_mpas_config">
<exec>&MET_BIN;/point_stat</exec>
<env>
<pair><name>BEG_DS</name> <value>-1800</value></pair>
<pair><name>END_DS</name> <value>1800</value></pair>
<pair><name>OUTPUT_PREFIX</name> <value>UGRID_MPAS_CFG_OUT_TEMP</value></pair>
<pair><name>CONFIG_DIR</name> <value>&CONFIG_DIR;</value></pair>
</env>
<param> \
&DATA_DIR_UGRID;/mpas/mpasout.2012-04-09_12.00.00_reduced.nc \
&OUTPUT_DIR;/pb2nc/gdas1.20120409.t12z.prepbufr.nc \
&CONFIG_DIR;/PointStatConfig_ugrid_no_dataset \
-ugrid_config ${MET_BASE}/config/UGridConfig_mpas \
-outdir &OUTPUT_DIR;/point_stat_ugrid -v 1
</param>
<output>
<stat>&OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V.stat</stat>
<stat>&OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_fho.txt</stat>
<stat>&OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_ctc.txt</stat>
<stat>&OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_cts.txt</stat>
<stat>&OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_cnt.txt</stat>
<stat>&OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_eclv.txt</stat>
<stat>&OUTPUT_DIR;/point_stat_ugrid/point_stat_UGRID_MPAS_CFG_OUT_TEMP_000000L_20120409_120000V_mpr.txt</stat>
</output>
</test>

</met_test>
23 changes: 1 addition & 22 deletions src/libcode/vx_data2d_ugrid/data2d_ugrid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,27 +322,6 @@ int MetUGridDataFile::data_plane_array(VarInfo &vinfo,
mlog << Error << "\n" << method_name
<< "LevelType_Time for unstructured grid is not enabled\n\n";
exit(1);
/* Not enabled
const int debug_level = 7;
LongArray time_offsets = collect_time_offsets(vinfo);
if (0 < time_offsets.n_elements()) {
for (int idx=0; idx<time_offsets.n_elements(); idx++) {
_cur_time_index = time_offsets[idx];
if (data_plane(vinfo, plane)) {
plane_array.add(plane, lvl_lower, lvl_upper);
n_rec++;
}
}

if (mlog.verbosity_level() >= debug_level) {
for (int idx=0; idx< time_offsets.n_elements(); idx++ ) {
mlog << Debug(debug_level) << method_name << "time: "
<< unix_to_yyyymmdd_hhmmss(_file->ValidTime[time_offsets[idx]])
<< " from index " << time_offsets[idx] << "\n";
}
}
}
*/
}
else if (level.type() == LevelType_Pres) {
if (nullptr == data_vinfo) {
Expand All @@ -353,7 +332,7 @@ int MetUGridDataFile::data_plane_array(VarInfo &vinfo,
if (vlevel >= lvl_lower && vlevel <= lvl_upper) {
vinfo.set_req_name(vinfo_list[idx]->name.c_str());
if (data_plane(vinfo, plane, vinfo_list[idx])) {
plane_array.add(plane, lvl_lower, lvl_upper);
plane_array.add(plane, vlevel, vlevel);
n_rec++;
}
mlog << Debug(5) << method_name
Expand Down
30 changes: 18 additions & 12 deletions src/libcode/vx_data2d_ugrid/ugrid_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -958,33 +958,39 @@ void UGridFile::read_netcdf_grid()

void UGridFile::set_dataset(ConcatString _dataset_name) {

const char *ugrid_config_name = nullptr;
ConcatString ugrid_config_name;
const string method_nmame = "UGridFile::set_dataset() ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const string method_nmame = "UGridFile::set_dataset() ";
const string method_name = "UGridFile::set_dataset() ";


if (0 == _dataset_name.length()) {
mlog << Error << "\nUGridFile::set_dataset()"
<< " The \"" << conf_key_ugrid_dataset
mlog << Error << "\n" << method_nmame
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mlog << Error << "\n" << method_nmame
mlog << Error << "\n" << method_name

<< "The \"" << conf_key_ugrid_dataset
<< "\" is not defined at the configuration file.\n\n";
exit(1);
}
dataset_name = _dataset_name;
ConcatString dataset_config(def_config_prefix);
dataset_config.add(dataset_name);
if (!file_exists(dataset_config.c_str())) {
dataset_config = def_config_prefix2;
if (file_exists(dataset_name.c_str())) {
/* UGridConfig file was passed as the ugrid_dataset */
ugrid_config_name = dataset_name;
}
else {
ConcatString dataset_config(def_config_prefix);
dataset_config.add(dataset_name);
dataset_config = replace_path(dataset_config.c_str());
if (!file_exists(dataset_config.c_str())) {
dataset_config = def_config_prefix2;
dataset_config.add(dataset_name);
dataset_config = replace_path(dataset_config.c_str());
}
ugrid_config_name = dataset_config;
}
ugrid_config_name = dataset_config.c_str();
if (file_exists(ugrid_config_name)) {
read_config(ugrid_config_name);
if (file_exists(ugrid_config_name.c_str())) {
read_config(ugrid_config_name.c_str());
}
else {
mlog << Error << "\nUGridFile::set_dataset()"
<< " The UGrid dataset \"" << dataset_name << "\" is not supported. Please add \""
<< ugrid_config_name << "\".\n\n";
exit(1);
}

}

////////////////////////////////////////////////////////////////////////
Expand Down
55 changes: 0 additions & 55 deletions src/libcode/vx_data2d_ugrid/var_info_ugrid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,61 +231,6 @@ void VarInfoUGrid::set_magic(const ConcatString &nstr, const ConcatString &lstr)
Level.set_is_offset(as_offset);
}
}
// Check for a range of times
else if ((ptr3 = strchr(ptr2, ':')) != nullptr) {
// Check if a range has already been supplied
if (Dimension.has(range_flag)) {
mlog << Error << "\n" << method_name
<< "only one dimension can have a range for NetCDF variable \""
<< MagicStr << "\".\n\n";
exit(1);
}
else {
int increment = 1;
// Store the dimension of the range and limits
*ptr3++ = 0;
char *ptr_inc = strchr(ptr3, ':');
if (ptr_inc != nullptr) *ptr_inc++ = 0;
mlog << Debug(7) << method_name
<< " start: " << ptr2 << ", end: " << ptr3 << "\n";

bool datestring_start = is_datestring(ptr2);
bool datestring_end = is_datestring(ptr3);
if (datestring_start != datestring_end) {
mlog << Error << "\n" << method_name
<< "the time value and an index/offset can not be mixed for NetCDF variable \""
<< MagicStr << "\".\n\n";
exit(1);
}
if (datestring_start && datestring_end) as_offset = false;

unixtime time_lower = datestring_start
? timestring_to_unix(ptr2)
: (as_offset ? atoi(ptr2) : atof(ptr2));
unixtime time_upper = datestring_end
? timestring_to_unix(ptr3)
: (as_offset ? atoi(ptr3) : atof(ptr3));
if (ptr_inc != nullptr) {
if (as_offset) increment = atoi(ptr_inc);
else {
increment = is_float(ptr_inc)
? atof(ptr_inc) : timestring_to_sec(ptr_inc);
mlog << Debug(7) << method_name
<< " increment: \"" << ptr_inc << "\" to "
<< increment << " seconds.\n";
}
}

add_dimension(range_flag, as_offset);
Level.set_lower(time_lower);
Level.set_upper(time_upper);
Level.set_increment(increment);

// Assume time level type for a range of levels
Level.set_type(LevelType_Time);
Level.set_is_offset(as_offset);
}
}
else {
// Single level
int level = 0;
Expand Down
Loading