Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
finam
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Code
Merge requests
4
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FINAM
finam
Commits
afbbe600
Commit
afbbe600
authored
1 year ago
by
Martin Lange
Browse files
Options
Downloads
Patches
Plain Diff
add book section on masked data
parent
de3f0f08
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!262
Book section on masked data
Pipeline
#189893
passed with stages
in 6 minutes and 47 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/source/finam-book/development/data_metadata.rst
+30
-1
30 additions, 1 deletion
docs/source/finam-book/development/data_metadata.rst
with
30 additions
and
1 deletion
docs/source/finam-book/development/data_metadata.rst
+
30
−
1
View file @
afbbe600
...
...
@@ -7,7 +7,7 @@ This chapter explains data and metadata in FINAM.
Data arrays
-----------
Internally, all data is passed as :class:`numpy.ndarray`, wrapped in :class:`pint.Quantity`.
Internally, all data is passed as :class:`numpy.ndarray`
(or :class:`numpy.ma.MaskedArray`, see `Masked arrays`_)
, wrapped in :class:`pint.Quantity`.
In addition, a time axis with a single entry is added at index 0.
Data can be pushed to outputs as any type that can be wrapped in :class:`numpy.ndarray`.
...
...
@@ -36,6 +36,35 @@ Several tool functions are provided in :mod:`.data` to convert to and from the i
* :func:`has_time_axis(xdata, grid) <.data.has_time_axis>`
Checks if the data has a time axis
Masked arrays
^^^^^^^^^^^^^
FINAM uses :class:`numpy.ma.MaskedArray` inside :class:`pint.Quantity` to represent masked data.
Masked data does not require any special treatment and can be used like usual numpy arrays.
Convenience functions for masked arrays are:
* :func:`is_masked_array <.data.is_masked_array>` to check if the given data is a masked array
* :func:`has_masked_values <.data.has_masked_values>` to check if the given data is a masked array and has some values masked
* :func:`filled <.data.filled>` to create a copy of the data with masked entries filled with a given value, if it is a masked array
.. warning::
Due to a :mod:`numpy` bug, quantities should not be created from masked data using multiplication syntax (i.e. ``magnitude * units``).
Instead, use method ``Quantity`` of :data:`.UNITS`.
.. testcode:: create-units-masked
:hide:
import finam
magnitude = 1.0
.. testcode:: create-units-masked
data = finam.UNITS.Quantity(magnitude, "m")
(See issues `pint#633 <https://github.com/hgrecco/pint/issues/633>`_, `numpy#15200 <https://github.com/numpy/numpy/issues/15200>`_)
Metadata
--------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment