Skip to content
Snippets Groups Projects
Commit 0724bdd6 authored by Rivers, Travis (Contractor) Creighton's avatar Rivers, Travis (Contractor) Creighton
Browse files

add validators to observatory

parent 9e5b1f81
No related branches found
No related tags found
No related merge requests found
from pydantic import BaseModel
from pydantic import BaseModel, validator
from typing import Dict
class Observatory(BaseModel):
......@@ -12,6 +13,33 @@ class Observatory(BaseModel):
declination_base: int
sensor_orientation: str
@validator("agency_name", always=true)
def validate_agency_name(cls, agency_name: str, values: Dict) -> str:
agency = values.get("agency")
if not agency_name:
if agency == "USGS":
agency_name = "United States Geological Survey (USGS)"
if agency == "GSC":
agency_name = "Geological Survey of Canada (GSC)"
if agency == "BGS":
agency_name = "British Geological Survey (BGS)"
if agency == "SANSA":
agency_name = "South African National Space Agency (SANSA)"
if agency == "JMA":
agency_name = "Japan Meteorological Agency (JMA)"
return agency_name
@validator("sensor_orientation", always=true)
def validate_sensor_orientation(cls, sensor_orientation: str, values: Dict) -> str:
agency = values.get("agency")
if not sensor_orientation:
if agency == "GSC":
sensor_orientation = "XYZF"
else:
sensor_orientation = "HDZF"
return sensor_orientation
OBSERVATORIES = [
Observatory(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment