Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos in documentation #340

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
0.19.2 (unreleased)
===================

- Addes test to ensure that the base ``common`` keyword groups exist within the ``schema.info`` tree. [#338]
- Adds test to ensure that the base ``common`` keyword groups exist within the ``schema.info`` tree. [#338]

0.19.1 (2024-04-04)
===================
Expand Down
2 changes: 1 addition & 1 deletion docs/roman_datamodels/datamodels/general_structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Some of the most relevant methods are:

While ASDF permits a wide variety of legal attribute names, the convention is that Roman
only uses attribute name that are legal Python variable names. This is so they can be
used as Python object attributes. Using the above example of for the keys that ``to_flat_dict``
used as Python object attributes. Using the above example for the keys that ``to_flat_dict``
returns, that permits using ``dm.meta.observation.date`` to obtain the value of that attribute
instead of ``dm.tree['roman']['meta']['observation']['date']``. The latter can still be used
if you enjoy typing lots of brackets and quotes instead of periods.
Expand Down
2 changes: 1 addition & 1 deletion docs/roman_datamodels/datamodels/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ schemas are used to validate the datafiles. Furthermore, these schemas also
include information used by the ground system to indicate where metadata and
data are obtained as well as their destination in the archive catalogs, and most
important, serve to keep the ground system definition of the data files and
the calibration pipeline definitin sync since both rely on the same schema
the calibration pipeline definition in sync since both rely on the same schema
files.

The schema/datamodel system is also intrinsic to how the ASDF converter
Expand Down
8 changes: 4 additions & 4 deletions docs/roman_datamodels/datamodels/stnode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ stnode objects construct from a schema file will be built off these two classes.
Hence, general functionality of an stnode object should be implemented in these
two classes so that all stnode objects can inherit from them.

Currently, there these two objects are implemented so that they follow the
Currently, these two objects are implemented so that they follow the
dictionary or list interface; meaning that, they can be accessed via the ``[]``
operator (``node["keyword"]`` or ``node[0]``). However, for the case of the
`~roman_datamodels.stnode.DNode` objects, keys can also be used to directly
Expand Down Expand Up @@ -105,14 +105,14 @@ the `roman_datamodels.datamodels` module.
Scalar Nodes
************

In addition, to the objects described above, there are the "scalar node"
In addition to the objects described above, there are the "scalar node"
objects, which are created from multiple inheritance of
`~roman_datamodels.stnode.TaggedScalarNode` and a scalar type. These objects are
used to represent the schemas under the ``tagged_scalars`` directory in RAD.
Those schemas are used to decorate a few common scalar ``meta`` fields with
additional information for the archive and sdp. Due to how the ``meta`` keyword
is assembled (via multiple combiners), ASDF has a hard time traversing the
schemas to look of this information. Thus, these scalar nodes are tagged so that
schemas to look for this information. Thus, these scalar nodes are tagged so that
ASDF has a hook to find them without trying a recursive search of the schema
files. If this issue is resolved in the future, or the metadata under ``meta``
is reorganized, then scalar node concept can be removed from the codebase.
Expand All @@ -135,7 +135,7 @@ on the fly when the data is set via the ``.`` interface; however, ASDF by
default will validate the data stored in the node against its schema during both
serialization and de-serialization.

In order to avoid, the overhead of re-validating all of the data in a node when
In order to avoid the overhead of re-validating all of the data in a node when
one thing is updated (this can induce a lot of overhead), the stnode objects
will attempt to parse a given "tagged-node's" schema down so that it is only
validating the field being updated. It performs the validation by attempting to
Expand Down
162 changes: 81 additions & 81 deletions docs/roman_datamodels/datamodels/using_datamodels.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Using Roman Datamodels

The following illustrates common operations with the datamodels.
This is most relevant for interactive use with a loaded datamodel
or if one is writing scripts or propgrams to view and manipulate
or if one is writing scripts or programs to view and manipulate
these data models. Developing new datamodels is a different topic
and may be covered in the future. For the most part, it involves
defining what the schema for such a model must be and what modifications
Expand All @@ -15,126 +15,126 @@ The normal approach is to open the datamodel as follows (this assumes
the file displayed as the Level 1 example in the general structure
page::

>>> import roman_datamodels as rdm
>>> dm = rdm.open('my_wonderful_roman_data.asdf')
>>> import roman_datamodels as rdm
>>> dm = rdm.open('my_wonderful_roman_data.asdf')

>>> type(dm)
roman_datamodels.datamodels.ScienceRawModel
>>> type(dm)
roman_datamodels.datamodels.ScienceRawModel

>>> print(dm.meta.instrument.optical_element)
GRISM
>>> print(dm.meta.instrument.optical_element)
GRISM

# most nodes have special types
# most nodes have special types

>>> type(dm.meta.exposure)
roman_datamodels.stnode.Exposure
>>> type(dm.meta.exposure)
roman_datamodels.stnode.Exposure

>>> print(dm.data.shape)
(6, 4096, 4096)
>>> print(dm.data.shape)
(6, 4096, 4096)

>>> print(dm.data.dtype)
uint16
>>> print(dm.data.dtype)
uint16

# Change metadata value
# Change metadata value

>>> dm.meta.exposure.start_time_mjd = 60000.
print(dm.meta.exposure.start_time_mjd)
60000.0
>>> dm.meta.exposure.start_time_mjd = 60000.
print(dm.meta.exposure.start_time_mjd)
60000.0

# Try to assign invalid type
# Try to assign invalid type

>>> d.meta.exposure.start_time_mjd = "hello"
>>> d.meta.exposure.start_time_mjd = "hello"

# Last part of resulting traceback
# Last part of resulting traceback

ValidationError: While validating start_time_mjd the following error occurred:
'hello' is not of type 'number'
ValidationError: While validating start_time_mjd the following error occurred:
'hello' is not of type 'number'

Failed validating 'type' in schema:
{'$schema': 'http://stsci.edu/schemas/asdf-schema/0.1.0/asdf-schema',
'archive_catalog': {'datatype': 'float',
'destination': ['ScienceCommon.exposure_start_time_mjd']},
'description': 'This records the time at the start of the exposure '
'using the\n'
'Modified Julian Date (MJD). This is used in the '
'archive catalog for\n'
'multi-mission matching.\n',
'sdf': {'source': {'origin': 'TBD'},
'special_processing': 'VALUE_REQUIRED'},
'title': '[d] exposure start time in MJD',
'type': 'number'}
Failed validating 'type' in schema:
{'$schema': 'http://stsci.edu/schemas/asdf-schema/0.1.0/asdf-schema',
'archive_catalog': {'datatype': 'float',
'destination': ['ScienceCommon.exposure_start_time_mjd']},
'description': 'This records the time at the start of the exposure '
'using the\n'
'Modified Julian Date (MJD). This is used in the '
'archive catalog for\n'
'multi-mission matching.\n',
'sdf': {'source': {'origin': 'TBD'},
'special_processing': 'VALUE_REQUIRED'},
'title': '[d] exposure start time in MJD',
'type': 'number'}

On instance:
'hello'
On instance:
'hello'

# Note the extra information in the schema segment showing origin of
# the information and the destination in the archive.
# Note the extra information in the schema segment showing origin of
# the information and the destination in the archive.

# Try to assign wrong kind of node
# Try to assign wrong kind of node

>>> dm.meta.observation = dm.meta.exposure
Failed validating 'tag' in schema:
{'$schema': 'http://stsci.edu/schemas/asdf-schema/0.1.0/asdf-schema',
'tag': 'asdf://stsci.edu/datamodels/roman/tags/observation-1.0.0'}
>>> dm.meta.observation = dm.meta.exposure
Failed validating 'tag' in schema:
{'$schema': 'http://stsci.edu/schemas/asdf-schema/0.1.0/asdf-schema',
'tag': 'asdf://stsci.edu/datamodels/roman/tags/observation-1.0.0'}

On instance:
{'groupgap': 0, 'ma_table_name': 'High Latitude Spec. Survey', 'ma_table_number': 1, 'nframes': 8, 'ngroups': 6, 'p_exptype': 'WFI_IMAGE|', 'type': 'WFI_IMAGE'}
On instance:
{'groupgap': 0, 'ma_table_name': 'High Latitude Spec. Survey', 'ma_table_number': 1, 'nframes': 8, 'ngroups': 6, 'p_exptype': 'WFI_IMAGE|', 'type': 'WFI_IMAGE'}

# Show and then change pixel value in data
# Show and then change pixel value in data

>>> dm.data[0, 10, 10]
115
>>> dm.data[0, 10, 10] = 42
>>> dm.data[0, 10, 10]
42
>>> dm.data[0, 10, 10]
115
>>> dm.data[0, 10, 10] = 42
>>> dm.data[0, 10, 10]
42

# Save to a new file
# Save to a new file

>>> dm.to_asdf('test.asdf')
>>> dm2 = rdm.open('test.asdf')
>>> dm2[0, 10, 10]
42
>>> dm2.meta.exposure_start_time_mjd
60000.0
>>> dm.to_asdf('test.asdf')
>>> dm2 = rdm.open('test.asdf')
>>> dm2.data[0, 10, 10]
42
>>> dm2.meta.exposure_start_time_mjd
60000.0


.. note::

There are a couple subtlties with regard to changing values in a datamodel.
There are a couple subtleties with regard to changing values in a datamodel.
If you assign dicts or lists to attributes, it will map these into the
corresponding DNode or LNode subclasses. In such uses, the assigned values
will be immediately checked by validating against the defining schemas.
When the value being assigned fails to pass that validation, an exception
will occur. This is generally a good thing, particularly if you are changing
values interactively.

If you are getting validation errors consult the corresponding schema in
``rad`` to se what is allowed. If you think the schema is wrong, or you
continue to have issues, please contact the Roman team for help.
If you are getting validation errors consult the corresponding schema in
``rad`` to see what is allowed. If you think the schema is wrong, or you
continue to have issues, please contact the Roman team for help.

As a method of last resort, if you wish to turn off validation, you can do
so by setting the environment variable ``ROMAN_VALIDATE`` to false. This is
not recommended! Moreover, this feature will be explicitly removed when the
datamodels stabilize.
As a method of last resort, if you wish to turn off validation, you can do
so by setting the environment variable ``ROMAN_VALIDATE`` to false. This is
not recommended! Moreover, this feature will be explicitly removed when the
datamodels stabilize.

.. code-block:: bash
.. code-block:: bash

export ROMAN_VALIDATE=false
export ROMAN_VALIDATE=false

To restore validation, set the environment variable to ``true`` or unset it.
To restore validation, set the environment variable to ``true`` or unset it.


.. warning::

We strongly recommend against ever turning off validation. This can lead to
a variety of unrecoverable problems. Such as not being able to write out
your datamodel or not being able to read it back in. Or worse, the data in
the datamodel may not be compatible with operations intended to run on that
datamodel. The Roman team will not assist with fixing such problems which
occur when validation is turned off.
We strongly recommend against ever turning off validation. This can lead to
a variety of unrecoverable problems. Such as not being able to write out
your datamodel or not being able to read it back in. Or worse, the data in
the datamodel may not be compatible with operations intended to run on that
datamodel. The Roman team will not assist with fixing such problems which
occur when validation is turned off.

Use this feature at your own risk!
Use this feature at your own risk!

If you are having problems due to validation errors, please contact the the
Roman team for help via raising a GitHub issue. We will do our best to assist
you.
If you are having problems due to validation errors, please contact the the
Roman team for help via raising a GitHub issue. We will do our best to assist
you.