Imviz#
- class jdaviz.configs.imviz.helper.Imviz(*args, **kwargs)[source]#
Bases:
ImageConfigHelperImviz Helper class.
Methods Summary
create_image_viewer([viewer_name])Create a new image viewer.
destroy_viewer(viewer_id)Destroy a viewer associated with the given ID.
get_alignment_method(data_label_1, data_label_2)Find the type of
gluelinking between the given data labels.get_data([data_label, spatial_subset, cls])Returns data with name equal to data_label of type cls with subsets applied from spatial_subset.
get_link_type(data_label_1, data_label_2)link_data([align_by, wcs_fallback_scheme, ...])(Re)link loaded data in Imviz with the desired link type.
load([inp, loader, format, target])Load data into the app.
load_data(data[, data_label, ...])Methods Documentation
- create_image_viewer(viewer_name=None)[source]#
Create a new image viewer.
To display data in this new viewer programmatically, first get the new viewer ID from the small tab on the top left of viewer display. Then, use
add_data_to_viewer()fromimviz.appby passing in the new viewer ID and the desired data label, once per dataset you wish to display.Alternately, you can also display data interactively via the UI.
- Parameters:
- Returns:
- viewer
ImvizImageView Image viewer instance.
- viewer
- destroy_viewer(viewer_id)[source]#
Destroy a viewer associated with the given ID.
- Raises:
- ValueError
Default viewer cannot be destroyed.
- get_alignment_method(data_label_1, data_label_2)[source]#
Find the type of
gluelinking between the given data labels. A link is bi-directional. If there are more than 2 data in the collection, one of the given labels should be the reference data or look-up will fail.- Parameters:
- data_label_1, data_label_2str
Labels for the data linked together.
- Returns:
- align_by{‘pixels’, ‘wcs’, ‘self’}
One of the link types accepted by the Orientation plugin or
'self'if the labels are identical.
- Raises:
- ValueError
Link look-up failed.
- get_aperture_photometry_results()[source]#
Deprecated since version 4.2: The get_aperture_photometry_results function is deprecated and may be removed in a future version. Use plugins[‘Aperture Photometry’].export_table() instead.
- Return aperture photometry results, if any.
Results are calculated using Aperture Photometry plugin.
- get_catalog_source_results()[source]#
Deprecated since version 4.2: The get_catalog_source_results function is deprecated and may be removed in a future version. Use plugins[‘Catalog Search’].export_table() instead.
- Return table of sources given by querying from a catalog, if any.
Results are calculated using Catalog Search plugin.
- get_data(data_label=None, spatial_subset=None, cls=None)[source]#
Returns data with name equal to data_label of type cls with subsets applied from spatial_subset.
- Parameters:
- Returns:
- datacls
Data is returned as type cls with subsets applied.
- get_link_type(data_label_1, data_label_2)[source]#
Deprecated since version 4.0: The get_link_type function is deprecated and may be removed in a future version. Use get_alignment_method instead.
- link_data(align_by='pixels', wcs_fallback_scheme=None, wcs_fast_approximation=True)[source]#
(Re)link loaded data in Imviz with the desired link type. All existing links will be replaced.
- Parameters:
- align_by{‘pixels’, ‘wcs’}
Choose to link by pixels or WCS.
- wcs_fallback_scheme{None, ‘pixels’}
If WCS linking failed, choose to fall back to linking by pixels or not at all. This is only used when
align_by='wcs'. ChoosingNonemay result in some Imviz functionality not working properly.- wcs_fast_approximationbool
Use an affine transform to represent the offset between images if possible (requires that the approximation is accurate to within 1 pixel with the full WCS transformations). If approximation fails, it will automatically fall back to full WCS transformation. This is only used when
align_by='wcs'. Affine approximation is much more performant at the cost of accuracy.
- load(inp=None, loader=None, format=None, target=None, **kwargs)[source]#
Load data into the app. A single valid loader/importer must be able to be matched based on the input, otherwise an error will be raised suggesting what further information to provide. For an interactive approach, see
loaders.- Parameters:
- inpstring or object or None
Input filename, url, data object, etc.
- loaderstring, optional
Only consider a specific loader/resolver
- formatstring, optional
Only consider a specific format
- targetstring, optional
Only consider a specific target
- kwargs
Additional kwargs are passed on to both the loader and importer, as applicable. Any kwargs that do not match valid inputs are silently ignored.
- load_data(data, data_label=None, show_in_viewer=True, gwcs_to_fits_sip=False, **kwargs)[source]#
Deprecated since version 4.3: The load_data function is deprecated and may be removed in a future version. Use load instead.
Load data into Imviz.
- Parameters:
- dataobj or str
File name or object to be loaded. Supported formats include:
'filename.fits'(or any extension thatastropy.io.fitssupports; first image extension found is loaded unlessextkeyword is also given)'filename.fits[SCI]'(loads only first SCI extension)'filename.fits[SCI,2]'(loads the second SCI extension)'filename.jpg'(requiresscikit-image; grayscale only)'filename.png'(requiresscikit-image; grayscale only)JWST ASDF-in-FITS file (requires
stdatamodelsandgwcs;dataor givenext+ GWCS)Roman ASDF file or
roman_datamodels.datamodels.ImageModel(requiresroman-datamodels)HDUListobject (first image extension found is loaded unlessextkeyword is also given)ImageHDUobjectNDDataobject (2D only but may have unit, mask, or uncertainty attached)Numpy array (2D or 3D); if 3D, it will treat each slice at
axis=0as a separate image (limit is 16 slices), however loading too many slices will cause performance issue, so consider using Cubeviz instead.
- data_labelstr or
None Data label to go with the given data. If not given, this is automatically determined from filename or randomly generated. The final label shown in Imviz may have additional information appended for clarity.
- show_in_viewerstr or bool
If
True, show the data in default viewer. If a string, show in that viewer.- gwcs_to_fits_sipbool, optional
Try to convert GWCS coordinates into an approximate FITS SIP solution. Typical precision loss due to this approximation is of order 0.1 pixels. This may improve image rendering performance for images with expensive GWCS transformations. (Default: False)
- kwargsdict
Extra keywords to be passed into app-level parser. The only one you might call directly here is
ext(any FITS extension format supported byastropy.io.fits).
Notes
When loading image formats that support RGB color like JPG or PNG, the files are converted to greyscale. This is done following the algorithm of
skimage.color.rgb2gray(), which involves weighting the channels as0.2125 R + 0.7154 G + 0.0721 B. If you prefer a different weighting, you can useskimage.io.imread()to produce your own greyscale image as Numpy array and load the latter instead.