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