Utilities and Constants#
Constants#
Methods timeseries#
- src.gwrefpy.methods.timeseries.analyze_offsets(obs: Series | Well, ref: Series | Well, offsets: Sequence[DateOffset | Timedelta | str], method: Literal['anchor', 'consecutive'] = 'anchor') Series[source]#
Tests the grouping of time series data by different offsets. This can be helpful when choosing an offset.
- Parameters:
- Returns:
The number of grouped pairs of data points for each offset.
- Return type:
pd.Series
- src.gwrefpy.methods.timeseries.groupby_time_equivalents(obs_timeseries: Series, ref_timeseries: Series, offset: DateOffset | Timedelta | str, aggregation: Literal['mean', 'median', 'min', 'max'] = 'mean', method: Literal['anchor', 'consecutive'] = 'anchor') 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 for matching reference points to each observation point.
aggregation (Literal["mean", "median", "min", "max"], optional) – The aggregation method to use when grouping data points within time equivalents. Default is “mean”.
method (Literal["anchor", "consecutive"], optional) –
The grouping method to use.
"anchor"(default): each observation time point is the center of a±offsetwindow; all reference points inside that window are aggregated into one output pair per observation time."consecutive": all timestamps from both series are merged and sorted, then split into groups wherever the gap between consecutive timestamps exceedsoffset. Both reference and observation values within each group are aggregated together.
- 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.