Skip to content

Commit

Permalink
FIX: _FillValue + History in the cfradial1 exporter (#132)
Browse files Browse the repository at this point in the history
* Fixed errors

* FIX: _FillValue + History

* add _FillValue + history to the CfRadial1 export

* Pre-commit run

* fix cfradial1 version + update history.md

* fix fillvalue

* remove fill_val

* update history

* add more calibs to model.py
  • Loading branch information
syedhamidali committed Oct 5, 2023
1 parent 1ef1ebe commit 6880b0c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/history.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# History

## Development version (unreleased)

* FIX: Add history to cfradial1 output, and fix minor error in CfRadial1_Export.ipynb notebook({pull}`132`) by [@syedhamidali](https://github.com/syedhamidali)

## 0.4.0 (2023-09-27)

* ENH: Add cfradial1 exporter ({issue}`124`) by [@syedhamidali](https://github.com/syedhamidali), ({pull}`126`) by [@syedhamidali](https://github.com/syedhamidali)
Expand All @@ -9,6 +13,7 @@
* MIN: use `cmweather` colormaps in xradar ({pull}`128`) by [@kmuehlbauer](https://github.com/kmuehlbauer).

## 0.3.0 (2023-07-11)

* ENH: Add new examples using radar data on AWS s3 bucket ({pull}`102`) by [@aladinor](https://github.com/aladinor)
* FIX: Correct DB_DBTE8/DB_DBZE8 and DB_DBTE16/DB_DBZE16 decoding for iris-backend ({pull}`110`) by [@kmuehlbauer](https://github.com/kmuehlbauer)
* FIX: Cast boolean string to int in rainbow dictionary ({pull}`113`) by [@egouden](https://github.com/egouden)
Expand Down
20 changes: 19 additions & 1 deletion examples/notebooks/CfRadial1_Export.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Plot Range vs. Time"
"### Plot Azimuth vs. Range"
]
},
{
Expand All @@ -74,6 +74,24 @@
"radar.sweep_0.DBZ.plot(cmap=\"ChaseSpectral\", vmin=-10, vmax=70)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Plot Time vs. Range"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"radar.sweep_0.DBZ.swap_dims({\"azimuth\": \"time\"}).sortby(\"time\").plot(\n",
" cmap=\"ChaseSpectral\", vmin=-10, vmax=70\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
7 changes: 7 additions & 0 deletions xradar/io/export/cfradial1.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"to_cfradial1",
]

from importlib.metadata import version

import numpy as np
import xarray as xr

Expand Down Expand Up @@ -304,6 +306,11 @@ def to_cfradial1(dtree=None, filename=None, calibs=True):

dataset.attrs = dtree.attrs

dataset.attrs["Conventions"] = "Cf/Radial"
dataset.attrs["version"] = "1.2"
xradar_version = version("xradar")
dataset.attrs["history"] += f": xradar v{xradar_version} CfRadial1 export"

if filename is None:
time = str(dataset.time[0].dt.strftime("%Y%m%d_%H%M%S").values)
filename = f"cfrad1_{dataset.instrument_name}_{time}.nc"
Expand Down
10 changes: 10 additions & 0 deletions xradar/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@
("receiver_slope_vc", None),
("receiver_slope_hx", None),
("receiver_slope_vx", None),
("k_squared_water", None),
("i0_dbm_hc", None),
("i0_dbm_vc", None),
("i0_dbm_hx", None),
("i0_dbm_vx", None),
("dynamic_range_db_hc", None),
("dynamic_range_db_vc", None),
("dynamic_range_db_hx", None),
("dynamic_range_db_vx", None),
("dbz_correction", None),
]
)

Expand Down

0 comments on commit 6880b0c

Please sign in to comment.