-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADD: Gridding with fasr-barnes-py #55 from syedhamidali/gridding-test
ADD: Gridding and AWS tools
- Loading branch information
Showing
26 changed files
with
2,759 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,4 @@ repos: | |
hooks: | ||
- id: black | ||
- id: black-jupyter | ||
args: ["--line-length", "88"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Grid Radar -> Plot Max-CAPPI" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We are using [fast-barnes-py](https://github.com/MeteoSwiss/fast-barnes-py.git) to grid the radar data. Please cite if you use it in your research." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import fsspec\n", | ||
"import radarx as rx\n", | ||
"import xradar as xd\n", | ||
"import cmweather # noqa\n", | ||
"import matplotlib.pyplot as plt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"file = \"s3://noaa-nexrad-level2/2022/03/30/KGWX/KGWX20220330_234639_V06\"\n", | ||
"local_file = fsspec.open_local(\n", | ||
" f\"simplecache::s3://{file}\",\n", | ||
" s3={\"anon\": True},\n", | ||
" filecache={\"cache_storage\": \".\"},\n", | ||
")\n", | ||
"dtree = xd.io.open_nexradlevel2_datatree(local_file)\n", | ||
"dtree = rx.combine_nexrad_sweeps(dtree)\n", | ||
"dtree = dtree.xradar.georeference()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"dtree.groups" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def filter_radar(ds):\n", | ||
" ds = ds.where((ds.DBZH > -10) & (ds.DBZH < 75))\n", | ||
" return ds" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"dtree = dtree.xradar.map_over_sweeps(filter_radar)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Create a figure and axis\n", | ||
"fig, ax = plt.subplots(figsize=(7, 5))\n", | ||
"dtree[\"sweep_2\"][\"DBZH\"].plot.contourf(\n", | ||
" x=\"x\",\n", | ||
" y=\"y\",\n", | ||
" levels=range(-10, 75),\n", | ||
" cmap=\"NWSRef\",\n", | ||
" ylim=(-200e3, 300e3), # Adjust y-axis limits\n", | ||
" xlim=(-200e3, 300e3), # Adjust x-axis limits\n", | ||
" ax=ax, # Use the created axis\n", | ||
")\n", | ||
"# Set the title\n", | ||
"ax.set_title(\n", | ||
" f\"{dtree.attrs['instrument_name']} {dtree['sweep_0']['time'].min().values}\"\n", | ||
")\n", | ||
"# Show the plot\n", | ||
"plt.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%time\n", | ||
"ds = dtree.radarx.to_grid(\n", | ||
" data_vars=[\"DBZH\"],\n", | ||
" pseudo_cappi=True,\n", | ||
" x_lim=(-100000.0, 100000.0),\n", | ||
" y_lim=(-100000.0, 100000.0),\n", | ||
" z_lim=(0, 10000.0),\n", | ||
" x_step=1000,\n", | ||
" y_step=1000,\n", | ||
" z_step=250,\n", | ||
" x_smth=0.2,\n", | ||
" y_smth=0.2,\n", | ||
" z_smth=1,\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ds.radarx.plot_max_cappi(\"DBZH\", cmap=\"ChaseSpectral\", add_slogan=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%time\n", | ||
"ds2 = dtree.radarx.to_grid(\n", | ||
" data_vars=[\"DBZH\"],\n", | ||
" pseudo_cappi=False,\n", | ||
" x_lim=(-200000.0, 200000.0),\n", | ||
" y_lim=(-200000.0, 200000.0),\n", | ||
" z_lim=(0, 15000.0),\n", | ||
" x_step=1000,\n", | ||
" y_step=1000,\n", | ||
" z_step=250,\n", | ||
" x_smth=0.2,\n", | ||
" y_smth=0.2,\n", | ||
" z_smth=1,\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ds2.radarx.plot_max_cappi(\"DBZH\", cmap=\"ChaseSpectral\", add_slogan=True)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.