Skip to content

Commit

Permalink
#99 Merge pull request from deshima-dev/astropenguin/issue98
Browse files Browse the repository at this point in the history
Release v2.3.0
  • Loading branch information
astropenguin authored Oct 25, 2023
2 parents 6115808 + b7b8318 commit beec656
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."

title: "decode"
title: "de:code"
abstract: "DESHIMA code for data analysis"
version: 2.2.0
version: 2.3.0
date-released: 2023-10-25
license: "MIT"
doi: "10.5281/zenodo.3384216"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ DESHIMA code for data analysis
## Installation

```shell
pip install decode==2.2.0
pip install decode==2.3.0
```
2 changes: 1 addition & 1 deletion decode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"plot",
"select",
]
__version__ = "2.2.0"
__version__ = "2.3.0"


# submodules
Expand Down
64 changes: 32 additions & 32 deletions decode/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
DEMS_DIMS = "time", "chan"


def state(
dems: xr.DataArray,
def data(
data: xr.DataArray,
/,
*,
on: Literal["time", "sky"] = "time",
squeeze: bool = True,
**options: Any,
) -> Artist:
"""Plot the state coordinate of DEMS.
"""Plot 1D or 2D data of DEMS or its coordinate.
Args:
dems: DEMS DataArray to be plotted.
on: On which plane the state coordinate is plotted.
data: DEMS DataArray or coordinate DataArray.
squeeze: Whether to squeeze the data before plotting.
Keyword Args:
options: Plotting options to be passed to Matplotlib.
Expand All @@ -34,41 +34,47 @@ def state(
Matplotlib artist object of the plotted data.
"""
if on == "time":
if squeeze:
data = data.squeeze()

if data.dims == (DEMS_DIMS[0],):
options = {
"edgecolors": "none",
"hue": "state",
"s": 3,
"x": "time",
"x": DEMS_DIMS[0],
**options,
}
return dems.state.sortby("state").plot.scatter(**options)
return data.plot.scatter(**options) # type: ignore

if on == "sky":
if data.dims == (DEMS_DIMS[1],):
options = {
"edgecolors": "none",
"hue": "state",
"s": 3,
"x": "lon",
"x": DEMS_DIMS[1],
**options,
}
return dems.lat.plot.scatter(**options)
return data.plot.scatter(**options) # type: ignore

raise ValueError("On must be either time or sky.")
if data.dims == DEMS_DIMS:
return data.plot.pcolormesh(**options) # type: ignore

raise ValueError(f"Dimensions must be subset of {DEMS_DIMS}.")

def data(
data: xr.DataArray,

def state(
dems: xr.DataArray,
/,
*,
squeeze: bool = True,
on: Literal["time", "sky"] = "time",
**options: Any,
) -> Artist:
"""Plot 1D or 2D data of DEMS or its coordinate.
"""Plot the state coordinate of DEMS.
Args:
data: DEMS DataArray or coordinate DataArray.
squeeze: Whether to squeeze the data before plotting.
dems: DEMS DataArray to be plotted.
on: On which plane the state coordinate is plotted.
Keyword Args:
options: Plotting options to be passed to Matplotlib.
Expand All @@ -77,30 +83,24 @@ def data(
Matplotlib artist object of the plotted data.
"""
if squeeze:
data = data.squeeze()

if data.dims == (DEMS_DIMS[0],):
if on == "time":
options = {
"edgecolors": "none",
"hue": "state",
"s": 3,
"x": DEMS_DIMS[0],
"x": "time",
**options,
}
return data.plot.scatter(**options) # type: ignore
return dems.state.sortby("state").plot.scatter(**options)

if data.dims == (DEMS_DIMS[1],):
if on == "sky":
options = {
"edgecolors": "none",
"hue": "state",
"s": 3,
"x": DEMS_DIMS[1],
"x": "lon",
**options,
}
return data.plot.scatter(**options) # type: ignore

if data.dims == DEMS_DIMS:
return data.plot.pcolormesh(**options) # type: ignore
return dems.lat.plot.scatter(**options)

raise ValueError(f"Dimensions must be subset of {DEMS_DIMS}.")
raise ValueError("On must be either time or sky.")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "decode"
version = "2.2.0"
version = "2.3.0"
description = "DESHIMA code for data analysis"
authors = ["Akio Taniguchi <taniguchi@a.phys.nagoya-u.ac.jp>"]
keywords = [
Expand Down

0 comments on commit beec656

Please sign in to comment.