@@ -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 :
@@ -1908,3 +1915,55 @@ def remove_mask(self, plot_id, mask_id):
19081915
19091916 payload = {'plotId' : plot_id , 'imageOverlayId' : mask_id }
19101917 return self .dispatch (ACTION_DICT ['DeleteOverlayMask' ], payload )
1918+
1919+ # ----------------------------
1920+ # actions on table
1921+ # ----------------------------
1922+
1923+ def apply_table_filters (self , tbl_id , filters ):
1924+ """
1925+ Apply filters to a loaded table.
1926+
1927+ Parameters
1928+ ----------
1929+ plot_id : `str`
1930+ ID of the table where you want to apply filters
1931+ filters : `str`
1932+ SQL WHERE clause-like string specifying filters. Column names must be quoted.
1933+ For e.g. '("ra" > 185 AND "ra" < 185.1) OR ("dec" > 15 AND "dec" < 15.1) AND "band" IN (1,2)'.
1934+
1935+ Returns
1936+ --------
1937+ out : `dict`
1938+ Status of the request, like {'success': True}
1939+ """
1940+ tbl_req = {'tbl_id' : tbl_id , 'filters' : filters }
1941+ payload = {'request' : tbl_req }
1942+ return self .dispatch (ACTION_DICT ['TableFilter' ], payload )
1943+
1944+ def sort_table_column (self , tbl_id , column_name , sort_direction = '' ):
1945+ """
1946+ Sort a loaded table by a given column name.
1947+
1948+ Parameters
1949+ ----------
1950+ plot_id : `str`
1951+ ID of the table where you want to apply sort
1952+ column_name : `str`
1953+ Name of the table column to sort
1954+ sort_direction : {'', 'ASC', 'DESC'}, optional
1955+ Direction of sort: '' for unsorted (or for removing the sort),
1956+ 'ASC' for ascending, and 'DESC' for descending. Default is ''.
1957+
1958+ Returns
1959+ --------
1960+ out : `dict`
1961+ Status of the request, like {'success': True}
1962+ """
1963+ sort_directions = ['' , 'ASC' , 'DESC' ]
1964+ if sort_direction not in sort_directions :
1965+ raise ValueError (f'Invalid sort_direction. Valid values are { sort_directions } ' )
1966+
1967+ tbl_req = {'tbl_id' : tbl_id , 'sortInfo' : f'{ sort_direction } ,{ column_name } ' }
1968+ payload = {'request' : tbl_req }
1969+ return self .dispatch (ACTION_DICT ['TableSort' ], payload )
0 commit comments