Skip to content

Commit

Permalink
Merge pull request #239 from NASA-IMPACT/feature-add_new_checks_shey
Browse files Browse the repository at this point in the history
Standard Product Check added
  • Loading branch information
svbagwell authored May 1, 2023
2 parents 57b3046 + bae889c commit 5e9d21c
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pyQuARC/code/custom_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,28 @@ def one_item_presence_check(*field_values):
break

return {"valid": validity, "value": value}

@staticmethod
def dif_standard_product_check(*field_values):
"""
Checks if the Extended_Metadata field in the DIF schema is being
utilized to specify whether or not the collection is a Standard Product.
This check is needed because DIF schema does not have a dedicated field
for Standard Product, and the Extended_Metadata field is also utilized
for other things.
"""
validity = False
value = None

for field_value in field_values:
if field_value:
if 'StandardProduct' in field_value:
value = field_value
validity = True
break
else:
pass
return {"valid": validity, "value": value}

@staticmethod
def granule_sensor_presence_check(sensor_values, collection_shortname=None, version=None, dataset_id=None):
Expand Down
16 changes: 16 additions & 0 deletions pyQuARC/schemas/check_messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,22 @@
},
"remediation": "Recommend providing the instrument short name."
},
"standard_product_check": {
"failure": "The Standard Product flag is missing.",
"help": {
"message": "For information please see:",
"url": "https://wiki.earthdata.nasa.gov/display/CMR/StandardProduct"
},
"remediation": "Recommend indicating whether this is a StandardProduct."
},
"dif_standard_product_check": {
"failure": "The Standard Product flag is missing.",
"help": {
"message": "For information please see:",
"url": "https://wiki.earthdata.nasa.gov/display/CMR/StandardProduct"
},
"remediation": "Recommend indicating whether this is a StandardProduct."
},
"validate_granule_instrument_against_collection": {
"failure": "The instrument short name listed in the granule metadata does not match the instrument short name listed in the collection metadata.",
"help": {
Expand Down
5 changes: 5 additions & 0 deletions pyQuARC/schemas/checks.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@
"check_function": "one_item_presence_check",
"available": true
},
"dif_standard_product_check": {
"data_type": "custom",
"check_function": "dif_standard_product_check",
"available": true
},
"doi_link_update": {
"data_type": "url",
"check_function": "doi_link_update",
Expand Down
35 changes: 35 additions & 0 deletions pyQuARC/schemas/rule_mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -2565,8 +2565,43 @@
]
},
"severity": "info",
"check_id": "one_item_presence_check"
},
"standard_product_check": {
"rule_name": "Standard Product Check",
"fields_to_apply": {
"echo-c": [
{
"fields": [
"Collection/StandardProduct"
]
}
],
"umm-c": [
{
"fields": [
"StandardProduct"
]
}
]
},
"severity": "warning",
"check_id": "one_item_presence_check"
},
"dif_standard_product_check": {
"rule_name": "Standard Product Check",
"fields_to_apply": {
"dif10": [
{
"fields": [
"DIF/Extended_Metadata/Metadata/Name"
]
}
]
},
"severity": "warning",
"check_id": "dif_standard_product_check"
},
"validate_granule_instrument_against_collection": {
"rule_name": "Granule Instrument Short Name Check",
"fields_to_apply": {
Expand Down

0 comments on commit 5e9d21c

Please sign in to comment.