Skip to content
Snippets Groups Projects
Commit 24e44700 authored by Sebastian Müller's avatar Sebastian Müller 🐈
Browse files

remove compress convenience routines again to keep the API clean

parent 73c460bb
No related branches found
No related tags found
1 merge request!258Grid mask support
Pipeline #186357 passed with stages
in 5 minutes and 7 seconds
......@@ -80,8 +80,6 @@ Utilities for data and metadata handling.
Info
UNITS
pull_compressed
push_compressed
Interfaces
==========
......@@ -182,7 +180,6 @@ from .sdk import (
TimeComponent,
TimeDelayAdapter,
)
from .tools import pull_compressed, push_compressed
try:
from ._version import __version__
......@@ -229,7 +226,6 @@ __all__ += [
]
__all__ += ["CellType", "Location"]
__all__ += ["UNITS", "Info"]
__all__ += ["pull_compressed", "push_compressed"]
__all__ += [
"FinamCircularCouplingError",
"FinamConnectError",
......
......@@ -57,22 +57,12 @@ Connect helper
FromInput
FromOutput
FromValue
IO helper
=========
.. autosummary::
:toctree: generated
pull_compressed
push_compressed
"""
from .connect_helper import ConnectHelper, FromInput, FromOutput, FromValue
from .cwd_helper import execute_in_cwd, set_directory
from .date_helper import is_timedelta
from .enum_helper import get_enum_value
from .inspect_helper import inspect
from .io_helper import pull_compressed, push_compressed
from .log_helper import (
ErrorLogger,
LogCStdOutStdErr,
......@@ -95,4 +85,3 @@ __all__ += [
"LogCStdOutStdErr",
]
__all__ += ["ConnectHelper", "FromInput", "FromOutput", "FromValue"]
__all__ += ["pull_compressed", "push_compressed"]
"""Input and Output helpers."""
import numpy as np
from ..interfaces import IInput, IOutput
def pull_compressed(io, time):
"""
Pull compressed data from an Input object.
Parameters
----------
io : IInput
The Input object to pull data from.
time : :class:`datetime <datetime.datetime>`
Simulation time to get the data for.
Returns
-------
:class:`pint.Quantity`
Flattened and unmasked data values for the given simulation time.
Raises
------
ValueError
If io is not an IInput instance.
"""
if not isinstance(io, IInput):
msg = "pull_compressed: Given io-object is not an IInput instance."
raise ValueError(msg)
return io.info.grid.to_compressed(io.pull_data(time))
def push_compressed(io, time, data, nodata=np.nan):
"""
Push compressed data to an Output object.
Parameters
----------
io : IOutput
The Output object to push data to.
time : :class:`datetime <datetime.datetime>`
Simulation time of the data set.
data : array_like
Flattened and unmasked data values to push.
nodata : numeric, optional
Fill value for masked values. Should have a compatible type.
By default np.nan
Raises
------
ValueError
If io is not an IOutput instance.
"""
if not isinstance(io, IOutput):
msg = "push_compressed: Given io-object is not an IOutput instance."
raise ValueError(msg)
io.push_data(io.info.grid.from_compressed(data, nodata), time)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment