arvi 0.2.8__py3-none-any.whl → 0.2.11__py3-none-any.whl
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.
- arvi/dace_wrapper.py +10 -6
- arvi/instrument_specific.py +23 -9
- arvi/kepmodel_wrapper.py +296 -0
- arvi/nasaexo_wrapper.py +7 -3
- arvi/plots.py +1 -3
- arvi/reports.py +108 -1
- arvi/stats.py +30 -5
- arvi/timeseries.py +316 -120
- arvi/utils.py +132 -8
- {arvi-0.2.8.dist-info → arvi-0.2.11.dist-info}/METADATA +1 -1
- {arvi-0.2.8.dist-info → arvi-0.2.11.dist-info}/RECORD +14 -13
- {arvi-0.2.8.dist-info → arvi-0.2.11.dist-info}/WHEEL +0 -0
- {arvi-0.2.8.dist-info → arvi-0.2.11.dist-info}/licenses/LICENSE +0 -0
- {arvi-0.2.8.dist-info → arvi-0.2.11.dist-info}/top_level.txt +0 -0
arvi/utils.py
CHANGED
|
@@ -2,6 +2,9 @@ import os
|
|
|
2
2
|
import sys
|
|
3
3
|
import time
|
|
4
4
|
from contextlib import contextmanager
|
|
5
|
+
from functools import partial
|
|
6
|
+
from collections import defaultdict
|
|
7
|
+
|
|
5
8
|
try:
|
|
6
9
|
from unittest.mock import patch
|
|
7
10
|
except ImportError:
|
|
@@ -67,6 +70,50 @@ def all_logging_disabled():
|
|
|
67
70
|
logging.disable(previous_level)
|
|
68
71
|
|
|
69
72
|
|
|
73
|
+
class record_removals:
|
|
74
|
+
def __init__(self, s, storage=None):
|
|
75
|
+
"""
|
|
76
|
+
A simple context manager to record removed files
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
s (RV):
|
|
80
|
+
An `RV` object
|
|
81
|
+
storage (dict):
|
|
82
|
+
A dictionary to store the removed files, with keys 'raw_file'
|
|
83
|
+
and 'reason' as lists.
|
|
84
|
+
|
|
85
|
+
Examples:
|
|
86
|
+
>>> with record_removals(s) as rec:
|
|
87
|
+
: s.remove_instrument('HARPS')
|
|
88
|
+
: rec.store('removed HARPS')
|
|
89
|
+
>>> rec.storage
|
|
90
|
+
"""
|
|
91
|
+
self.s = s
|
|
92
|
+
if storage is None:
|
|
93
|
+
self.storage = defaultdict(list)
|
|
94
|
+
else:
|
|
95
|
+
if 'raw_file' not in storage:
|
|
96
|
+
storage['raw_file'] = []
|
|
97
|
+
if 'reason' not in storage:
|
|
98
|
+
storage['reason'] = []
|
|
99
|
+
self.storage = storage
|
|
100
|
+
self.raw_file_start = self.s.raw_file.copy()
|
|
101
|
+
|
|
102
|
+
def store(self, reason):
|
|
103
|
+
missing = ~ np.isin(self.raw_file_start, self.s.raw_file[self.s.mask])
|
|
104
|
+
if missing.any():
|
|
105
|
+
lost = self.raw_file_start[missing]
|
|
106
|
+
self.storage['raw_file'].extend(lost)
|
|
107
|
+
self.storage['reason'].extend(len(lost) * [reason])
|
|
108
|
+
self.raw_file_start = self.s.raw_file[self.s.mask].copy()
|
|
109
|
+
|
|
110
|
+
def __enter__(self):
|
|
111
|
+
return self
|
|
112
|
+
|
|
113
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
114
|
+
pass
|
|
115
|
+
|
|
116
|
+
|
|
70
117
|
@contextmanager
|
|
71
118
|
def timer(name=None):
|
|
72
119
|
""" A simple context manager to time a block of code """
|
|
@@ -98,8 +145,9 @@ def sanitize_path(path):
|
|
|
98
145
|
path = path.replace('*', '_')
|
|
99
146
|
return path
|
|
100
147
|
|
|
101
|
-
def pretty_print_table(rows, line_between_rows=True,
|
|
102
|
-
|
|
148
|
+
def pretty_print_table(rows, line_between_rows=True, string=False,
|
|
149
|
+
markdown=False, latex=False, logger=None):
|
|
150
|
+
r"""
|
|
103
151
|
Example Output
|
|
104
152
|
┌──────┬─────────────┬────┬───────┐
|
|
105
153
|
│ True │ short │ 77 │ catty │
|
|
@@ -110,25 +158,76 @@ def pretty_print_table(rows, line_between_rows=True, logger=None):
|
|
|
110
158
|
└──────┴─────────────┴────┴───────┘
|
|
111
159
|
"""
|
|
112
160
|
_print = logger.info if logger else print
|
|
161
|
+
if string:
|
|
162
|
+
def _print(x, s):
|
|
163
|
+
s += x + '\n'
|
|
164
|
+
return s
|
|
165
|
+
else:
|
|
166
|
+
if logger:
|
|
167
|
+
def _print(x, _):
|
|
168
|
+
logger.info(x)
|
|
169
|
+
else:
|
|
170
|
+
def _print(x, _):
|
|
171
|
+
print(x)
|
|
172
|
+
|
|
173
|
+
if latex or markdown:
|
|
174
|
+
line_between_rows = False
|
|
175
|
+
|
|
176
|
+
s = ''
|
|
113
177
|
|
|
114
178
|
# find the max length of each column
|
|
115
179
|
max_col_lens = list(map(max, zip(*[(len(str(cell)) for cell in row) for row in rows])))
|
|
116
180
|
|
|
181
|
+
if markdown:
|
|
182
|
+
bar_char = '|'
|
|
183
|
+
else:
|
|
184
|
+
bar_char = r'│'
|
|
185
|
+
|
|
117
186
|
# print the table's top border
|
|
118
|
-
|
|
187
|
+
if markdown:
|
|
188
|
+
pass
|
|
189
|
+
elif latex:
|
|
190
|
+
s = _print(r'\begin{table*}', s)
|
|
191
|
+
# s = _print(r'\centering', s)
|
|
192
|
+
s = _print(r'\begin{tabular}' + '{' + ' c ' * len(rows[0]) + '}', s)
|
|
193
|
+
else:
|
|
194
|
+
s = _print(r'┌' + r'┬'.join(r'─' * (n + 2) for n in max_col_lens) + r'┐', s)
|
|
119
195
|
|
|
120
|
-
|
|
196
|
+
if markdown:
|
|
197
|
+
header_separator = bar_char + bar_char.join('-' * (n + 2) for n in max_col_lens) + bar_char
|
|
121
198
|
|
|
122
|
-
|
|
199
|
+
rows_separator = r'├' + r'┼'.join(r'─' * (n + 2) for n in max_col_lens) + r'┤'
|
|
200
|
+
|
|
201
|
+
if latex:
|
|
202
|
+
row_fstring = ' & '.join("{: <%s}" % n for n in max_col_lens)
|
|
203
|
+
else:
|
|
204
|
+
row_fstring = bar_char.center(3).join("{: <%s}" % n for n in max_col_lens)
|
|
123
205
|
|
|
124
206
|
for i, row in enumerate(rows):
|
|
125
|
-
|
|
207
|
+
if markdown and i == 1:
|
|
208
|
+
s = _print(header_separator, s)
|
|
209
|
+
|
|
210
|
+
if latex:
|
|
211
|
+
s = _print(row_fstring.format(*map(str, row)) + r' \\', s)
|
|
212
|
+
else:
|
|
213
|
+
s = _print(bar_char + ' ' + row_fstring.format(*map(str, row)) + ' ' + bar_char, s)
|
|
126
214
|
|
|
215
|
+
|
|
127
216
|
if line_between_rows and i < len(rows) - 1:
|
|
128
|
-
_print(rows_separator)
|
|
217
|
+
s = _print(rows_separator, s)
|
|
218
|
+
|
|
129
219
|
|
|
130
220
|
# print the table's bottom border
|
|
131
|
-
|
|
221
|
+
if markdown:
|
|
222
|
+
pass
|
|
223
|
+
elif latex:
|
|
224
|
+
s = _print(r'\end{tabular}', s)
|
|
225
|
+
s = _print(r'\end{table*}', s)
|
|
226
|
+
else:
|
|
227
|
+
s = _print(r'└' + r'┴'.join(r'─' * (n + 2) for n in max_col_lens) + r'┘', s)
|
|
228
|
+
|
|
229
|
+
if string:
|
|
230
|
+
return s
|
|
132
231
|
|
|
133
232
|
|
|
134
233
|
def strtobool(val):
|
|
@@ -238,3 +337,28 @@ def get_object_fast(file):
|
|
|
238
337
|
value = f.read(20)
|
|
239
338
|
return value.decode().split("'")[1].strip()
|
|
240
339
|
|
|
340
|
+
|
|
341
|
+
def get_simbad_oid(self):
|
|
342
|
+
import requests
|
|
343
|
+
if isinstance(self, str):
|
|
344
|
+
star = self
|
|
345
|
+
else:
|
|
346
|
+
star = self.star
|
|
347
|
+
oid = requests.post('https://simbad.cds.unistra.fr/simbad/sim-tap/sync',
|
|
348
|
+
data=dict(format='text', request='doQuery', lang='adql', phase='run',
|
|
349
|
+
query=f"SELECT basic.OID FROM basic JOIN ident ON oidref = oid WHERE id = '{star}';"))
|
|
350
|
+
oid = oid.text.split()[-1]
|
|
351
|
+
return oid
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
# from https://stackoverflow.com/questions/37765197/darken-or-lighten-a-color-in-matplotlib
|
|
356
|
+
def adjust_lightness(color, amount=0.5):
|
|
357
|
+
import matplotlib.colors as mc
|
|
358
|
+
import colorsys
|
|
359
|
+
try:
|
|
360
|
+
c = mc.cnames[color]
|
|
361
|
+
except KeyError:
|
|
362
|
+
c = color
|
|
363
|
+
c = colorsys.rgb_to_hls(*mc.to_rgb(c))
|
|
364
|
+
return colorsys.hls_to_rgb(c[0], max(0, min(1, amount * c[1])), c[2])
|
|
@@ -4,35 +4,36 @@ arvi/ariadne_wrapper.py,sha256=YvilopJa9T4NwPcj3Nah_U8smSeSAU5-HYZMb_GJ-BQ,2232
|
|
|
4
4
|
arvi/berv.py,sha256=eKnpuPC1w45UrUEyFRbs9F9j3bXz3kxYzNXbnRgvFQM,17596
|
|
5
5
|
arvi/binning.py,sha256=NK9y9bUrdyWCbh79LkcRABHG-n5MtlETMHMvLj1z-OM,15437
|
|
6
6
|
arvi/config.py,sha256=JkHSwF-EEqwwbcc8thGgbFc9udDZPjQH-9XFjqDepBY,2337
|
|
7
|
-
arvi/dace_wrapper.py,sha256=
|
|
7
|
+
arvi/dace_wrapper.py,sha256=i3aIRKSc2MylEzM5WbbU-BnuLbz8JlG1ez6sK_vvQH0,26125
|
|
8
8
|
arvi/exofop_wrapper.py,sha256=8S7UEcrBAgANIweMV0-CvaWaVTPgGVo8vQQk_KRa0nU,2414
|
|
9
9
|
arvi/extra_data.py,sha256=Xi65pI5kkzqlMmHGl9xFoumtH699611pJJ5PV-a_IfU,3397
|
|
10
10
|
arvi/gaia_wrapper.py,sha256=HTuigIduin3raWfSC7QYuQxDk2dEXYH_4egRkzzg7Xw,4379
|
|
11
11
|
arvi/headers.py,sha256=uvdJebw1M5YkGjE3vJJwYBOnLikib75uuZE9FXB5JJM,1673
|
|
12
|
-
arvi/instrument_specific.py,sha256=
|
|
12
|
+
arvi/instrument_specific.py,sha256=94oMb6UeH6tp7H8YXnXHpxEhIz2evz0iYsT_HrNOCTo,12105
|
|
13
|
+
arvi/kepmodel_wrapper.py,sha256=mmHudetAZ4cBxKDwzQzgUydzkjhomCWw5VVuyiKfXq8,10288
|
|
13
14
|
arvi/kima_wrapper.py,sha256=GrAZWkDCg8ukhW41M1VTadSbab0GBa6BIzjtAtvjk58,3891
|
|
14
15
|
arvi/lbl_wrapper.py,sha256=_ViGVkpakvuBR_xhu9XJRV5EKHpj5Go6jBZGJZMIS2Y,11850
|
|
15
|
-
arvi/nasaexo_wrapper.py,sha256=
|
|
16
|
-
arvi/plots.py,sha256=
|
|
16
|
+
arvi/nasaexo_wrapper.py,sha256=ZKY3IUClqsJuysxDv0Gu51EnzMX7101zQb7UQy_urhI,7431
|
|
17
|
+
arvi/plots.py,sha256=U4VUNyIx4h_rEFd7ZWgBcawUcIGcURES0A4VXIBKp3U,35240
|
|
17
18
|
arvi/programs.py,sha256=M8o8hXr6W22dMiIX3Nxz4pgb8lsJXApDlq7HStyTfqs,9047
|
|
18
|
-
arvi/reports.py,sha256=
|
|
19
|
+
arvi/reports.py,sha256=a38EZNhyGoSSzJh63wBQCAt3_xhqbpVGcDOXaZWTLXs,11127
|
|
19
20
|
arvi/setup_logger.py,sha256=dHzO2gPjw6CaKWpYZd2f83z09tmxgi--qpp7k1jROjI,615
|
|
20
21
|
arvi/simbad_wrapper.py,sha256=uZc8mcfNijXsQi29LReRTabZb2hRPhYdLsDLMgq1OEI,9927
|
|
21
22
|
arvi/sophie_wrapper.py,sha256=KUeWccXud5_Lrx72S1HSemHIZRdjd2oLvqyofwsL0QQ,3440
|
|
22
23
|
arvi/spectra.py,sha256=ebF1ocodTastLx0CyqLSpE8EZNDXBF8riyfxMr3L6H0,7491
|
|
23
|
-
arvi/stats.py,sha256=
|
|
24
|
+
arvi/stats.py,sha256=gvMkKzP83AV8_Oi71JHmA8QH8Y1z1viYykV9ELVDqZI,3547
|
|
24
25
|
arvi/stellar.py,sha256=GQ7yweuBRnfkJ0M5eWjvLd8uvGq_by81PbXfidBvWis,4918
|
|
25
|
-
arvi/timeseries.py,sha256=
|
|
26
|
+
arvi/timeseries.py,sha256=suXPLmFlNbnFbfixXufNMwqwZWz-FwKdckJ1x2PtrXQ,104664
|
|
26
27
|
arvi/translations.py,sha256=PUSrn4zvYO2MqGzUxlFGwev_tBkgJaJrIYs6NKHzbWo,951
|
|
27
|
-
arvi/utils.py,sha256=
|
|
28
|
+
arvi/utils.py,sha256=MuAgjyXr297Sm_T6QmB1riVUktyT9ud1qngGMgKlXMc,10863
|
|
28
29
|
arvi/data/info.svg,sha256=0IMI6W-eFoTD8acnury79WJJakpBwLa4qKS4JWpsXiI,489
|
|
29
30
|
arvi/data/obs_affected_ADC_issues.dat,sha256=tn93uOL0eCTYhireqp1wG-_c3CbxPA7C-Rf-pejVY8M,10853
|
|
30
31
|
arvi/data/obs_affected_blue_cryostat_issues.dat,sha256=z4AK17xfz8tGTDv1FjRvQFnio4XA6PNNfDXuicewHk4,1771
|
|
31
32
|
arvi/data/extra/HD86226_PFS1.rdb,sha256=vfAozbrKHM_j8dYkCBJsuHyD01KEM1asghe2KInwVao,3475
|
|
32
33
|
arvi/data/extra/HD86226_PFS2.rdb,sha256=F2P7dB6gVyzCglUjNheB0hIHVClC5RmARrGwbrY1cfo,4114
|
|
33
34
|
arvi/data/extra/metadata.json,sha256=C69hIw6CohyES6BI9vDWjxwSz7N4VOYX0PCgjXtYFmU,178
|
|
34
|
-
arvi-0.2.
|
|
35
|
-
arvi-0.2.
|
|
36
|
-
arvi-0.2.
|
|
37
|
-
arvi-0.2.
|
|
38
|
-
arvi-0.2.
|
|
35
|
+
arvi-0.2.11.dist-info/licenses/LICENSE,sha256=6JfQgl7SpM55t0EHMFNMnNh-AdkpGW25MwMiTnhdWQg,1068
|
|
36
|
+
arvi-0.2.11.dist-info/METADATA,sha256=G2yojj2vhNVuEPtoY81O3aWPvgMMxNw5ax4_40zVhb8,1933
|
|
37
|
+
arvi-0.2.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
38
|
+
arvi-0.2.11.dist-info/top_level.txt,sha256=4EeiKDVLD45ztuflTGfQ3TU8GVjJg5Y95xS5XjI-utU,5
|
|
39
|
+
arvi-0.2.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|