Displaying 3-Color FITS Images#
This notebook shows how to create a 3-color composite image (RGB) in Firefly.
Setup#
First, we create a FireflyClient instance and open a Firefly viewer. See Initializing a FireflyClient instance for more details.
[1]:
from firefly_client import FireflyClient
# Initialize a FireflyClient instance
fc = FireflyClient.make_client(url="https://irsa.ipac.caltech.edu/irsaviewer")
Show 3-color image#
A 3-color composite is built by providing per-band inputs to the show_fits_3color method.
This method accepts a three_color_params parameter, which takes a list of dictionaries (one per band) in the order [R, G, B]. The dictionary should have key names defined in FITS Plotting Parameters for the Firefly JavaScript. Key names can be case-insensitive.
Warning
The 3-color image creation from FireflyClient uses low-level API at the moment. Hence, show_fits_3color is not symmetric to the API of show_fits_image method and may be unstable (in some cases).
From a URL#
Provide url key in each band’s dictionary:
[2]:
# [W4, W3, W2] from WISE all-sky as [R, G, B]
rgb_urls = [f'https://irsa.ipac.caltech.edu/ibe/data/wise/allsky/4band_p1bm_frm/9a/05379a/141/05379a141-{band}-int-1b.fits'
for band in ['w4', 'w3', 'w2']]
[3]:
three_color_params = [
{
'url': url,
'title': '3 color image'
} for url in rgb_urls
]
fc.show_fits_3color(three_color_params=three_color_params,
plot_id='3color-img')
[3]:
{'success': True}
From a local file#
Provide file key in each band’s dictionary. The file value is the location on Firefly server instead of location on your machine, so it must be the return value of upload_file method.
[4]:
from astropy.utils.data import download_file
rgb_local_paths = [download_file(url, cache=True, timeout=120) for url in rgb_urls]
three_color_params = [
{
'file': fc.upload_file(fpath),
'title': '3 color image'
} for fpath in rgb_local_paths
]
[ ]:
fc.show_fits_3color(three_color_params=three_color_params,
plot_id='3color-img' # same id to replace previous image plot
)
{'success': True}
From IRSA-Specific Searches#
Since show_fits_3color uses low-level API, you can also retrieve images on-the-fly (instead of providing a url or local path) by utilizing Firefly’s image search processors that powers the IRSA archives. See more details in Retrieving Images Using IRSA-Specific Searches.
[6]:
rv = '92,-2,92,8,NaN,2,44,25,600,120'
ra = 202.4841667
dec = 47.23055556
target = f'{ra};{dec};EQ_J2000'
size_deg = 0.25
threeC = [
{
'Type': 'SERVICE',
'Service': 'WISE',
'Title': '3 color',
'SurveyKey': '3a',
'SurveyKeyBand': '4',
'WorldPt': target,
'RangeValues': rv,
'SizeInDeg': size_deg
},
{
'Type': 'SERVICE',
'Service': 'WISE',
'Title': '3 color',
'SurveyKey': '3a',
'SurveyKeyBand': '2',
'WorldPt': target,
'RangeValues': rv,
'SizeInDeg': size_deg
},
{
'Type': 'SERVICE',
'Service': 'WISE',
'Title': '3 color',
'SurveyKey': '3a',
'SurveyKeyBand': '1',
'WorldPt': target,
'RangeValues': rv,
'SizeInDeg': size_deg
}
]
fc.show_fits_3color(three_color_params=threeC,
plot_id='wise_m51')
[6]:
{'success': True}