Skip to content

Commit

Permalink
Revert "Improve docstrings"
Browse files Browse the repository at this point in the history
This reverts commit 290c3a3.
  • Loading branch information
dnerini committed Mar 25, 2019
1 parent 290c3a3 commit ed0e8b3
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 400 deletions.
36 changes: 2 additions & 34 deletions pysteps/cascade/__init__.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,4 @@
"""
.. _pysteps.cascade:
Scale-based decomposition of precipitation fields (:mod:`pysteps.cascade`)
**************************************************************************
Methods for constructing bandpass filters and decomposing 2d precipitation
fields into different spatial scales.
pysteps.cascade.interface
-------------------------
.. automodule:: pysteps.cascade.interface
:members:
pysteps.cascade.bandpass_filters
--------------------------------
.. currentmodule:: pysteps.cascade.bandpass_filters
.. autosummary::
filter_uniform
filter_gaussian
.. automodule:: pysteps.cascade.bandpass_filters
:members:
pysteps.cascade.decomposition
-----------------------------
.. automodule:: pysteps.cascade.decomposition
:members:
"""
"""Methods for constructing bandpass filters and decomposing 2d precipitation
fields into different spatial scales."""

from .interface import get_method
29 changes: 4 additions & 25 deletions pysteps/extrapolation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
"""
.. _pysteps.extrapolation:
Advection-based extrapolation (:mod:`pysteps.extrapolation`)
************************************************************
Methods for advection-based extrapolation of precipitation fields. Currently
the module contains an implementation of the semi-Lagrangian method described
in :cite:`GZ2002` and the eulerian persistence.
pysteps\.extrapolation\.interface
---------------------------------
.. automodule:: pysteps.extrapolation.interface
:members:
pysteps\.extrapolation\.semilagrangian
--------------------------------------
.. automodule:: pysteps.extrapolation.semilagrangian
:members:
"""
"""Methods for advection-based extrapolation of precipitation fields.
Currently the module contains an implementation of the
semi-Lagrangian method described in :cite:`GZ2002` and the
eulerian persistence."""

from pysteps.extrapolation.interface import get_method


66 changes: 2 additions & 64 deletions pysteps/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,67 +1,5 @@
"""
.. _pysteps.io:
Input/output routines (:mod:`pysteps.io`)
*****************************************
Methods for browsing data archives, reading 2d precipitation fields and writing
forecasts into files.
pysteps\.io\.interface
----------------------
.. automodule:: pysteps.io.interface
:members:
pysteps\.io\.archive
--------------------
.. automodule:: pysteps.io.archive
:members:
pysteps\.io\.importers
----------------------
.. currentmodule:: pysteps.io.importers
.. autosummary::
import_bom_rf3
import_fmi_pgm
import_knmi_hdf5
import_mch_gif
import_mch_hdf5
import_mch_metranet
import_odim_hdf5
.. automodule:: pysteps.io.importers
:members:
pysteps\.io\.readers
--------------------
.. automodule:: pysteps.io.readers
:members:
pysteps\.io\.exporters
----------------------
.. currentmodule:: pysteps.io.exporters
.. autosummary::
initialize_forecast_exporter_kineros
initialize_forecast_exporter_netcdf
export_forecast_dataset
close_forecast_file
.. automodule:: pysteps.io.exporters
:members:
pysteps\.io\.nowcast\_importers
-------------------------------
.. automodule:: pysteps.io.nowcast_importers
:members:
"""
"""Methods for browsing data archives, reading 2d precipitation fields and writing
forecasts into files."""

from .interface import get_method
from .archive import *
Expand Down
2 changes: 0 additions & 2 deletions pysteps/io/importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@
except ImportError:
h5py_imported = False
try:
import sys
sys.path.append('/store/mch/msrad/python/library/radar/io/') # path to metranet library
import metranet
metranet_imported = True
except ImportError:
Expand Down
138 changes: 0 additions & 138 deletions pysteps/io/nowcast_importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,141 +194,3 @@ def _convert_grid_mapping_to_proj4(grid_mapping):
return proj_str
else:
return None

def import_netcdf_cosmo1(filename, timebounds=None):
"""Read a COSMO-1 forecast from a NetCDF file conforming to the
CF 1.7 specification."""
if not netcdf4_imported:
raise Exception("netCDF4 not imported")

ds = netCDF4.Dataset(filename, 'r')

var_names = list(ds.variables.keys())

metadata = {}

time_var = ds.variables['time']
if timebounds is None:
timebounds = np.ones(len(time_var[:]), dtype=bool)
leadtimes = np.array(time_var[timebounds])/60. # minutes leadtime
timestamps = np.array([netCDF4.num2date(time,time_var.units) for time in time_var[timebounds]])
metadata["leadtimes"] = leadtimes
metadata["timestamps"] = timestamps
f = np.vectorize(lambda x: x.replace(microsecond=0))
metadata["timestamps"] = f(metadata["timestamps"])

no_data = ds.variables[var_names[-1]]._FillValue
R = ds.variables[var_names[-1]][timebounds, :, :]
R = R[...].squeeze().astype(float)
R=R[:,::-1,:] # flip upside-down
R[R==no_data] = np.nan

# TODO: Read the metadata to the dictionary.
time_step = (timestamps[1] - timestamps[0]).total_seconds()/60
metadata["accutime"] = time_step
metadata["unit"] = "mm"
metadata["transform"] = None
metadata["zerovalue"] = np.nanmin(R)
if np.any(np.isfinite(R)):
metadata["threshold"] = np.nanmin(R[R > np.nanmin(R)])
else:
metadata["threshold"] = np.nan

# LV03 Swiss projection definition in Proj4
projdef = ""
projdef += "+proj=somerc "
projdef += " +lon_0=7.43958333333333"
projdef += " +lat_0=46.9524055555556"
projdef += " +k_0=1"
projdef += " +x_0=600000"
projdef += " +y_0=200000"
projdef += " +ellps=bessel"
projdef += " +towgs84=674.374,15.056,405.346,0,0,0,0"
projdef += " +units=m"
projdef += " +no_defs"
metadata["projection"] = projdef

metadata["x1"] = 255000.
metadata["y1"] = -160000.
metadata["x2"] = 965000.
metadata["y2"] = 480000.

metadata["xpixelsize"] = 1000.
metadata["ypixelsize"] = 1000.

metadata["yorigin"] = "upper"

ds.close()

return R,metadata

def import_netcdf_cosmoe(filename):
"""Read a COSMO-E ensemble forecast from a NetCDF file conforming to the
CF 1.7 specification."""
if not netcdf4_imported:
raise Exception("netCDF4 not imported")

ds = netCDF4.Dataset(filename, 'r')

var_names = list(ds.variables.keys())

R = ds.variables[var_names[-1]]
no_data = R._FillValue
R = R[...].squeeze().astype(float)
R=R[:,:,::-1,:] # flip upside-down
R[R==no_data] = np.nan

metadata = {}

time_var = ds.variables['time']
leadtimes = np.array(time_var[:])/60. # minutes leadtime
metadata["leadtimes"] = np.array(leadtimes)
timestamps = [netCDF4.num2date(time,time_var.units) for time in time_var[:]]
metadata["timestamps"] = np.array(timestamps)

# remove milliseconds
f = np.vectorize(lambda x: x.replace(microsecond=0))
metadata["timestamps"] = f(metadata["timestamps"])

# swpax axes: [time, eps, y, x] -> [eps, time, y, x]
R = np.swapaxes(R, 0, 1)

# TODO: Read the metadata to the dictionary.
time_step = (timestamps[1] - timestamps[0]).total_seconds()/60
metadata["accutime"] = time_step
metadata["unit"] = "mm"
metadata["transform"] = None
metadata["zerovalue"] = np.nanmin(R)
if np.any(np.isfinite(R)):
metadata["threshold"] = np.nanmin(R[R > np.nanmin(R)])
else:
metadata["threshold"] = np.nan
metadata["eps"] = R.shape[0]

# LV03 Swiss projection definition in Proj4
projdef = ""
projdef += "+proj=somerc "
projdef += " +lon_0=7.43958333333333"
projdef += " +lat_0=46.9524055555556"
projdef += " +k_0=1"
projdef += " +x_0=600000"
projdef += " +y_0=200000"
projdef += " +ellps=bessel"
projdef += " +towgs84=674.374,15.056,405.346,0,0,0,0"
projdef += " +units=m"
projdef += " +no_defs"
metadata["projection"] = projdef

metadata["x1"] = 255000.
metadata["y1"] = -160000.
metadata["x2"] = 965000.
metadata["y2"] = 480000.

metadata["xpixelsize"] = 1000.
metadata["ypixelsize"] = 1000.

metadata["yorigin"] = "upper"

ds.close()

return R,metadata
2 changes: 1 addition & 1 deletion pysteps/verification/detcatscores.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def det_cat_fct(pred, obs, thr, scores="", axis=None):
See also
--------
pysteps.verification.detcontscores.det_cont_fct
pysteps.verification.detcontscores
"""
Expand Down
15 changes: 6 additions & 9 deletions pysteps/verification/detcontscores.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ def det_cont_fct(pred, obs, scores="", axis=None, conditioning=None):
| scatter* | half the distance between the 16% and 84% percentiles |
| | of the weighted cumulative error distribution, |
| | where error = dB(pred/obs), |
| | as in Germann et al. (2006) |
| | as in `Germann et al. (2006)`_ |
+------------+--------------------------------------------------------+
.. _`Germann et al. (2006)`:https://doi.org/10.1256/qj.05.190
axis : {int, tuple of int, None}, optional
Axis or axes along which a score is integrated. The default, axis=None,
will integrate all of the elements of the input arrays.\n
Expand All @@ -88,19 +90,14 @@ def det_cont_fct(pred, obs, scores="", axis=None, conditioning=None):
Note
----
Score names denoted by * can only be computed offline.\n
Multiplicative scores can be computed by passing log-tranformed values.
Score names denoted by * can only be computed offline.
References
----------
Multiplicative scores can be computed by passing log-tranformed values.
Germann, U. , Galli, G. , Boscacci, M. and Bolliger, M. (2006), Radar
precipitation measurement in a mountainous region. Q.J.R. Meteorol. Soc.,
132: 1669-1692. doi:10.1256/qj.05.190
See also
--------
pysteps.verification.detcatscores.det_cat_fct
pysteps.verification.detcatscores
"""

Expand Down
14 changes: 5 additions & 9 deletions pysteps/verification/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_method(name, type="deterministic"):
| scatter* | half the distance between the 16% and 84% percentiles |
| | of the weighted cumulative error distribution, |
| | where error = dB(pred/obs), |
| | as in Germann et al. (2006) |
| | as in `Germann et al. (2006)`_ |
+------------+--------------------------------------------------------+
| binary_mse| binary MSE |
+------------+--------------------------------------------------------+
Expand Down Expand Up @@ -105,15 +105,11 @@ def get_method(name, type="deterministic"):
| ROC | ROC curve |
+------------+--------------------------------------------------------+
type : {'deterministic', 'ensemble', 'probabilistic'}, optional
Type of the verification method.
type : str
Type of the method. The available options are 'deterministic', 'ensemble'
and 'probabilistic'.
References
----------
Germann, U. , Galli, G. , Boscacci, M. and Bolliger, M. (2006), Radar
precipitation measurement in a mountainous region. Q.J.R. Meteorol. Soc.,
132: 1669-1692. doi:10.1256/qj.05.190
.. _`Germann et al. (2006)`:https://doi.org/10.1256/qj.05.190
"""

Expand Down

0 comments on commit ed0e8b3

Please sign in to comment.