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
Merge requests
!262
Book section on masked data
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Book section on masked data
masks-in-book
into
main
Overview
0
Commits
1
Pipelines
2
Changes
1
Merged
Martin Lange
requested to merge
masks-in-book
into
main
1 year ago
Overview
0
Commits
1
Pipelines
2
Changes
1
Expand
👍
0
👎
0
Merge request reports
Compare
main
version 2
35c17d64
1 year ago
version 1
35c17d64
1 year ago
main (base)
and
latest version
latest version
afbbe600
1 commit,
1 year ago
version 2
35c17d64
1 commit,
1 year ago
version 1
35c17d64
1 commit,
1 year ago
1 file
+
30
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
docs/source/finam-book/development/data_metadata.rst
+
30
−
1
Options
@@ -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
--------
Loading