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

changes to comp_z #1562

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

dopplerchase
Copy link
Contributor

Code for issue #1559, where composite reflectivity code carried artifacts through with poor quality radar data from velocity sweeps. I also made a change to the interpolator because it was flagged as depreciated (e.g., scipy.interpolate.interp2d).

This is now open for comment from the maintainers! Happy to make changes as needed.

Example usage:

compz = pyart.retrieve.composite_reflectivity(radar, field="reflectivity")

image

The code is flexible, and allows you to still have the old functionality through the simple bool:

compz = pyart.retrieve.composite_reflectivity(radar, field="reflectivity",same_nyquist=False)

image

@dopplerchase dopplerchase requested a review from zssherman as a code owner April 15, 2024 16:53
@zssherman
Copy link
Collaborator

@dopplerchase Thanks for the PR! The errors seem to be PEP8 fixes.

@@ -9,11 +9,12 @@
from netCDF4 import num2date
from pandas import to_datetime
from scipy.interpolate import interp2d
Copy link
Collaborator

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


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):
Copy link
Collaborator

Choose a reason for hiding this comment

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

space between between the comment and same_

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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Defult to Default

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.
nyquist_vector_idx: int
Copy link
Collaborator

Choose a reason for hiding this comment

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

Space around colon


# Apply the interpolation
z = z_interpolator(ranges, azimuth_final)
z = z_interpolator(azimuth_final,ranges)
Copy link
Collaborator

Choose a reason for hiding this comment

The 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,:])
Copy link
Collaborator

Choose a reason for hiding this comment

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

space after comma

@@ -190,4 +214,4 @@ def composite_reflectivity(radar, field="reflectivity", gatefilter=None):
azimuth,
elevation,
instrument_parameters=instrument_parameters,
)
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove no newline

@mgrover1
Copy link
Collaborator

@dopplerchase - is there anything we can do to help here?

@dopplerchase
Copy link
Contributor Author

@mgrover1 find me some more time? lol We need to think carefully about Ryan's comments noted on #1559

@mgrover1
Copy link
Collaborator

no worries 😄 that is a good point!!

@decadeneo
Copy link

I'm glad to hear that someone has encountered a similar bug. When directly using the function pyart.retrieve.composite_reflectivity, I found that the interpolated composite reflectivity values are all NaN. Upon diving into the source code, I was prompted to change the interpolation method. However, when attempting to modify it with alternative interpolation methods, I encountered an error indicating that the number of azimuth angles per layer in my radar data is inconsistent, thereby preventing a smooth interpolation process.

@zssherman
Copy link
Collaborator

@mgrover1 I'm seeing the testing fail due to the depreciation of interp2d, we might need to do a PR just with the depreciation change. I can work on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Composite Z bugs (issue and fix)
4 participants