Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
observingClouds committed Apr 17, 2024
1 parent 5494af4 commit 808bfb6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/ArtificialInformation_Filter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@
"outputs": [],
"source": [
"ds = xr.open_zarr(\n",
" \"s3://hytest/conus404/conus404_hourly.zarr\",\n",
" \"s3://hytest/conus404/conus404_monthly.zarr\",\n",
" storage_options={\n",
" \"anon\": True,\n",
" \"requester_pays\": False,\n",
" \"client_kwargs\": {\"endpoint_url\": \"https://usgs.osn.mghpcc.org\"},\n",
" },\n",
")\n",
"# selecting water vapor mixing ratio at 2 meters\n",
"data = ds[\"ACSWUPB\"]\n",
"data = ds[\"ACSWDNT\"]\n",
"# select subset of data for demonstration purposes\n",
"chunk = data.isel(time=slice(0, 9), y=slice(0, 525), x=slice(0, 525))\n",
"chunk = data.isel(time=slice(0, 2), y=slice(0, 1015), x=slice(0, 1050))\n",
"chunk"
]
},
Expand Down
20 changes: 17 additions & 3 deletions xbitinfo/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def split_dataset_by_dims(info_per_bit):
return var_by_dim


def plot_bitinformation(bitinfo, cmap="turku", crop=None):
def plot_bitinformation(bitinfo, information_filter=None, cmap="turku", crop=None):
"""Plot bitwise information content as in Klöwer et al. 2021 Figure 2.
Klöwer, M., Razinger, M., Dominguez, J. J., Düben, P. D., & Palmer, T. N. (2021).
Expand All @@ -214,6 +214,9 @@ def plot_bitinformation(bitinfo, cmap="turku", crop=None):
----------
bitinfo : :py:func:`xarray.Dataset`
Containing the bitwise information content for each variable
information_filter : str
Filter algorithm to filter artificial information content. Defaults to ``None``.
Available filters are: ``"Gradient"``.
cmap : str or plt.cm
Colormap. Defaults to ``"turku"``.
crop : int
Expand Down Expand Up @@ -252,8 +255,19 @@ def plot_bitinformation(bitinfo, cmap="turku", crop=None):
nvars = len(bitinfo)
varnames = list(bitinfo.keys())

infbits_dict = get_keepbits(bitinfo, 0.99)
infbits100_dict = get_keepbits(bitinfo, 0.999999999)
if information_filter == "Gradient":
infbits_dict = get_keepbits(
bitinfo, 0.99, information_filter, **{"threshold": 0.7, "tolerance": 0.001}
)
infbits100_dict = get_keepbits(
bitinfo,
0.999999999,
information_filter,
**{"threshold": 0.7, "tolerance": 0.001},
)
else:
infbits_dict = get_keepbits(bitinfo, 0.99)
infbits100_dict = get_keepbits(bitinfo, 0.999999999)

ICnan = np.zeros((nvars, 64))
infbits = np.zeros(nvars)
Expand Down

0 comments on commit 808bfb6

Please sign in to comment.