Mosviz

class jdaviz.configs.mosviz.helper.Mosviz(*args, **kwargs)[source] [edit on github]

Bases: ConfigHelper, LineListMixin

Mosviz Helper class

Attributes Summary

specviz

A Specviz helper (Specviz) for the Jdaviz application that is wrapped by Mosviz.

specviz2d

A Specviz2d helper (Specviz2d) for the Jdaviz application that is wrapped by Mosviz.

Methods Summary

add_column(column_name[, data, show])

Add a new data column to the table.

get_column(column_name)

Get the data from a column in the table.

get_column_names([visible])

List the names of the columns in the table.

get_spectrum_1d([row, apply_slider_redshift])

Access a 1D spectrum for any row in the Table.

get_spectrum_2d([row, apply_slider_redshift])

Access a 2D spectrum for any row in the Table.

hide_column(column_name)

Hide a single column in the table.

link_table_data(data_obj)

Batch link data in the Mosviz table rather than doing it on data load.

load_1d_spectra(data_obj[, data_labels])

Load and parse a set of 1D spectra objects.

load_2d_spectra(data_obj[, data_labels])

Load and parse a set of 2D spectra objects.

load_data([spectra_1d, spectra_2d, images, ...])

Load and parse a set of MOS spectra and images.

load_images(data_obj[, data_labels, share_image])

Load and parse a set of image objects.

load_jwst_directory(data_obj[, data_labels, ...])

load_metadata(data_obj[, ids, spectra, sp1d])

Load and parse a set of FITS objects to extract any relevant metadata.

load_spectra(spectra_1d, spectra_2d)

Load 1D and 2D spectra using lists or strings to represent each.

load_spectra_from_directory(directory, ...)

Load 1D and 2D spectra from a directory.

set_visible_columns([column_names])

Set the columns to be visible in the table.

show_column(column_name)

Show a hidden column in the table.

to_csv([filename, selected, overwrite])

Creates a csv file with the contents of the MOS table viewer

to_table()

Creates an astropy QTable object from the MOS table viewer.

update_column(column_name, data[, row])

Update the data in an existing column.

Attributes Documentation

specviz

A Specviz helper (Specviz) for the Jdaviz application that is wrapped by Mosviz.

specviz2d

A Specviz2d helper (Specviz2d) for the Jdaviz application that is wrapped by Mosviz.

Methods Documentation

add_column(column_name, data=None, show=True)[source] [edit on github]

Add a new data column to the table.

If column_name is ‘Redshift’, the column will be synced with the redshift in the respective spectrum objects.

Parameters
column_namestr

Header string to be shown in the table. If already exists as a column in the table, the data for that column will be updated.

dataarray-like

Array-like set of data values, e.g. redshifts, RA, DEC, etc.

show: bool or None

Whether to show the column in the table (defaults to True). If None, will show if the column is new, otherwise will leave at current state.

Returns
array

copy of the data in the added or edited column.

get_column(column_name)[source] [edit on github]

Get the data from a column in the table.

Parameters
column_name: str

Header string of an existing column in the table.

Returns
array

copy of the data array.

get_column_names(visible=None)[source] [edit on github]

List the names of the columns in the table.

Parameters
visible: bool or None

If None (default): will show all available column names. If True: will only show columns names currently shown in the table. If False: will only show column names currently not shown in the table.

get_spectrum_1d(row=None, apply_slider_redshift='Warn')[source] [edit on github]

Access a 1D spectrum for any row in the Table.

Parameters
row: int or None

Row index in the Table. If not provided or None, will access from the currently selected row.

apply_slider_redshift: bool or “Warn”

Whether to apply the redshift in the Table to the returned Spectrum. If not provided or “Warn”, will apply the redshift but raise a warning.

Returns
Spectrum1D
get_spectrum_2d(row=None, apply_slider_redshift='Warn')[source] [edit on github]

Access a 2D spectrum for any row in the Table.

Parameters
row: int or None

Row index in the Table. If not provided or None, will access from the currently selected row.

apply_slider_redshift: bool or “Warn”

Whether to apply the redshift in the Table to the returned Spectrum. If not provided or “Warn”, will apply the redshift but raise a warning.

Returns
Spectrum1D
hide_column(column_name)[source] [edit on github]

Hide a single column in the table.

Parameters
column_name: str

Name of the column to hide

Batch link data in the Mosviz table rather than doing it on data load.

Parameters
data_objobj

Input for Mosviz data parsers.

load_1d_spectra(data_obj, data_labels=None)[source] [edit on github]

Load and parse a set of 1D spectra objects.

Parameters
data_objlist or str

A list of spectra as translatable container objects (e.g. Spectrum1D) that can be read by glue-jupyter. Alternatively, can be a string file path.

data_labelsstr or list

String representing the label for the data item loaded via data_obj. Can be a list of strings representing data labels for each item in data_obj if data_obj is a list.

load_2d_spectra(data_obj, data_labels=None)[source] [edit on github]

Load and parse a set of 2D spectra objects.

Parameters
data_objlist or str

A list of 2D spectra as translatable container objects (e.g. Spectrum1D) that can be read by glue-jupyter. Alternatively, can be a string file path.

data_labelsstr or list

String representing the label for the data item loaded via data_obj. Can be a list of strings representing data labels for each item in data_obj if data_obj is a list.

load_data(spectra_1d=None, spectra_2d=None, images=None, spectra_1d_label=None, spectra_2d_label=None, images_label=None, *args, **kwargs)[source] [edit on github]

Load and parse a set of MOS spectra and images.

Parameters
spectra_1dlist or str

A list of spectra as translatable container objects (e.g. Spectrum1D) that can be read by glue-jupyter. Alternatively, can be a string file path.

spectra_2dlist or str

A list of spectra as translatable container objects (e.g. Spectrum1D) that can be read by glue-jupyter. Alternatively, can be a string file path.

imageslist of obj, str, or None

A list of images as translatable container objects (string file path, FITS HDU, FITS HDUList, NDData, or numpy array). Alternatively, can be a string file path. If None, no images are displayed.

spectra_1d_labelstr or list

String representing the label for the data item loaded via spectra_1d. Can be a list of strings representing data labels for each item in spectra_1d if spectra_1d is a list.

spectra_2d_labelstr or list

String representing the label for the data item loaded via spectra_2d. Can be a list of strings representing data labels for each item in spectra_2d if spectra_2d is a list.

images_labelstr or list

String representing the label for the data item loaded via images. Can be a list of strings representing data labels for each item in images if images is a list.

directorystr, optional

Instead of loading lists of spectra and images, the path to a directory containing all files for a single JWST observation may be given.

instrument{‘niriss’, ‘nircam’, ‘nirspec’}, optional

Required if directory is specified. Value is not case sensitive.

load_images(data_obj, data_labels=None, share_image=0)[source] [edit on github]

Load and parse a set of image objects. If providing a file path, it must be readable by astropy.io.fits.

Parameters
data_objlist of obj, str, or None

A list of images as translatable container objects (FITS HDU, FITS HDUList, NDData, or numpy array). Alternatively, can be a string file path. If None, no images are displayed.

data_labelsstr or list

String representing the label for the data item loaded via data_obj. Can be a list of strings representing data labels for each item in data_obj if data_obj is a list.

share_imageint, optional

If 0, images are treated as applying to individual spectra. If non-zero, a single image will be shared by multiple spectra so that clicking a different row in the table does not reload the displayed image. Currently, if non-zero, the provided number must match the number of spectra.

load_jwst_directory(data_obj, data_labels=None, instrument=None)[source] [edit on github]
load_metadata(data_obj, ids=None, spectra=False, sp1d=False)[source] [edit on github]

Load and parse a set of FITS objects to extract any relevant metadata.

Parameters
data_objlist or str

A list of FITS objects with parseable headers. Alternatively, can be a string file path.

idslist of str

A list with identification strings to be used to label mosviz table rows. Typically, a list with file names.

spectraBoolean

In case the FITS objects are related to spectral data.

sp1dBoolean

In case the FITS objects are related to 1d spectral data.

load_spectra(spectra_1d, spectra_2d)[source] [edit on github]

Load 1D and 2D spectra using lists or strings to represent each.

Parameters
spectra_1dlist or str

A list of spectra as translatable container objects (e.g. Spectrum1D) that can be read by glue-jupyter. Alternatively, can be a string file path.

spectra_2dlist or str

A list of spectra as translatable container objects (e.g. Spectrum1D) that can be read by glue-jupyter. Alternatively, can be a string file path.

load_spectra_from_directory(directory, instrument)[source] [edit on github]

Load 1D and 2D spectra from a directory.

Parameters
directorystr

The path of the directory where Mosviz data is located.

instrumentstr

The instrument the Mosviz data originated from.

set_visible_columns(column_names=None)[source] [edit on github]

Set the columns to be visible in the table.

Parameters
column_names: list or None

list of columns to be visible in the table. If None, will default to original visible columns.

show_column(column_name)[source] [edit on github]

Show a hidden column in the table.

Parameters
column_name: str

Name of the column to show

to_csv(filename='MOS_data.csv', selected=False, overwrite=False)[source] [edit on github]

Creates a csv file with the contents of the MOS table viewer

Parameters
filename: str

Filename for the output CSV file.

selected: bool

If set to True, only the checked rows in the table will be output.

to_table()[source] [edit on github]

Creates an astropy QTable object from the MOS table viewer.

Returns
QTable

An astropy table constructed from the loaded mos data.

update_column(column_name, data, row=None)[source] [edit on github]

Update the data in an existing column.

If column_name is ‘Redshift’, the column will be synced with the redshift in the respective spectrum objects.

Parameters
column_name: str

Name of the existing column to update

data: array-like or float/int/string

Array-like set of data values or value at a single index (in which case row must be provided)

row: None or int

Index of the row to replace. If None, will replace entire column and data must be array-like with the appropriate length.

Returns
array

copy of the data in the edited column