Utilities and Constants#
Constants#
Methods timeseries#
- src.gwrefpy.methods.timeseries.analyze_offsets(ref: Series | Well, obs: Series | Well, offsets: Sequence[DateOffset | Timedelta | str]) Series[source]#
Tests the grouping of time series data by different offsets. This can be helpful when choosing an offset.
- src.gwrefpy.methods.timeseries.groupby_time_equivalents(obs_timeseries: Series, ref_timeseries: Series, offset: DateOffset | Timedelta | str, aggregation: Literal['mean', 'median', 'min', 'max'] = 'mean') tuple[Series, Series, int][source]#
Groups the reference and observation timeseries by their time equivalents.
- Parameters:
obs_timeseries (pd.Series) – The observed timeseries data.
ref_timeseries (pd.Series) – The reference timeseries data.
offset (pd.DateOffset | pd.Timedelta | str) – Maximum date offset to allow to group pairs of data points.
aggregation (Literal["mean", "median", "min", "max"], optional) – The aggregation method to use when grouping data points. Default is “mean”.
- Returns:
pd.Series – Reference time series data grouped by their time equivalents.
pd.Series – Observed time series data grouped by their time equivalents.
int – Number of grouped pairs of data points.
Utilities#
- src.gwrefpy.utils.datetime_to_float(date_time: Timestamp) float[source]#
Convert a datetime object to a float representation.
- Parameters:
date_time (datetime) – The datetime object to convert.
- Returns:
The float representation of the datetime.
- Return type:
float
- src.gwrefpy.utils.enable_file_logging(name: str = 'gwrefpy.log', filemode: str = 'w', loglevel: str = 'DEBUG') None[source]#
Enable logging to a file named ‘gwrefpy.log’ in the current directory.
- Parameters:
name (str) – The name of the log file. Default is ‘gwrefpy.log’.
filemode (str) – The mode to open the log file. Default is ‘w’ (write mode). Other common mode is ‘a’ (append mode).
loglevel (str) – The logging level for the file handler. Default is ‘DEBUG’. Options are ‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’, ‘CRITICAL’.
- src.gwrefpy.utils.float_to_datetime(float_time: float) Timestamp[source]#
Convert a float representation of time back to a datetime object.
- Parameters:
float_time (float) – The float representation of time.
- Returns:
The corresponding datetime object.
- Return type:
pd.Timestamp
- src.gwrefpy.utils.set_log_level(level: str, all_handlers: bool = False) None[source]#
Set the logging level for the gwrefpy logger.
- Parameters:
level (str) – The logging level to set. Options are ‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’, ‘CRITICAL’.
all_handlers (bool) – If True, set the log level for all handlers. Default is False for which only the StreamHandler is set.