From e6c29645ab932af487f17e79df01fd087456b3ce Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 28 Sep 2024 15:43:48 +1200 Subject: [PATCH] Add type hints to resolution and region parameters Following changes at https://github.com/GenericMappingTools/pygmt/pull/3260 and https://github.com/GenericMappingTools/pygmt/pull/3272 --- pygmt/datasets/earth_daynight.py | 40 ++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/pygmt/datasets/earth_daynight.py b/pygmt/datasets/earth_daynight.py index f231d3f345c..fcb78ad445b 100644 --- a/pygmt/datasets/earth_daynight.py +++ b/pygmt/datasets/earth_daynight.py @@ -5,14 +5,32 @@ The grids are available in various resolutions. """ +from collections.abc import Sequence +from typing import Literal + +import xarray as xr from pygmt.datasets.load_remote_dataset import _load_remote_dataset -from pygmt.helpers import kwargs_to_strings __doctest_skip__ = ["load_blue_marble"] -@kwargs_to_strings(region="sequence") -def load_blue_marble(resolution="01d", region=None): +def load_blue_marble( + resolution: Literal[ + "01d", + "30m", + "20m", + "15m", + "10m", + "06m", + "05m", + "04m", + "03m", + "02m", + "01m", + "30s", + ] = "01d", + region: Sequence[float] | str | None = None, +) -> xr.DataArray: r""" Load NASA Blue Marble images in various resolutions. @@ -36,20 +54,18 @@ def load_blue_marble(resolution="01d", region=None): Parameters ---------- - resolution : str + resolution The image resolution. The suffix ``d``, ``m``, and ``s`` stand for arc-degree, - arc-minute, and arc-second. It can be ``"01d"``, ``"30m"``, ``"20m"``, - ``"15m"``, ``"10m"``, ``"06m"``, ``"05m"``, ``"04m"``, ``"03m"``, ``"02m"``, - ``"01m"``, or ``"30s"``. + arc-minute, and arc-second. - region : str or list - The subregion of the image to load, in the form of a list [*xmin*, *xmax*, - *ymin*, *ymax*] or a string *xmin/xmax/ymin/ymax*. Required for images with - resolutions higher than 5 arc-minutes (i.e., ``"05m"``). + region + The subregion of the image to load, in the form of a sequence [*xmin*, *xmax*, + *ymin*, *ymax*]. Required for images with resolutions higher than 5 arc-minutes + (i.e., ``"05m"``). Returns ------- - image : :class:`xarray.DataArray` + image The NASA Blue Marble image. Coordinates are latitude and longitude in degrees. Examples