Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • berntm/saqc
  • rdm-software/saqc
  • schueler/saqc
3 results
Show changes
Commits on Source (4)
...@@ -10,10 +10,12 @@ SPDX-License-Identifier: GPL-3.0-or-later ...@@ -10,10 +10,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
[List of commits](https://git.ufz.de/rdm-software/saqc/-/compare/v2.2.1...develop) [List of commits](https://git.ufz.de/rdm-software/saqc/-/compare/v2.2.1...develop)
### Added ### Added
- add option to not overwrite existing flags to `concatFlags` - add option to not overwrite existing flags to `concatFlags`
- add option to pass existing axis object to `plot`
### Changed ### Changed
- Remove all flag value restrictions from the default flagging scheme `FloatTranslator` - Remove all flag value restrictions from the default flagging scheme `FloatTranslator`
- Renamed `TranslationScheme.forward` to `TranslationScheme.toInternal` - Renamed `TranslationScheme.forward` to `TranslationScheme.toInternal`
- Renamed `TranslationScheme.backward` to `TranslationScheme.toExternal` - Renamed `TranslationScheme.backward` to `TranslationScheme.toExternal`
- Changed Default value of the parameter `limit` for `SaQC.interpolateIndex` and `SaQC.interpolateInvalid` to ``None`
### Removed ### Removed
### Fixed ### Fixed
......
...@@ -143,7 +143,7 @@ class InterpolationMixin: ...@@ -143,7 +143,7 @@ class InterpolationMixin:
field: str, field: str,
method: _SUPPORTED_METHODS, method: _SUPPORTED_METHODS,
order: int = 2, order: int = 2,
limit: int = 2, limit: int | None = None,
downgrade: bool = False, downgrade: bool = False,
flag: float = UNFLAGGED, flag: float = UNFLAGGED,
**kwargs, **kwargs,
...@@ -167,9 +167,8 @@ class InterpolationMixin: ...@@ -167,9 +167,8 @@ class InterpolationMixin:
If there your selected interpolation method can be performed at different 'orders' - here you pass the desired If there your selected interpolation method can be performed at different 'orders' - here you pass the desired
order. order.
limit : int, default 2 limit : int, optional
Maximum number of consecutive 'nan' values allowed for a gap to be interpolated. This really restricts the Maximum number of consecutive `nan` values to fill. Must be greater than 0.
interpolation to chunks, containing not more than `limit` successive nan entries.
flag : float or None, default UNFLAGGED flag : float or None, default UNFLAGGED
Flag that is set for interpolated values. If ``None``, no flags are set at all. Flag that is set for interpolated values. If ``None``, no flags are set at all.
...@@ -210,7 +209,7 @@ class InterpolationMixin: ...@@ -210,7 +209,7 @@ class InterpolationMixin:
freq: str, freq: str,
method: _SUPPORTED_METHODS, method: _SUPPORTED_METHODS,
order: int = 2, order: int = 2,
limit: int = 2, limit: int | None = None,
downgrade: bool = False, downgrade: bool = False,
**kwargs, **kwargs,
) -> "SaQC": ) -> "SaQC":
...@@ -237,9 +236,8 @@ class InterpolationMixin: ...@@ -237,9 +236,8 @@ class InterpolationMixin:
If there your selected interpolation method can be performed at different 'orders' - here you pass the desired If there your selected interpolation method can be performed at different 'orders' - here you pass the desired
order. order.
limit : int, default 2 limit : int, optional
Maximum number of consecutive 'nan' values allowed for a gap to be interpolated. This really restricts the Maximum number of missing index values (with respect to `freq`) to fill. Must be greater than 0.
interpolation to chunks, containing not more than `limit` successive nan entries.
downgrade : bool, default False downgrade : bool, default False
If `True` and the interpolation can not be performed at current order, retry with a lower order. If `True` and the interpolation can not be performed at current order, retry with a lower order.
......
...@@ -234,6 +234,7 @@ class ToolsMixin: ...@@ -234,6 +234,7 @@ class ToolsMixin:
xscope: Optional[slice] = None, xscope: Optional[slice] = None,
phaseplot: Optional[str] = None, phaseplot: Optional[str] = None,
store_kwargs: Optional[dict] = None, store_kwargs: Optional[dict] = None,
ax: mpl.axes.Axes | None = None,
ax_kwargs: Optional[dict] = None, ax_kwargs: Optional[dict] = None,
dfilter: float = FILTER_NONE, dfilter: float = FILTER_NONE,
**kwargs, **kwargs,
...@@ -297,7 +298,6 @@ class ToolsMixin: ...@@ -297,7 +298,6 @@ class ToolsMixin:
""" """
data, flags = self._data.copy(), self._flags.copy() data, flags = self._data.copy(), self._flags.copy()
interactive = path is None
level = kwargs.get("flag", UNFLAGGED) level = kwargs.get("flag", UNFLAGGED)
if dfilter < np.inf: if dfilter < np.inf:
...@@ -309,9 +309,8 @@ class ToolsMixin: ...@@ -309,9 +309,8 @@ class ToolsMixin:
if ax_kwargs is None: if ax_kwargs is None:
ax_kwargs = {} ax_kwargs = {}
if interactive: if not path:
mpl.use(_MPL_DEFAULT_BACKEND) mpl.use(_MPL_DEFAULT_BACKEND)
else: else:
mpl.use("Agg") mpl.use("Agg")
...@@ -324,13 +323,14 @@ class ToolsMixin: ...@@ -324,13 +323,14 @@ class ToolsMixin:
history=history, history=history,
xscope=xscope, xscope=xscope,
phaseplot=phaseplot, phaseplot=phaseplot,
ax=ax,
ax_kwargs=ax_kwargs, ax_kwargs=ax_kwargs,
) )
if interactive: if ax is None:
plt.show() plt.show()
else: if path:
if store_kwargs.pop("pickle", False): if store_kwargs.pop("pickle", False):
with open(path, "wb") as f: with open(path, "wb") as f:
pickle.dump(fig, f) pickle.dump(fig, f)
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import annotations
import itertools import itertools
from typing import Optional, Union from typing import Optional, Union
...@@ -58,11 +60,12 @@ def makeFig( ...@@ -58,11 +60,12 @@ def makeFig(
field: str, field: str,
flags: Flags, flags: Flags,
level: float, level: float,
max_gap: Optional[str] = None, max_gap: str | None = None,
history: Union[Optional[Literal["valid", "complete"]], list] = "valid", history: Literal["valid", "complete"] | None | list[str] = "valid",
xscope: Optional[slice] = None, xscope: slice | None = None,
phaseplot: Optional[str] = None, phaseplot: str | None = None,
ax_kwargs: Optional[dict] = None, ax: mpl.axes.Axes | None = None,
ax_kwargs: dict | None = None,
): ):
""" """
Returns a figure object, containing data graph with flag marks for field. Returns a figure object, containing data graph with flag marks for field.
...@@ -152,9 +155,10 @@ def makeFig( ...@@ -152,9 +155,10 @@ def makeFig(
d = _insertBlockingNaNs(d, max_gap) d = _insertBlockingNaNs(d, max_gap)
# figure composition # figure composition
fig = mpl.pyplot.figure(constrained_layout=True, **FIG_KWARGS) if ax is None:
grid = fig.add_gridspec() fig = mpl.pyplot.figure(constrained_layout=True, **FIG_KWARGS)
ax = fig.add_subplot(grid[0]) grid = fig.add_gridspec()
ax = fig.add_subplot(grid[0])
_plotVarWithFlags( _plotVarWithFlags(
ax, ax,
...@@ -172,7 +176,7 @@ def makeFig( ...@@ -172,7 +176,7 @@ def makeFig(
) )
plt.rcParams["font.size"] = default plt.rcParams["font.size"] = default
return fig return ax.figure
def _plotVarWithFlags( def _plotVarWithFlags(
......
...@@ -301,7 +301,7 @@ def interpolateNANs( ...@@ -301,7 +301,7 @@ def interpolateNANs(
:return: :return:
""" """
inter_limit = int(inter_limit) inter_limit = int(inter_limit or len(data) + 1)
data = pd.Series(data, copy=True) data = pd.Series(data, copy=True)
gap_mask = data.isna().rolling(inter_limit, min_periods=0).sum() != inter_limit gap_mask = data.isna().rolling(inter_limit, min_periods=0).sum() != inter_limit
......
...@@ -124,7 +124,7 @@ def test_gridInterpolation(data, method, fill_history): ...@@ -124,7 +124,7 @@ def test_gridInterpolation(data, method, fill_history):
res = qc.interpolate( res = qc.interpolate(
field, field,
freq, freq,
order=10, order=9,
method=method, method=method,
downcast_interpolation=True, downcast_interpolation=True,
) )
......