Skip to content

Commit

Permalink
Add and fix pydocstyle rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiggi committed Mar 31, 2024
1 parent 16b9979 commit 21548d4
Show file tree
Hide file tree
Showing 48 changed files with 413 additions and 396 deletions.
2 changes: 2 additions & 0 deletions gpm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
# SOFTWARE.

# -----------------------------------------------------------------------------.
"""GPM-API Package."""

import contextlib
import os
from importlib.metadata import PackageNotFoundError, version
Expand Down
2 changes: 1 addition & 1 deletion gpm/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# SOFTWARE.

# -----------------------------------------------------------------------------.
"""This module create a donfig utility
"""Donfig configuration utility.
See https://donfig.readthedocs.io/en/latest/configuration.html for more info.
"""
Expand Down
2 changes: 1 addition & 1 deletion gpm/bucket/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def merge_granule_buckets(
batch_readahead=16,
fragment_readahead=4,
):
"""Merge the per-granule bucket archive in a single optimized archive !
"""Merge the per-granule bucket archive in a single optimized archive.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion gpm/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# SOFTWARE.

# -----------------------------------------------------------------------------.
"""This module define and retrieve the GPM-API configurations."""
"""GPM-API configurations settings."""
import os
import platform
from subprocess import Popen
Expand Down
10 changes: 6 additions & 4 deletions gpm/dataset/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@


def _is_str_list(s):
"""Return a boolean indicating if the string start and end with brackets and can
be converted to a list.
"""Check if the string start and end with brackets.
Return a boolean indicating if the string can be converted to a list.
"""
if s.startswith("[") and s.endswith("]"):
try:
Expand Down Expand Up @@ -139,7 +141,7 @@ def _parse_attr_string(s):


def decode_string(string):
"""Decode string dictionary.
r"""Decode string dictionary.
Format: ``"<key>=<value>\\n".``.
Expand Down Expand Up @@ -192,7 +194,7 @@ def get_granule_attrs(dt):


def add_history(ds):
"""Add the history attribute to the xr.Dataset"""
"""Add the history attribute to the xr.Dataset."""
current_time = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
history = f"Created by ghiggi/gpm_api software on {current_time}"
ds.attrs["history"] = history
Expand Down
11 changes: 7 additions & 4 deletions gpm/dataset/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _get_projection_coords_attrs(crs):


def _get_proj_dim_coords(xr_obj):
"""Determine the spatial 1D dimensions of the `xarray.DataArray`
"""Determine the spatial 1D dimensions of the `xarray.DataArray`.
Parameters
----------
Expand Down Expand Up @@ -227,7 +227,7 @@ def _get_proj_dim_coords(xr_obj):


def _get_swath_dim_coords(xr_obj):
"""Determine the spatial 1D dimensions of the `xarray.DataArray`
"""Determine the spatial 1D dimensions of the `xarray.DataArray`.
Cases:
- 2D x/y coordinates with 2 dimensions (along-track-cross-track scan)
Expand Down Expand Up @@ -574,7 +574,7 @@ def remove_existing_crs_info(ds):


def set_dataset_single_crs(ds, crs, grid_mapping_name="spatial_ref", inplace=False):
"""Add CF-compliant CRS information to an xr.Dataset
"""Add CF-compliant CRS information to an xr.Dataset.
It assumes all dataset variables have same CRS !
For projected CRS, it expects that the CRS dimension coordinates are specified.
Expand Down Expand Up @@ -611,7 +611,7 @@ def set_dataset_single_crs(ds, crs, grid_mapping_name="spatial_ref", inplace=Fal


def set_dataset_crs(ds, crs, grid_mapping_name="spatial_ref", inplace=False):
"""Add CF-compliant CRS information to an xr.Dataset
"""Add CF-compliant CRS information to an xr.Dataset.
It assumes all dataset variables have same CRS !
For projected CRS, it expects that the CRS dimension coordinates are specified.
Expand Down Expand Up @@ -736,6 +736,7 @@ def get_pyproj_crs(xr_obj):


def get_pyresample_swath(xr_obj):
"""Get pyresample SwathDefinition from CF-compliant xarray object."""
from pyresample import SwathDefinition

if not has_swath_coords(xr_obj):
Expand Down Expand Up @@ -765,6 +766,7 @@ def get_pyresample_swath(xr_obj):

def _compute_extent(x_coords, y_coords):
"""Compute the extent (x_min, x_max, y_min, y_max) from the pixel centroids in x and y coordinates.
This function assumes that the spacing between each pixel is uniform.
"""
# Calculate the pixel size assuming uniform spacing between pixels
Expand All @@ -779,6 +781,7 @@ def _compute_extent(x_coords, y_coords):


def get_pyresample_projection(xr_obj):
"""Get pyresample AreaDefinition from CF-compliant xarray object."""
from pyresample import AreaDefinition

if not has_proj_coords(xr_obj):
Expand Down
3 changes: 1 addition & 2 deletions gpm/dataset/granule.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ def open_granule(
chunks={},
prefix_group=False,
):
"""Create a lazy ``xarray.Dataset`` with relevant GPM data and attributes
for a specific granule.
"""Create a lazy ``xarray.Dataset`` with relevant GPM data and attributes for a specific granule.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion gpm/io/ges_disc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# SOFTWARE.

# -----------------------------------------------------------------------------.
"""This module contains the routines required to search data on the NASA GES DISC servers"""
"""Routines required to search data on the NASA GES DISC servers."""

import datetime
import re
Expand Down
4 changes: 2 additions & 2 deletions gpm/io/pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _get_pps_data_server(product_type):


def _get_pps_nrt_product_folder_name(product):
""" "Retrieve NASA PPS server folder name for NRT product_type."""
"""Retrieve NASA PPS server folder name for NRT product_type."""
folder_name = get_product_info(product).get("pps_nrt_dir", None)
if folder_name is None:
raise ValueError(
Expand All @@ -73,7 +73,7 @@ def _get_pps_nrt_product_folder_name(product):


def _get_pps_rs_product_folder_name(product):
""" "Retrieve NASA PPS server folder name for RS product_type."""
"""Retrieve NASA PPS server folder name for RS product_type."""
folder_name = get_product_info(product).get("pps_rs_dir", None)
if folder_name is None:
raise ValueError(
Expand Down
Loading

0 comments on commit 21548d4

Please sign in to comment.