diff --git a/CITATION.cff b/CITATION.cff index b9f110b..402cdd3 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -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" diff --git a/README.md b/README.md index 8790170..9e4db2c 100644 --- a/README.md +++ b/README.md @@ -11,5 +11,5 @@ DESHIMA code for data analysis ## Installation ```shell -pip install decode==2.2.0 +pip install decode==2.3.0 ``` diff --git a/decode/__init__.py b/decode/__init__.py index 0047b4a..9f5227c 100644 --- a/decode/__init__.py +++ b/decode/__init__.py @@ -5,7 +5,7 @@ "plot", "select", ] -__version__ = "2.2.0" +__version__ = "2.3.0" # submodules diff --git a/decode/plot.py b/decode/plot.py index decdee9..80c9e2d 100644 --- a/decode/plot.py +++ b/decode/plot.py @@ -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. @@ -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. @@ -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.") diff --git a/pyproject.toml b/pyproject.toml index 44d547b..456561e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] keywords = [