Commit f6cabb71 authored by Drew Leonard's avatar Drew Leonard
Browse files

Add basic outline of a Fido client

Doesn't do anything yet until I know how to query SDC's database.
parent 490c6500
Pipeline #2296 failed with stage
in 26 seconds
import sunpy.net.attrs as a
from sunpy.net.attr import AttrAnd, AttrOr, AttrWalker, DataAttr
from sunpy.net.base_client import BaseClient, QueryResponseTable
walker = AttrWalker()
@walker.add_creator(AttrOr)
def create_or(wlk, tree):
""""""
results = []
for sub in tree.attrs:
results.append(wlk.create(sub))
return results
@walker.add_creator(AttrAnd, DataAttr)
def create_and(wlk, tree):
""""""
result = dict()
wlk.apply(tree, result)
return [result]
@walker.add_applier(a.Time)
def _(wlk, attr, params):
""""""
return params.update({"startTime": attr.start.isot, "endTime": attr.end.isot})
@walker.add_applier(a.Level)
def _(wlk, attr, params):
""""""
return params.update({"level": attr.value})
class KISClient(BaseClient):
def __init__(self):
""""""
def _query_api(self, query_params):
"""API query process TBD."""
def search(self, query):
""""""
queries = walker.create(query)
results = []
for query_params in queries:
results.append(self._query_api(query_params))
return QueryResponseTable(results, client=self)
def fetch(self):
""""""
@classmethod
def _can_handle_query(cls, *query):
""""""
query_attrs = set(type(x) for x in query)
supported_attrs = {a.Time, a.Level}
return supported_attrs.issuperset(query_attrs)
@classmethod
def register_values(cls):
""""""
adict = {
a.Provider: [
(
"KIS-SDC",
"Science Data Centre at the Leibniz-Institut für Sonnenphysik",
)
]
}
return adict
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment