Skip to content

Commit b01365f

Browse files
Merge pull request #307 from jaladh-singhal/euclid-phz-firefly-improv
Simplify & update firefly_client use in Euclid PHZ tutorial
2 parents 001d90c + 34f761c commit b01365f

1 file changed

Lines changed: 14 additions & 27 deletions

File tree

tutorials/euclid/4_Euclid_intro_PHZ_catalog.md

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ We rely on ``astroquery`` features that have been recently added, so please make
7373
```{code-cell} ipython3
7474
import os
7575
import re
76+
import io
7677
import urllib
7778
7879
import numpy as np
@@ -394,51 +395,37 @@ ax.imshow(cutout_galaxy.data, cmap='gray', origin='lower',
394395

395396
## 6. Load the image in Firefly for interactive exploration
396397

397-
+++
398-
399-
Save the data locally if you have not already done so, in order to upload to IRSA viewer.
398+
First we intialize the Firefly client as explained [here](https://caltech-ipac.github.io/firefly_client/usage/initializing-vanilla.html) so that we can send our data to Firefly for visualization.
400399

401400
```{code-cell} ipython3
402-
download_path = "data"
403-
if os.path.exists(download_path):
404-
print("Output directory already created.")
405-
else:
406-
print("Creating data directory.")
407-
os.mkdir(download_path)
401+
fc = FireflyClient.make_client('https://irsa.ipac.caltech.edu/irsaviewer')
408402
```
409403

410-
### Vizualize the image with Firefly
404+
### Vizualize the FITS image with Firefly
411405

412-
First initialize the client, then set the path to the image, upload it to firefly, load it and align with WCS.
406+
After initializing the client, we can directly use the FITS image file URL to visualise it in Firefy.
413407

414408
Note this can take a while to upload the full MER image.
415409

416410
```{code-cell} ipython3
417-
fc = FireflyClient.make_client('https://irsa.ipac.caltech.edu/irsaviewer')
418-
419-
fc.show_fits(url=filename)
420-
421-
fc.align_images(lock_match=True)
411+
fc.show_fits_image(filename)
422412
```
423413

424-
### Save the table as a CSV for Firefly upload
425-
426-
```{code-cell} ipython3
427-
csv_path = os.path.join(download_path, "mer_df.csv")
428-
result_galaxies.write(csv_path, format="csv")
429-
```
414+
### Display the table as an overlay on the FITS image
430415

431-
### Upload the CSV table to Firefly and display as an overlay on the FITS image
416+
Since our galaxies table is in memory, we write it to an IO stream (file-like object) for visualizing it in Firefly.
417+
Besides displaying the table, Firefly will also overlay the positions of the galaxies on the FITS image we visualized earlier.
418+
You can click on a table row to inspect the particular galaxy in the image, or click on an overlay marker to inspect the particular galaxy in the table.
432419

433420
```{code-cell} ipython3
434-
uploaded_table = fc.upload_file(csv_path)
435-
print(f"Uploaded Table URL: {uploaded_table}")
421+
tbl_stream = io.BytesIO()
422+
result_galaxies.write(tbl_stream, format='votable')
436423
437-
fc.show_table(uploaded_table)
424+
fc.show_table(tbl_stream)
438425
```
439426

440427
## About this Notebook
441428

442-
**Updated**: 2025-09-24
429+
**Updated**: 2026-04-29
443430

444431
**Contact:** [the IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions or reporting problems.

0 commit comments

Comments
 (0)