Commit 2b6e9a04 authored by Drew Leonard's avatar Drew Leonard
Browse files

Update references to sdc to kisfido

parent 74acabb6
Pipeline #4162 failed with stage
in 36 seconds
"""
Search attributes which are specific to the `sdc.net.KISClient`.
Search attributes which are specific to the `kisfido.net.KISClient`.
Other attributes provided by `sunpy.net.attrs` are supported by the client.
"""
......@@ -97,7 +97,7 @@ class Date(_attr.SimpleAttr):
def __repr__(self):
time = self.time.iso
return f'<sunpy.net.attrs.sdc.Date({str(time)})>'
return f'<sunpy.net.attrs.kisfido.Date({str(time)})>'
# description.FILTER
......
......@@ -17,7 +17,7 @@ from sunpy.net.base_client import (BaseClient, QueryResponseTable, QueryResponse
convert_row_to_table)
from sunpy.util.exceptions import SunpyUserWarning
# from sunpy.net.attrs import Instrument, Level, Physobs, Provider, Time, Wavelength
import sdc.attrs as sattrs
import kisfido.attrs as sattrs
import urllib.parse
import urllib.request
......@@ -364,7 +364,7 @@ class KISClient(BaseClient):
"""
Check if query attributes are valid and supported by this client.
Tests that all attributes in tree are in `~sunpy.net.attrs` or `~sunpy.net.attrs.sdc`
Tests that all attributes in tree are in `~sunpy.net.attrs` or `~sunpy.net.attrs.kisfido`
and, if in registered attributes, have a registered value.
Parameters
......@@ -381,9 +381,9 @@ class KISClient(BaseClient):
"""
query_attrs = set(type(x) for x in query)
sunpy_attrs = [getattr(a, x) for x in a.__all__ if isinstance(getattr(a, x), AttrMeta)]
sdc_attrs = [getattr(a.sdc, x) for x in a.sdc.__all__ if
isinstance(getattr(a.sdc, x), AttrMeta)]
supported_attrs = set(sunpy_attrs + sdc_attrs + [AttrAnd, AttrOr])
kisfido_attrs = [getattr(a.kisfido, x) for x in a.kisfido.__all__ if
isinstance(getattr(a.kisfido, x), AttrMeta)]
supported_attrs = set(sunpy_attrs + kisfido_attrs + [AttrAnd, AttrOr])
# Remove a.Provider, a.Source, a.ExtentType here since they are not used as filters?
if not supported_attrs.issuperset(query_attrs):
......@@ -426,7 +426,7 @@ class KISClient(BaseClient):
@classmethod
def _attrs_module(cls):
return 'sdc', 'sdc.attrs'
return 'kisfido', 'kisfido.attrs'
@classmethod
def register_values(cls):
......@@ -450,7 +450,7 @@ class KISClient(BaseClient):
# ("TIP-II", "Tenerife Infrared Polarimeter @ VTT"), # name?
# ("ZIMPOL", "Zeeman Imaging Polarimeter @ Gregor"), # 404 error
# description.TELESCOPE - Name of the telescope
a.sdc.Telescope: [("ChroTel", "10 cm Chromospheric Telescope, Observatorio del Teide"),
a.kisfido.Telescope: [("ChroTel", "10 cm Chromospheric Telescope, Observatorio del Teide"),
("Gregor", "150 cm Gregor Solar Telescope, Observatorio del Teide"),
("VTT", "70 cm Vacuum Tower Telescope, Observatorio del Teide")],
# description.CALIB_LEVEL - Degree of data processing - note IVOA also specifies 3 & 4.
......
......@@ -16,7 +16,7 @@ from sunpy.net import Fido
from sunpy.net import attrs as a
from sunpy.net.base_client import QueryResponseTable
from sdc.client import KISClient
from kisfido.client import KISClient
_BASE_URL = "http://dockertest:8083/sdc/"
......@@ -67,7 +67,7 @@ def test_docker(client):
data = json.loads(response.read())
assert 'description' in data['_embedded'][0]
res = client.search(a.Instrument("GRIS") & a.sdc.ObsName('gris_20140426_000'))
res = client.search(a.Instrument("GRIS") & a.kisfido.ObsName('gris_20140426_000'))
assert isinstance(res, QueryResponseTable)
assert len(res) == 105
assert res[0]['INSTRUMENT'] == 'gris'
......@@ -137,7 +137,7 @@ def test_gridfs(client):
import gridfs
from kis_tools.generic import get_sdc_connection
res = client.search(a.Instrument("GRIS") & a.sdc.ObsName('gris_20140426_000'))
res = client.search(a.Instrument("GRIS") & a.kisfido.ObsName('gris_20140426_000'))
links = res[0]['_embedded'][0].get('links')
file_ids = [ld['$oid'] for ld in links['l1_data']]
sdc = get_sdc_connection()
......@@ -174,7 +174,7 @@ def test_search(client):
client.search(query)
# Maximum numer of returned observation records defaults to 100 per query.
query = a.Instrument("LARS") & a.sdc.HelioProjLat(-10*u.arcsec, 0.2*u.arcmin)
query = a.Instrument("LARS") & a.kisfido.HelioProjLat(-10*u.arcsec, 0.2*u.arcmin)
assert client._can_handle_query(query)
if HAS_DOCKERTEST:
res = client.search(query)
......@@ -186,7 +186,7 @@ def test_search(client):
r"{'description.HPLT_TAN_MAX':{'.gte':-10}}"):
client.search(query)
query = a.Instrument("LARS"), a.sdc.HelioProjLat(-10*u.arcsec, 0.2*u.arcmin)
query = a.Instrument("LARS"), a.kisfido.HelioProjLat(-10*u.arcsec, 0.2*u.arcmin)
assert client._can_handle_query(*query)
if HAS_DOCKERTEST:
res = client.search(*query)
......@@ -198,7 +198,7 @@ def test_search(client):
r"{'description.HPLT_TAN_MAX':{'.gte':-10}}"):
client.search(*query)
query = a.Instrument("GRIS") & (a.sdc.Theta(85*u.deg, 3000*u.arcmin) | a.sdc.PolStates('iquv'))
query = a.Instrument("GRIS") & (a.kisfido.Theta(85*u.deg, 3000*u.arcmin) | a.kisfido.PolStates('iquv'))
assert client._can_handle_query(query)
if HAS_DOCKERTEST:
res = client.search(query)
......@@ -213,7 +213,7 @@ def test_search(client):
assert "{'description.THETA':{'$gte':50,'$lte':85}}" in str(exc.value)
assert "{'description.POL_STATES':" not in str(exc.value)
query = a.Instrument("LARS") | a.Instrument("GRIS"), a.sdc.Theta(85*u.deg, 3000*u.arcmin)
query = a.Instrument("LARS") | a.Instrument("GRIS"), a.kisfido.Theta(85*u.deg, 3000*u.arcmin)
if HAS_DOCKERTEST:
res = client.search(*query)
assert len(res) == 163
......@@ -231,11 +231,11 @@ def test_fido_search():
"""Test search using the Fido base class with AttrAnd, AttrOr and lists of *args."""
two_inst = (a.Instrument("LARS") | a.Instrument("GRIS"))
if HAS_DOCKERTEST:
res = Fido.search(a.Instrument("GRIS") & a.sdc.Theta(50*u.deg, 80*u.deg))
res = Fido.search(a.Instrument("GRIS") & a.kisfido.Theta(50*u.deg, 80*u.deg))
assert len(res['kis']) == 162
assert (min(res['kis']['THETA']) >= 50*u.deg) & (max(res['kis']['THETA']) <= 80*u.deg)
res = Fido.search(a.Instrument("GRIS"), a.sdc.Theta(50*u.deg, 80*u.deg))
res = Fido.search(a.Instrument("GRIS"), a.kisfido.Theta(50*u.deg, 80*u.deg))
assert len(res['kis']) == 162
assert (min(res['kis']['THETA']) >= 50*u.deg) & (max(res['kis']['THETA']) <= 80*u.deg)
......@@ -245,7 +245,7 @@ def test_fido_search():
assert max(res['kis']['DATE_BEG']) < date.end
assert min(res['kis']['DATE_END']) > date.start
res = Fido.search(two_inst, a.sdc.Theta(50*u.deg, 80*u.deg))
res = Fido.search(two_inst, a.kisfido.Theta(50*u.deg, 80*u.deg))
assert len(res['kis']) == 2
assert len(res['kis'][0]) == 1
assert len(res['kis'][1]) == 162
......@@ -259,7 +259,7 @@ def test_fido_search():
assert (min(theta) >= 50*u.deg) & (max(theta) <= 80*u.deg)
date = a.Time("2016/08/26 16:25", "2016/08/26 16:45")
res = Fido.search(a.Instrument("GRIS"), a.sdc.PolStates('iquv'), date)
res = Fido.search(a.Instrument("GRIS"), a.kisfido.PolStates('iquv'), date)
assert len(res['kis']) == 400
assert all(res['kis']['POL_STATES'] == 'IQUV')
assert max(res['kis']['DATE_BEG']) < date.end
......@@ -267,14 +267,14 @@ def test_fido_search():
else:
with pytest.raises(URLError, match=rf"{_dockerexc('gris')}"
r"{'description.THETA':{'.gte':50,'.lte':80}}"):
Fido.search(a.Instrument("GRIS") & a.sdc.Theta(50*u.deg, 80*u.deg))
Fido.search(a.Instrument("GRIS") & a.kisfido.Theta(50*u.deg, 80*u.deg))
with pytest.raises(URLError, match=rf"{_dockerexc('gris')}"
r"{'description.THETA':{'.gte':50,'.lte':80}}"):
Fido.search(a.Instrument("GRIS"), a.sdc.Theta(50*u.deg, 80*u.deg))
Fido.search(a.Instrument("GRIS"), a.kisfido.Theta(50*u.deg, 80*u.deg))
with pytest.raises(URLError, match=rf"{_dockerexc('LARS')}") as exc:
Fido.search(two_inst, a.sdc.Theta(50*u.deg, 80*u.deg))
Fido.search(two_inst, a.kisfido.Theta(50*u.deg, 80*u.deg))
assert "{'description.THETA':{'$gte':50,'$lte':80}}" in str(exc.value)
assert "{'description.INSTRUMENT':'gris'" not in str(exc.value)
......@@ -404,7 +404,7 @@ def test_fido_fetch_2():
def test_level_data(level):
"""Test search and fetch of l{level[0]}_data - no actual data found for l0 + l2."""
obsname = 'gris_20160826_012'
query = (a.Instrument("GRIS"), a.sdc.ObsName(obsname), a.Level(level[0]))
query = (a.Instrument("GRIS"), a.kisfido.ObsName(obsname), a.Level(level[0]))
if not HAS_DOCKERTEST:
with pytest.raises(URLError, match=rf"{_dockerexc('gris')}"
......@@ -440,7 +440,7 @@ def test_level_data(level):
@pytest.mark.parametrize("query", ((a.Instrument("GRIS") & a.Level(3)),
(a.Instrument("ChroTel") & a.Physobs("perspective.vortex")),
(a.Level(0) & a.Instrument("Bob")),
(a.Instrument("LARS") & a.sdc.Telescope("Leviathan"))))
(a.Instrument("LARS") & a.kisfido.Telescope("Leviathan"))))
def test_cant_handle_query(client, query):
"""Some examples of invalid queries with exceptions."""
assert not client._can_handle_query(*query.attrs)
......@@ -450,19 +450,19 @@ def test_cant_handle_query(client, query):
@pytest.mark.parametrize("query", (a.Level(1), a.Wavelength(3200*u.AA, 1.6*u.micron),
a.sdc.DataProduct('cube'), a.sdc.ObsName('gris_20140426_000'),
a.sdc.Date('2021/01/31'), a.sdc.Filter('LOT%233802'),
a.sdc.PolStates('IQUV'), a.sdc.Telescope('VTT'),
a.sdc.Target('Sunspot_22'), a.sdc.AtmosR0(*([1, 20000]*u.mm)),
a.sdc.Theta(20*u.arcmin, 89*u.deg), a.sdc.Mu(0.1, 1),
a.sdc.ExposureTime(*([5, 60]*u.min)),
a.sdc.HelioProjLon(5*u.arcsec), a.sdc.HelioProjLat(9*u.arcsec),
a.sdc.SpatialResolution(0.1*u.arcsec, 0.8*u.arcsec),
a.sdc.SpectralResolution(6000, 200000),
a.sdc.TemporalResolution(2*u.s, 30*u.s),
a.sdc.NDimensions(1, 2), a.sdc.PolXel(2, 4),
a.sdc.SpatialXel1(200, 3000), a.sdc.SpatialXel2(100, 4000),
a.sdc.SpectralXel(320, 4096), a.sdc.TimeXel(60, 86400)))
a.kisfido.DataProduct('cube'), a.kisfido.ObsName('gris_20140426_000'),
a.kisfido.Date('2021/01/31'), a.kisfido.Filter('LOT%233802'),
a.kisfido.PolStates('IQUV'), a.kisfido.Telescope('VTT'),
a.kisfido.Target('Sunspot_22'), a.kisfido.AtmosR0(*([1, 20000]*u.mm)),
a.kisfido.Theta(20*u.arcmin, 89*u.deg), a.kisfido.Mu(0.1, 1),
a.kisfido.ExposureTime(*([5, 60]*u.min)),
a.kisfido.HelioProjLon(5*u.arcsec), a.kisfido.HelioProjLat(9*u.arcsec),
a.kisfido.SpatialResolution(0.1*u.arcsec, 0.8*u.arcsec),
a.kisfido.SpectralResolution(6000, 200000),
a.kisfido.TemporalResolution(2*u.s, 30*u.s),
a.kisfido.NDimensions(1, 2), a.kisfido.PolXel(2, 4),
a.kisfido.SpatialXel1(200, 3000), a.kisfido.SpatialXel2(100, 4000),
a.kisfido.SpectralXel(320, 4096), a.kisfido.TimeXel(60, 86400)))
def test_all_queries(client, query):
"""Test an example of all supported query attributes with automatic field names."""
assert client._can_handle_query(a.Instrument("GRIS"), query)
......@@ -514,7 +514,7 @@ def test_full_range(client):
client.search(query)
# Test with inverted `min`, `max` inputs.
hplt = a.sdc.HelioProjLat(0.1*u.arcmin, -2*u.arcsec)
hplt = a.kisfido.HelioProjLat(0.1*u.arcmin, -2*u.arcsec)
query = a.Instrument("LARS") & hplt
if HAS_DOCKERTEST:
res = client.search(query)
......
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