Commit ec0609b2 authored by Paulo Medeiros's avatar Paulo Medeiros
Browse files

Lint domains.py docstrings.

parent 26957b4b
......@@ -81,7 +81,7 @@ class Grid2D:
@property
def ny(self):
"""Return the number of grid points along the x-direction."""
"""Return the number of grid points along the y-direction."""
return self._yaxis.npts
@ny.setter
......@@ -300,6 +300,7 @@ class Domain:
"""Model domain geometry and grid.
See <https://hirlam.org/trac/wiki/HarmonieSystemDocumentation/ModelDomain>.
"""
def __init__(
......@@ -327,6 +328,7 @@ class Domain:
self.lmrt = lmrt
def init_proj(ngrid_lonlat, proj_lon0_lat0, grid_spacing):
"""Help routine to initialise domain projection."""
if self.lmrt and abs(proj_lon0_lat0[1]) > 0:
logger.warning(
"lat0 should be 0 if lmrt=True. Resetting lat0 to 0."
......@@ -348,6 +350,7 @@ class Domain:
# Initialise grid #
###################
def init_grid(ngrid_lonlat, grid_spacing, ezone_ngrid):
"""Help routine to initialise domain grid."""
# (a) Get projected coords of grid center
center_xy = proj.lonlat2xy(
lon=center_lonlat[0], lat=center_lonlat[1]
......@@ -397,7 +400,16 @@ class Domain:
@classmethod
def construct_from_dict(cls, config):
"""Construct domain from info in config dict."""
"""Construct domain from info in the config dict.
Args:
config (netatmoqc.config.ConfigDict): Configs dictionary.
Returns:
netatmoqc.domains.Domain: New class instance constructed from
info in the config dict.
"""
return cls(
name=config.name,
ngrid_lonlat=(config.nlon, config.nlat),
......@@ -412,11 +424,10 @@ class Domain:
)
def _auto_choose_projname(self, lat0, y_range):
"""Define domain projection.
"""Define domain projection."""
# Do this in a way close to what is explained at
# <https://hirlam.org/trac/wiki/HarmonieSystemDocumentation/ModelDomain>
In a way close to what is explained at
<https://hirlam.org/trac/wiki/HarmonieSystemDocumentation/ModelDomain>
"""
latrange = 180 * y_range / _EQUATOR_PERIM
if self.lmrt or latrange > 35 or np.isclose(latrange, 0):
# <https://proj.org/operations/projections/merc.html>
......@@ -465,7 +476,24 @@ class Domain:
return np.prod(self._nsplit_lonlat)
def split(self, nsplit_lon=None, nsplit_lat=None):
"""Split a domain "nsplit_lon(lat)" times along the lon(lat) axis."""
"""Split a domain "nsplit_lon(lat)" times along the lon(lat) axis.
Args:
nsplit_lon (int): Number of divisions along the longitude axis.
(Default value = None).
nsplit_lat (int): Number of divisions along the latitude axis.
(Default value = None).
Returns:
list: List of subdomains (Domain objects) obtained as a result of
the split.
Raises:
TypeError: If nsplit_lon, nsplit_lon are not integers.
ValueError: If nsplit_lon and nsplit_lat do not divide
nlon and nlat, respectively.
"""
if nsplit_lon is None:
nsplit_lon = self._nsplit_lonlat[0]
if nsplit_lat is None:
......@@ -517,7 +545,15 @@ class Domain:
return splits
def trim_obs(self, df):
"""Remove from dataframe "df" those obs that lie outside the domain."""
"""Remove from dataframe "df" those obs that lie outside the domain.
Args:
df (pandas.Dataframe): Dataframe to be trimmed.
Returns:
pandas.Dataframe: Trimmed dataframe.
"""
trimmed_df = df[self.contains_lonlat(df.lon, df.lat)].copy()
trimmed_df = trimmed_df.reset_index(drop=True)
return trimmed_df
......@@ -570,14 +606,25 @@ class Domain:
)
def get_fig(self, **kwargs):
"""Get domain figure."""
"""Get domain figure.
Args:
**kwargs: Passed to get_domain_fig.
Returns:
go.Figure: Domain figure.
"""
return get_domain_fig(self, **kwargs)
def show(self, config=None, **kwargs):
"""Show domain figure.
The "config" arg is plotly's fig.show config, not our parsed config
file.
Args:
config (dict): Plotly's fig.show config, not our parsed config
file.
**kwargs: Passed to self.get_fig.
"""
default_config = DEF_FIGSHOW_CONFIG.copy()
if config is not None:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment