11"""Plots time series."""
22
3+ from __future__ import annotations
4+ import typing
5+
36import numpy as np
47import matplotlib .pyplot as plt
58import pandas as pd
811from .error import InvalidTimeFractionError
912from .stagyydata import StagyyData
1013
14+ if typing .TYPE_CHECKING :
15+ from typing import Optional
16+ from pandas import DataFrame
17+
1118
12- def _collect_marks (sdat ):
19+ def _collect_marks (sdat : StagyyData ):
1320 """Concatenate mark* config variable."""
1421 times = list (conf .time .marktimes )
1522 times .extend (step .timeinfo ['t' ]
@@ -19,13 +26,13 @@ def _collect_marks(sdat):
1926 return times
2027
2128
22- def plot_time_series (sdat , names ):
29+ def plot_time_series (sdat : StagyyData , names : str ):
2330 """Plot requested time series.
2431
2532 Args:
26- sdat ( :class:`~stagpy.stagyydata.StagyyData`): a StagyyData instance.
27- names (str) : time series names separated by ``-`` (figures), ``.``
28- (subplots) and ``,`` (same subplot).
33+ sdat: a :class:`~stagpy.stagyydata.StagyyData` instance.
34+ names: time series names separated by ``-`` (figures), ``.`` (subplots)
35+ and ``,`` (same subplot).
2936
3037 Other Parameters:
3138 conf.time.tstart: the starting time.
@@ -81,19 +88,19 @@ def plot_time_series(sdat, names):
8188 _helpers .saveplot (fig , '_' .join (fname ))
8289
8390
84- def compstat (sdat , * names , tstart = None , tend = None ):
91+ def compstat (sdat : StagyyData , * names : str , tstart : Optional [float ] = None ,
92+ tend : Optional [float ] = None ) -> DataFrame :
8593 """Compute statistics from series output by StagYY.
8694
8795 Args:
88- sdat ( :class:`~stagpy.stagyydata.StagyyData`): a StagyyData instance.
89- names (str) : variables whose statistics should be computed.
90- tstart (float) : starting time. Set to None to start at the beginning of
96+ sdat: a :class:`~stagpy.stagyydata.StagyyData` instance.
97+ names: variables whose statistics should be computed.
98+ tstart: starting time. Set to None to start at the beginning of
9199 available data.
92- tend (float): ending time. Set to None to stop at the end of available
93- data.
100+ tend: ending time. Set to None to stop at the end of available data.
94101 Returns:
95- :class:`pandas.DataFrame`: computed statistics with 'mean' and 'rms' as
96- index and variable names as columns.
102+ a :class:`pandas.DataFrame` with statistics. 'mean' and 'rms' as index,
103+ variable names as columns.
97104 """
98105 stats = pd .DataFrame (columns = names , index = ['mean' , 'rms' ])
99106 for name in names :
0 commit comments