timewise 0.4.10__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 CHANGED
@@ -2,4 +2,4 @@ from timewise.wise_data_by_visit import WiseDataByVisit
2
2
  from timewise.wise_bigdata_desy_cluster import WISEDataDESYCluster
3
3
  from timewise.parent_sample_base import ParentSampleBase
4
4
 
5
- __version__ = "0.4.10"
5
+ __version__ = "0.4.12"
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
@@ -150,6 +151,23 @@ class PanSTARRSQueryError(Exception):
150
151
  pass
151
152
 
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
+
153
171
  def annotate_not_available(ax):
154
172
  xlim = ax.get_xlim()
155
173
  ylim = ax.get_ylim()
@@ -170,7 +188,8 @@ def getimages(ra, dec, filters="grizy"):
170
188
 
171
189
  service = "https://ps1images.stsci.edu/cgi-bin/ps1filenames.py"
172
190
  url = f"{service}?ra={ra}&dec={dec}&filters={filters}"
173
- table = Table.read(url, format='ascii')
191
+ content = load_cache_or_download(url)
192
+ table = Table.read(content.decode(), format='ascii')
174
193
  return table
175
194
 
176
195
 
@@ -231,8 +250,8 @@ def getcolorim(ra, dec, size=240, output_size=None, filters="grizy", format="jpg
231
250
  if format not in ("jpg", "png"):
232
251
  raise ValueError("format must be jpg or png")
233
252
  url = geturl(ra, dec, size=size, filters=filters, output_size=output_size, format=format, color=True)
234
- r = requests.get(url)
235
- im = Image.open(BytesIO(r.content))
253
+ content = load_cache_or_download(url)
254
+ im = Image.open(BytesIO(content))
236
255
  return im
237
256
 
238
257
 
@@ -253,8 +272,8 @@ def getgrayim(ra, dec, size=240, output_size=None, filter="g", format="jpg"):
253
272
  if filter not in list("grizy"):
254
273
  raise ValueError("filter must be one of grizy")
255
274
  url = geturl(ra, dec, size=size, filters=filter, output_size=output_size, format=format)
256
- r = requests.get(url[0])
257
- im = Image.open(BytesIO(r.content))
275
+ content = load_cache_or_download(url[0])
276
+ im = Image.open(BytesIO(content))
258
277
  return im
259
278
 
260
279
 
@@ -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
- markers = list(Line2D.filled_markers) + ["$1$", "$2$", "$3$", "$4$", "$5$", "$6$", "$7$", "$8$", "$9$"]
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,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: timewise
3
- Version: 0.4.10
3
+ Version: 0.4.12
4
4
  Summary: A small package to download infrared data from the WISE satellite
5
5
  Home-page: https://github.com/JannisNe/timewise
6
6
  License: MIT
@@ -1,17 +1,17 @@
1
- timewise/__init__.py,sha256=bpaFG17d5deZG7A2f0cudusG-8-rgHkfs1efXLC6F74,204
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=0EfB5cEmT25xe3c-YDr4pqkDwZQthVRJEXCE1z4Y6Eo,14476
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=e-tb_Zk_iEz0Jglzo-oKhQn244I6wKRramdtI-atGgY,28785
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.10.dist-info/LICENSE,sha256=sVoNJWiTlH-NarJx0wdsob468Pg3JE6vIIgll4lCa3E,1070
14
- timewise-0.4.10.dist-info/METADATA,sha256=O7ggTZMS4IpDnZ6t_gzpFMxrjMyi0_Jm5yEc2Edsoro,2496
15
- timewise-0.4.10.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
16
- timewise-0.4.10.dist-info/entry_points.txt,sha256=yIWgzM0CZCJBrSR9-zbQW9d8MpFae0KlRVnZXF8rZow,54
17
- timewise-0.4.10.dist-info/RECORD,,
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,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.8.1
2
+ Generator: poetry-core 2.0.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any