nasa / opera-sds-pge

Observational Products for End-Users from Remote Sensing Analysis (OPERA)
Apache License 2.0
16 stars 6 forks source link

[New Feature]: Automated XML Generation for ISO Measured Parameters #484

Closed collinss-jpl closed 1 month ago

collinss-jpl commented 3 months ago

Checked for duplicates

Yes - I've already checked

Alternatives considered

Yes - and alternatives don't suffice

Related problems

The purpose of this ticket is to prototype a new capability for automatic generation of the MeasuredParameters section of an ISO XML template, based on the Metadata available within a given OPERA product (GeoTIFF or HD5).

Currently, this section of the ISO XML template is derived manually based on inspection of the available product metadata and Product Spec Document, however, this can be error prone and lead to missing or mismatched metadata between product and ISO XML.

Describe the feature request

A better approach might be to further "templatize" the MeasuredParameters section of the current Jinja2 template into a loop that traverses over a dictionary of product metadata and creates the individual XML entries automatically.

A template Jinja2 loop for each measured parameter could look like the following:

{%- for metadata_field, metadata_value in product_metadata %}
                            <eos:AdditionalAttribute>
                                  <eos:reference>
                                      <eos:EOS_AdditionalAttributeDescription>
                                          <eos:type>
                                              <eos:EOS_AdditionalAttributeTypeCode codeList="https://cdn.earthdata.nasa.gov/iso/resources/Codelist/eosCodelists.xml#EOS_AdditionalAttributeTypeCode" codeListValue="processingInformation">processingInformation</eos:EOS_AdditionalAttributeTypeCode>
                                          </eos:type>
                                          <eos:name>
                                              <gco:CharacterString>{{ metadata_field }}</gco:CharacterString>
                                          </eos:name>
                                          <eos:description>
                                              <gco:CharacterString>{{ Metadata Description (TBD) }}</gco:CharacterString>
                                          </eos:description>
                                          <eos:dataType>
                                              <eos:EOS_AdditionalAttributeDataTypeCode codeList="https://cdn.earthdata.nasa.gov/iso/resources/Codelist/eosCodelists.xml#EOS_AdditionalAttributeDataTypeCode" codeListValue="{{ str(type(metadata_value)) }}">{{ str(type(metadata_value)) }}</eos:EOS_AdditionalAttributeDataTypeCode>
                                          </eos:dataType>
                                      </eos:EOS_AdditionalAttributeDescription>
                                  </eos:reference>
                                  <eos:value>
                                      <gco:CharacterString>{{ metadata_value }}</gco:CharacterString>
                                  </eos:value>
                              </eos:AdditionalAttribute>
{%- endfor %}

Note that this example is mostly for explanatory purposes and will likely not work as-is in the Jinja2 template syntax.

For the initial prototype, lets not worry about filling in the field descriptions, as this will likely require a separate effort to develop a separate look-up table with descriptions sourced from a Product Spec document. Also for the initial prototype, let's only focus on the DSWx-S1 PGE.

That being said, the goals of this ticket are as follows:

collinss-jpl commented 1 month ago

Closed by #496