adss 1.32__tar.gz → 1.34__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: adss
3
- Version: 1.32
3
+ Version: 1.34
4
4
  Summary: Astronomical Data Smart System
5
5
  Author-email: Gustavo Schwarz <gustavo.b.schwarz@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/schwarzam/adss
@@ -9,6 +9,7 @@ Requires-Python: >=3.8
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE
11
11
  Requires-Dist: pyarrow
12
+ Requires-Dist: httpx
12
13
  Requires-Dist: requests
13
14
  Requires-Dist: astropy
14
15
  Dynamic: license-file
@@ -213,5 +214,112 @@ cl.list_files(1) ## pass the collection ID
213
214
  You can then download a file by its filename:
214
215
 
215
216
  ```python
216
- cl.images.download_file("SPLUS-s17s23_F515_swpweight.fz", download_path=".")
217
+ file_bytes = cl.download_file(
218
+ file_id=28,
219
+ output_path=None
220
+ )
221
+ ```
222
+
223
+ Then handle the bytes. Example:
224
+
225
+ ```python
226
+ # if a fits you may open like
227
+ import io
228
+ from astropy.io import fits
229
+
230
+ hdul = fits.open(io.BytesIO(file_bytes))
231
+
232
+ # or a image
233
+ from PIL import Image
234
+ import matplotlib.pyplot as plt
235
+
236
+ image = Image.open(io.BytesIO(file_bytes))
237
+ plt.imshow(image)
238
+ ```
239
+
240
+ ### Image Tools
241
+
242
+ Now notice that (**if**) the image collection has some wcs parameters as `ra_center`, `dec_center`, `pixel_scale`. This allows us to do some image cutouts and colored images in real time. Example:
243
+
244
+ ```python
245
+ cutout_bytes = cl.create_stamp_by_coordinates(
246
+ collection_id = 1,
247
+ ra = 0.1,
248
+ dec = 0.1,
249
+ size = 300,
250
+ filter = "R",
251
+ size_unit="pixels",
252
+ format = "fits",
253
+ pattern="swp."
254
+ )
255
+
256
+ hdul = fits.open(BytesIO(cutout_bytes))
257
+ ```
258
+
259
+ or if the image collection has object_name info you may filter by it, forcing the cutout from that object:
260
+
261
+ ```python
262
+ cutout_bytes = cl.stamp_images.create_stamp_by_object(
263
+ collection_id=1,
264
+ object_name="STRIPE82-0002",
265
+ size=300,
266
+ ra=0.1,
267
+ dec=0.1,
268
+ filter_name="R",
269
+ size_unit="pixels",
270
+ format="fits"
271
+ )
272
+ cutout = fits.open(BytesIO(cutout_bytes))
273
+ ```
274
+
275
+ or just by file_id, this will force the cutout from that specific file:
276
+
277
+ ```python
278
+ cl.stamp_images.create_stamp(
279
+ file_id=28,
280
+ size=300,
281
+ ra=0.1,
282
+ dec=0.1,
283
+ size_unit="pixels",
284
+ format="fits"
285
+ )
286
+ ```
287
+
288
+ ### Colored images
289
+
290
+ Colored images API is very similar to the cutouts. You just need to provide a list of filters and the output format (png or jpg). Example with lupton et al. (2004) algorithm:
291
+
292
+ ```python
293
+ im_bytes = cl.create_rgb_image_by_coordinates(
294
+ collection_id=1,
295
+ ra=0.1,
296
+ dec=0.1,
297
+ size=300,
298
+ size_unit="pixels",
299
+ r_filter="I",
300
+ g_filter="R",
301
+ b_filter="G",
302
+ )
303
+
304
+ im = Image.open(BytesIO(im_bytes))
305
+ im.show()
306
+ ```
307
+
308
+ Or trilogy algorithm:
309
+
310
+ ```python
311
+ im_bytes = cl.trilogy_images.create_trilogy_rgb_by_coordinates(
312
+ collection_id=1,
313
+ ra=0.1,
314
+ dec=0.1,
315
+ size=300,
316
+ size_unit="pixels",
317
+ r_filters=["I", "R", "Z", "F861", "G"],
318
+ g_filters=["F660"],
319
+ b_filters=["U", "F378", "F395", "F410", "F430", "F515"],
320
+ satpercent=0.15,
321
+ )
322
+
323
+ im = Image.open(BytesIO(im_bytes))
324
+ im.show()
217
325
  ```
@@ -198,5 +198,112 @@ cl.list_files(1) ## pass the collection ID
198
198
  You can then download a file by its filename:
199
199
 
200
200
  ```python
201
- cl.images.download_file("SPLUS-s17s23_F515_swpweight.fz", download_path=".")
201
+ file_bytes = cl.download_file(
202
+ file_id=28,
203
+ output_path=None
204
+ )
205
+ ```
206
+
207
+ Then handle the bytes. Example:
208
+
209
+ ```python
210
+ # if a fits you may open like
211
+ import io
212
+ from astropy.io import fits
213
+
214
+ hdul = fits.open(io.BytesIO(file_bytes))
215
+
216
+ # or a image
217
+ from PIL import Image
218
+ import matplotlib.pyplot as plt
219
+
220
+ image = Image.open(io.BytesIO(file_bytes))
221
+ plt.imshow(image)
222
+ ```
223
+
224
+ ### Image Tools
225
+
226
+ Now notice that (**if**) the image collection has some wcs parameters as `ra_center`, `dec_center`, `pixel_scale`. This allows us to do some image cutouts and colored images in real time. Example:
227
+
228
+ ```python
229
+ cutout_bytes = cl.create_stamp_by_coordinates(
230
+ collection_id = 1,
231
+ ra = 0.1,
232
+ dec = 0.1,
233
+ size = 300,
234
+ filter = "R",
235
+ size_unit="pixels",
236
+ format = "fits",
237
+ pattern="swp."
238
+ )
239
+
240
+ hdul = fits.open(BytesIO(cutout_bytes))
241
+ ```
242
+
243
+ or if the image collection has object_name info you may filter by it, forcing the cutout from that object:
244
+
245
+ ```python
246
+ cutout_bytes = cl.stamp_images.create_stamp_by_object(
247
+ collection_id=1,
248
+ object_name="STRIPE82-0002",
249
+ size=300,
250
+ ra=0.1,
251
+ dec=0.1,
252
+ filter_name="R",
253
+ size_unit="pixels",
254
+ format="fits"
255
+ )
256
+ cutout = fits.open(BytesIO(cutout_bytes))
257
+ ```
258
+
259
+ or just by file_id, this will force the cutout from that specific file:
260
+
261
+ ```python
262
+ cl.stamp_images.create_stamp(
263
+ file_id=28,
264
+ size=300,
265
+ ra=0.1,
266
+ dec=0.1,
267
+ size_unit="pixels",
268
+ format="fits"
269
+ )
270
+ ```
271
+
272
+ ### Colored images
273
+
274
+ Colored images API is very similar to the cutouts. You just need to provide a list of filters and the output format (png or jpg). Example with lupton et al. (2004) algorithm:
275
+
276
+ ```python
277
+ im_bytes = cl.create_rgb_image_by_coordinates(
278
+ collection_id=1,
279
+ ra=0.1,
280
+ dec=0.1,
281
+ size=300,
282
+ size_unit="pixels",
283
+ r_filter="I",
284
+ g_filter="R",
285
+ b_filter="G",
286
+ )
287
+
288
+ im = Image.open(BytesIO(im_bytes))
289
+ im.show()
290
+ ```
291
+
292
+ Or trilogy algorithm:
293
+
294
+ ```python
295
+ im_bytes = cl.trilogy_images.create_trilogy_rgb_by_coordinates(
296
+ collection_id=1,
297
+ ra=0.1,
298
+ dec=0.1,
299
+ size=300,
300
+ size_unit="pixels",
301
+ r_filters=["I", "R", "Z", "F861", "G"],
302
+ g_filters=["F660"],
303
+ b_filters=["U", "F378", "F395", "F410", "F430", "F515"],
304
+ satpercent=0.15,
305
+ )
306
+
307
+ im = Image.open(BytesIO(im_bytes))
308
+ im.show()
202
309
  ```