ytCube¶
- class spectral_cube.ytcube.ytCube(cube, dataset, spectral_factor=1.0)[source]¶
Bases:
object
Light wrapper of a yt object with ability to translate yt<->wcs coordinates
Methods Summary
auto_transfer_function
(cmap_range[, log, ...])quick_isocontour
([level, title, ...])Export isocontours to sketchfab
quick_render_movie
(outdir[, size, nframes, ...])Create a movie rotating the cube 360 degrees from PP -> PV -> PP -> PV -> PP
world2yt
(world_coord[, first_index])Convert a position in world coordinates to the coordinates used by a yt dataset that has been generated using the
to_yt
method.yt2world
(yt_coord[, first_index])Convert a position in yt's coordinates to world coordinates from a yt dataset that has been generated using the
to_yt
method.Methods Documentation
- quick_isocontour(level='3 sigma', title='', description='', color_map='hot', color_log=False, export_to='sketchfab', filename=None, **kwargs)[source]¶
Export isocontours to sketchfab
Requires that you have an account on https://sketchfab.com and are logged in
- Parameters:
- level: str or float
The level of the isocontours to create. Can be specified as n-sigma with strings like ‘3.3 sigma’ or ‘2 sigma’ (there must be a space between the number and the word)
- title: str
A title for the uploaded figure
- description: str
A short description for the uploaded figure
- color_map: str
Any valid colormap. See
yt.show_colormaps
- color_log: bool
Whether the colormap should be log scaled. With the default parameters, this has no effect.
- export_to: ‘sketchfab’, ‘obj’, ‘ply’
You can export to sketchfab, to a .obj file (and accompanying .mtl file), or a .ply file. The latter two require
filename
specification- filename: None or str
Optional - prefix for output filenames if
export_to
is ‘obj’, or the full filename whenexport_to
is ‘ply’. Ignored for ‘sketchfab’- kwargs: dict
Keyword arguments are passed to the appropriate yt function
- Returns:
- The result of the
yt.surface.export_sketchfab
function
- The result of the
- quick_render_movie(outdir, size=256, nframes=30, camera_angle=(0, 0, 1), north_vector=(0, 0, 1), rot_vector=(1, 0, 0), colormap='doom', cmap_range='auto', transfer_function='auto', start_index=0, image_prefix='', output_filename='out.mp4', log_scale=False, rescale=True)[source]¶
Create a movie rotating the cube 360 degrees from PP -> PV -> PP -> PV -> PP
- Parameters:
- outdir: str
The output directory in which the individual image frames and the resulting output mp4 file should be stored
- size: int
The size of the individual output frame in pixels (i.e., size=256 will result in a 256x256 image)
- nframes: int
The number of frames in the resulting movie
- camera_angle: 3-tuple
The initial angle of the camera
- north_vector: 3-tuple
The vector of ‘north’ in the data cube. Default is coincident with the spectral axis
- rot_vector: 3-tuple
The vector around which the camera will be rotated
- colormap: str
A valid colormap. See
yt.show_colormaps
- transfer_function: ‘auto’ or `yt.visualization.volume_rendering.TransferFunction`
Either ‘auto’ to use the colormap specified, or a valid TransferFunction instance
- log_scale: bool
Should the colormap be log scaled?
- rescale: bool
If True, the images will be rescaled to have a common 95th percentile brightness, which can help reduce flickering from having a single bright pixel in some projections
- start_indexint
The number of the first image to save
- image_prefixstr
A string to prepend to the image name for each image that is output
- output_filenamestr
The movie file name to output. The suffix may affect the file type created. Defaults to ‘out.mp4’. Will be placed in
outdir
- Returns:
- world2yt(world_coord, first_index=0)[source]¶
Convert a position in world coordinates to the coordinates used by a yt dataset that has been generated using the
to_yt
method.- Parameters:
- world_coord: `astropy.wcs.WCS.wcs_world2pix`-valid input
The world coordinates
- first_index: 0 or 1
The first index of the data. In python and yt, this should be zero, but for the FITS coordinates, use 1
- yt2world(yt_coord, first_index=0)[source]¶
Convert a position in yt’s coordinates to world coordinates from a yt dataset that has been generated using the
to_yt
method.- Parameters:
- world_coord: `astropy.wcs.WCS.wcs_pix2world`-valid input
The yt pixel coordinates to convert back to world coordinates
- first_index: 0 or 1
The first index of the data. In python and yt, this should be zero, but for the FITS coordinates, use 1