Mosviz#
- class jdaviz.configs.mosviz.helper.Mosviz(*args, **kwargs)[source]#
Bases:
ConfigHelper
,LineListMixin
Mosviz Helper class
Attributes Summary
A Specviz helper (
Specviz
) for the Jdaviz application that is wrapped by Mosviz.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_data
([data_label, spectral_subset, cls])Returns data with name equal to data_label of type cls with subsets applied from spectral_subset.
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, ...])Load and parse a set of image objects.
load_jwst_directory
(data_obj[, data_labels, ...])Load NIRISS or NIRCam data from a directory.
Parse the internal meta for our expected information
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
Methods Documentation
- add_column(column_name, data=None, show=True)[source]#
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]#
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]#
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_data(data_label=None, spectral_subset=None, cls=None)[source]#
Returns data with name equal to data_label of type cls with subsets applied from spectral_subset.
- Parameters:
- data_labelstr, optional
Provide a label to retrieve a specific data set from data_collection.
- spectral_subsetstr, optional
Spectral subset applied to data.
- cls
Spectrum1D
,CCDData
, optional The type that data will be returned as.
- Returns:
- datacls
Data is returned as type cls with subsets applied.
- get_spectrum_1d(row=None, apply_slider_redshift='Warn')[source]#
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:
- get_spectrum_2d(row=None, apply_slider_redshift='Warn')[source]#
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:
- hide_column(column_name)[source]#
Hide a single column in the table.
- Parameters:
- column_name: str
Name of the column to hide
- link_table_data(data_obj)[source]#
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, add_redshift_column=False)[source]#
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 indata_obj
ifdata_obj
is a list.- add_redshift_columnbool
Add redshift column to Mosviz table.
- Returns:
- n_specsint
Number of data objects loaded.
- load_2d_spectra(data_obj, data_labels=None, add_redshift_column=False)[source]#
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 indata_obj
ifdata_obj
is a list.- add_redshift_columnbool
Add redshift column to Mosviz table.
- Returns:
- n_specsint
Number of data objects loaded.
- load_data(spectra_1d=None, spectra_2d=None, images=None, spectra_1d_label=None, spectra_2d_label=None, images_label=None, directory=None, instrument=None)[source]#
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 inspectra_1d
ifspectra_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 inspectra_2d
ifspectra_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 inimages
ifimages
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. If this is provided, all the above inputs are ignored.
- instrument{‘niriss’, ‘nircam’, ‘nirspec’}, optional
Required and only used if
directory
is specified. Value is not case sensitive.
- load_images(data_obj, data_labels=None, share_image=0, add_redshift_column=False)[source]#
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 indata_obj
ifdata_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.
- add_redshift_columnbool
Add redshift column to Mosviz table.
- data_objlist of obj, str, or
- load_jwst_directory(data_obj, data_labels=None, instrument=None, add_redshift_column=False)[source]#
Load NIRISS or NIRCam data from a directory.
- load_spectra(spectra_1d, spectra_2d)[source]#
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]#
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]#
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]#
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]#
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]#
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]#
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