obsarray 0.2.4__tar.gz → 0.2.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {obsarray-0.2.4 → obsarray-0.2.6}/.gitignore +2 -2
- {obsarray-0.2.4/obsarray.egg-info → obsarray-0.2.6}/PKG-INFO +5 -4
- obsarray-0.2.6/docs/conf.py +181 -0
- obsarray-0.2.6/docs/index.rst +66 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/__init__.py +1 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/_version.py +3 -3
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/err_corr.py +109 -32
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/flag_accessor.py +19 -336
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/templater/dataset_util.py +12 -8
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/templater/dswriter.py +2 -1
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/templater/template_util.py +1 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/test/test_err_corr_forms.py +60 -6
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/test/test_flag_accessor.py +68 -9
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/test/test_unc_accessor.py +41 -11
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/unc_accessor.py +35 -39
- {obsarray-0.2.4 → obsarray-0.2.6/obsarray.egg-info}/PKG-INFO +5 -4
- obsarray-0.2.6/obsarray.egg-info/requires.txt +12 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/setup.py +16 -5
- {obsarray-0.2.4 → obsarray-0.2.6}/versioneer.py +2 -2
- obsarray-0.2.4/docs/conf.py +0 -364
- obsarray-0.2.4/docs/index.rst +0 -37
- obsarray-0.2.4/obsarray.egg-info/requires.txt +0 -9
- {obsarray-0.2.4 → obsarray-0.2.6}/.pre-commit-config.yaml +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/LICENSE +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/MANIFEST.in +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/README.md +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/docs/Makefile +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/docs/make.bat +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/templater/__init__.py +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/templater/dsdoc.py +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/templater/dstemplater.py +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/templater/template_util_jon.py +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/templater/tests/__init__.py +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/templater/tests/test_dataset_util.py +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/templater/tests/test_dsdoc.py +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/templater/tests/test_dswriter.py +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/templater/tests/test_template_util.py +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/test/__init__.py +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray/utils.py +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray.egg-info/SOURCES.txt +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray.egg-info/dependency_links.txt +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/obsarray.egg-info/top_level.txt +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/.gitignore +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/QualityDocumentation.tex +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/base/CookiecutterMacros.tex +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/base/acronyms.tex +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/base/history.tex +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/base/metadata.tex +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/base/pythoninputstyle.tex +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/base/sil2.tex +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/base/sil3.tex +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/base/sources.bib +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/base/sources.tex +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/countpdfpages.sh +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/footnotehyper-sphinx.sty +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/obsarray_QF-59.docm +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/obsarray_requirements.docx +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/review_checklists/qf-16a.docx +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/review_checklists/qf-16b.docx +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/review_checklists/qf-16c.docx +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/review_checklists/qf-16d.docx +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/review_checklists/qf-16e.docx +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/review_checklists/qf-16f.docx +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/softwareRequirements.sty +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/sphinx.sty +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/sphinxcyrillic.sty +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/sphinxhighlight.sty +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/sphinxhowto.cls +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/sphinxmanual.cls +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/sphinxmessages.sty +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/sphinxmulticell.sty +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/quality_documentation/uml/copy your design png file into this folder.txt +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/setup.cfg +0 -0
- {obsarray-0.2.4 → obsarray-0.2.6}/tox.ini +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: obsarray
|
|
3
|
-
Version: 0.2.
|
|
4
|
-
Summary: Measurement
|
|
3
|
+
Version: 0.2.6
|
|
4
|
+
Summary: Measurement data handling in Python
|
|
5
5
|
Home-page: https://github.com/comet-toolkit/obsarray
|
|
6
6
|
Author: CoMet Toolkit Team
|
|
7
7
|
Author-email: team@comet-toolkit.org
|
|
@@ -9,9 +9,10 @@ License: GPLv3
|
|
|
9
9
|
Platform: UNKNOWN
|
|
10
10
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
11
|
Classifier: Programming Language :: Python
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
14
12
|
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
16
|
Provides-Extra: dev
|
|
16
17
|
License-File: LICENSE
|
|
17
18
|
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
#
|
|
3
|
+
# obsarray documentation build configuration file, created by
|
|
4
|
+
# cookiecutter
|
|
5
|
+
#
|
|
6
|
+
# This file is execfile()d with the current directory set to its
|
|
7
|
+
# containing dir.
|
|
8
|
+
#
|
|
9
|
+
# Note that not all possible configuration values are present in this
|
|
10
|
+
# autogenerated file.
|
|
11
|
+
#
|
|
12
|
+
# All configuration values have a default; values that are commented out
|
|
13
|
+
# serve to show the default.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# If extensions (or modules to document with autodoc) are in another
|
|
17
|
+
# directory, add these directories to sys.path here. If the directory is
|
|
18
|
+
# relative to the documentation root, use os.path.abspath to make it
|
|
19
|
+
# absolute, like shown here.
|
|
20
|
+
|
|
21
|
+
import sphinx_autosummary_accessors
|
|
22
|
+
import obsarray
|
|
23
|
+
|
|
24
|
+
project_title = "obsarray".replace("_", " ").title()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# -- General configuration ---------------------------------------------
|
|
28
|
+
|
|
29
|
+
# If your documentation needs a minimal Sphinx version, state it here.
|
|
30
|
+
#
|
|
31
|
+
# needs_sphinx = '1.0'
|
|
32
|
+
|
|
33
|
+
# Attempt to make links automatially
|
|
34
|
+
default_role = "code"
|
|
35
|
+
|
|
36
|
+
# Add any Sphinx extension module names here, as strings. They can be
|
|
37
|
+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
|
38
|
+
# CFAB added napolean to support google-style docstrings
|
|
39
|
+
extensions = [
|
|
40
|
+
"sphinx.ext.autodoc",
|
|
41
|
+
"sphinx.ext.autosummary",
|
|
42
|
+
"sphinx.ext.intersphinx",
|
|
43
|
+
"sphinx.ext.viewcode",
|
|
44
|
+
"sphinx.ext.napoleon",
|
|
45
|
+
"IPython.sphinxext.ipython_directive",
|
|
46
|
+
"IPython.sphinxext.ipython_console_highlighting",
|
|
47
|
+
"sphinx_design",
|
|
48
|
+
"sphinx_autosummary_accessors",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
# Add any paths that contain templates here, relative to this directory.
|
|
52
|
+
templates_path = ["_templates", sphinx_autosummary_accessors.templates_path]
|
|
53
|
+
|
|
54
|
+
# The suffix(es) of source filenames.
|
|
55
|
+
# You can specify multiple suffix as a list of string:
|
|
56
|
+
#
|
|
57
|
+
# source_suffix = ['.rst', '.md']
|
|
58
|
+
source_suffix = ".rst"
|
|
59
|
+
|
|
60
|
+
# The master toctree document.
|
|
61
|
+
master_doc = "index"
|
|
62
|
+
|
|
63
|
+
# General information about the project.
|
|
64
|
+
project = project_title
|
|
65
|
+
copyright = "CoMet Toolkit Team"
|
|
66
|
+
author = "CoMet Toolkit Team"
|
|
67
|
+
|
|
68
|
+
# The version info for the project you're documenting, acts as replacement
|
|
69
|
+
# for |version| and |release|, also used in various other places throughout
|
|
70
|
+
# the built documents.
|
|
71
|
+
#
|
|
72
|
+
# The short X.Y version.
|
|
73
|
+
version = obsarray.__version__
|
|
74
|
+
# The full version, including alpha/beta/rc tags.
|
|
75
|
+
release = obsarray.__version__
|
|
76
|
+
|
|
77
|
+
# The language for content autogenerated by Sphinx. Refer to documentation
|
|
78
|
+
# for a list of supported languages.
|
|
79
|
+
#
|
|
80
|
+
# This is also used if you do content translation via gettext catalogs.
|
|
81
|
+
# Usually you set "language" from the command line for these cases.
|
|
82
|
+
language = None
|
|
83
|
+
|
|
84
|
+
# List of patterns, relative to source directory, that match files and
|
|
85
|
+
# directories to ignore when looking for source files.
|
|
86
|
+
# This patterns also effect to html_static_path and html_extra_path
|
|
87
|
+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
|
88
|
+
|
|
89
|
+
# The name of the Pygments (syntax highlighting) style to use.
|
|
90
|
+
pygments_style = "sphinx"
|
|
91
|
+
|
|
92
|
+
rst_prolog = """
|
|
93
|
+
.. role:: python(code)
|
|
94
|
+
:language: python
|
|
95
|
+
:class: highlight
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
|
99
|
+
todo_include_todos = False
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
# -- Options for HTML output -------------------------------------------
|
|
103
|
+
|
|
104
|
+
# The theme to use for HTML and HTML Help pages. See the documentation for
|
|
105
|
+
# a list of builtin themes.
|
|
106
|
+
#
|
|
107
|
+
html_theme = "sphinx_book_theme"
|
|
108
|
+
|
|
109
|
+
# Theme options are theme-specific and customize the look and feel of a
|
|
110
|
+
# theme further. For a list of options available for each theme, see the
|
|
111
|
+
# documentation.
|
|
112
|
+
#
|
|
113
|
+
# html_theme_options = {}
|
|
114
|
+
|
|
115
|
+
html_logo = "figs/comet_logo.png"
|
|
116
|
+
|
|
117
|
+
# Add any paths that contain custom static files (such as style sheets) here,
|
|
118
|
+
# relative to this directory. They are copied after the builtin static files,
|
|
119
|
+
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
120
|
+
html_static_path = ["_static"]
|
|
121
|
+
|
|
122
|
+
# -- Options for HTMLHelp output ---------------------------------------
|
|
123
|
+
|
|
124
|
+
# Output file base name for HTML help builder.
|
|
125
|
+
htmlhelp_basename = "obsarraydoc"
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# -- Options for LaTeX output ------------------------------------------
|
|
129
|
+
|
|
130
|
+
latex_elements = {
|
|
131
|
+
# The paper size ('letterpaper' or 'a4paper').
|
|
132
|
+
#
|
|
133
|
+
# 'papersize': 'letterpaper',
|
|
134
|
+
# The font size ('10pt', '11pt' or '12pt').
|
|
135
|
+
#
|
|
136
|
+
# 'pointsize': '10pt',
|
|
137
|
+
# Additional stuff for the LaTeX preamble.
|
|
138
|
+
#
|
|
139
|
+
# 'preamble': '',
|
|
140
|
+
# Latex figure (float) alignment
|
|
141
|
+
#
|
|
142
|
+
# 'figure_align': 'htbp',
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
# Grouping the document tree into LaTeX files. List of tuples
|
|
146
|
+
# (source start file, target name, title, author, documentclass
|
|
147
|
+
# [howto, manual, or own class]).
|
|
148
|
+
latex_documents = [
|
|
149
|
+
(
|
|
150
|
+
master_doc,
|
|
151
|
+
"user_manual.tex",
|
|
152
|
+
"{} Documentation".format(project_title),
|
|
153
|
+
"CoMet Toolkit Team",
|
|
154
|
+
"manual",
|
|
155
|
+
),
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
# -- Options for manual page output ------------------------------------
|
|
160
|
+
|
|
161
|
+
# One entry per manual page. List of tuples
|
|
162
|
+
# (source start file, name, description, authors, manual section).
|
|
163
|
+
man_pages = [(master_doc, "obsarray", "obsarray Documentation", [author], 1)]
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
# -- Options for Texinfo output ----------------------------------------
|
|
167
|
+
|
|
168
|
+
# Grouping the document tree into Texinfo files. List of tuples
|
|
169
|
+
# (source start file, target name, title, author,
|
|
170
|
+
# dir menu entry, description, category)
|
|
171
|
+
texinfo_documents = [
|
|
172
|
+
(
|
|
173
|
+
master_doc,
|
|
174
|
+
"obsarray",
|
|
175
|
+
"obsarray Documentation",
|
|
176
|
+
author,
|
|
177
|
+
"obsarray",
|
|
178
|
+
"Extension to xarray for handling uncertainty quantified observation data",
|
|
179
|
+
"Miscellaneous",
|
|
180
|
+
),
|
|
181
|
+
]
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
obsarray: Measurement data handling in Python
|
|
2
|
+
=============================================
|
|
3
|
+
|
|
4
|
+
**obsarray** is an extension to `xarray <https://docs.xarray.dev/en/stable/>`_ to support defining, storing and interfacing with measurement data - in particular, measurement uncertainty information using standardised metadata. It is designed to work well with `netCDF <https://www.unidata.ucar.edu/software/netcdf/>`_ files and for the Earth Observation community.
|
|
5
|
+
|
|
6
|
+
**obsarray** is part of the `CoMet Toolkit <https://www.comet-toolkit.org>`_ (community metrology toolkit), and can combined with the `punpy <https://punpy.readthedocs.io/en/latest/>`_ (propagating uncertainties in python) module for very simple propagation of defined data uncertainties through arbitrary python functions.
|
|
7
|
+
|
|
8
|
+
.. grid:: 2
|
|
9
|
+
:gutter: 2
|
|
10
|
+
|
|
11
|
+
.. grid-item-card:: Quickstart Guide
|
|
12
|
+
:link: content/user/quickstart
|
|
13
|
+
:link-type: doc
|
|
14
|
+
|
|
15
|
+
New to *obsarray*? Check out the quickstart guide for an introduction.
|
|
16
|
+
|
|
17
|
+
.. grid-item-card:: User Guide
|
|
18
|
+
:link: content/user/user_guide
|
|
19
|
+
:link-type: doc
|
|
20
|
+
|
|
21
|
+
The user guide provides a documentation and examples how to use **obsarray** to handle measurement data.
|
|
22
|
+
|
|
23
|
+
.. grid-item-card:: API Reference
|
|
24
|
+
:link: content/user/api
|
|
25
|
+
:link-type: doc
|
|
26
|
+
|
|
27
|
+
The API Reference contains a description the **obsarray** API.
|
|
28
|
+
|
|
29
|
+
.. grid-item-card:: Developer Guide
|
|
30
|
+
:link: content/developer/developer_guide
|
|
31
|
+
:link-type: doc
|
|
32
|
+
|
|
33
|
+
Guide for contributing to **obsarray** (under development).
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
Acknowledgements
|
|
37
|
+
----------------
|
|
38
|
+
|
|
39
|
+
obsarray has been developed by `Sam Hunt <https://github.com/shunt16>`_.
|
|
40
|
+
|
|
41
|
+
The development has been funded by:
|
|
42
|
+
|
|
43
|
+
* The UK's Department for Business, Energy and Industrial Strategy's (BEIS) National Measurement System (NMS) programme
|
|
44
|
+
* The IDEAS-QA4EO project funded by the European Space Agency.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
Project status
|
|
48
|
+
--------------
|
|
49
|
+
|
|
50
|
+
obsarray is under active development. It is beta software.
|
|
51
|
+
|
|
52
|
+
.. toctree::
|
|
53
|
+
:maxdepth: 2
|
|
54
|
+
:hidden:
|
|
55
|
+
:caption: For users
|
|
56
|
+
|
|
57
|
+
Quickstart <content/user/quickstart>
|
|
58
|
+
User Guide <content/user/user_guide>
|
|
59
|
+
API Reference <content/user/api>
|
|
60
|
+
|
|
61
|
+
.. toctree::
|
|
62
|
+
:maxdepth: 2
|
|
63
|
+
:hidden:
|
|
64
|
+
:caption: For developers/contributors
|
|
65
|
+
|
|
66
|
+
Developer Guide <content/developer/developer_guide>
|
|
@@ -8,6 +8,7 @@ from obsarray import unc_accessor, flag_accessor
|
|
|
8
8
|
from obsarray.err_corr import err_corr_forms
|
|
9
9
|
from obsarray.templater.template_util import create_ds
|
|
10
10
|
from obsarray.templater.dstemplater import DSTemplater
|
|
11
|
+
from obsarray.templater.dswriter import DSWriter
|
|
11
12
|
|
|
12
13
|
__version__ = get_versions()["version"]
|
|
13
14
|
del get_versions
|
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "
|
|
11
|
+
"date": "2024-03-26T17:59:27+0000",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "v0.2.
|
|
14
|
+
"full-revisionid": "3f90a44048e43a24a7ec1115d7b727944416ba9f",
|
|
15
|
+
"version": "v0.2.6"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""err_corr_forms - module for the defintion of error-correlation parameterisation forms"""
|
|
2
2
|
|
|
3
3
|
import abc
|
|
4
|
-
from typing import Callable, Type, Union
|
|
4
|
+
from typing import Callable, Type, Union, List
|
|
5
5
|
import numpy as np
|
|
6
6
|
from comet_maths.linear_algebra.matrix_conversion import expand_errcorr_dims
|
|
7
7
|
|
|
@@ -69,23 +69,79 @@ class BaseErrCorrForm(abc.ABC):
|
|
|
69
69
|
"""Form name"""
|
|
70
70
|
pass
|
|
71
71
|
|
|
72
|
-
def expand_dim_matrix(
|
|
72
|
+
def expand_dim_matrix(
|
|
73
|
+
self, submatrix: np.ndarray, submatrix_dim: Union[str, List[str]], sli: tuple
|
|
74
|
+
):
|
|
73
75
|
return expand_errcorr_dims(
|
|
74
76
|
in_corr=submatrix,
|
|
75
|
-
in_dim=
|
|
77
|
+
in_dim=submatrix_dim,
|
|
76
78
|
out_dim=list(self._obj[self._unc_var_name][sli].dims),
|
|
77
|
-
dim_sizes=
|
|
78
|
-
dim: self._obj.dims[dim]
|
|
79
|
-
for dim in self._obj[self._unc_var_name][sli].dims
|
|
80
|
-
},
|
|
79
|
+
dim_sizes=self.get_sliced_dim_sizes_uncvar(sli),
|
|
81
80
|
)
|
|
82
81
|
|
|
83
|
-
def
|
|
84
|
-
|
|
82
|
+
def get_sliced_dim_sizes_uncvar(self, sli: tuple) -> dict:
|
|
83
|
+
"""
|
|
84
|
+
Return dictionary with sizes of sliced dimensions of unc variable, including all dimensions.
|
|
85
|
+
|
|
86
|
+
:param sli: slice (tuple with slice for each dimension)
|
|
87
|
+
:return: shape of included sliced dimensions
|
|
88
|
+
"""
|
|
89
|
+
uncvar_dims = self._obj[self._unc_var_name][sli].dims
|
|
90
|
+
uncvar_shape = self._obj[self._unc_var_name][sli].shape
|
|
91
|
+
return {
|
|
92
|
+
uncvar_dims[idim]: uncvar_shape[idim] for idim in range(len(uncvar_dims))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
def get_sliced_dim_sizes_errcorr(self, sli: tuple) -> dict:
|
|
96
|
+
"""
|
|
97
|
+
Return dictionary with sizes of sliced dimensions of unc variable, including only dimensions which are
|
|
98
|
+
included in the current error correlation form.
|
|
99
|
+
|
|
100
|
+
:param sli: slice (tuple with slice for each dimension)
|
|
101
|
+
:return: shape of included sliced dimensions
|
|
102
|
+
"""
|
|
103
|
+
uncvar_sizes = self.get_sliced_dim_sizes_uncvar(sli)
|
|
104
|
+
sliced_dims = self.get_sliced_dims_errcorr(sli)
|
|
105
|
+
|
|
106
|
+
return {dim: uncvar_sizes[dim] for dim in sliced_dims}
|
|
107
|
+
|
|
108
|
+
def get_sliced_dims_errcorr(self, sli: tuple) -> list:
|
|
109
|
+
"""
|
|
110
|
+
Return dimensions which are within the slice and included in the current error correlation form.
|
|
111
|
+
|
|
112
|
+
:param sli: slice (tuple with slice for each dimension)
|
|
113
|
+
:return: list with sliced dimensions
|
|
114
|
+
"""
|
|
115
|
+
all_dims = self._obj[self._unc_var_name].dims
|
|
116
|
+
return [
|
|
117
|
+
all_dims[idim]
|
|
118
|
+
for idim in range(len(all_dims))
|
|
119
|
+
if (isinstance(sli[idim], slice) and all_dims[idim] in self.dims)
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
def get_sliced_shape_errcorr(self, sli: tuple) -> tuple:
|
|
123
|
+
"""
|
|
124
|
+
return shape of sliced uncertainty variable, including only dimensions which are included in the current error correlation form.
|
|
125
|
+
|
|
126
|
+
:param sli: slice (tuple with slice for each dimension)
|
|
127
|
+
:return: shape of included sliced dimensions
|
|
128
|
+
"""
|
|
129
|
+
uncvar_sizes = self.get_sliced_dim_sizes_uncvar(sli)
|
|
130
|
+
sliced_dims = self.get_sliced_dims_errcorr(sli)
|
|
131
|
+
|
|
132
|
+
return tuple([uncvar_sizes[dim] for dim in sliced_dims])
|
|
133
|
+
|
|
134
|
+
def slice_full_cov(self, full_matrix: np.ndarray, sli: tuple) -> np.ndarray:
|
|
135
|
+
return self.slice_flattened_matrix(
|
|
136
|
+
full_matrix, self._obj[self._unc_var_name].shape, sli
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
def slice_flattened_matrix(self, flattened_matrix, variable_shape, sli):
|
|
140
|
+
mask_array = np.ones(variable_shape, dtype=bool)
|
|
85
141
|
mask_array[sli] = False
|
|
86
142
|
|
|
87
143
|
return np.delete(
|
|
88
|
-
np.delete(
|
|
144
|
+
np.delete(flattened_matrix, mask_array.ravel(), 0), mask_array.ravel(), 1
|
|
89
145
|
)
|
|
90
146
|
|
|
91
147
|
@abc.abstractmethod
|
|
@@ -100,6 +156,20 @@ class BaseErrCorrForm(abc.ABC):
|
|
|
100
156
|
"""
|
|
101
157
|
pass
|
|
102
158
|
|
|
159
|
+
def build_dot_matrix(self, sli: Union[np.ndarray, tuple]) -> np.ndarray:
|
|
160
|
+
"""
|
|
161
|
+
Returns uncertainty effect error-correlation matrix, populated with error-correlation values defined
|
|
162
|
+
in this parameterisation
|
|
163
|
+
|
|
164
|
+
:param sli: slice of observation variable to return error-correlation matrix for
|
|
165
|
+
|
|
166
|
+
:return: populated error-correlation matrix
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
return self.expand_dim_matrix(
|
|
170
|
+
self.build_matrix(sli), self.get_sliced_dims_errcorr(sli), sli
|
|
171
|
+
)
|
|
172
|
+
|
|
103
173
|
|
|
104
174
|
def register_err_corr_form(form_name: str) -> Callable:
|
|
105
175
|
"""
|
|
@@ -122,7 +192,7 @@ class RandomCorrelation(BaseErrCorrForm):
|
|
|
122
192
|
form = "random"
|
|
123
193
|
is_random = True
|
|
124
194
|
|
|
125
|
-
def build_matrix(self, sli):
|
|
195
|
+
def build_matrix(self, sli: tuple) -> np.ndarray:
|
|
126
196
|
"""
|
|
127
197
|
Returns uncertainty effect error-correlation matrix, populated with error-correlation values defined
|
|
128
198
|
in this parameterisation
|
|
@@ -133,16 +203,12 @@ class RandomCorrelation(BaseErrCorrForm):
|
|
|
133
203
|
"""
|
|
134
204
|
|
|
135
205
|
# evaluate correlation over matrices in form defintion
|
|
136
|
-
dim_lens =
|
|
206
|
+
dim_lens = self.get_sliced_shape_errcorr(sli)
|
|
137
207
|
n_elems = int(np.prod(dim_lens))
|
|
138
208
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
# expand to correlation matrix over all variable dims
|
|
142
|
-
return self.expand_dim_matrix(dims_matrix, sli)
|
|
209
|
+
submatrix = np.eye(n_elems)
|
|
143
210
|
|
|
144
|
-
|
|
145
|
-
# return self.slice_full_cov(full_matrix, sli)
|
|
211
|
+
return submatrix
|
|
146
212
|
|
|
147
213
|
|
|
148
214
|
@register_err_corr_form("systematic")
|
|
@@ -151,7 +217,7 @@ class SystematicCorrelation(BaseErrCorrForm):
|
|
|
151
217
|
form = "systematic"
|
|
152
218
|
is_systematic = True
|
|
153
219
|
|
|
154
|
-
def build_matrix(self, sli):
|
|
220
|
+
def build_matrix(self, sli: tuple) -> np.ndarray:
|
|
155
221
|
"""
|
|
156
222
|
Returns uncertainty effect error-correlation matrix, populated with error-correlation values defined
|
|
157
223
|
in this parameterisation
|
|
@@ -162,16 +228,12 @@ class SystematicCorrelation(BaseErrCorrForm):
|
|
|
162
228
|
"""
|
|
163
229
|
|
|
164
230
|
# evaluate correlation over matrices in form defintion
|
|
165
|
-
dim_lens =
|
|
231
|
+
dim_lens = self.get_sliced_shape_errcorr(sli)
|
|
166
232
|
n_elems = int(np.prod(dim_lens))
|
|
167
233
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
# expand to correlation matrix over all variable dims
|
|
171
|
-
return self.expand_dim_matrix(dims_matrix, sli)
|
|
234
|
+
submatrix = np.ones((n_elems, n_elems))
|
|
172
235
|
|
|
173
|
-
|
|
174
|
-
# return self.slice_full_cov(full_matrix, sli)
|
|
236
|
+
return submatrix
|
|
175
237
|
|
|
176
238
|
|
|
177
239
|
@register_err_corr_form("err_corr_matrix")
|
|
@@ -179,7 +241,7 @@ class ErrCorrMatrixCorrelation(BaseErrCorrForm):
|
|
|
179
241
|
|
|
180
242
|
form = "err_corr_matrix"
|
|
181
243
|
|
|
182
|
-
def build_matrix(self, sli):
|
|
244
|
+
def build_matrix(self, sli: tuple) -> np.ndarray:
|
|
183
245
|
"""
|
|
184
246
|
Returns uncertainty effect error-correlation matrix, populated with error-correlation values defined
|
|
185
247
|
in this parameterisation
|
|
@@ -189,11 +251,26 @@ class ErrCorrMatrixCorrelation(BaseErrCorrForm):
|
|
|
189
251
|
:return: populated error-correlation matrix
|
|
190
252
|
"""
|
|
191
253
|
|
|
192
|
-
|
|
193
|
-
|
|
254
|
+
all_dims = self._obj[self._unc_var_name].dims
|
|
255
|
+
all_dims_sizes = self._obj.sizes
|
|
256
|
+
|
|
257
|
+
sli_submatrix = tuple(
|
|
258
|
+
[sli[i] for i in range(len(all_dims)) if all_dims[i] in self.dims]
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
sliced_shape = tuple(
|
|
262
|
+
[
|
|
263
|
+
all_dims_sizes[all_dims[i]]
|
|
264
|
+
for i in range(len(all_dims))
|
|
265
|
+
if all_dims[i] in self.dims
|
|
266
|
+
]
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
submatrix = self.slice_flattened_matrix(
|
|
270
|
+
self._obj[self.params[0]], sliced_shape, sli_submatrix
|
|
271
|
+
)
|
|
194
272
|
|
|
195
|
-
|
|
196
|
-
# return self.slice_full_cov(full_matrix, sli)
|
|
273
|
+
return submatrix
|
|
197
274
|
|
|
198
275
|
|
|
199
276
|
@register_err_corr_form("ensemble")
|
|
@@ -201,7 +278,7 @@ class EnsembleCorrelation(BaseErrCorrForm):
|
|
|
201
278
|
|
|
202
279
|
form = "ensemble"
|
|
203
280
|
|
|
204
|
-
def build_matrix(self, sli):
|
|
281
|
+
def build_matrix(self, sli: tuple) -> np.ndarray:
|
|
205
282
|
"""
|
|
206
283
|
Returns uncertainty effect error-correlation matrix, populated with error-correlation values defined
|
|
207
284
|
in this parameterisation
|