@@ -1812,6 +1812,7 @@ def compute_2d_stats(
18121812 vmin = None ,
18131813 vmax = None ,
18141814 transform = None ,
1815+ cap_limits = False ,
18151816):
18161817 """
18171818 computes a 2D histogram and statistics of the data
@@ -1827,13 +1828,16 @@ def compute_2d_stats(
18271828 step2 : float
18281829 size of the bins along dimension 2
18291830 vmin: float
1830- Minimum value of the density plot . If vmin or vmax are not define the range limits
1831+ Minimum value of the 2D histogram . If vmin or vmax are not define the range limits
18311832 of the field as defined in the Py-ART config file are going to be used.
18321833 vmax: float
1833- Maximum value of the density plot . If vmin or vmax are not define the range limits
1834+ Maximum value of the 2D histogram . If vmin or vmax are not define the range limits
18341835 of the field as defined in the Py-ART config file are going to be used.
18351836 transform : func
18361837 A function to use to transform the data prior to computing the stats
1838+ cap_limits: bool
1839+ If true, all values larger than vmax or smaller than vmin will be discarded from the
1840+ scatter plot. Otherwise, they will be kept and assigned to the smallest/largest bin
18371841
18381842 Returns
18391843 -------
@@ -1875,6 +1879,7 @@ def compute_2d_stats(
18751879 transform = transform ,
18761880 vmin = vmin ,
18771881 vmax = vmax ,
1882+ cap_limits = cap_limits ,
18781883 )
18791884 step_aux1 = bin_edges1 [1 ] - bin_edges1 [0 ]
18801885 bin_centers1 = bin_edges1 [:- 1 ] + step_aux1 / 2.0
@@ -1960,9 +1965,10 @@ def compute_2d_hist(
19601965 field_name2 ,
19611966 step1 = None ,
19621967 step2 = None ,
1963- transform = None ,
19641968 vmin = None ,
19651969 vmax = None ,
1970+ transform = None ,
1971+ cap_limits = False ,
19661972):
19671973 """
19681974 computes a 2D histogram of the data
@@ -1977,10 +1983,17 @@ def compute_2d_hist(
19771983 size of the bins along dimension 1
19781984 step2 : float
19791985 size of the bins along dimension 2
1980-
1981-
1986+ vmin: float
1987+ Minimum value of the 2D histogram. If vmin or vmax are not define the range limits
1988+ of the field as defined in the Py-ART config file are going to be used.
1989+ vmax: float
1990+ Maximum value of the 2D histogram. If vmin or vmax are not define the range limits
1991+ of the field as defined in the Py-ART config file are going to be used.
19821992 transform: func
19831993 A function to use to transform the histogram bins
1994+ cap_limits: bool
1995+ If true, all values larger than vmax or smaller than vmin will be discarded from the
1996+ scatter plot. Otherwise, they will be kept and assigned to the smallest/largest bin
19841997
19851998 Returns
19861999 -------
@@ -2001,17 +2014,22 @@ def compute_2d_hist(
20012014 step_aux2 = bin_edges2 [1 ] - bin_edges2 [0 ]
20022015 bin_centers2 = bin_edges2 [:- 1 ] + step_aux2 / 2.0
20032016
2004- field1 [field1 < bin_centers1 [0 ]] = bin_centers1 [0 ]
2005- field1 [field1 > bin_centers1 [- 1 ]] = bin_centers1 [- 1 ]
2017+ if not cap_limits :
2018+ field1 [field1 < bin_centers1 [0 ]] = bin_centers1 [0 ]
2019+ field1 [field1 > bin_centers1 [- 1 ]] = bin_centers1 [- 1 ]
20062020
2007- field2 [field2 < bin_centers2 [0 ]] = bin_centers2 [0 ]
2008- field2 [field2 > bin_centers2 [- 1 ]] = bin_centers2 [- 1 ]
2021+ field2 [field2 < bin_centers2 [0 ]] = bin_centers2 [0 ]
2022+ field2 [field2 > bin_centers2 [- 1 ]] = bin_centers2 [- 1 ]
2023+ hist_range = None
2024+ else :
2025+ hist_range = [[vmin , vmax ], [vmin , vmax ]]
20092026
20102027 fill_value = pyart .config .get_fillvalue ()
20112028 return np .histogram2d (
20122029 field1 .filled (fill_value = fill_value ),
20132030 field2 .filled (fill_value = fill_value ),
20142031 bins = [bin_edges1 , bin_edges2 ],
2032+ range = hist_range ,
20152033 )
20162034
20172035
0 commit comments