Skip to content

Commit f73bc43

Browse files
authored
Merge pull request #7 from comet-toolkit/flag_accessor
Flag accessor
2 parents 1ca1fb2 + 2092521 commit f73bc43

File tree

8 files changed

+1361
-38
lines changed

8 files changed

+1361
-38
lines changed

docs/conf.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
#
2323
import obsarray
2424

25-
sys.path.insert(0, os.path.abspath('..'))
25+
sys.path.insert(0, os.path.abspath(".."))
2626

2727
project_title = "obsarray".replace("_", " ").title()
2828

2929
# -- General configuration ---------------------------------------------
3030

31-
latex_toplevel_sectioning = 'section'
31+
latex_toplevel_sectioning = "section"
3232

3333
# If your documentation needs a minimal Sphinx version, state it here.
3434
#
@@ -41,22 +41,22 @@
4141
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
4242
# CFAB added napolean to support google-style docstrings
4343
extensions = [
44-
'sphinx.ext.autodoc',
45-
'sphinx.ext.viewcode',
46-
'sphinx.ext.napoleon',
44+
"sphinx.ext.autodoc",
45+
"sphinx.ext.viewcode",
46+
"sphinx.ext.napoleon",
4747
]
4848

4949
# Add any paths that contain templates here, relative to this directory.
50-
templates_path = ['_templates']
50+
templates_path = ["_templates"]
5151

5252
# The suffix(es) of source filenames.
5353
# You can specify multiple suffix as a list of string:
5454
#
5555
# source_suffix = ['.rst', '.md']
56-
source_suffix = '.rst'
56+
source_suffix = ".rst"
5757

5858
# The master toctree document.
59-
master_doc = 'index'
59+
master_doc = "index"
6060

6161
# General information about the project.
6262
project = project_title
@@ -82,10 +82,10 @@
8282
# List of patterns, relative to source directory, that match files and
8383
# directories to ignore when looking for source files.
8484
# This patterns also effect to html_static_path and html_extra_path
85-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
85+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
8686

8787
# The name of the Pygments (syntax highlighting) style to use.
88-
pygments_style = 'sphinx'
88+
pygments_style = "sphinx"
8989

9090
# If true, `todo` and `todoList` produce output, else they produce nothing.
9191
todo_include_todos = False
@@ -96,7 +96,7 @@
9696
# The theme to use for HTML and HTML Help pages. See the documentation for
9797
# a list of builtin themes.
9898
#
99-
html_theme = 'sphinx_rtd_theme'
99+
html_theme = "sphinx_rtd_theme"
100100

101101
# Theme options are theme-specific and customize the look and feel of a
102102
# theme further. For a list of options available for each theme, see the
@@ -107,13 +107,13 @@
107107
# Add any paths that contain custom static files (such as style sheets) here,
108108
# relative to this directory. They are copied after the builtin static files,
109109
# so a file named "default.css" will overwrite the builtin "default.css".
110-
html_static_path = ['_static']
110+
html_static_path = ["_static"]
111111

112112

113113
# -- Options for HTMLHelp output ---------------------------------------
114114

115115
# Output file base name for HTML help builder.
116-
htmlhelp_basename = 'obsarraydoc'
116+
htmlhelp_basename = "obsarraydoc"
117117

118118

119119
# -- Options for LaTeX output ------------------------------------------
@@ -122,15 +122,12 @@
122122
# The paper size ('letterpaper' or 'a4paper').
123123
#
124124
# 'papersize': 'letterpaper',
125-
126125
# The font size ('10pt', '11pt' or '12pt').
127126
#
128127
# 'pointsize': '10pt',
129-
130128
# Additional stuff for the LaTeX preamble.
131129
#
132130
# 'preamble': '',
133-
134131
# Latex figure (float) alignment
135132
#
136133
# 'figure_align': 'htbp',
@@ -140,21 +137,21 @@
140137
# (source start file, target name, title, author, documentclass
141138
# [howto, manual, or own class]).
142139
latex_documents = [
143-
(master_doc, 'user_manual.tex',
144-
'{} Documentation'.format(project_title),
145-
'Sam Hunt', 'manual'),
140+
(
141+
master_doc,
142+
"user_manual.tex",
143+
"{} Documentation".format(project_title),
144+
"Sam Hunt",
145+
"manual",
146+
),
146147
]
147148

148149

149150
# -- Options for manual page output ------------------------------------
150151

151152
# One entry per manual page. List of tuples
152153
# (source start file, name, description, authors, manual section).
153-
man_pages = [
154-
(master_doc, 'obsarray',
155-
'obsarray Documentation',
156-
[author], 1)
157-
]
154+
man_pages = [(master_doc, "obsarray", "obsarray Documentation", [author], 1)]
158155

159156

160157
# -- Options for Texinfo output ----------------------------------------
@@ -163,12 +160,15 @@
163160
# (source start file, target name, title, author,
164161
# dir menu entry, description, category)
165162
texinfo_documents = [
166-
(master_doc, 'obsarray',
167-
'obsarray Documentation',
168-
author,
169-
'obsarray',
170-
'Propagating UNcertainties in PYthon',
171-
'Miscellaneous'),
163+
(
164+
master_doc,
165+
"obsarray",
166+
"obsarray Documentation",
167+
author,
168+
"obsarray",
169+
"Propagating UNcertainties in PYthon",
170+
"Miscellaneous",
171+
),
172172
]
173173

174174
"""
@@ -361,4 +361,4 @@ def setup(app):
361361
"Miscellaneous",
362362
),
363363
]
364-
"""
364+
"""
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Interfacing with Flag Information
2+
+++++++++++++++++++++++++++++++++
3+
4+
obsarray enables users to define, store and interface with flag variables in :py:class:`xarray.Dataset`'s following the `CF Convention <https://cfconventions.org/Data/cf-conventions/cf-conventions-1.10/cf-conventions.html#flags>`_ metadata standard.
5+
6+
To access the information from a particular flag variable, use the dataset's ``flag`` accessor as follows,
7+
8+
.. code-block:: python
9+
10+
import xarray as xr
11+
import obsarray
12+
13+
ds = xr.open_dataset("measurement_data.nc")
14+
print(ds.flag["flag_var"])
15+
16+
This lists the flags for that variable. To access the flag values for a particular flag variable,
17+
18+
.. code-block:: python
19+
20+
ds.flag["flag_var"]["flag_1"].value # get flag mask
21+
ds.flag["flag_var"]["flag_1"][:, 0] = True # set flag mask values
22+
23+
24+
25+
You can add a flag variable in a similar way to adding a new variable to a dataset,
26+
27+
.. code-block:: python
28+
29+
ds.flag["new_flag_var"] = (["dims"], {"flag_meanings": ["f1", "f2"]})
30+
31+
or add a new flag to an existing flag variable,
32+
33+
.. code-block:: python
34+
35+
ds.flag["new_flag_var"]["f3"] = False

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ obsarray is under active development. It is beta software.
2727
:caption: User Guide
2828

2929
content/user/unc_accessor
30+
content/user/flag_accessor
3031
content/user/templater
3132

3233
.. toctree::

obsarray/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
__all__ = []
55

66
from ._version import get_versions
7-
from obsarray import unc_accessor
7+
from obsarray import unc_accessor, flag_accessor
88
from obsarray.err_corr import err_corr_forms
99
from obsarray.templater.template_util import create_ds
1010
from obsarray.templater.dstemplater import DSTemplater

0 commit comments

Comments
 (0)