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

ENH: Use pooch for sample files, add gridding tutorial #104

Merged
merged 4 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion REQUIREMENTS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ arm_pyart
cartopy
wheels
pandas
dask
six
pooch
cmweather
1 change: 1 addition & 0 deletions continuous_integration/environment-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies:
- eccodes
- dask
- distributed
- cmweather
- jax
- tensorflow>=2.6
- tensorflow-probability
1 change: 1 addition & 0 deletions doc/environment_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies:
- pip
- arm_pyart
- cython
- cmweather
- pytest
- pytest-mpl
- pytest-cov
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.cost_functions.J_function
===============================
pydda.cost\_functions.J\_function
=================================

.. currentmodule:: pydda.cost_functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.cost_functions.calculate_background_cost
==============================================
pydda.cost\_functions.calculate\_background\_cost
=================================================

.. currentmodule:: pydda.cost_functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.cost_functions.calculate_background_gradient
==================================================
pydda.cost\_functions.calculate\_background\_gradient
=====================================================

.. currentmodule:: pydda.cost_functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.cost_functions.calculate_fall_speed
=========================================
pydda.cost\_functions.calculate\_fall\_speed
============================================

.. currentmodule:: pydda.cost_functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.cost_functions.calculate_grad_radial_vel
==============================================
pydda.cost\_functions.calculate\_grad\_radial\_vel
==================================================

.. currentmodule:: pydda.cost_functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.cost_functions.calculate_mass_continuity
==============================================
pydda.cost\_functions.calculate\_mass\_continuity
=================================================

.. currentmodule:: pydda.cost_functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.cost_functions.calculate_mass_continuity_gradient
=======================================================
pydda.cost\_functions.calculate\_mass\_continuity\_gradient
===========================================================

.. currentmodule:: pydda.cost_functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.cost_functions.calculate_radial_vel_cost_function
=======================================================
pydda.cost\_functions.calculate\_radial\_vel\_cost\_function
============================================================

.. currentmodule:: pydda.cost_functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.cost_functions.calculate_smoothness_cost
==============================================
pydda.cost\_functions.calculate\_smoothness\_cost
=================================================

.. currentmodule:: pydda.cost_functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.cost_functions.calculate_smoothness_gradient
==================================================
pydda.cost\_functions.calculate\_smoothness\_gradient
=====================================================

.. currentmodule:: pydda.cost_functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.cost_functions.calculate_vertical_vorticity_cost
======================================================
pydda.cost\_functions.calculate\_vertical\_vorticity\_cost
==========================================================

.. currentmodule:: pydda.cost_functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.cost_functions.calculate_vertical_vorticity_gradient
==========================================================
pydda.cost\_functions.calculate\_vertical\_vorticity\_gradient
==============================================================

.. currentmodule:: pydda.cost_functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.cost_functions.grad_J
===========================
pydda.cost\_functions.grad\_J
=============================

.. currentmodule:: pydda.cost_functions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.retrieval.get_bca
=======================
pydda.retrieval.get\_bca
========================

.. currentmodule:: pydda.retrieval

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.retrieval.get_dd_wind_field
=================================
pydda.retrieval.get\_dd\_wind\_field
====================================

.. currentmodule:: pydda.retrieval

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.vis.plot_horiz_xsection_barbs
===================================
pydda.vis.plot\_horiz\_xsection\_barbs
======================================

.. currentmodule:: pydda.vis

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.vis.plot_xz_xsection_barbs
================================
pydda.vis.plot\_xz\_xsection\_barbs
===================================

.. currentmodule:: pydda.vis

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydda.vis.plot_yz_xsection_barbs
================================
pydda.vis.plot\_yz\_xsection\_barbs
===================================

.. currentmodule:: pydda.vis

Expand Down
10 changes: 2 additions & 8 deletions examples/hurricane_florence.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,8 @@
H = Herbie("2018-09-14 06:00", model="hrrr", product="prs", fxx=0)
H.download()

grid_mhx_path = pooch.retrieve(
url="https://github.com/rcjackson/pydda-sample-data/raw/main/pydda-sample-data/grid_mhx.nc",
known_hash=None,
)
grid_ltx_path = pooch.retrieve(
url="https://github.com/rcjackson/pydda-sample-data/raw/main/pydda-sample-data/grid_ltx.nc",
known_hash=None,
)
grid_mhx_path = pydda.tests.get_sample_file("grid_mhx.nc")
grid_ltx_path = pydda.tests.get_sample_file("grid_ltx.nc")

grid_mhx = pyart.io.read_grid(grid_mhx_path)
grid_ltx = pyart.io.read_grid(grid_ltx_path)
Expand Down
20 changes: 4 additions & 16 deletions examples/plot_sydney_tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,10 @@
import numpy as np
import pooch

grid1_path = pooch.retrieve(
url="https://github.com/rcjackson/pydda-sample-data/raw/main/pydda-sample-data/grid1_sydney.nc",
known_hash=None,
)
grid2_path = pooch.retrieve(
url="https://github.com/rcjackson/pydda-sample-data/raw/main/pydda-sample-data/grid2_sydney.nc",
known_hash=None,
)
grid3_path = pooch.retrieve(
url="https://github.com/rcjackson/pydda-sample-data/raw/main/pydda-sample-data/grid3_sydney.nc",
known_hash=None,
)
grid4_path = pooch.retrieve(
url="https://github.com/rcjackson/pydda-sample-data/raw/main/pydda-sample-data/grid4_sydney.nc",
known_hash=None,
)
grid1_path = pydda.tests.get_sample_file("grid1_sydney.nc")
grid2_path = pydda.tests.get_sample_file("grid2_sydney.nc")
grid3_path = pydda.tests.get_sample_file("grid3_sydney.nc")
grid4_path = pydda.tests.get_sample_file("grid4_sydney.nc")
grid1 = pyart.io.read_grid(grid1_path)
grid2 = pyart.io.read_grid(grid2_path)
grid3 = pyart.io.read_grid(grid3_path)
Expand Down
2 changes: 2 additions & 0 deletions pydda/cost_functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
calculate_point_gradient
"""

import cmweather

from . import _cost_functions_tensorflow as tf
from . import _cost_functions_numpy as np
from . import _cost_functions_jax as jax
Expand Down
2 changes: 1 addition & 1 deletion pydda/cost_functions/_cost_functions_tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def calculate_mass_continuity(u, v, w, z, dx, dy, dz, coeff=1500.0, anel=1):
anel_term = tf.ones(w.shape)

return (
coeff * tf.math.reduce_sum(tf.math.square(dudx + dvdy + dwdz * anel_term)) / 2.0
coeff * tf.math.reduce_sum(tf.math.square(dudx + dvdy + dwdz + anel_term)) / 2.0
)


Expand Down
1 change: 0 additions & 1 deletion pydda/cost_functions/cost_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
JAX_AVAILABLE = False

import pyart
import scipy.ndimage.filters

# Added to incorpeate JAX within the cost functions
from . import _cost_functions_jax
Expand Down
2 changes: 1 addition & 1 deletion pydda/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"""

from .sample_files import EXAMPLE_RADAR0, EXAMPLE_RADAR1
from .sample_files import SOUNDING_PATH
from .sample_files import SOUNDING_PATH, get_sample_file
from .procedures import make_test_divergence_field
Binary file removed pydda/tests/data/example_grid_radar0.nc
Binary file not shown.
Binary file removed pydda/tests/data/example_grid_radar1.nc
Binary file not shown.
Binary file removed pydda/tests/data/test_sounding.cdf
Binary file not shown.
54 changes: 49 additions & 5 deletions pydda/tests/sample_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,54 @@
MHX_GRID
"""
import os
import pooch

DATA_PATH = os.path.join(os.path.dirname(__file__), "data")

EXAMPLE_RADAR0 = os.path.join(DATA_PATH, "example_grid_radar0.nc")
EXAMPLE_RADAR1 = os.path.join(DATA_PATH, "example_grid_radar1.nc")
SOUNDING_PATH = os.path.join(DATA_PATH, "test_sounding.cdf")
ERA_PATH = os.path.join(DATA_PATH, "test_era5.nc")
sha256_hashes = {
"cfrad.20110520_081431.542_to_20110520_081813.238_KTLX_SUR.nc": "c43409767d3280113f24c6511505e2bd5775e4e15a3f719d89673eeab272ca9f",
"cfrad.20110520_081444.871_to_20110520_081914.520_KICT_SUR.nc": "0a41a184d9d551837dbd47b4e4ba673a1d56eabc26453b62dfda997e06255e40",
"example_grid_radar0.nc": "7b36da5579230078953db31752237b2dead60378c30752c3e2ab0d21f0b41622",
"example_grid_radar1.nc": "450420c36f3163b30ead18d8fcd789fbe8f4be79cf1dc9a89e4bd5fd2ef055cb",
"grid0.20171004.095021.nc": "ea239cc9bca120a7ef871f06dd139c0fab2afce9800487964a6502bda06fe88a",
"grid1.20171004.095021.nc": "8b22b20afa2bd7a643b0a5aae912688c7728bd07185de7478c473872b74b728b",
"grid1_sydney.nc": "967469882c4dfb536a29ac40b5036261036a4cfcceb9427dafc4e4e5e9947036",
"grid2_sydney.nc": "4d0bd0ac1cb2cce5ea616280e321c9e74b9ba05f200d15d9d973af6160cec054",
"grid3_sydney.nc": "6a6fa0a9634ebe07679c0cb289adf4433fb21d677e082f602b0adf0d6354152b",
"grid4_sydney.nc": "a43a08aca0f065c166631a0cf0fcea1d725ece56187b12365186dd0e30b531c2",
"grid_ltx.nc": "d848a9cf33cd3b0008f8542680b35019f9aae80940d09327c2b6ded197096ffa",
"grid_mhx.nc": "b7ccaa9e09fdc03c02c5d254c04dfb1ecf737f170da0cc8510ef061f9adc3752",
"ruc2anl_130_20110520_0800_001.grb2": "2a09f35d21e4119ed8f9aa1813c4bf44e5ed16404794590cd6ebd1b66e68331e",
"sgpsondeadjustS2.c1.20110520.083000.cdf": "ad851f08c0857ffd6317f135981c589b82a753cfc83c024c1d40f3024845b1dc",
"sgpsondewnpnC1.b1.20120520.053800.cdf": "9d487427e6756dcab3150fb16ad69ac72f308568fc3ebdc61c7b99c1379c4fb4",
"test_era_interim.nc": "d4af3999a622d4ce0bf0427a43c6b258274ccbe79ce4a5b5e8862b8ca38dcfb2",
"test_sounding.cdf": "828f6acfdc6f12b8df5232c75f2b649891d0796a9cc67318399364d4f14ace5d",
"twpsondewnpnC3.b1.20060119.050300.cdf": "7bbef7f91de8a4c6e5ab083ce60b7b61d5dbbff05ef2434885b89cbd3ac733ef",
"twpsondewnpnC3.b1.20060119.112000.cdf": "102b5bf7221a5b80a102803f5a4339ca1614d23e6daf8180c064e134f3aa0830",
"twpsondewnpnC3.b1.20060119.163300.cdf": "8343687d880fec71a4ad4f07bc56a6dce433ad38885fd91266868fd069f1eaa5",
}
fido = pooch.create(
path=pooch.os_cache("pydda"),
base_url="https://github.com/rcjackson/pydda-sample-data/raw/main/pydda-sample-data/",
registry=sha256_hashes,
)


def get_sample_file(file_name):
"""
Retrieves a test file from the PyDDA test files GitHub repository.
The repository is located at:

https://github.com/rcjackson/pydda-sample-data

Returns
-------
file_name: str
Location of sample file on local machine
"""
return fido.fetch(file_name)


EXAMPLE_RADAR0 = fido.fetch("example_grid_radar0.nc")
EXAMPLE_RADAR1 = fido.fetch("example_grid_radar1.nc")
SOUNDING_PATH = fido.fetch("test_sounding.cdf")
ERA_PATH = fido.fetch("test_era_interim.nc")
8 changes: 4 additions & 4 deletions pydda/vis/barb_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def plot_horiz_xsection_barbs(
ax=None,
background_field="reflectivity",
level=1,
cmap="pyart_LangRainbow12",
cmap="ChaseSpectral",
vmin=None,
vmax=None,
u_vel_contours=None,
Expand Down Expand Up @@ -275,7 +275,7 @@ def plot_horiz_xsection_barbs_map(
ax=None,
background_field="reflectivity",
level=1,
cmap="pyart_LangRainbow12",
cmap="ChaseSpectral",
vmin=None,
vmax=None,
u_vel_contours=None,
Expand Down Expand Up @@ -611,7 +611,7 @@ def plot_xz_xsection_barbs(
ax=None,
background_field="reflectivity",
level=1,
cmap="pyart_LangRainbow12",
cmap="ChaseSpectral",
vmin=None,
vmax=None,
u_vel_contours=None,
Expand Down Expand Up @@ -844,7 +844,7 @@ def plot_yz_xsection_barbs(
ax=None,
background_field="reflectivity",
level=1,
cmap="pyart_LangRainbow12",
cmap="ChaseSpectral",
vmin=None,
vmax=None,
u_vel_contours=None,
Expand Down
8 changes: 4 additions & 4 deletions pydda/vis/quiver_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def plot_horiz_xsection_quiver(
ax=None,
background_field="reflectivity",
level=1,
cmap="pyart_LangRainbow12",
cmap="ChaseSpectral",
vmin=None,
vmax=None,
u_vel_contours=None,
Expand Down Expand Up @@ -323,7 +323,7 @@ def plot_horiz_xsection_quiver_map(
ax=None,
background_field="reflectivity",
level=1,
cmap="pyart_LangRainbow12",
cmap="ChaseSpectral",
vmin=None,
vmax=None,
u_vel_contours=None,
Expand Down Expand Up @@ -738,7 +738,7 @@ def plot_xz_xsection_quiver(
ax=None,
background_field="reflectivity",
level=1,
cmap="pyart_LangRainbow12",
cmap="ChaseSpectral",
vmin=None,
vmax=None,
u_vel_contours=None,
Expand Down Expand Up @@ -1023,7 +1023,7 @@ def plot_yz_xsection_quiver(
ax=None,
background_field="reflectivity",
level=1,
cmap="pyart_LangRainbow12",
cmap="ChaseSpectral",
vmin=None,
vmax=None,
u_vel_contours=None,
Expand Down
Loading
Loading