Skip to content
Snippets Groups Projects
Commit 7c4eab8e authored by Rivers, Travis (Contractor) Creighton's avatar Rivers, Travis (Contractor) Creighton Committed by Jeremy M Fee
Browse files

create method to translate elements to feature collection

parent e05cc2b5
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ from ...iaga2002 import IAGA2002Writer ...@@ -15,7 +15,7 @@ from ...iaga2002 import IAGA2002Writer
from ...imfjson import IMFJSONWriter from ...imfjson import IMFJSONWriter
from ...TimeseriesUtility import get_interval_from_delta from ...TimeseriesUtility import get_interval_from_delta
from .DataApiQuery import DataApiQuery, DataType, OutputFormat, SamplingPeriod from .DataApiQuery import DataApiQuery, DataType, OutputFormat, SamplingPeriod
from .elements import elements from .elements import ELEMENTS, ELEMENT_INDEX
ERROR_CODE_MESSAGES = { ERROR_CODE_MESSAGES = {
204: "No Data", 204: "No Data",
...@@ -238,4 +238,14 @@ def get_data(request: Request, query: DataApiQuery = Depends(parse_query)): ...@@ -238,4 +238,14 @@ def get_data(request: Request, query: DataApiQuery = Depends(parse_query)):
@app.get("/elements/") @app.get("/elements/")
def get_elements(): def get_elements():
elements = {"type": "FeatureCollection", "features": []}
for e in ELEMENTS:
elements["features"].append(
{
"type": "Feature",
"id": e.id,
"properties": {"name": e.name, "units": e.units},
"geometry": None,
}
)
return JSONResponse(elements) return JSONResponse(elements)
...@@ -8,142 +8,37 @@ class Element(BaseModel): ...@@ -8,142 +8,37 @@ class Element(BaseModel):
units: str units: str
elements = { ELEMENTS = [
"type": "FeatureCollection", Element(id="H", abbreviation="H", name="Observatory North Component", units="nT"),
"features": [ Element(id="E", abbreviation="E", name="Observatory East Component", units="nT"),
{ Element(id="X", abbreviation="X", name="Geographic North Magnitude", units="nT"),
"type": "Feature", Element(id="Y", abbreviation="Y", name="Geographic East Magnitude", units="nT"),
"id": "H", Element(id="D", abbreviation="D", name="Declination (deci-arcminute)", units="dam"),
"properties": {"name": "Observatory North Component", "units": "nT"}, Element(
"geometry": None, id="Z", abbreviation="Z", name="Observatory Vertical Component", units="nT"
}, ),
{ Element(id="F", abbreviation="F", name="Total Field Magnitude", units="nT"),
"type": "Feature", Element(
"id": "E", id="G", abbreviation="ΔF", name="Observatory Vertical Component", units="∆nT"
"properties": {"name": "Observatory East Component", "units": "nT"}, ),
"geometry": None, Element(id="E-E", abbreviation="E-E", name="E=Field East", units="mV/km"),
}, Element(id="E-N", abbreviation="E-N", name="E-Field North", units="mV/km"),
{ Element(id="MDT", abbreviation="DIST", name="Disturbance", units="nT"),
"type": "Feature", Element(id="MSQ", abbreviation="SQ", name="Solar Quiet", units="nT"),
"id": "D", Element(id="MSV", abbreviation="SV", name="Solar Variation", units="nT"),
"properties": {"name": "Declination (deci-arcminute)", "units": "dam"}, Element(
"geometry": None, id="UK1", abbreviation="T-Electric", name="Electronics Temperature", units="°C"
}, ),
{ Element(
"type": "Feature", id="UK2",
"id": "Z", abbreviation="T-Total Field",
"properties": {"name": "Observatory Vertical Component", "units": "nT"}, name="Total Field Temperature",
"geometry": None, units="°C",
}, ),
{ Element(
"type": "Feature", id="UK3", abbreviation="T-Fluxgate", name="Fluxgate Temperature", units="°C"
"id": "F", ),
"properties": {"name": "Total Field Magnitude", "units": "nT"}, Element(id="UK4", abbreviation="T-Outside", name="Outside Temperature", units="°C"),
"geometry": None, ]
},
{ ELEMENT_INDEX = {e.id: e for e in ELEMENTS}
"type": "Feature",
"id": "G",
"properties": {"abbreviation": "ΔF", "name": "Delta F", "units": "∆nT"},
"geometry": None,
},
{
"type": "Feature",
"id": "X",
"properties": {"name": "Geographic North Magnitude", "units": "nT"},
"geometry": None,
},
{
"type": "Feature",
"id": "Y",
"properties": {"name": "Geographic East Magnitude", "units": "nT"},
"geometry": None,
},
{
"type": "Feature",
"id": "MDT",
"properties": {
"abbreviation": "Dist",
"name": "Disturbance",
"units": "nT",
},
"geometry": None,
},
{
"type": "Feature",
"id": "MSQ",
"properties": {"abbreviation": "SQ", "name": "Solar Quiet", "units": "nT"},
"geometry": None,
},
{
"type": "Feature",
"id": "MSV",
"properties": {
"abbreviation": "SV",
"name": "Solar Variation",
"units": "nT",
},
"geometry": None,
},
{
"type": "Feature",
"id": "E-N",
"properties": {
"abbreviation": "E-N",
"name": "E-Field North",
"units": "mV/km",
},
"geometry": None,
},
{
"type": "Feature",
"id": "E-E",
"properties": {
"abbreviation": "E-E",
"name": "E-Field East",
"units": "mV/km",
},
"geometry": None,
},
{
"type": "Feature",
"id": "UK1",
"properties": {
"abbreviation": "T-Electric",
"name": "Electronics Temperature",
"units": "°C",
},
"geometry": None,
},
{
"type": "Feature",
"id": "UK3",
"properties": {
"abbreviation": "T-Fluxgate",
"name": "Fluxgate Temperature",
"units": "°C",
},
"geometry": None,
},
{
"type": "Feature",
"id": "UK2",
"properties": {
"abbreviation": "T-Total Field",
"name": "Total Field Temperature",
"units": "°C",
},
"geometry": None,
},
{
"type": "Feature",
"id": "UK4",
"properties": {
"abbreviation": "T-Outside",
"name": "Outside Temperature",
"units": "°C",
},
"geometry": None,
},
],
}
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