Skip to content

Commit

Permalink
Fix codestyle issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiggi committed Apr 2, 2024
1 parent 29c22f1 commit 3156d08
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 54 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
| Linting | [![Black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat)](https://github.com/psf/black) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&style=flat)](https://github.com/astral-sh/ruff) [![Codespell](https://img.shields.io/badge/Codespell-enabled-brightgreen?style=flat)](https://github.com/codespell-project/codespell) |
| Code Coverage | [![Coveralls](https://coveralls.io/repos/github/ghiggi/gpm_api/badge.svg?branch=main&style=flat)](https://coveralls.io/github/ghiggi/gpm_api?branch=main) [![Codecov](https://codecov.io/gh/ghiggi/gpm_api/branch/main/graph/badge.svg?style=flat)](https://codecov.io/gh/ghiggi/gpm_api) |
| Code Quality | [![Codefactor](https://www.codefactor.io/repository/github/ghiggi/gpm_api/badge?style=flat)](https://www.codefactor.io/repository/github/ghiggi/gpm_api) [![Codebeat](https://codebeat.co/badges/236abcf2-cbae-4ca9-8a2d-3b70495bb16b?style=flat)](https://codebeat.co/projects/github-com-ghiggi-gpm_api-main) [![Codacy](https://app.codacy.com/project/badge/Grade/bee842cb10004ad8bb9288256f2fc8af?style=flat)](https://app.codacy.com/gh/ghiggi/gpm_api/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [![Codescene](https://codescene.io/projects/36767/status-badges/code-health?style=flat)](https://codescene.io/projects/36767) |
| Code Review | [![pyOpenSci](https://tinyurl.com/XXXX)](#) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/XXXX/badge?style=flat)](#) |
| License | [![License](https://img.shields.io/github/license/ghiggi/gpm_api?style=flat)](https://github.com/ghiggi/gpm_api/blob/main/LICENSE) |
| Community | [![Slack](https://img.shields.io/badge/Slack-gpm_api-green.svg?logo=slack&style=flat)](https://join.slack.com/t/gpmapi/shared_invite/zt-28vkxzjs1-~cIYci2o3G0qEEoQJVMQRg) [![GitHub Discussions](https://img.shields.io/badge/GitHub-Discussions-green?logo=github&style=flat)](https://github.com/ghiggi/gpm_api/discussions) |
| Citation | [![DOI](https://zenodo.org/badge/286664485.svg?style=flat)](https://doi.org/10.5281/zenodo.10255084) |
Expand Down
4 changes: 2 additions & 2 deletions docs/source/03_quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ instructions available at the following `link <https://disc.gsfc.nasa.gov/earthd
.. note::
For enhanced security and command-line robustness,
refrain from including single quotes ('), double quotes ("), blank spaces, or backslashes (\\)
in both usernames and passwords
in both username and password.


Register to the NASA PPS
Expand All @@ -35,7 +35,7 @@ NRT products includes for example the IMERG Early and Late Runs products.
.. note::
For enhanced security and command-line robustness,
refrain from including single quotes ('), double quotes ("), blank spaces, or backslashes (\\)
in both usernames and passwords.
in both username and password.


Create the GPM-API configuration file
Expand Down
8 changes: 4 additions & 4 deletions docs/source/04_tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ Tutorials
This page provides read-only access to the GPM-API Jupyter Notebook tutorials.
The tutorials are available in the `tutorials <https://github.com/ghiggi/gpm_api/tree/main/tutorials>`__ directory of the GPM-API GitHub repository.

TODO
- CORRA and LH tutorials
- Add COLAB link

.. toctree::
:maxdepth: 1

tutorials/tutorial_02_IMERG
tutorials/tutorial_02_PMW_1C
tutorials/tutorial_02_PMW_2A
tutorials/tutorial_02_RADAR_2A

.. warning::

More tutorials will be available soon !
21 changes: 13 additions & 8 deletions docs/source/05_advanced_tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
Advanced Tools
=========================

Storm Labelling
Storm Tracking with IMERG
Patch Extraction
Geographic Bucket
3D Visualization of Radar Data
Bivariate Visualization
Retrievals
Dataset Zarrification
This section provides tutorials covering advanced GPM-API tools that can be used to perform more complex analysis on the data:

- Storm Labelling and Patch Extraction
- Storm Tracking with IMERG
- Community-based Retrievals
- 3D Radar Visualization
- Dataset Zarrification
- Geographic Bucketing


.. warning::

The following section is still in development. It will be available soon !
4 changes: 0 additions & 4 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ It's a great place to connect with others and get support.

Let's get started and unlock the full potential of the GPM data archive together!

.. warning::

The GPM-API is still in development. Feel free to try it out and to report issues or to suggest changes.


Documentation
=============
Expand Down
Binary file modified docs/source/static/collaborative_process.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/static/documentation_release.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/static/package_release.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gpm/bucket/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _try_write_granule_bucket(**kwargs):
try:
# synchronous
with dask.config.set(scheduler="single-threaded"):
_ = write_granule_bucket(**kwargs)
write_granule_bucket(**kwargs)
# If works, return None
info = None
except Exception as e:
Expand Down
8 changes: 4 additions & 4 deletions gpm/io/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def _get_list_failing_commands(dict_futures, pbar=None):
pbar.update(1) # Update the progress bar
# Collect all commands that caused problems
if future.exception() is not None:
index, cmd = dict_futures[future]
_, cmd = dict_futures[future] # {index: cmd}
l_cmd_error.append(cmd)
return l_cmd_error

Expand Down Expand Up @@ -896,12 +896,12 @@ def _check_download_status(status, product, verbose):
if all_already_local:
if verbose:
print(f"All the available GPM {product} product files are already on disk.")
pass
return True
# - Files available but all download failed
elif n_failed == n_remote_files:
if n_failed == n_remote_files:
print(f"{n_failed} files were available, but the download failed !")
return None
elif verbose:
if verbose:
if n_failed != 0:
print(f"The download of {n_failed} files failed.")
if n_downloads > 0:
Expand Down
16 changes: 3 additions & 13 deletions gpm/utils/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@

import numpy as np

from gpm.io.checks import (
check_start_end_time,
)
from gpm.io.checks import check_start_end_time
from gpm.io.find import find_filepaths
from gpm.io.info import (
get_end_time_from_filepaths,
get_granule_from_filepaths,
get_start_time_from_filepaths,
)
from gpm.utils.warnings import GPM_Warning

Expand Down Expand Up @@ -98,11 +98,6 @@ def check_time_period_coverage(filepaths, start_time, end_time, raise_error=Fals
If raise_error=False, it raise a GPM warning.
"""
from gpm.io.info import (
get_end_time_from_filepaths,
get_start_time_from_filepaths,
)

# Check valid start/end time
start_time, end_time = check_start_end_time(start_time, end_time)

Expand Down Expand Up @@ -142,11 +137,6 @@ def get_time_period_with_missing_files(filepaths):
List of tuple (start_time, end_time).
"""
from gpm.io.info import (
get_end_time_from_filepaths,
get_granule_from_filepaths,
get_start_time_from_filepaths,
)
from gpm.utils.checks import _is_contiguous_granule
from gpm.utils.slices import get_list_slices_from_bool_arr

Expand Down
11 changes: 1 addition & 10 deletions gpm/utils/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
list_slices_filter,
list_slices_flatten,
list_slices_intersection,
list_slices_simplify,
list_slices_sort,
list_slices_union,
)
Expand Down Expand Up @@ -205,8 +206,6 @@ def _get_timesteps(xr_obj):
@check_is_gpm_object
def _infer_time_tolerance(xr_obj):
"""Infer time interval tolerance between timesteps."""
from gpm.checks import is_grid, is_orbit

# For GPM ORBIT objects, use the ORBIT_TIME_TOLERANCE
if is_orbit(xr_obj):
tolerance = ORBIT_TIME_TOLERANCE
Expand Down Expand Up @@ -806,8 +805,6 @@ def _replace_0_values(x):


def _get_non_wobbling_lats(lats, threshold=100):
from gpm.utils.slices import list_slices_filter, list_slices_simplify

# Get direction (1 ascending , -1 descending)
directions = np.sign(np.diff(lats))
directions = np.append(directions[0], directions) # include startpoint
Expand All @@ -832,8 +829,6 @@ def get_slices_non_wobbling_swath(xr_obj, threshold=100):
The function extract the along-track boundary on both swath sides and
identify where the change in orbit direction occurs.
"""
from gpm.utils.slices import list_slices_intersection

xr_obj = xr_obj.transpose("cross_track", "along_track", ...)
lats = xr_obj["lat"].to_numpy()
lats_side0 = lats[0, :]
Expand Down Expand Up @@ -872,8 +867,6 @@ def is_regular(xr_obj):
For GPM ORBITS, it checks that the scans are contiguous.
For GPM GRID, it checks that the timesteps are regularly spaced.
"""
from gpm.checks import is_grid, is_orbit

if is_orbit(xr_obj):
return has_contiguous_scans(xr_obj)
if is_grid(xr_obj):
Expand Down Expand Up @@ -911,8 +904,6 @@ def get_slices_regular(xr_obj, min_size=None, min_n_scans=3):
Output format: [slice(start,stop), slice(start,stop),...]
"""
from gpm.checks import is_grid, is_orbit

if is_orbit(xr_obj):
min_size = 2 if min_size is None else min_size
# Get swath portions where there are not missing scans (and granules)
Expand Down
2 changes: 0 additions & 2 deletions gpm/visualization/facetgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,6 @@ def optimize_layout(self):

def set_extent(self, extent):
"""Modify extent of all Cartopy subplots."""
from cartopy.mpl.geoaxes import GeoAxes

if extent is None:
return
# Modify extent
Expand Down
4 changes: 2 additions & 2 deletions gpm/visualization/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def _plot_grid_image(
if ax is None:
if "rgb" not in plot_kwargs:
check_is_spatial_2d(da)
fig, ax = plt.subplots(**fig_kwargs)
_, ax = plt.subplots(**fig_kwargs)

# - Sanitize plot_kwargs set by by xarray FacetGrid.map_datarray
is_facetgrid = plot_kwargs.get("_is_facetgrid", False)
Expand Down Expand Up @@ -301,9 +301,9 @@ def plot_grid_mesh(
subplot_kwargs=None,
**plot_kwargs,
):
"""Plot GPM grid mesh in a cartographic map."""
from gpm.visualization.orbit import _plot_cartopy_pcolormesh

"""Plot GPM grid mesh in a cartographic map."""
# - Initialize figure if necessary
ax = initialize_cartopy_plot(
ax=ax,
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ dependencies = [
"click",
"donfig",
"trollsift",

"matplotlib>=3.8.3", # introduce pcolormesh rgb
"cartopy>=0.22.0",
"pyproj",
Expand Down Expand Up @@ -171,6 +170,7 @@ select = [
"C4",
# Ruff custom rules
"RUF"

#---------------------
#### Future rules ####
# flake8-use-pathlib
Expand Down Expand Up @@ -201,8 +201,6 @@ ignore = [
"PLR2004",
"PLR0912",
"PLR0915",


]

# Allow autofix for all enabled rules (when `--fix`) is provided.
Expand Down

0 comments on commit 3156d08

Please sign in to comment.