astro-otter 0.3.5__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of astro-otter might be problematic. Click here for more details.
- {astro_otter-0.3.5/src/astro_otter.egg-info → astro_otter-0.4.1}/PKG-INFO +1 -1
- {astro_otter-0.3.5 → astro_otter-0.4.1/src/astro_otter.egg-info}/PKG-INFO +1 -1
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/otter/_version.py +1 -1
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/otter/io/otter.py +14 -14
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/otter/io/transient.py +10 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/tests/test_data_finder.py +1 -1
- {astro_otter-0.3.5 → astro_otter-0.4.1}/tests/test_otter.py +67 -1
- {astro_otter-0.3.5 → astro_otter-0.4.1}/tests/test_transient.py +11 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/LICENSE +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/README.md +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/pyproject.toml +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/setup.cfg +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/astro_otter.egg-info/SOURCES.txt +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/astro_otter.egg-info/dependency_links.txt +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/astro_otter.egg-info/requires.txt +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/astro_otter.egg-info/top_level.txt +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/otter/__init__.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/otter/exceptions.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/otter/io/__init__.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/otter/io/data_finder.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/otter/io/host.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/otter/plotter/__init__.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/otter/plotter/otter_plotter.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/otter/plotter/plotter.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/otter/schema.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/src/otter/util.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/tests/test_exceptions.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/tests/test_host.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/tests/test_package.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/tests/test_plotter.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/tests/test_schema.py +0 -0
- {astro_otter-0.3.5 → astro_otter-0.4.1}/tests/test_util.py +0 -0
|
@@ -63,15 +63,15 @@ class Otter(Database):
|
|
|
63
63
|
|
|
64
64
|
def __init__(
|
|
65
65
|
self,
|
|
66
|
-
url: str = "
|
|
66
|
+
url: str = "https://otter.idies.jhu.edu/api",
|
|
67
67
|
username: str = os.environ.get("ARANGO_USER_USERNAME", "user-guest"),
|
|
68
|
-
password: str = os.environ.get("ARANGO_USER_PASSWORD", ""),
|
|
68
|
+
password: str = os.environ.get("ARANGO_USER_PASSWORD", "test"),
|
|
69
69
|
gen_summary: bool = False,
|
|
70
70
|
datadir: str = None,
|
|
71
71
|
debug: bool = False,
|
|
72
72
|
**kwargs,
|
|
73
73
|
) -> None:
|
|
74
|
-
print("Attempting to login with the following credentials:")
|
|
74
|
+
print(f"Attempting to login to {url} with the following credentials:")
|
|
75
75
|
print(f"username: {username}")
|
|
76
76
|
print(f"password: {password}")
|
|
77
77
|
|
|
@@ -85,9 +85,6 @@ class Otter(Database):
|
|
|
85
85
|
|
|
86
86
|
self.debug = debug
|
|
87
87
|
|
|
88
|
-
if gen_summary:
|
|
89
|
-
self.generate_summary_table(save=True)
|
|
90
|
-
|
|
91
88
|
# make sure the data directory exists
|
|
92
89
|
if not os.path.exists(self.DATADIR):
|
|
93
90
|
try:
|
|
@@ -99,6 +96,9 @@ class Otter(Database):
|
|
|
99
96
|
)
|
|
100
97
|
pass
|
|
101
98
|
|
|
99
|
+
if gen_summary:
|
|
100
|
+
self.generate_summary_table(save=True)
|
|
101
|
+
|
|
102
102
|
connection = Connection(username=username, password=password, arangoURL=url)
|
|
103
103
|
super().__init__(connection, "otter", **kwargs)
|
|
104
104
|
|
|
@@ -943,7 +943,7 @@ class Otter(Database):
|
|
|
943
943
|
|
|
944
944
|
# merge the meta and phot data
|
|
945
945
|
if phot is not None:
|
|
946
|
-
data = pd.merge(phot, meta, on="name", how="
|
|
946
|
+
data = pd.merge(phot, meta, on="name", how="outer")
|
|
947
947
|
else:
|
|
948
948
|
data = meta
|
|
949
949
|
|
|
@@ -951,11 +951,11 @@ class Otter(Database):
|
|
|
951
951
|
assert (
|
|
952
952
|
len(data[pd.isna(data.ra)].name.unique()) == 0
|
|
953
953
|
), "Missing some RA and Decs, please check the input files!"
|
|
954
|
-
if phot is not None:
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
954
|
+
# if phot is not None:
|
|
955
|
+
# for name in meta.name:
|
|
956
|
+
# assert len(data[data.name == name]) == len(
|
|
957
|
+
# phot[phot.name == name]
|
|
958
|
+
# ), f"failed on {name}"
|
|
959
959
|
|
|
960
960
|
# actually do the data conversion to OTTER
|
|
961
961
|
all_jsons = []
|
|
@@ -1084,7 +1084,7 @@ class Otter(Database):
|
|
|
1084
1084
|
# skip the photometry code if there is no photometry file
|
|
1085
1085
|
# if there is a photometry file then we want to convert it below
|
|
1086
1086
|
phot_sources = []
|
|
1087
|
-
if phot is not None:
|
|
1087
|
+
if phot is not None and not np.all(pd.isna(tde["flux"])):
|
|
1088
1088
|
tde["obs_type"] = [
|
|
1089
1089
|
freq_to_obstype(vv * u.Unit(uu))
|
|
1090
1090
|
for vv, uu in zip(
|
|
@@ -1531,7 +1531,7 @@ class Otter(Database):
|
|
|
1531
1531
|
all_jsons.append(Transient(json))
|
|
1532
1532
|
|
|
1533
1533
|
if db is None:
|
|
1534
|
-
db = Otter(datadir=local_outpath)
|
|
1534
|
+
db = Otter(datadir=local_outpath, gen_summary=True)
|
|
1535
1535
|
else:
|
|
1536
1536
|
db.DATADIR = local_outpath
|
|
1537
1537
|
|
|
@@ -432,6 +432,16 @@ class Transient(MutableMapping):
|
|
|
432
432
|
if "host" in self:
|
|
433
433
|
max_hosts = min([max_hosts, len(self["host"])])
|
|
434
434
|
for h in self["host"][:max_hosts]:
|
|
435
|
+
# only return hosts with their ra and dec stored
|
|
436
|
+
if (
|
|
437
|
+
"host_ra" not in h
|
|
438
|
+
or "host_dec" not in h
|
|
439
|
+
or "host_ra_units" not in h
|
|
440
|
+
or "host_dec_units" not in h
|
|
441
|
+
):
|
|
442
|
+
continue
|
|
443
|
+
|
|
444
|
+
# now we can construct a host object from this
|
|
435
445
|
host.append(Host(transient_name=self.default_name, **dict(h)))
|
|
436
446
|
|
|
437
447
|
# then try BLAST
|
|
@@ -23,6 +23,18 @@ def test_otter_constructor():
|
|
|
23
23
|
db = Otter(url=OTTER_URL, password=OTTER_TEST_PASSWORD)
|
|
24
24
|
assert isinstance(db, Otter)
|
|
25
25
|
|
|
26
|
+
# and using a custom local directory
|
|
27
|
+
otter_test_dir = os.path.join(os.getcwd(), "otter-test")
|
|
28
|
+
db = Otter(
|
|
29
|
+
url=OTTER_URL,
|
|
30
|
+
password=OTTER_TEST_PASSWORD,
|
|
31
|
+
datadir=otter_test_dir,
|
|
32
|
+
gen_summary=True,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
assert os.path.exists(otter_test_dir) # make sure it was created
|
|
36
|
+
assert isinstance(db, Otter)
|
|
37
|
+
|
|
26
38
|
|
|
27
39
|
def test_get_meta():
|
|
28
40
|
"""
|
|
@@ -87,7 +99,7 @@ def test_get_phot():
|
|
|
87
99
|
"reference",
|
|
88
100
|
]
|
|
89
101
|
|
|
90
|
-
names = ["2018hyz", "2018zr", "ASASSN-14li"]
|
|
102
|
+
names = ["2018hyz", "2018zr", "ASASSN-14li", "2016fnl", "J123715"]
|
|
91
103
|
|
|
92
104
|
# first with returning an astropy table (the default)
|
|
93
105
|
allphot = db.get_phot(names=names)
|
|
@@ -107,6 +119,10 @@ def test_get_phot():
|
|
|
107
119
|
with pytest.raises(FailedQueryError):
|
|
108
120
|
db.get_phot(names="foo")
|
|
109
121
|
|
|
122
|
+
# some other random tests
|
|
123
|
+
with pytest.raises(OSError):
|
|
124
|
+
db.get_phot(names="ASASSN-14li", return_type="foobar")
|
|
125
|
+
|
|
110
126
|
|
|
111
127
|
def test_query():
|
|
112
128
|
"""
|
|
@@ -135,3 +151,53 @@ def test_query():
|
|
|
135
151
|
# test hasphot and hasspec
|
|
136
152
|
assert len(db.query(hasspec=True)) == 0
|
|
137
153
|
assert "ASASSN-20il" not in {t["name/default_name"] for t in db.query(hasphot=True)}
|
|
154
|
+
|
|
155
|
+
# test has_*_phot
|
|
156
|
+
assert len(db.query(has_radio_phot=True)) >= 92
|
|
157
|
+
assert len(db.query(has_xray_phot=True)) >= 35
|
|
158
|
+
assert len(db.query(has_uvoir_phot=True)) >= 120
|
|
159
|
+
assert len(db.query(has_radio_phot=True, has_xray_phot=True)) < len(
|
|
160
|
+
db.query(has_radio_phot=True)
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
# test classification related queries
|
|
164
|
+
assert len(db.query(spec_classed=True)) > 140
|
|
165
|
+
assert len(db.query(unambiguous=True)) > 190
|
|
166
|
+
assert len(db.query(classification="SLSN")) >= 1
|
|
167
|
+
|
|
168
|
+
# check that querying based on references works
|
|
169
|
+
fake_test_bibcodes = ["'tasdfasdf...lkjsfd'", "'asfd...kjasdf...lkjs'"]
|
|
170
|
+
assert len(db.query(refs=fake_test_bibcodes)) == 0
|
|
171
|
+
assert len(db.query(refs=fake_test_bibcodes[0])) == 0
|
|
172
|
+
|
|
173
|
+
# try querying with the fake "private" data
|
|
174
|
+
db2 = Otter(
|
|
175
|
+
url=OTTER_URL,
|
|
176
|
+
password=OTTER_TEST_PASSWORD,
|
|
177
|
+
datadir=os.path.join(
|
|
178
|
+
os.path.dirname(os.path.abspath(__file__)), "private_otter_data"
|
|
179
|
+
),
|
|
180
|
+
gen_summary=True,
|
|
181
|
+
)
|
|
182
|
+
res = db2.query(names="2018hyz", query_private=True)
|
|
183
|
+
assert res[0].default_name == "2018hyz"
|
|
184
|
+
|
|
185
|
+
# check that some errors are thrown when appropriate
|
|
186
|
+
with pytest.raises(Exception):
|
|
187
|
+
db.query(names=10)
|
|
188
|
+
db.query(refs=10)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def test_from_csvs():
|
|
192
|
+
"""
|
|
193
|
+
This tests the "from_csvs" method which allows for interaction with locally
|
|
194
|
+
stored datasets
|
|
195
|
+
"""
|
|
196
|
+
|
|
197
|
+
metapath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "meta-test.csv")
|
|
198
|
+
photpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "phot-test.csv")
|
|
199
|
+
outpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "from-csvs-out")
|
|
200
|
+
|
|
201
|
+
db = Otter.from_csvs(metafile=metapath, photfile=photpath, local_outpath=outpath)
|
|
202
|
+
|
|
203
|
+
assert isinstance(db, Otter)
|
|
@@ -31,6 +31,13 @@ def test_transient_constructor():
|
|
|
31
31
|
assert t.srcmap["2012MNRAS.421.1942W"] == "Wiersema et al. (2012)", srcmap_msg
|
|
32
32
|
assert t.srcmap["2011ApJ...737..103S"] == "Schlafly & Finkbeiner (2011)", srcmap_msg
|
|
33
33
|
|
|
34
|
+
with pytest.raises(AttributeError):
|
|
35
|
+
Transient(d={"name": {"default": "foo"}})
|
|
36
|
+
|
|
37
|
+
del test_json["name"]
|
|
38
|
+
t = Transient(test_json, name="SwJ1644+57")
|
|
39
|
+
assert t.default_name == "SwJ1644+57", "default_name is incorrect!"
|
|
40
|
+
|
|
34
41
|
|
|
35
42
|
def test_getitem():
|
|
36
43
|
"""
|
|
@@ -131,6 +138,10 @@ def test_iter():
|
|
|
131
138
|
"""
|
|
132
139
|
Test that my __iter__ overwrite works
|
|
133
140
|
"""
|
|
141
|
+
t = Transient({"test1": {"mytest": "nothing to see here", "other": 1}})
|
|
142
|
+
|
|
143
|
+
assert list(iter(t)) == list(iter(t.data))
|
|
144
|
+
|
|
134
145
|
true_vals = [
|
|
135
146
|
{"value": "Sw J1644+57", "reference": ["Swift"]},
|
|
136
147
|
{"value": "GRB 110328A", "reference": [["2011Sci...333..203B"]]},
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|