Skip to content

Commit

Permalink
Addition of qvp functions from MeteoSwiss Py-ART + support of demixin…
Browse files Browse the repository at this point in the history
…g in hydroclass_semisupervised (#1618)

* ENH: addition of qvp functions from MeteoSwiss Py-ART + entropy computation in hydroclass_semisupervised

* FIX: fixing est_rain_rate_hydro to match ARM original

* ENH: black formatting

* FIX: modified pyart examples to handle new hydroclass_semisupervised output

* FIX: fix in plot_hydrometeor_class_x_band.py example which was using wrong hydroclass labels

* ENH: updated defaut_config.py to account for new outputs of hydroclass_semisupervised

* FIX: adapted hydroclass_semisupervised to account for specified radar_freq

* FIX: adapted hydroclass_semisupervised to account for specified radar_freq

* ADD: new tests for missing fcts

* ENH: add support for more scan modes in qvp fcts

* FIX: docstring correction in cartesian_to_antenna

* FIX: missing hydrometeor variables in default_config.py

* fixes to make tests pass

* fixes to make tests pass

* FIX: changed value in ZDR standardization from -5 to 5 to -1.5 to 5 according to Besic (2016)
  • Loading branch information
wolfidan authored Aug 29, 2024
1 parent 664865b commit 4889289
Show file tree
Hide file tree
Showing 59 changed files with 2,829 additions and 154 deletions.
1 change: 1 addition & 0 deletions examples/correct/plot_attenuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
for a polarimetric radar using a Z-PHI method implemented in Py-ART.
"""

print(__doc__)

# Author: Jonathan J. Helmus ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/correct/plot_dealias.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
In this example doppler velocities are dealiased using the ial condition of the dealiasing,
using the region-based dealiasing algorithm in Py-ART.
"""

print(__doc__)

# Author: Jonathan J. Helmus ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/io/plot_nexrad_data_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
and plot quick looks of the datasets.
"""

print(__doc__)

# Author: Max Grover ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/io/plot_older_nexrad_data_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
to 2008 that are missing some coordinate metadata.
"""

print(__doc__)


Expand Down
1 change: 1 addition & 0 deletions examples/mapping/plot_compare_two_radars_gatemapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
another radar in Antenna coordinates and compare the fields.
"""

print(__doc__)

# Author: Max Grover ([email protected]) and Bobby Jackson ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/mapping/plot_grid_single_sweep_ppi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
negligible at low elevation angles common to PPI sweeps.
"""

print(__doc__)

# =====================
Expand Down
1 change: 1 addition & 0 deletions examples/mapping/plot_map_one_radar_to_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Cartesian grid.
"""

print(__doc__)

# Author: Jonathan J. Helmus ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/mapping/plot_map_two_radars_to_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
coordinates to a Cartesian grid.
"""

print(__doc__)

# Author: Jonathan J. Helmus ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/plotting/plot_choose_a_colormap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
and how to add them to your own plots.
"""

print(__doc__)

# Author: Max Grover ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/plotting/plot_cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
of your radar grid using the GridMapDisplay
"""

print(__doc__)

# Author: Max Grover ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/plotting/plot_modify_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
within a Py-ART display object.
"""

print(__doc__)

# Author: Joe O'Brien ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/plotting/plot_nexrad_multiple_moments.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
NEXRAD Archive file.
"""

print(__doc__)

# Author: Jonathan J. Helmus ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/plotting/plot_nexrad_reflectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
NEXRAD file.
"""

print(__doc__)

# Author: Jonathan J. Helmus ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/plotting/plot_ppi_cfradial.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
An example which creates a PPI plot of a Cfradial file.
"""

print(__doc__)

# Author: Max Grover ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/plotting/plot_ppi_mdv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
An example which creates a PPI plot of a MDV file using a RadarDisplay object.
"""

print(__doc__)

# Author: Jonathan J. Helmus ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/plotting/plot_rhi_cfradial.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
a RadarDisplay object.
"""

print(__doc__)

# Author: Jonathan J. Helmus ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/plotting/plot_rhi_cfradial_singlescan.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
a RadarDisplay object.
"""

print(__doc__)

import matplotlib.pyplot as plt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
and adding differnential Reflectivity contours from the same MDV file.
"""

print(__doc__)

# Author: Cory Weber ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/plotting/plot_rhi_data_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
and adding Reflectivity contours from the same MDV file.
"""

print(__doc__)

# Author: Cory Weber ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/plotting/plot_rhi_mdv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
An example which creates a RHI plot of a MDV file using a RadarDisplay object.
"""

print(__doc__)

# Author: Jonathan J. Helmus ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/plotting/plot_rhi_two_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
included in the two panels are reflectivity and doppler velocity.
"""

print(__doc__)

# Author: Max Grover ([email protected])
Expand Down
1 change: 1 addition & 0 deletions examples/plotting/plot_xsect.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
of PPI scans and plots both cross sections.
"""

print(__doc__)

# Author: Jonathan J. Helmus ([email protected])
Expand Down
5 changes: 3 additions & 2 deletions examples/plotting/radar-cross-section.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"import pyart\n",
"from pyart.testing import get_test_data\n",
"\n",
Expand Down Expand Up @@ -344,7 +345,7 @@
"outputs": [],
"source": [
"fig = plt.figure(figsize=(10, 8))\n",
"title = \"($^\\circ$N)\"\n",
"title = r\"($^\\circ$N)\"\n",
"cross.corrected_reflectivity_horizontal.plot(\n",
" cmap=\"pyart_HomeyerRainbow\",\n",
" x=None,\n",
Expand All @@ -362,7 +363,7 @@
"metadata": {},
"outputs": [],
"source": [
"from pyart.graph.common import generate_grid_time_begin, generate_field_name\n",
"from pyart.graph.common import generate_field_name, generate_grid_time_begin\n",
"\n",
"\n",
"def generate_cross_section_title(grid, field, start, end):\n",
Expand Down
7 changes: 4 additions & 3 deletions examples/retrieve/column-example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
"metadata": {},
"outputs": [],
"source": [
"import pyart\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import cartopy.crs as ccrs\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"import pyart\n",
"from pyart.testing import get_test_data"
]
},
Expand Down
2 changes: 1 addition & 1 deletion examples/retrieve/plot_hydrometeor.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
kdp_field="specific_differential_phase",
rhv_field="uncorrected_cross_correlation_ratio",
temp_field="temperature",
)
)["hydro"]

radar.add_field("radar_echo_classification", hydro)

Expand Down
22 changes: 10 additions & 12 deletions examples/retrieve/plot_hydrometeor_class_x_band.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
kdp_field="filtered_corrected_specific_diff_phase",
rhv_field="RHOHV",
temp_field="sounding_temperature",
)
)["hydro"]

radar.add_field("hydro_classification", hydromet_class, replace_existing=True)

Expand All @@ -69,7 +69,7 @@
rhv_field="RHOHV",
temp_field="sounding_temperature",
radar_freq=9.2e9,
)
)["hydro"]

radar.add_field("hydro_classification", hydromet_class, replace_existing=True)

Expand Down Expand Up @@ -98,7 +98,7 @@
rhv_field="RHOHV",
temp_field="sounding_temperature",
radar_freq=9.2e9,
)
)["hydro"]

radar.add_field("hydro_classification", hydromet_class, replace_existing=True)

Expand All @@ -121,27 +121,25 @@
"Lime",
"Yellow",
"Red",
"Fuchsia",
]
cmaphid = colors.ListedColormap(hid_colors)
cmapmeth = colors.ListedColormap(hid_colors[0:6])
cmapmeth_trop = colors.ListedColormap(hid_colors[0:7])


def adjust_fhc_colorbar_for_pyart(cb):
cb.set_ticks(np.arange(1.4, 10, 0.9))
cb.set_ticks(np.arange(1.4, 9, 0.9))
cb.ax.set_yticklabels(
[
"Drizzle",
"Rain",
"Ice Crystals",
"Aggregates",
"Wet Snow",
"Ice Crystals",
"Light rain",
"Rain",
"Vertical Ice",
"LD Graupel",
"Wet snow",
"HD Graupel",
"Hail",
"Big Drops",
"Melting hail",
"Dry hail or high-density graupel",
]
)
cb.ax.set_ylabel("")
Expand Down
10 changes: 5 additions & 5 deletions examples/retrieve/wavelet_echo_class_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@
}
],
"source": [
"import pyart\n",
"import numpy as np"
"import numpy as np\n",
"\n",
"import pyart"
]
},
{
Expand Down Expand Up @@ -281,10 +282,9 @@
"source": [
"# Required imports\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.colors as mcolors\n",
"import cartopy.crs as ccrs\n",
"\n",
"import matplotlib.colors as mcolors\n",
"import matplotlib.pyplot as plt\n",
"\n",
"display = pyart.graph.GridMapDisplay(grid)\n",
"\n",
Expand Down
1 change: 1 addition & 0 deletions pyart/__check_build/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" Module to give helpful messages to the user that did not
compile Py-ART properly.
"""

import os

INPLACE_MSG = """
Expand Down
1 change: 1 addition & 0 deletions pyart/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .transforms import cartesian_vectors_to_geographic # noqa
from .transforms import geographic_to_cartesian # noqa
from .transforms import geographic_to_cartesian_aeqd # noqa
from .transforms import cartesian_to_antenna # noqa
from .wind_profile import HorizontalWindProfile # noqa

__all__ = [s for s in dir() if not s.startswith("_")]
27 changes: 27 additions & 0 deletions pyart/core/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,33 @@ def antenna_to_cartesian(ranges, azimuths, elevations):
return x, y, z


def cartesian_to_antenna(x, y, z):
"""
Returns antenna coordinates from Cartesian coordinates.
Parameters
----------
x, y, z : array
Cartesian coordinates in meters from the radar.
Returns
-------
ranges : array
Distances to the center of the radar gates (bins) in m.
azimuths : array
Azimuth angle of the radar in degrees. [-180., 180]
elevations : array
Elevation angle of the radar in degrees.
"""
ranges = np.sqrt(x**2.0 + y**2.0 + z**2.0)
elevations = np.rad2deg(np.arctan(z / np.sqrt(x**2.0 + y**2.0)))
azimuths = np.rad2deg(np.arctan2(x, y)) # [-180, 180]
azimuths[azimuths < 0.0] += 360.0 # [0, 360]

return ranges, azimuths, elevations


def antenna_vectors_to_cartesian(ranges, azimuths, elevations, edges=False):
"""
Calculate Cartesian coordinate for gates from antenna coordinate vectors.
Expand Down
1 change: 0 additions & 1 deletion pyart/core/wind_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""


import numpy as np


Expand Down
Loading

0 comments on commit 4889289

Please sign in to comment.