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 all 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
17 changes: 4 additions & 13 deletions data/config/UGridConfig_lfric
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Unstructured grid configuration file.
//
// UGridConfig_lfric at the current working directory overrides the settings here.
// UGridConfig_lfric at the current working directory replaces the settings here.
// For additional or updated information, please see the MET User's Guide.
//
////////////////////////////////////////////////////////////////////////////////
Expand All @@ -12,23 +12,14 @@
//
ugrid_metadata_map = [
{ key = "dim_face"; val = "nMesh2d_face"; },
{ key = "dim_node"; val = "nMesh2d_node"; },
{ key = "dim_edge"; val = "nMesh2d_edge"; },
{ key = "dim_time"; val = "time_counter"; },
{ key = "dim_vert"; val = "nVertLevels"; },
{ key = "cell_id"; val = "indexToCellID"; },
{ key = "dim_vert"; val = ""; }, // optional
{ key = "lat_face"; val = "Mesh2d_face_y"; },
{ key = "lon_face"; val = "Mesh2d_face_x"; },
{ key = "vert_face"; val = "zCell"; },
{ key = "lat_edge"; val = "Mesh2d_edge_y"; },
{ key = "lon_edge"; val = "Mesh2d_edge_x"; },
{ key = "lat_node"; val = "Mesh2d_node_y"; },
{ key = "lon_node"; val = "Mesh2d_node_x"; },
{ key = "time"; val = "time_centered"; }
{ key = "vert_face"; val = ""; }, // optional
{ key = "time"; val = "time_instant"; }
];

ugrid_max_distance_km = 30;

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

version = "V12.0.0";
Expand Down
15 changes: 3 additions & 12 deletions data/config/UGridConfig_mpas
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Unstructured grid configuration file.
//
// UGridConfig_mpas at the current working directory overrides the settings here.
// UGridConfig_mpas at the current working directory replaces the settings here.
// For additional or updated information, please see the MET User's Guide.
//
////////////////////////////////////////////////////////////////////////////////
Expand All @@ -12,23 +12,14 @@
//
ugrid_metadata_map = [
{ key = "dim_face"; val = "nCells"; },
{ key = "dim_node"; val = "nVertices"; },
{ key = "dim_edge"; val = "nEdges"; },
{ key = "dim_time"; val = "Time"; },
{ key = "dim_vert"; val = "nVertLevels"; },
{ key = "cell_id"; val = "indexToCellID"; },
{ key = "dim_vert"; val = "nVertLevels"; }, // optional
{ key = "lat_face"; val = "latCell"; },
{ key = "lon_face"; val = "lonCell"; },
{ key = "vert_face"; val = "zCell"; },
{ key = "lat_edge"; val = "latEdge"; },
{ key = "lon_edge"; val = "lonEdge"; },
{ key = "lat_node"; val = "latVertex"; },
{ key = "lon_node"; val = "lonVertex"; },
{ key = "vert_face"; val = "zCell"; }, // optional
{ key = "time"; val = "xtime"; }
];

ugrid_max_distance_km = 30;

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

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
37 changes: 23 additions & 14 deletions src/libcode/vx_data2d_ugrid/ugrid_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,9 @@ void UGridFile::read_netcdf_grid()
}
}

// Convert longitude from degrees east to west
for (int idx=0; idx<face_count; idx++) _lon[idx] = -1.0*rescale_deg(_lon[idx], -180, 180);

grid_data.set_points(face_count, _lon, _lat);
grid_data.max_distance_km = max_distance_km;

Expand All @@ -958,33 +961,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_name = "UGridFile::set_dataset() ";

if (0 == _dataset_name.length()) {
mlog << Error << "\nUGridFile::set_dataset()"
<< " The \"" << conf_key_ugrid_dataset
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 \""
mlog << Error << "\n" << method_name
<< "The UGrid dataset \"" << dataset_name << "\" is not supported. Please add \""
<< ugrid_config_name << "\".\n\n";
exit(1);
}

}

////////////////////////////////////////////////////////////////////////
Expand Down
Loading
Loading