-
Notifications
You must be signed in to change notification settings - Fork 270
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
changes to comp_z #1562
base: main
Are you sure you want to change the base?
changes to comp_z #1562
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,11 +9,12 @@ | |
from netCDF4 import num2date | ||
from pandas import to_datetime | ||
from scipy.interpolate import interp2d | ||
from scipy.interpolate import RectBivariateSpline | ||
|
||
from pyart.core import Radar | ||
|
||
|
||
def composite_reflectivity(radar, field="reflectivity", gatefilter=None): | ||
def composite_reflectivity(radar, field="reflectivity", gatefilter=None,same_nyquist=True,nyquist_vector_idx=0): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. space between between the comment and same_ |
||
""" | ||
Composite Reflectivity | ||
|
||
|
@@ -41,6 +42,14 @@ def composite_reflectivity(radar, field="reflectivity", gatefilter=None): | |
gatefilter : GateFilter | ||
GateFilter instance. None will result in no gatefilter mask being | ||
applied to data. | ||
same_nyquist: bool | ||
During a volume scan (i.e., file) the PRF (nyqust velocity) can change. | ||
This can create some odd artifacts at times with if data quality is low on certain scans. | ||
To get around this, you can change the code to only take the max of scans with the same nyquist +/- 1 m/s. | ||
Defult this will be on (True), but folks can turn this off. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Defult to Default |
||
nyquist_vector_idx: int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space around colon |
||
This integer works alongside the same_nyquist parameter. Do you want to match all the nyquists to sweep 0? use idx 0, sweep 1, use idx 1. | ||
By default it is set to 0. | ||
|
||
Returns | ||
------- | ||
|
@@ -58,6 +67,7 @@ def composite_reflectivity(radar, field="reflectivity", gatefilter=None): | |
# Determine the lowest sweep (used for metadata and such) | ||
minimum_sweep = np.min(radar.sweep_number["data"]) | ||
|
||
|
||
# loop over all measured sweeps | ||
for sweep in sorted(radar.sweep_number["data"]): | ||
# get start and stop index numbers | ||
|
@@ -66,6 +76,9 @@ def composite_reflectivity(radar, field="reflectivity", gatefilter=None): | |
# grab radar data | ||
z = radar.get_field(sweep, field) | ||
z_dtype = z.dtype | ||
|
||
#get the nyquist, so we know which sweeps are the same sens. | ||
nyquist = np.asarray([np.round(radar.get_nyquist_vel(sweep=sweep))]) | ||
|
||
# Use gatefilter | ||
if gatefilter is not None: | ||
|
@@ -102,18 +115,29 @@ def composite_reflectivity(radar, field="reflectivity", gatefilter=None): | |
lat_0[-1, :] = lat_0[0, :] | ||
|
||
else: | ||
# Configure the intperpolator | ||
z_interpolator = interp2d(ranges, az, z, kind="linear") | ||
# Configure the intperpolator | ||
z_interpolator = RectBivariateSpline(az, ranges, z) | ||
|
||
|
||
# Apply the interpolation | ||
z = z_interpolator(ranges, azimuth_final) | ||
z = z_interpolator(azimuth_final,ranges) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. space after comma |
||
|
||
# if first sweep, create new dim, otherwise concat them up | ||
if sweep == minimum_sweep: | ||
z_stack = copy.deepcopy(z[np.newaxis, :, :]) | ||
nyquist_stack = copy.deepcopy(nyquist[np.newaxis,:]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. space after comma |
||
else: | ||
z_stack = np.concatenate([z_stack, z[np.newaxis, :, :]]) | ||
nyquist_stack = np.concatenate([nyquist_stack, nyquist[np.newaxis,:]]) | ||
|
||
#only stack up sweeps with the same nyquist | ||
if same_nyquist: | ||
left = np.where(nyquist_stack >= nyquist_stack[nyquist_vector_idx]-1)[0] | ||
right = np.where(nyquist_stack <= nyquist_stack[nyquist_vector_idx]+1)[0] | ||
same_ny = np.intersect1d(left,right) | ||
|
||
z_stack = z_stack[same_ny] | ||
|
||
# now that the stack is made, take max across vertical | ||
compz = z_stack.max(axis=0).astype(z_dtype) | ||
|
||
|
@@ -190,4 +214,4 @@ def composite_reflectivity(radar, field="reflectivity", gatefilter=None): | |
azimuth, | ||
elevation, | ||
instrument_parameters=instrument_parameters, | ||
) | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove no newline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old import should be removed