Skip to content

Commit 0405f94

Browse files
committed
ADD: possibility to define vmin and vmax for PLOT_SCATTER_INTERCOMP product
1 parent d07e862 commit 0405f94

File tree

2 files changed

+52
-13
lines changed

2 files changed

+52
-13
lines changed

src/pyrad_proc/pyrad/prod/process_intercomp_products.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def generate_intercomp_products(dataset, prdcfg):
4242
Generates radar intercomparison products. Accepted product types:
4343
'PLOT_AND_WRITE_INTERCOMP_TS': Writes statistics of radar
4444
intercomparison in a file and plots the time series of the
45-
statistics.
45+
statistics. Note that in order to use this product you need
46+
to also define the product WRITE_INTERCOMP_TIME_AVG for the dataset in question.
4647
User defined parameters:
4748
voltype: str
4849
name of the pyrad variable to use, it must be available in the dataset
@@ -71,14 +72,21 @@ def generate_intercomp_products(dataset, prdcfg):
7172
The minimum correlation to consider the statistics
7273
valid and therefore use the data point in the plotting.
7374
Default 0.
74-
'PLOT_SCATTER_INTERCOMP': Plots a density plot with the points of
75-
radar 1 versus the points of radar 2
75+
'PLOT_SCATTER_INTERCOMP': Plots a density plot (2D histogram) with the points of
76+
radar 1 versus the points of radar 2. Note that in order to use this product you need
77+
to also define the product WRITE_INTERCOMP_TIME_AVG for the dataset in question.
7678
User defined parameters:
7779
voltype: str
7880
name of the pyrad variable to use, it must be available in the dataset
7981
step: float
8082
The quantization step of the data. If none it will be
8183
computed using the Py-ART config file. Default None
84+
vmin: float
85+
Minimum value of the density plot. If vmin or vmax are not define the range limits
86+
of the field as defined in the Py-ART config file are going to be used.
87+
vmax: float
88+
Maximum value of the density plot. If vmin or vmax are not define the range limits
89+
of the field as defined in the Py-ART config file are going to be used.
8290
scatter_type: str
8391
Type of scatter plot. Can be a plot for each radar volume
8492
(instant) or at the end of the processing period
@@ -200,6 +208,8 @@ def generate_intercomp_products(dataset, prdcfg):
200208
transform = parse_math_expression(transform_str)
201209
range_bins = prdcfg.get("range_bins", [0, np.inf])
202210
step = prdcfg.get("step", None)
211+
vmin = prdcfg.get("vmin", None)
212+
vmax = prdcfg.get("vmax", None)
203213

204214
fname_list = []
205215
for i in range(len(range_bins) - 1): # loop on range bins
@@ -244,6 +254,8 @@ def generate_intercomp_products(dataset, prdcfg):
244254
step1=step,
245255
step2=step,
246256
transform=transform,
257+
vmin=vmin,
258+
vmax=vmax,
247259
)
248260
if hist_2d is None:
249261
return None
@@ -274,7 +286,6 @@ def generate_intercomp_products(dataset, prdcfg):
274286
+ "{:.2f}".format(float(stats["intercep"]))
275287
+ "\n"
276288
)
277-
278289
if transform_str != "x":
279290
field_name = f"{transform_str} of {field_name}"
280291
plot_scatter(
@@ -479,7 +490,10 @@ def generate_colocated_gates_products(dataset, prdcfg):
479490
gridMapImageConfig structure of the loc file.
480491
User defined parameters:
481492
grid_size: float
482-
Size of the grid in degrees (lat/lon). Default is 0.02 degrees.
493+
Size of the grid in degrees (lat/lon). If not provided,
494+
the grid size defined in gridMapImageConfig with
495+
lat_min, lon_min, lat_max, lon_max and lonstep, latstep
496+
will be used.
483497
All the products of the 'VOL' dataset group
484498
485499

src/pyrad_proc/pyrad/util/radar_utils.py

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,9 +1822,16 @@ def compute_2d_stats(
18221822
the two fields
18231823
field_name1, field_nam2: str
18241824
the name of the fields
1825-
step1, step2 : float
1826-
size of bin
1827-
vmin
1825+
step1: float
1826+
size of the bins along dimension 1
1827+
step2 : float
1828+
size of the bins along dimension 2
1829+
vmin: float
1830+
Minimum value of the density plot. If vmin or vmax are not define the range limits
1831+
of the field as defined in the Py-ART config file are going to be used.
1832+
vmax: float
1833+
Maximum value of the density plot. If vmin or vmax are not define the range limits
1834+
of the field as defined in the Py-ART config file are going to be used.
18281835
transform : func
18291836
A function to use to transform the data prior to computing the stats
18301837
@@ -1866,6 +1873,8 @@ def compute_2d_stats(
18661873
step1=step1,
18671874
step2=step2,
18681875
transform=transform,
1876+
vmin=vmin,
1877+
vmax=vmax,
18691878
)
18701879
step_aux1 = bin_edges1[1] - bin_edges1[0]
18711880
bin_centers1 = bin_edges1[:-1] + step_aux1 / 2.0
@@ -1945,7 +1954,15 @@ def compute_1d_stats(field1, field2):
19451954

19461955

19471956
def compute_2d_hist(
1948-
field1, field2, field_name1, field_name2, step1=None, step2=None, transform=None
1957+
field1,
1958+
field2,
1959+
field_name1,
1960+
field_name2,
1961+
step1=None,
1962+
step2=None,
1963+
transform=None,
1964+
vmin=None,
1965+
vmax=None,
19491966
):
19501967
"""
19511968
computes a 2D histogram of the data
@@ -1956,8 +1973,12 @@ def compute_2d_hist(
19561973
the radar fields
19571974
field_name1, field_name2 : str
19581975
field names
1959-
step1, step2 : float
1960-
size of the bins
1976+
step1: float
1977+
size of the bins along dimension 1
1978+
step2 : float
1979+
size of the bins along dimension 2
1980+
1981+
19611982
transform: func
19621983
A function to use to transform the histogram bins
19631984
@@ -1969,10 +1990,14 @@ def compute_2d_hist(
19691990
the bin edges along each dimension
19701991
19711992
"""
1972-
bin_edges1 = get_histogram_bins(field_name1, step=step1, transform=transform)
1993+
bin_edges1 = get_histogram_bins(
1994+
field_name1, step=step1, transform=transform, vmin=vmin, vmax=vmax
1995+
)
19731996
step_aux1 = bin_edges1[1] - bin_edges1[0]
19741997
bin_centers1 = bin_edges1[:-1] + step_aux1 / 2.0
1975-
bin_edges2 = get_histogram_bins(field_name2, step=step2, transform=transform)
1998+
bin_edges2 = get_histogram_bins(
1999+
field_name2, step=step2, transform=transform, vmin=vmin, vmax=vmax
2000+
)
19762001
step_aux2 = bin_edges2[1] - bin_edges2[0]
19772002
bin_centers2 = bin_edges2[:-1] + step_aux2 / 2.0
19782003

0 commit comments

Comments
 (0)