timewise 0.4.9__py3-none-any.whl → 0.4.12__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.
- timewise/__init__.py +1 -1
- timewise/utils.py +53 -9
- timewise/wise_data_by_visit.py +7 -1
- {timewise-0.4.9.dist-info → timewise-0.4.12.dist-info}/METADATA +2 -2
- {timewise-0.4.9.dist-info → timewise-0.4.12.dist-info}/RECORD +8 -8
- {timewise-0.4.9.dist-info → timewise-0.4.12.dist-info}/WHEEL +1 -1
- {timewise-0.4.9.dist-info → timewise-0.4.12.dist-info}/LICENSE +0 -0
- {timewise-0.4.9.dist-info → timewise-0.4.12.dist-info}/entry_points.txt +0 -0
timewise/__init__.py
CHANGED
timewise/utils.py
CHANGED
|
@@ -12,6 +12,7 @@ from functools import cache
|
|
|
12
12
|
from astropy.table import Table
|
|
13
13
|
from PIL import Image
|
|
14
14
|
from io import BytesIO
|
|
15
|
+
import hashlib
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
from timewise.general import cache_dir, backoff_hndlr
|
|
@@ -146,6 +147,36 @@ def plot_sdss_cutout(ra, dec, arcsec=20, arcsec_per_px=0.1, interactive=False, f
|
|
|
146
147
|
#####################################################
|
|
147
148
|
|
|
148
149
|
|
|
150
|
+
class PanSTARRSQueryError(Exception):
|
|
151
|
+
pass
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def load_cache_or_download(url):
|
|
155
|
+
logger.debug(f"loading or downloading {url}")
|
|
156
|
+
h = hashlib.md5(url.encode()).hexdigest()
|
|
157
|
+
cache_file = os.path.join(cache_dir, h + ".cache")
|
|
158
|
+
logger.debug(f"cache file is {cache_file}")
|
|
159
|
+
if not os.path.isfile(cache_file):
|
|
160
|
+
logger.debug(f"downloading {url}")
|
|
161
|
+
r = requests.get(url)
|
|
162
|
+
with open(cache_file, 'wb') as f:
|
|
163
|
+
f.write(r.content)
|
|
164
|
+
return r.content
|
|
165
|
+
else:
|
|
166
|
+
logger.debug(f"loading {cache_file}")
|
|
167
|
+
with open(cache_file, 'rb') as f:
|
|
168
|
+
return f.read()
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def annotate_not_available(ax):
|
|
172
|
+
xlim = ax.get_xlim()
|
|
173
|
+
ylim = ax.get_ylim()
|
|
174
|
+
x = sum(xlim) / 2
|
|
175
|
+
y = sum(ylim) / 2
|
|
176
|
+
logger.debug(f"annotate_not_available at {x}, {y}")
|
|
177
|
+
ax.annotate("Outside\nPanSTARRS\nFootprint", (x, y), color='red', ha='center', va='center', fontsize=10)
|
|
178
|
+
|
|
179
|
+
|
|
149
180
|
def getimages(ra, dec, filters="grizy"):
|
|
150
181
|
"""Query ps1filenames.py service to get a list of images
|
|
151
182
|
|
|
@@ -157,7 +188,8 @@ def getimages(ra, dec, filters="grizy"):
|
|
|
157
188
|
|
|
158
189
|
service = "https://ps1images.stsci.edu/cgi-bin/ps1filenames.py"
|
|
159
190
|
url = f"{service}?ra={ra}&dec={dec}&filters={filters}"
|
|
160
|
-
|
|
191
|
+
content = load_cache_or_download(url)
|
|
192
|
+
table = Table.read(content.decode(), format='ascii')
|
|
161
193
|
return table
|
|
162
194
|
|
|
163
195
|
|
|
@@ -180,6 +212,8 @@ def geturl(ra, dec, size=240, output_size=None, filters="grizy", format="jpg", c
|
|
|
180
212
|
if format not in ("jpg", "png", "fits"):
|
|
181
213
|
raise ValueError("format must be one of jpg, png, fits")
|
|
182
214
|
table = getimages(ra, dec, filters=filters)
|
|
215
|
+
if len(table) == 0:
|
|
216
|
+
raise PanSTARRSQueryError("No images available")
|
|
183
217
|
url = (f"https://ps1images.stsci.edu/cgi-bin/fitscut.cgi?"
|
|
184
218
|
f"ra={ra}&dec={dec}&size={size}&format={format}")
|
|
185
219
|
if output_size:
|
|
@@ -216,8 +250,8 @@ def getcolorim(ra, dec, size=240, output_size=None, filters="grizy", format="jpg
|
|
|
216
250
|
if format not in ("jpg", "png"):
|
|
217
251
|
raise ValueError("format must be jpg or png")
|
|
218
252
|
url = geturl(ra, dec, size=size, filters=filters, output_size=output_size, format=format, color=True)
|
|
219
|
-
|
|
220
|
-
im = Image.open(BytesIO(
|
|
253
|
+
content = load_cache_or_download(url)
|
|
254
|
+
im = Image.open(BytesIO(content))
|
|
221
255
|
return im
|
|
222
256
|
|
|
223
257
|
|
|
@@ -238,8 +272,8 @@ def getgrayim(ra, dec, size=240, output_size=None, filter="g", format="jpg"):
|
|
|
238
272
|
if filter not in list("grizy"):
|
|
239
273
|
raise ValueError("filter must be one of grizy")
|
|
240
274
|
url = geturl(ra, dec, size=size, filters=filter, output_size=output_size, format=format)
|
|
241
|
-
|
|
242
|
-
im = Image.open(BytesIO(
|
|
275
|
+
content = load_cache_or_download(url[0])
|
|
276
|
+
im = Image.open(BytesIO(content))
|
|
243
277
|
return im
|
|
244
278
|
|
|
245
279
|
|
|
@@ -276,9 +310,14 @@ def plot_panstarrs_cutout(
|
|
|
276
310
|
axss = ax
|
|
277
311
|
|
|
278
312
|
for j, fil in enumerate(list(filters)):
|
|
279
|
-
im = getgrayim(ra, dec, size=ang_px, filter=fil)
|
|
280
313
|
axs = axss[1]
|
|
281
|
-
|
|
314
|
+
try:
|
|
315
|
+
im = getgrayim(ra, dec, size=ang_px, filter=fil)
|
|
316
|
+
axs[j].imshow(im, cmap='gray', **imshow_kwargs)
|
|
317
|
+
except PanSTARRSQueryError:
|
|
318
|
+
axs[j].set_xlim(-arcsec / 2, arcsec / 2)
|
|
319
|
+
axs[j].set_ylim(-arcsec / 2, arcsec / 2)
|
|
320
|
+
annotate_not_available(axs[j])
|
|
282
321
|
|
|
283
322
|
axs[j].scatter(*scatter_args, **scatter_kwargs)
|
|
284
323
|
axs[j].set_title(fil)
|
|
@@ -292,8 +331,13 @@ def plot_panstarrs_cutout(
|
|
|
292
331
|
fig = plt.gcf()
|
|
293
332
|
axss = ax
|
|
294
333
|
|
|
295
|
-
|
|
296
|
-
|
|
334
|
+
try:
|
|
335
|
+
im = getcolorim(ra, dec, size=ang_px)
|
|
336
|
+
axss.imshow(im, **imshow_kwargs)
|
|
337
|
+
except PanSTARRSQueryError:
|
|
338
|
+
axss.set_xlim(-arcsec / 2, arcsec / 2)
|
|
339
|
+
axss.set_ylim(-arcsec / 2, arcsec / 2)
|
|
340
|
+
annotate_not_available(axss)
|
|
297
341
|
axss.scatter(*scatter_args, **scatter_kwargs)
|
|
298
342
|
|
|
299
343
|
_this_title = title if title else f"{ra}_{dec}"
|
timewise/wise_data_by_visit.py
CHANGED
|
@@ -5,6 +5,8 @@ import logging
|
|
|
5
5
|
from scipy import stats
|
|
6
6
|
import matplotlib.pyplot as plt
|
|
7
7
|
from matplotlib.lines import Line2D
|
|
8
|
+
from matplotlib.markers import MarkerStyle
|
|
9
|
+
from matplotlib.transforms import Affine2D
|
|
8
10
|
|
|
9
11
|
from timewise.wise_data_base import WISEDataBase
|
|
10
12
|
from timewise.utils import get_excess_variance
|
|
@@ -538,7 +540,11 @@ class WiseDataByVisit(WISEDataBase):
|
|
|
538
540
|
)
|
|
539
541
|
|
|
540
542
|
# set markers for visits
|
|
541
|
-
|
|
543
|
+
markers_strings = list(Line2D.filled_markers) + ["$1$", "$2$", "$3$", "$4$", "$5$", "$6$", "$7$", "$8$", "$9$"]
|
|
544
|
+
markers_straight = [MarkerStyle(im) for im in markers_strings]
|
|
545
|
+
rot = Affine2D().rotate_deg(180)
|
|
546
|
+
markers_rotated = [MarkerStyle(im, transform=rot) for im in markers_strings]
|
|
547
|
+
markers = markers_straight + markers_rotated
|
|
542
548
|
|
|
543
549
|
# calculate ra and dec relative to center of cutout
|
|
544
550
|
ra = (lightcurve.ra - pos[self.parent_sample.default_keymap["ra"]]) * 3600
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
timewise/__init__.py,sha256=
|
|
1
|
+
timewise/__init__.py,sha256=gnpyn_jjCr_5brbB3Xi6G1eDotPNrlP6PINA-UAHGnM,204
|
|
2
2
|
timewise/big_parent_sample.py,sha256=B7w7TMJx2mohsVfY0RiBHQU9N6mn_MDqrB7Ica0aafU,3480
|
|
3
3
|
timewise/cli.py,sha256=LRBR3cOd_qBEpGkyP7tbJBCKvO0XxRQA8BgoMZfw08k,533
|
|
4
4
|
timewise/config_loader.py,sha256=gqu881fSoBIzK_-KSVSCDV1pLPuD_g0AHbWovKFtWEA,5675
|
|
5
5
|
timewise/general.py,sha256=cadgPIACEWpFsa4yncFb-nboGgXmJ1TicjPQalB_SAU,1472
|
|
6
6
|
timewise/parent_sample_base.py,sha256=fHRBS791w51JCEwkfrCMyzXSyyc94NNSu-J9AfRFf2E,3298
|
|
7
7
|
timewise/point_source_utils.py,sha256=4dmxfujrrNxDLkh2rVziSR-NNaHzrKFa8xgx_Lj-ZNE,2171
|
|
8
|
-
timewise/utils.py,sha256
|
|
8
|
+
timewise/utils.py,sha256=-tS5jrRnMYa7tosWvs_Jitjv8qPfi9VZE-o0-DMHKEQ,15144
|
|
9
9
|
timewise/wise_bigdata_desy_cluster.py,sha256=8Zd1jCgVpR8nefGrmHxFtyBasP2oaOZ04NXUuEikyhI,56173
|
|
10
10
|
timewise/wise_data_base.py,sha256=PrOhI7RtgVgdAaZKzGcmiFAIPhwLjg2aT_y9opG8DhQ,82744
|
|
11
|
-
timewise/wise_data_by_visit.py,sha256=
|
|
11
|
+
timewise/wise_data_by_visit.py,sha256=5fR5qaDz_liWJaBwnDhsEx--yoyh3oxPKKpXGpEsXmk,29129
|
|
12
12
|
timewise/wise_flux_conversion_correction.dat,sha256=XLnYqk0g1NVthVSNGsKlqinzKI7QUwJidO-qg4tHXKU,1095
|
|
13
|
-
timewise-0.4.
|
|
14
|
-
timewise-0.4.
|
|
15
|
-
timewise-0.4.
|
|
16
|
-
timewise-0.4.
|
|
17
|
-
timewise-0.4.
|
|
13
|
+
timewise-0.4.12.dist-info/LICENSE,sha256=sVoNJWiTlH-NarJx0wdsob468Pg3JE6vIIgll4lCa3E,1070
|
|
14
|
+
timewise-0.4.12.dist-info/METADATA,sha256=s4qqipfvBVCdeFyTy5ko5d7dsjXlXYPFWOcpHFEdFoc,2496
|
|
15
|
+
timewise-0.4.12.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
|
16
|
+
timewise-0.4.12.dist-info/entry_points.txt,sha256=yIWgzM0CZCJBrSR9-zbQW9d8MpFae0KlRVnZXF8rZow,54
|
|
17
|
+
timewise-0.4.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|