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 1815 level value #2190

Merged
merged 33 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7ea50d0
#1815 Renamed time_as_offset to Is_offset
Jun 13, 2022
c5e9639
#1815 Added vx_data2d_dim_by_value
Jun 13, 2022
e7152fa
#1815 Added convert_value_to_offset and renamed _time_dim_offset to _…
Jun 14, 2022
2d0ff3a
#1815 Added convert_value_to_offset and renamed _time_dim_offset to _…
Jun 14, 2022
80dd0a8
#1815 Support @ for the value insteaed of offset for slicing
Jun 14, 2022
fc5a5cb
#1815 Support value insteaed of offset for slicing
Jun 14, 2022
8d59e18
#1815 Deleted unused local variable
Jun 14, 2022
7837db8
#1815 Deleted unused local variable
Jun 14, 2022
239dd08
#1815 Added level by value with @
Jun 14, 2022
7657431
#1815 Added plot_data_plane_NCCF_latlon_by_value
Jun 14, 2022
7bce984
#1815 Added level by value with @
Jun 14, 2022
329e4f6
#1815 Updated level
Jun 14, 2022
2c9d528
Merge remote-tracking branch 'origin/develop' into feature_1815_level…
Jun 15, 2022
c8f1f95
#1815 call is_eq to comapre two double values
Jun 15, 2022
560c8b7
Merge remote-tracking branch 'origin/develop' into feature_1815_level…
Jun 21, 2022
49ba0ad
Merge remote-tracking branch 'origin/develop' into feature_1815_level…
Jun 22, 2022
c56a507
#1815 Added more attribute names
Jun 23, 2022
ca77ab2
#1815 Added get_index_for_dim
Jun 23, 2022
9483883
#1815 Formatting
Jun 23, 2022
6741041
#1815 Support a differnt dimension name from thw first data variable
Jun 23, 2022
033ccda
#1815 Use constants for attr names
Jun 23, 2022
d4886d3
#1815 cleanup
Jun 27, 2022
5a1e381
#1815 cleanup
Jun 27, 2022
1a9f1b4
#1851 cleanup
Jun 27, 2022
38211de
#1851 cleanup
Jun 27, 2022
1f63628
#1815 Added get_att_unixtime
Jun 27, 2022
7c1ad06
#1851 cleanup
Jun 27, 2022
ca162f5
#1815 cleanup
Jun 27, 2022
4f1343f
#1815 cleanup
Jun 27, 2022
9541e84
#1815 Support @ for pinterp
Jun 27, 2022
2066939
#1815 Do not call to_string
Jun 27, 2022
161227f
#1815 cleanup
Jun 27, 2022
f4d9706
#1815 Changed @time to time at plot_data_plane_NCCF_time
Jun 30, 2022
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
12 changes: 9 additions & 3 deletions docs/Users_Guide/appendixA.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ Q. How do I choose a time slice in a NetCDF file?

A.
When processing NetCDF files, the level information needs to be
specified to tell MET which 2D slice of data to use. There is
currently no way to explicitly define which time slice to use
other than selecting the time index.
specified to tell MET which 2D slice of data to use. The index is selected from
a value when it starts with "@" for vertical level (pressure or height)
and time. The actual time, @YYYYMMDD_HHMM, is allowed instead of selecting
the time index.

Let's use plot_data_plane as an example:

Expand All @@ -160,6 +161,11 @@ Let's use plot_data_plane as an example:
obs.ps \
'name="APCP"; level="(5,*,*)";'
plot_data_plane \
gtg_obs_forecast.20130730.i00.f00.nc \
altitude_20000.ps \
'name = "edr"; level = "(@20130730_0000,@20000,*,*)";'
Assuming that the first array is the time, this will select the 6-th
time slice of the APCP data and plot it since these indices are 0-based.

Expand Down
14 changes: 13 additions & 1 deletion docs/Users_Guide/config_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,8 @@ File-format specific settings for the "field" entry:

* (i,...,j,*,*) for a single field, where i,...,j specifies fixed
dimension values and *,* specifies the two dimensions for the
gridded field. For example:
gridded field. @ specifies the vertical level value or time value
instead of offset, (i,...,@NNN,*,*). For example:

.. code-block:: none

Expand All @@ -1006,6 +1007,17 @@ File-format specific settings for the "field" entry:
}
];

field = [
{
name = "QVAPOR";
level = "(@20220601_1200,@850,*,*)";
},
{
name = "TMP_P850_ENS_MEAN";
level = [ "(*,*)" ];
}
];

* Python (using PYTHON_NUMPY or PYTHON_XARRAY):

* The Python interface for MET is described in Appendix F of the MET
Expand Down
18 changes: 16 additions & 2 deletions internal/test_unit/xml/unit_plot_data_plane.xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,20 @@
</output>
</test>

<test name="plot_data_plane_NCCF_latlon_by_value">
<exec>&MET_BIN;/plot_data_plane</exec>
<param> \
&DATA_DIR_MODEL;/nccf/gtg/latlon/gtg_obs_forecast.20130730.i00.f00.nc \
&OUTPUT_DIR;/plot_data_plane/gtg_obs_forecast.20130730.i00.f00.NCCF_latlon_20000.ps \
'name = "edr"; level = "(0,@20000,*,*)";' \
-title "NCCF Latitude/Longitude Level 0" \
-v 1
</param>
<output>
<ps>&OUTPUT_DIR;/plot_data_plane/gtg_obs_forecast.20130730.i00.f00.NCCF_latlon_20000.ps</ps>
</output>
</test>

<test name="plot_data_plane_NCCF_north_to_south">
<exec>&MET_BIN;/plot_data_plane</exec>
<param> \
Expand All @@ -292,7 +306,7 @@
<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;' \
'name="TEC"; level="(@20150317_000500,*,*)"; file_type=NETCDF_NCCF;' \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still have tests that ensure that specifying the time value still works without the added @ symbol? If not, I think we should add at least 1 since that syntax is currently used by users.

-title "NCCF GloTEC - Total Electron Content" \
-v 1
</param>
Expand Down Expand Up @@ -403,7 +417,7 @@
<param> \
&DATA_DIR_MODEL;/easm/pr_day_MPI-ESM-MR_rcp85_r1i1p1_20060101-20091231.nc \
&OUTPUT_DIR;/plot_data_plane/EaSM_CMIP5_pr_day_MPI-ESM-MR_rcp85_r1i1p1_20060101_12_time.ps \
'name="pr"; level="(20060102_000000,*,*)";' \
'name="pr"; level="(@20060102_000000,*,*)";' \
-v 4
</param>
<output>
Expand Down
1 change: 1 addition & 0 deletions src/basic/vx_util/util_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ static const double const_gop = 9.80616; // from The Ceaseless Wind
static const double const_rd = 287.0; // kg/k dry gas constant

static const int vx_data2d_star = -12345;
static const int vx_data2d_dim_by_value = -123456; // apply the value instead of offset for slicing

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

Expand Down
22 changes: 4 additions & 18 deletions src/libcode/vx_data2d/level_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ void LevelInfo::init_from_scratch() {

clear();

return;
}

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -88,9 +87,8 @@ void LevelInfo::assign(const LevelInfo &l) {
Upper = l.upper();
Lower = l.lower();
Increment = l.increment();
time_as_offset = l.is_time_as_offset();
Is_offset = l.is_offset();

return;
}

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -106,9 +104,8 @@ void LevelInfo::clear() {
Upper = 0.0;
Lower = 0.0;
Increment = 0.0;
time_as_offset = true;
Is_offset = true;

return;
}

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -125,78 +122,67 @@ void LevelInfo::dump(ostream &out) const {
<< " Upper = " << Upper << "\n"
<< " Increment = " << Increment << "\n";

return;
}

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

void LevelInfo::set_type(LevelType lt) {
Type = lt;
return;
}

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

void LevelInfo::set_type_num(int i) {
TypeNum = i;
return;
}

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

void LevelInfo::set_req_name(const char *str) {
ReqName = str;
return;
}

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

void LevelInfo::set_name(const char *str) {
Name = str;
return;
}

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

void LevelInfo::set_units(const char *str) {
Units = str;
return;
}

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

void LevelInfo::set_upper(double u) {
Upper = u;
return;
}

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

void LevelInfo::set_lower(double l) {
Lower = l;
return;
}

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

void LevelInfo::set_range(double l, double u) {
Lower = l;
Upper = u;
return;
}

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

void LevelInfo::set_increment(double i) {
Increment = i;
return;
}

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

void LevelInfo::set_time_as_offset(bool b) {
time_as_offset = b;
return;
void LevelInfo::set_is_offset(bool b) {
Is_offset = b;
}

///////////////////////////////////////////////////////////////////////////////
8 changes: 4 additions & 4 deletions src/libcode/vx_data2d/level_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class LevelInfo
double Upper; // Upper level limit
double Lower; // Lower level limit
double Increment; // Increment (time: seconds, 0 for no increment)
bool time_as_offset;// default: true, false: the (time) value instead
bool Is_offset; // default: true, false: the value instead
// of the offset at Lower and Upper

void init_from_scratch();
Expand Down Expand Up @@ -77,7 +77,7 @@ class LevelInfo
double upper() const;
double lower() const;
double increment() const;
bool is_time_as_offset()const;
bool is_offset() const;

//
// set stuff
Expand All @@ -92,7 +92,7 @@ class LevelInfo
void set_lower(double l);
void set_range(double l, double u);
void set_increment(double i);
void set_time_as_offset(bool b);
void set_is_offset(bool b);

};

Expand All @@ -106,7 +106,7 @@ inline ConcatString LevelInfo::units() const { return(Units); }
inline double LevelInfo::upper() const { return(Upper); }
inline double LevelInfo::lower() const { return(Lower); }
inline double LevelInfo::increment()const { return(Increment);}
inline bool LevelInfo::is_time_as_offset()const { return(time_as_offset);}
inline bool LevelInfo::is_offset()const { return(Is_offset);}

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

Expand Down
Loading