@@ -732,6 +732,8 @@ def show_fits(self, file_on_server=None, plot_id=None, viewer_id=None, **additio
732
732
Display only a particular image extension from the file (zero-based index).
733
733
**Title** : `str`, optional
734
734
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.
735
737
736
738
Returns
737
739
-------
@@ -803,18 +805,20 @@ def show_fits_3color(self, three_color_params, plot_id=None, viewer_id=None):
803
805
warning and r .update ({'warning' : warning })
804
806
return r
805
807
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 ,
807
809
meta = None , target_search_info = None , options = None , table_index = None ,
808
810
column_spec = None , filters = None , visible = True ):
809
811
"""
810
812
Show a table.
811
813
812
814
Parameters
813
815
----------
814
- file_on_server : `str`
816
+ file_on_server : `str`, optional
815
817
The name of the file on the server.
816
818
If you use `upload_file()`, then it is the return value of the method. Otherwise it is a file that
817
819
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.
818
822
tbl_id : `str`, optional
819
823
A table ID. It will be created automatically if not specified.
820
824
title : `str`, optional
@@ -872,28 +876,32 @@ def show_table(self, file_on_server=None, tbl_id=None, title=None, page_size=100
872
876
A string specifying filters. Column names must be quoted.
873
877
For example, '("coord_dec" > -0.478) and ("parent" > 0)'.
874
878
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()`
876
881
877
882
Returns
878
883
-------
879
884
out : `dict`
880
885
Status of the request, like {'success': True}.
881
886
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`
883
890
"""
884
891
885
892
if not tbl_id :
886
893
tbl_id = gen_item_id ('Table' )
887
894
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 )
889
896
890
897
meta_info = {'title' : title , 'tbl_id' : tbl_id }
891
898
meta and meta_info .update (meta )
892
899
893
900
tbl_req = {'startIdx' : 0 , 'pageSize' : page_size , 'tbl_id' : tbl_id }
894
- if file_on_server :
901
+ if file_on_server or url :
895
902
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 ,
897
905
'id' : 'IpacTableFromSource' })
898
906
table_index and tbl_req .update ({'tbl_index' : table_index })
899
907
elif target_search_info :
@@ -941,7 +949,6 @@ def fetch_table(self, file_on_server, tbl_id=None, title=None, page_size=1, tabl
941
949
out : `dict`
942
950
Status of the request, like {'success': True}.
943
951
"""
944
-
945
952
if not tbl_id :
946
953
tbl_id = gen_item_id ('Table' )
947
954
if not title :
@@ -1908,3 +1915,55 @@ def remove_mask(self, plot_id, mask_id):
1908
1915
1909
1916
payload = {'plotId' : plot_id , 'imageOverlayId' : mask_id }
1910
1917
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