Skip to content

Commit

Permalink
Improve viz tools
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiggi committed Jan 14, 2025
1 parent 8d8b535 commit 6241033
Show file tree
Hide file tree
Showing 47 changed files with 976 additions and 375 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.10"
- name: Ruff
if: success() || failure()
uses: pre-commit/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
experimental: [false]
include:
- os: ubuntu-latest
python-version: "3.12"
python-version: "3.13"
experimental: true
- os: ubuntu-latest
python-version: "3.11"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
experimental: [false]
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Deployment | [![PyPI](https://badge.fury.io/py/gpm_api.svg?style=flat)](https://pypi.org/project/gpm_api/) [![Conda](https://img.shields.io/conda/vn/conda-forge/gpm-api.svg?logo=conda-forge&logoColor=white&style=flat)](https://anaconda.org/conda-forge/gpm-api) |
| Activity | [![PyPI Downloads](https://img.shields.io/pypi/dm/gpm_api.svg?label=PyPI%20downloads&style=flat)](https://pypi.org/project/gpm_api/) [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/gpm-api.svg?label=Conda%20downloads&style=flat)](https://anaconda.org/conda-forge/gpm-api) |
| Python Versions | [![Python Versions](https://img.shields.io/badge/Python-3.9%20%203.10%20%203.11%20%203.12-blue?style=flat)](https://www.python.org/downloads/) |
| Python Versions | [![Python Versions](https://img.shields.io/badge/Python-3.10%20%203.11%20%203.12%20%203.13-blue?style=flat)](https://www.python.org/downloads/) |
| Supported Systems | [![Linux](https://img.shields.io/github/actions/workflow/status/ghiggi/gpm_api/.github/workflows/tests.yaml?label=Linux&style=flat)](https://github.com/ghiggi/gpm_api/actions/workflows/tests.yaml) [![macOS](https://img.shields.io/github/actions/workflow/status/ghiggi/gpm_api/.github/workflows/tests.yaml?label=macOS&style=flat)](https://github.com/ghiggi/gpm_api/actions/workflows/tests.yaml) [![Windows](https://img.shields.io/github/actions/workflow/status/ghiggi/gpm_api/.github/workflows/tests_windows.yaml?label=Windows&style=flat)](https://github.com/ghiggi/gpm_api/actions/workflows/tests_windows.yaml) |
| Project Status | [![Project Status](https://www.repostatus.org/badges/latest/active.svg?style=flat)](https://www.repostatus.org/#active) |
| Build Status | [![Tests](https://github.com/ghiggi/gpm_api/actions/workflows/tests.yaml/badge.svg?style=flat)](https://github.com/ghiggi/gpm_api/actions/workflows/tests.yaml) [![Lint](https://github.com/ghiggi/gpm_api/actions/workflows/lint.yaml/badge.svg?style=flat)](https://github.com/ghiggi/gpm_api/actions/workflows/lint.yaml) [![Docs](https://readthedocs.org/projects/gpm_api/badge/?version=latest&style=flat)](https://gpm-api.readthedocs.io/en/latest/) |
Expand Down
2 changes: 1 addition & 1 deletion docs/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- pandoc
- pip
- polars
- python>=3.9
- python>=3.10
- pyvista
- sphinx-book-theme==1.1.0
- sphinx-gallery
Expand Down
60 changes: 59 additions & 1 deletion gpm/accessor/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import inspect
import re
import sys
from typing import Callable
from collections.abc import Callable

import numpy as np
import xarray as xr
Expand Down Expand Up @@ -317,6 +317,20 @@ def extract_transect_at_points(
new_dim=new_dim,
)

@auto_wrap_docstring
def extract_transect_along_dimension(
self,
point,
dim,
):
from gpm.utils.manipulations import extract_transect_along_dimension

return extract_transect_along_dimension(
self._obj,
point=point,
dim=dim,
)

#### Range subset utility
@auto_wrap_docstring
def slice_range_at_bin(self, bins):
Expand Down Expand Up @@ -579,6 +593,8 @@ def plot_transect_line(
ax=None,
add_direction=True,
add_background=True,
add_gridlines=True,
add_labels=True,
fig_kwargs=None,
subplot_kwargs=None,
text_kwargs=None,
Expand All @@ -592,6 +608,8 @@ def plot_transect_line(
ax=ax,
add_direction=add_direction,
add_background=add_background,
add_gridlines=add_gridlines,
add_labels=add_labels,

Check notice on line 612 in gpm/accessor/methods.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Excess Number of Function Arguments

GPM_Base_Accessor.plot_transect_line increases from 8 to 10 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
fig_kwargs=fig_kwargs,
subplot_kwargs=subplot_kwargs,
text_kwargs=text_kwargs,
Expand All @@ -609,6 +627,8 @@ def plot_swath(
fig_kwargs=None,
subplot_kwargs=None,
add_background=True,
add_gridlines=True,
add_labels=True,
**plot_kwargs,
):
from gpm.visualization.orbit import plot_swath
Expand All @@ -620,6 +640,8 @@ def plot_swath(
edgecolor=edgecolor,
alpha=alpha,
add_background=add_background,
add_gridlines=add_gridlines,
add_labels=add_labels,

Check notice on line 644 in gpm/accessor/methods.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Excess Number of Function Arguments

GPM_Base_Accessor.plot_swath increases from 8 to 10 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
fig_kwargs=fig_kwargs,
subplot_kwargs=subplot_kwargs,
**plot_kwargs,
Expand All @@ -634,6 +656,8 @@ def plot_swath_lines(
linestyle="--",
color="k",
add_background=True,
add_gridlines=True,
add_labels=True,
fig_kwargs=None,
subplot_kwargs=None,
**plot_kwargs,
Expand All @@ -648,6 +672,8 @@ def plot_swath_lines(
linestyle=linestyle,
color=color,
add_background=add_background,
add_gridlines=add_gridlines,
add_labels=add_labels,

Check notice on line 676 in gpm/accessor/methods.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Excess Number of Function Arguments

GPM_Base_Accessor.plot_swath_lines increases from 9 to 11 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
fig_kwargs=fig_kwargs,
subplot_kwargs=subplot_kwargs,
**plot_kwargs,
Expand All @@ -662,6 +688,8 @@ def plot_map_mesh(
edgecolors="k",
linewidth=0.1,
add_background=True,
add_gridlines=True,
add_labels=True,
fig_kwargs=None,
subplot_kwargs=None,
**plot_kwargs,
Expand All @@ -676,6 +704,8 @@ def plot_map_mesh(
edgecolors=edgecolors,
linewidth=linewidth,
add_background=add_background,
add_gridlines=add_gridlines,
add_labels=add_labels,

Check notice on line 708 in gpm/accessor/methods.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Excess Number of Function Arguments

GPM_Base_Accessor.plot_map_mesh increases from 9 to 11 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
fig_kwargs=fig_kwargs,
subplot_kwargs=subplot_kwargs,
**plot_kwargs,
Expand All @@ -690,6 +720,8 @@ def plot_map_mesh_centroids(
c="r",
s=1,
add_background=True,
add_gridlines=True,
add_labels=True,
fig_kwargs=None,
subplot_kwargs=None,
**plot_kwargs,
Expand All @@ -704,6 +736,8 @@ def plot_map_mesh_centroids(
c=c,
s=s,
add_background=add_background,
add_gridlines=add_gridlines,
add_labels=add_labels,

Check notice on line 740 in gpm/accessor/methods.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Excess Number of Function Arguments

GPM_Base_Accessor.plot_map_mesh_centroids increases from 9 to 11 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
fig_kwargs=fig_kwargs,
subplot_kwargs=subplot_kwargs,
**plot_kwargs,
Expand Down Expand Up @@ -827,6 +861,8 @@ def plot_map(
add_colorbar=True,
add_swath_lines=True,
add_background=True,
add_gridlines=True,
add_labels=True,
interpolation="nearest", # used only for GPM grid object
fig_kwargs=None,
subplot_kwargs=None,
Expand All @@ -843,6 +879,8 @@ def plot_map(
add_colorbar=add_colorbar,
add_swath_lines=add_swath_lines,
add_background=add_background,
add_gridlines=add_gridlines,
add_labels=add_labels,

Check notice on line 883 in gpm/accessor/methods.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Excess Number of Function Arguments

GPM_Dataset_Accessor.plot_map increases from 12 to 14 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
interpolation=interpolation,
fig_kwargs=fig_kwargs,
subplot_kwargs=subplot_kwargs,
Expand Down Expand Up @@ -889,6 +927,7 @@ def plot_cross_section(
add_colorbar=True,
interpolation="nearest",
zoom=True,
check_contiguity=True,
fig_kwargs=None,
cbar_kwargs=None,
**plot_kwargs,
Expand All @@ -903,6 +942,7 @@ def plot_cross_section(
add_colorbar=add_colorbar,
interpolation=interpolation,
zoom=zoom,
check_contiguity=check_contiguity,

Check notice on line 945 in gpm/accessor/methods.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Excess Number of Function Arguments

GPM_Dataset_Accessor.plot_cross_section increases from 10 to 11 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
fig_kwargs=fig_kwargs,
cbar_kwargs=cbar_kwargs,
**plot_kwargs,
Expand Down Expand Up @@ -1013,6 +1053,18 @@ def get_slices_var_between(self, dim, vmin=-np.inf, vmax=np.inf, criteria="all")

return get_slices_var_between(self._obj, dim=dim, vmin=vmin, vmax=vmax, criteria=criteria)

@auto_wrap_docstring
def locate_max_value(self, return_isel_dict=False):
from gpm.utils.manipulations import locate_max_value

return locate_max_value(self._obj, return_isel_dict=return_isel_dict)

@auto_wrap_docstring
def locate_min_value(self, return_isel_dict=False):
from gpm.utils.manipulations import locate_min_value

return locate_min_value(self._obj, return_isel_dict=return_isel_dict)

@auto_wrap_docstring
def title(
self,
Expand Down Expand Up @@ -1042,6 +1094,8 @@ def plot_map(
add_colorbar=True,
add_swath_lines=True,
add_background=True,
add_gridlines=True,
add_labels=True,
interpolation="nearest", # used only for GPM grid object
fig_kwargs=None,
subplot_kwargs=None,
Expand All @@ -1058,6 +1112,8 @@ def plot_map(
add_colorbar=add_colorbar,
add_swath_lines=add_swath_lines,
add_background=add_background,
add_gridlines=add_gridlines,
add_labels=add_labels,

Check notice on line 1116 in gpm/accessor/methods.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Excess Number of Function Arguments

GPM_DataArray_Accessor.plot_map increases from 11 to 13 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
interpolation=interpolation,
fig_kwargs=fig_kwargs,
subplot_kwargs=subplot_kwargs,
Expand Down Expand Up @@ -1102,6 +1158,7 @@ def plot_cross_section(
add_colorbar=True,
interpolation="nearest",
zoom=True,
check_contiguity=True,
fig_kwargs=None,
cbar_kwargs=None,
**plot_kwargs,
Expand All @@ -1116,6 +1173,7 @@ def plot_cross_section(
add_colorbar=add_colorbar,
interpolation=interpolation,
zoom=zoom,
check_contiguity=check_contiguity,

Check notice on line 1176 in gpm/accessor/methods.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Excess Number of Function Arguments

GPM_DataArray_Accessor.plot_cross_section increases from 9 to 10 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
fig_kwargs=fig_kwargs,
cbar_kwargs=cbar_kwargs,
**plot_kwargs,
Expand Down
2 changes: 1 addition & 1 deletion gpm/bucket/partitioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def add_labels(self, df, x, y, remove_invalid_rows=True):
if self.n_levels == 1:
labels = [labels]
# Add labels to dataframe
for partition, values in zip(self.levels, labels):
for partition, values in zip(self.levels, labels, strict=False):
df = df_add_column(df=df, column=partition, values=values)
# Check if invalid labels
invalid_rows = labels[0] == "nan"
Expand Down
11 changes: 5 additions & 6 deletions gpm/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import os
import platform
from subprocess import Popen
from typing import Optional

from gpm.utils.yaml import read_yaml, write_yaml

Expand Down Expand Up @@ -81,11 +80,11 @@ def _define_config_filepath():


def define_configs(
base_dir: Optional[str] = None,
username_pps: Optional[str] = None,
password_pps: Optional[str] = None,
username_earthdata: Optional[str] = None,
password_earthdata: Optional[str] = None,
base_dir: str | None = None,
username_pps: str | None = None,
password_pps: str | None = None,
username_earthdata: str | None = None,
password_earthdata: str | None = None,
):
"""Defines the GPM-API configuration file with the given credentials and base directory.
Expand Down
4 changes: 2 additions & 2 deletions gpm/dataset/conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def _get_chunks_encodings(ds):
chunksizes = ds[name].encoding.get("chunksizes", None)
if preferred_chunks:
# Use values() to remove phony_dim_* keys
dict_preferred_chunks[name] = dict(zip(ds[name].dims, preferred_chunks.values()))
dict_preferred_chunks[name] = dict(zip(ds[name].dims, preferred_chunks.values(), strict=False))
if preferred_chunks:
dict_chunksizes[name] = dict(zip(ds[name].dims, chunksizes))
dict_chunksizes[name] = dict(zip(ds[name].dims, chunksizes, strict=False))
return dict_chunksizes, dict_preferred_chunks


Expand Down
2 changes: 1 addition & 1 deletion gpm/dataset/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_orbit_coords(dt, scan_mode):
granule_id = np.repeat(granule_id, n_along_track)
along_track_id = np.arange(n_along_track)
cross_track_id = np.arange(n_cross_track)
gpm_id = [str(g) + "-" + str(z) for g, z in zip(granule_id, along_track_id)]
gpm_id = [str(g) + "-" + str(z) for g, z in zip(granule_id, along_track_id, strict=False)]

return {
"lon": xr.DataArray(lon, dims=["along_track", "cross_track"]),
Expand Down
2 changes: 1 addition & 1 deletion gpm/dataset/dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _get_dataarray_dim_dict(da):
dim_names_str = da.attrs.get("DimensionNames", None)
if dim_names_str is not None:
dim_names = dim_names_str.split(",")
for dim, new_dim in zip(list(da.dims), dim_names):
for dim, new_dim in zip(list(da.dims), dim_names, strict=False):
# Deal with missing DimensionNames in
# - sunVectorInBodyFrame variable in V5 products
# - 1B-Ku/Ka V5 *Temp products
Expand Down
Loading

0 comments on commit 6241033

Please sign in to comment.