vasca.tables

Module Contents

Classes

TableCollection

Collection of Table objects. Base calss for data storage classes in VASCA.

Data

API

vasca.tables.dimless = None
vasca.tables.FILE_DIR = 'dirname(...)'
vasca.tables.ROOT_DIR = None
class vasca.tables.TableCollection[source]

Collection of Table objects. Base calss for data storage classes in VASCA.

Initialization

static table_from_template(dd_data: dict, template_name: str) astropy.table.Table[source]

Creates a new astropy table.

Parameters:
  • dd_data (dict) – Data dictionaty with the key corresponding to the templates columns. Id data==None an empty template table is returned.

  • template_name (str) – Identifier to select a table template. Templates are selected by setting the class key and a corresponding table key in one string separated by a colon, e.g. template_name=<class_key>:<table_key>.

Return type:

Table

remove_tables(ll_table_names: list[str]) None[source]

Removes table from collection

Parameters:

ll_table_names (list[str]) – List with name of tables

add_table(data: list | numpy.ndarray, template_name: str) None[source]

Add a VASCA table to the colection

Parameters:
  • data (list, array-like) – Data of the table with shape (n, n_cols) or as dictionary with the key corresponding to the templates columns.

  • template_name (str) – Identifier to select a table template. Templates are selected by setting the class key and a corresponding table key in one string separated by a colon, e.g. template_name=<class_key>:<table_key>. If no “:” is in the templatename, assume that this is not a VASCA table, but proceed adding it to the collection anyhow. template_name will be used as a table name in that case. The available VASCA templates are defined in tables_dict.

remove_unselected(table_name: str) None[source]

Remove unselected rows from given table

Parameters:

table_name (str) – Table to delete the unselected rows from. Has to contain the “sel” column.

write_to_fits(file_name: str = 'tables.fits', overwrite: bool = True, fits_verify: str = 'fix') None[source]

Write tables and image of a collection to a fits file.

Parameters:
  • file_name (str, optional) – File name. The default is “field_default.fits”.

  • overwrite (bool, optional) – Overwrite existing file. The default is True.

  • fits_verfy (str, optional) – Verify if output is compatible with FITS format. Options are: ‘exception’, ‘ignore’, ‘fix’, ‘silentfix’, ‘warn’ See https://docs.astropy.org/en/stable/io/fits/api/verification.html The default is ‘warn’.

load_from_fits(file_name: str) None[source]

Loads collection from a fits file

Parameters:

file_name (str) – File name

info() None[source]

Print out information on tables in the collection.

__str__() str[source]

Return string with information about the collection.

select_from_config(dd_selections: dict) None[source]

Apply multiple selections at once.

Parameters:

dd_selections (dict) – Dictionary with selection table, variables and cut values

select_rows(selections: dict, remove_unselected: bool = False) None[source]

Apply selection to a passed table.

Parameters:
  • selections (dict) – Dictionary with selection table, variables and cut values

  • remove_unselected (bool, optional) – Remove table rows with entry False in ‘sel’ table.

get_light_curve(fd_src_ids: int | list[int] | None = None, rg_src_ids: int | list[int] | None = None, flux_var: str = 'flux') dict[source]

Get a light curves for one or list of sources, for regions or fields.

Parameters:
  • fd_src_ids (list, int, optional) – List or single field source IDs to plot. Default is None.

  • rg_src_ids (list, int, optional) – List or single region source IDs to plot. Default is None.

  • flux_var (str, optional) – Variable in table to be used to get flux Jy. Flux error assumed to be named flux_var+’_err’

Returns:

Dictionary {src_id : light_curve). Light curve as an astropy Table compatible with astropy BinnedTimeSeries.

Return type:

dict

cluster_meanshift(**ms_kw) int[source]

Apply MeanShift clustering algorithm using to derive sources. Runs only on selected detections or sources.

Parameters:

ms_kw (dict, optional) – Keywords passed to the scikit MeanShift function. Note that the bandwidth is assumed to be in units of arc seconds.

Returns:

Number of detected clusters.

Return type:

int

set_src_stats(src_id_name: str = 'fd_src_id') None[source]

Calculates source parameters from detections and stores them in the source table (tt_source).

Parameters:

src_id_name (str, optional) – Name of the src_id to calculate statistics for. ‘rg_src_id’ indicates operations being performed on vasca.region objects whereas ‘fd_src_id’ would indicate vasca.field objects.

set_hardness_ratio(obs_filter_id1: int = 1, obs_filter_id2: int = 2) None[source]

Calculated hardness ratio from detections flux(filter_2)/ flux(filter_1). Only simultaneous detections are considered

Parameters:
  • obs_filter_id1 (int, optional) – Observation filter ID1. The default is 1.

  • obs_filter_id2 (int, optional) – Observation filter ID2. The default is 1. The default is 2.

add_column(table_name: str, col_name: str, col_data: dict | numpy.ndarray | None = None) None[source]

Adds column in a table, using the predefined VASCA columns. If column exists already replace it.

Parameters:
  • table_name (str) – Name of the table.

  • col_name (str) – Name of the column

  • col_data (dict or np.ndarray) – Data to be inserted. If “None” use vasca.table_dict default value.

copy_table_columns(tab_name_to: str, tab_name_from: str, copy_vars: list[str], match_var: str = 'rg_src_id', select_matched: bool = False) None[source]

Copy a column from one table to the other, for those columns that have a matching variable value ‘match_variable’

Parameters:
  • tab_name_to (str) – Table name of tabla to copy into

  • tab_name_from (str) – Table name of tabla to copy into

  • copy_vars (list[str]) – Variable names of column to copy

  • match_var (str) – Variable name to match rows in tables

  • select_matched (bool) – Adjust the “sel” column in ‘tab_name_to’

cross_match(dist_max: astropy.units.Quantity = 1.5 * uu.arcsec, dist_s2n_max: float = 3, cat_table_name: str = 'tt_coadd_sources', cat_id_name: str = 'coadd_src_id', cat_name: str = 'coadd', src_table_name: str = 'tt_sources') None[source]

Cross match sources to a catalog by position. Typically this is the coadd catalog.

Parameters:
  • dist_max (Quantity, optional) – Maximum angular distance under which all associations are done, independent of dist_s2n. The default is “1 arcsec”.

  • dist_s2n_max (float, optional) – Maximum distance in units of position error. All sources below this cut are associated, independently of the dist_max selection.

  • cat_table_name (str, optional) – Catalog table name. Has to contain “ra”,”dec” (in deg), “flux” (in microJy) and “cat_id_name” columns. Marks associated catalog sources in the “sel” column of the catalog table, if it exists.

  • cat_id_name (str, optional) – Catalog ID Br. variable name. The default is “coadd_src_id”.

  • src_table_name (str, optional) – Table to cross match to catalog. The default is “tt_sources”.