Skip to content

Commit 6169398

Browse files
FIREFLY-1623: Add url param to show_table (and fits)
Also add it to documentation
1 parent d2018de commit 6169398

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

docs/usage/displaying-images.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,15 @@ It is possible to create a 3-color composite image using a list of dictionaries
221221
fc.show_fits_3color(threeC,
222222
plot_id='wise_m101',
223223
viewer_id='3C')
224+
225+
226+
Displaying Image from a URL
227+
---------------------------
228+
229+
If you have the URL of an image, you can pass it directly instead of
230+
downloading it and then uploading it to firefly:
231+
232+
.. code-block:: py
233+
234+
image_url = 'http://irsa.ipac.caltech.edu/ibe/data/wise/allsky/4band_p1bm_frm/6a/02206a/149/02206a149-w1-int-1b.fits?center=70,20&size=200pix'
235+
fc.show_fits(url=image_url, plot_id='wise-allsky', title='WISE all-sky')

docs/usage/viewing-tables.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,10 @@ the table overlaid on the image, `is_catalog=False` can be specified:
2626
2727
fc.show_table(file_on_server=tval, tbl_id='2mass-tbl', is_catalog=False)
2828
29+
If you have the URL of a table, you can pass it directly instead of
30+
downloading it and then uploading it to firefly:
31+
32+
.. code-block:: py
33+
34+
table_url = "http://irsa.ipac.caltech.edu/TAP/sync?FORMAT=IPAC_TABLE&QUERY=SELECT+*+FROM+fp_psc+WHERE+CONTAINS(POINT('J2000',ra,dec),CIRCLE('J2000',70.0,20.0,0.1))=1"
35+
fc.show_table(url=table_url, tbl_id='2mass-point-source-catalog')

firefly_client/firefly_client.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ def show_fits(self, file_on_server=None, plot_id=None, viewer_id=None, **additio
732732
Display only a particular image extension from the file (zero-based index).
733733
**Title** : `str`, optional
734734
Title to display with the image.
735+
**url** : `str`, optional
736+
URL of the fits image file, if it's not a local file you can upload.
735737
736738
Returns
737739
-------
@@ -803,18 +805,20 @@ def show_fits_3color(self, three_color_params, plot_id=None, viewer_id=None):
803805
warning and r.update({'warning': warning})
804806
return r
805807

806-
def show_table(self, file_on_server=None, tbl_id=None, title=None, page_size=100, is_catalog=True,
808+
def show_table(self, file_on_server=None, url=None, tbl_id=None, title=None, page_size=100, is_catalog=True,
807809
meta=None, target_search_info=None, options=None, table_index=None,
808810
column_spec=None, filters=None, visible=True):
809811
"""
810812
Show a table.
811813
812814
Parameters
813815
----------
814-
file_on_server : `str`
816+
file_on_server : `str`, optional
815817
The name of the file on the server.
816818
If you use `upload_file()`, then it is the return value of the method. Otherwise it is a file that
817819
Firefly has direct access to.
820+
url : `str`, optional
821+
URL of the table file, if it's not a local file you can upload.
818822
tbl_id : `str`, optional
819823
A table ID. It will be created automatically if not specified.
820824
title : `str`, optional
@@ -872,28 +876,32 @@ def show_table(self, file_on_server=None, tbl_id=None, title=None, page_size=100
872876
A string specifying filters. Column names must be quoted.
873877
For example, '("coord_dec" > -0.478) and ("parent" > 0)'.
874878
visible: `bool`, optional
875-
If false, only load the table to Firefly but don't show it in the UI
879+
If false, only load the table to Firefly but don't show it in the UI.
880+
Similar to `fetch_table()`
876881
877882
Returns
878883
-------
879884
out : `dict`
880885
Status of the request, like {'success': True}.
881886
882-
.. note:: `file_on_server` and `target_search_info` are exclusively required.
887+
.. note:: `url`, `file_on_server`, and `target_search_info` are exclusively required.
888+
If more than one of these 3 parameters are passed, precedence order is:
889+
`url` > `file_on_server` > `target_search_info`
883890
"""
884891

885892
if not tbl_id:
886893
tbl_id = gen_item_id('Table')
887894
if not title:
888-
title = tbl_id if file_on_server else target_search_info.get('catalog', tbl_id)
895+
title = tbl_id if file_on_server or url else target_search_info.get('catalog', tbl_id)
889896

890897
meta_info = {'title': title, 'tbl_id': tbl_id}
891898
meta and meta_info.update(meta)
892899

893900
tbl_req = {'startIdx': 0, 'pageSize': page_size, 'tbl_id': tbl_id}
894-
if file_on_server:
901+
if file_on_server or url:
895902
tbl_type = 'table' if not is_catalog else 'catalog'
896-
tbl_req.update({'source': file_on_server, 'tblType': tbl_type,
903+
source = url if url else file_on_server
904+
tbl_req.update({'source': source, 'tblType': tbl_type,
897905
'id': 'IpacTableFromSource'})
898906
table_index and tbl_req.update({'tbl_index': table_index})
899907
elif target_search_info:
@@ -941,7 +949,6 @@ def fetch_table(self, file_on_server, tbl_id=None, title=None, page_size=1, tabl
941949
out : `dict`
942950
Status of the request, like {'success': True}.
943951
"""
944-
945952
if not tbl_id:
946953
tbl_id = gen_item_id('Table')
947954
if not title:

0 commit comments

Comments
 (0)