Skip to content

Commit

Permalink
Updates for #275
Browse files Browse the repository at this point in the history
Add a constraint to make sure first/last bin centers have identical units.
  • Loading branch information
acraugh committed Apr 2, 2024
1 parent e5cc71b commit 11d9c0b
Show file tree
Hide file tree
Showing 5 changed files with 585 additions and 6 deletions.
16 changes: 15 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Spectral Discipline Namespace Change Log

## Changes from v1.3.1.1 ro v1.3.2.0

### Issue #277: Missing Energy Classes

The new energy spectrum classes Uniformly_Sampled_Energy and Axis_Bin_Set_Energy were
inadvertently omitted from the Bin_Description class. They have now been added.

### Issue #275: First/Last Bin Comparison Unit Check

In the Uniformly_Sampled classes, the first_center and last_center values were compared
numerically, but there was no constraint requiring that they have the same unit of
measure. This invalidates a simple numeric check for first < last. They are now
required to have the same units for all spectrum types.

## Changes from v1.3.1.0 to 1.3.1.1

These changes should be transparent to users creating labels with the Spectral Discipline
Expand All @@ -8,7 +22,7 @@ classes.
### Recoding for issue #52

Replaced the "pds." syntax-kludge notation for referencing the _pds:_ namespace with
the _DD_Associate_External_Class_ class, which providef a mechanism for defining
the _DD_Associate_External_Class_ class, which provides a mechanism for defining
reference type values as the external reference is made. These superseded both the
corresponding _DD_Associate_ classes and the _DD_Rule_ Schematron rule classes
needed to define the permissible values in each context.
Expand Down
32 changes: 30 additions & 2 deletions src/PDS4_SPECTRAL_IngestLDD.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
DD_Associate_External_Class.
2024-04-01 cgobat Version 1.3.2.0 Add missing Axis_Bin_Set_Energy and Uniformly_Sampled_Energy as
permissible options within the Bin_Description class.
2024-04-02 ACR Version 1.3.2.0 Clearing some additional issues from the queue:
Issue #275: Conside units when comparing values of first_center_*
and last_center_*
</comment>
<last_modification_date_time>2024-04-02</last_modification_date_time>
<!--
Expand Down Expand Up @@ -3322,8 +3325,8 @@
This context has a number of rules to make sure that the appropriate type of classes are
being used, and the references to information elsewhere in the label are resolvable.
The specifics vary, but the techniques are the same as already seen. They are used
a lot in this dictionary because of the range of spectral types covered. Consequently
There is a DD_Rule for each spectral type of Uniformly_Sampled_* (energy, frequenct,
a lot in this dictionary because of the range of spectral types covered. Consequently,
there is a DD_Rule for each spectral type of Uniformly_Sampled_* (energy, frequency,
wavelength, and wavenumber).
-->
<local_identifier>us_energy</local_identifier>
Expand Down Expand Up @@ -3357,6 +3360,16 @@
<rule_test>if (sp:sampling_scale ne 'Linear') then (sp:sampling_base) else true()</rule_test>
<rule_message>The sp:sampling_base attribute is required for non-Linear sampling scales.</rule_message>
</DD_Rule_Statement>
<!--
The next rule requires that the same unit of measure is used for the first and last wavelengths, so that
the comparison is valid for the desired constraint (i.e., first < last). Note that in this case we're
comparing the value if the "unit" XML attribute ("unit='keV'", e.g.), not of the PDS attribute.
-->
<DD_Rule_Statement>
<rule_type>Assert</rule_type>
<rule_test>sp:first_center_energy/@unit eq sp:last_center_energy/@unit</rule_test>
<rule_message>In the Uniformly_Sampled classes, the first_center and last_center values must have the same units of measure.</rule_message>
</DD_Rule_Statement>
<DD_Rule_Statement>
<rule_type>Assert</rule_type>
<rule_test>number(sp:first_center_energy) lt number(sp:last_center_energy)</rule_test>
Expand Down Expand Up @@ -3396,6 +3409,11 @@
<rule_test>if (sp:sampling_scale ne 'Linear') then (sp:sampling_base) else true()</rule_test>
<rule_message>The sp:sampling_base attribute is required for non-Linear sampling scales.</rule_message>
</DD_Rule_Statement>
<DD_Rule_Statement>
<rule_type>Assert</rule_type>
<rule_test>sp:first_center_frequency/@unit eq sp:last_center_frequency/@unit</rule_test>
<rule_message>In the Uniformly_Sampled classes, the first_center and last_center values must have the same units of measure.</rule_message>
</DD_Rule_Statement>
<DD_Rule_Statement>
<rule_type>Assert</rule_type>
<rule_test>number(sp:first_center_frequency) lt number(sp:last_center_frequency)</rule_test>
Expand Down Expand Up @@ -3435,6 +3453,11 @@
<rule_test>if (sp:sampling_scale ne 'Linear') then (sp:sampling_base) else true()</rule_test>
<rule_message>The sp:sampling_base attribute is required for non-Linear sampling scales.</rule_message>
</DD_Rule_Statement>
<DD_Rule_Statement>
<rule_type>Assert</rule_type>
<rule_test>sp:first_center_wavelength/@unit eq sp:last_center_wavelength/@unit</rule_test>
<rule_message>In the Uniformly_Sampled classes, the first_center and last_center values must have the same units of measure.</rule_message>
</DD_Rule_Statement>
<DD_Rule_Statement>
<rule_type>Assert</rule_type>
<rule_test>number(sp:first_center_wavelength) lt number(sp:last_center_wavelength)</rule_test>
Expand Down Expand Up @@ -3474,6 +3497,11 @@
<rule_test>if (sp:sampling_scale ne 'Linear') then (sp:sampling_base) else true()</rule_test>
<rule_message>The sp:sampling_base attribute is required for non-Linear sampling scales.</rule_message>
</DD_Rule_Statement>
<DD_Rule_Statement>
<rule_type>Assert</rule_type>
<rule_test>sp:first_center_wavenumber/@unit eq sp:last_center_wavenumber/@unit</rule_test>
<rule_message>In the Uniformly_Sampled classes, the first_center and last_center values must have the same units of measure.</rule_message>
</DD_Rule_Statement>
<DD_Rule_Statement>
<rule_type>Assert</rule_type>
<rule_test>number(sp:first_center_wavenumber) lt number(sp:last_center_wavenumber)</rule_test>
Expand Down
11 changes: 8 additions & 3 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ This directory contains files used to perform regression testing of the Spectral
> attempt to use these as templates for real data without understanding the proper application
> of the Spectral Dictionary metadata.***
The test file set includes:
The general test file set includes:

* *SP-Test1-VALID.xml* and *SP-Test2-VALID.xml* - Two test labels that should show no validation errors
* *SP-Test1-FAIL.xml* and *SP-Test2-FAIL.xml* - Two test labels identical to the corresponding *VALID*
labels, except with specific, documented errors to demonstrate proper behavior of key
Spectral class features
Spectral class features.
* *No.Data* - A zero-length data file included to satisfy the *Validate Tool* requirement for a data file to exist

Specific tests for resolved issues:
* *SP-Energy-VALID.xml* - A label to demonstrate that the Axis_Bin_Set_Energy class has now been
included in Bin_Description (it was omitted) [#277]
* *No.Data* - A zero-length data file included to satisfy the *Validate Tool* requirement for a data file to exist
* *SP-usUnitMatch-VALID/FAIL.xml* - These labels demonstrate the enforcement of a requirement that the
first and last bin centers in the Uniformly_Sampled class must have the same unit of
measure, so that the first &lt; last test is valid. [#275]

The labels are formatted to work with the automated build process in this repo, so all references to
schema files have been removed. Test results are part of the reports generated by the _Actions_ used
Expand Down
Loading

0 comments on commit 11d9c0b

Please sign in to comment.