galaximview.galviewer module¶
- class galaximview.galviewer.GalViewer(sim_obj, step=1, ibeg=None, compstr=None, frac_3d_ini=0.05, adaptive_zoom_ini=True, rmax=60.0, nbins=256, ids=None, seed=None, figname='GalaXimView', coords_conv_type='astro', global_conv_type='astro', retrieve_current_2d_hist=False)[source]¶
Bases:
object
Particles simulations viewer to rotate particles, project them (2D surface density and mass-weighted quantities.) You can rotate the 3D view and obtain the 2D projection by pressing the “Set View” button. You can zoom in or out using your graphics backend usual buttons on the 2D projection and replot the 2D projection with the same number of bins as before zooming by pressing the ‘Set View’ button.
- Parameters
sim_obj (IterOnSim) – Simulation object, of class IterOnSim.
step (int, default = 1) – Interval between snapshots when in viewer.
ibeg (int or None, default = None) – Number of first snapshot viewed in viewer. If is None set to minimum snapshot number in simulation directory.
compstr (str or None, default = None) – Member of Snap.listcomps that viewer starts showing. If is None, the viewer selects an existing component.
frac_3d_ini (float in [0,1], default = 0.05) – Fraction of particles shown in the 3D plot, between 0 and 1. Defaults to 0.05, i.e. 5%.
adaptive_zoom_ini (bool, default = True) – If True, adapts limits of 2D and 3D plots to enclose most particles.
rmax (float, optional) – Size of initial 3D box and 2D projection if adaptive_zoom_ini is False. If adaptive_zoom_ini is False, 3D plot has x, y, and z in [-rmax, rmax] and 2D projection has x_projected and y_projected in [-rmax, rmax]. In default configuration, adpative_zoom_ini is True.
nbins (int, default = 256) – Initial number of bins in x_projected, for 2D projection.
ids (int ndarray, optional) – Specific particles identifiers (not fully developped).
seed (int, optional) – Specific eed for random generator, can be set to specific natural integer for reproduction.
figname (str, default = 'GalaXimView') – Name of matplotlib figure.
coords_conv_type ({‘astro’, cgs’, None}) – Type of units conversion for spatial coordinates.
global_conv_type ({‘astro’, cgs’, None}) – Type of units conversion.
retrieve_current_2d_hist (bool, default = False) – True to store current 2D histogram and edges in self.current_2d_hist, self.current 2d_yedges and self.current 2d_xedges.
- simu¶
Simulation object.
- snap¶
Current snapshot object.
- class ButtonsActions(outer, dic_onoff3d, dic_3dview, dic_show2d, dic_2dview, dic_2dkin, dic_timecontrol, dic_1d, dic_gas, dic_new_buttons)[source]¶
Bases:
object
Subclass to create buttons.
- Parameters
outer (GalViewer object) – Outer instance, i.e. GalViewer object.
dic_onoff3d (dictionary) – Dictionary of axes of buttons for 3D view of components.
dic_3dview (dictionary) – Dictionary of axes of buttons for 3D view.
dic_show2d (dictionary) – Dictionary of axes of buttons for 2D view of components.
dic_2dview (dictionary) – Dictionary of axes of buttons for 2D view.
dic_2dkin (dictionary) – Dictionary of axes of buttons for 2D kinematics view.
dic_timecontrol (dictionary) – Dictionary of axes of buttons for navigation in simulation.
dic_1d (dictionary) – Dictionary of axes of buttons for 1D plots.
- action_hist_comp(compstr, event)[source]¶
- Parameters
compstr (str) – Member of self.outer_instance.snap.listcomps.
event –
- action_set_view(event)[source]¶
Replots 2D plot so that the projection corresponds to the viewgin angle of the 3D plots, the number of bins is the current number of bins.
- action_time(event)[source]¶
Performed when changing shown time by pressing one of the time-control buttons.
- add_rem_comp(compstr, but, event)[source]¶
- Parameters
compstr (str) – Member of self.outer_instance.snap.listcomps.
but (matplotlib button) –
- hist_all_stars(event)[source]¶
Executes
action_hist_comp()
for ‘all stars’ when button ‘All*
’ is pressed.
- hist_bulge(event)[source]¶
Executes
action_hist_comp()
for ‘bulge stars’ when button ‘Bulge*
’ is pressed.
- hist_disc(event)[source]¶
Executes
action_hist_comp()
for ‘disc stars’ when button ‘Disc*
’ is pressed.
- hist_new_stars(event)[source]¶
Executes
action_hist_comp()
for ‘new stars’ when button ‘New*
’ is pressed.
- hist_old_stars(event)[source]¶
Executes
action_hist_comp()
for ‘old stars’ when button ‘Old*
’ is pressed.
- create_buttons()[source]¶
Creates buttons using GalViewer.ButtonSetView. :returns: GalViewer.ButtonsActions object. :rtype:
ButtonsActions
object.
- lims_from3d()[source]¶
Finds coordinates limits to use in 2D projection if button ‘Zoom 3D’ is pressed. :returns: x and y limits to use in 2D projection. :rtype: (float, float), (float, float)
- match_2d_view()[source]¶
Centres 3D plot in xc, yc, zc with xc the middle of the x_projected axis, yc the middle of the y_projected) axis, and zc the mass-weighted average of the z position, on a z axis orthogonal to the projection plane, of particles (of all types) that can be viewed in the 2D projection.
- match_3d_view()[source]¶
Projects positions and velocities on the right basis to obtain projection. This actually modifies self.snap.data[‘pos’] and self.snap.data[‘vel’]. Untouched positions and velocities are stored in self.snap.posini and self.snap.velini.
- plot_2d(compstr, initial_plot=False, zoom_ini=False, zoom_3d=False)[source]¶
Plots projected surface density or mass-weighted quantity.
- Parameters
compstr (str) – Member of self.snap.listcomps.
initial_plot (bool, default = ` False`) – True if method plots the 2D view for the first time with no adaptive initial zoom, in self.__init__
zoom_ini (bool, default = ` False`) – True to get back to initial zoom, set to True by pressing button ‘Zoom ini”.
zoom_3d (bool, default = ` False`) – True to get 2D projection with limits set to correspond to 3D view, by self.lims_from3s. Set to True by pressing button ‘Zoom 3D”.
- plot_comps_in_3d(initial_plot=False, xlimit=None, ylimit=None, zlimit=None, elev=None, azim=None)[source]¶
Plots 3D plot. self.snap.posini, i.e. the untouched positions, are used with a possible translation if plot’s “zero-point” is modified by self.match_2d_view.
- Parameters
initial_plot (bool, default = ` False`) – True if method plots the 3D view for the first time with no adaptive initial zoom, in self.__init__ (Default value = False)
xlimit ((float, float) or None, default = None) – Limits of x axis. If None, limits are obtained from current axis self.ax3d.
ylimit ((float, float) or None, default = None) – Limits of y axis. If None, limits are obtained from current axis self.ax3d.
zlimit ((float, float) or None, default = None) – Limits of z axis. If None, limits are obtained from current axis self.ax3d.
elev (float or None, optional) – Elevation of matplotlib camera in 3D plot used for first plotting. If None, set to matplotlib default.
azim – Azimuth of matplotlib camera in 3D plot used for first plotting. If None, set to matplotlib default.
- plot_quiv_2d_vels(compstr)[source]¶
Plots quiver plot of velocities projected on plane in sparsed bins, to avoid crowdedeness (1 in 8 bins in x, and same in y).
- Parameters
compstr (str) – Member of self.snap.listcomps.
- plot_surf_dens_of_rad(xlimit=None, ylimit_densofr=None, ylimit_velofr=None, ylimit_dispvofr=None)[source]¶
Plots surface density/volume density/mass-weighted histogram of particles, cylindrical/spherical/los velocity and cylindrical/spherical/los velocity dispersion as a function of cylindrical radius/spherical radius/x axis for self.plotted_1D = ‘cyl’/’spher’/’PV’. PV diagrams use the x_projected axis as x axis.
- Parameters
xlimit ((float, float) or None, optional.) – x limits for the 3 plots. (Default value = None)
ylimit_densofr ((float, float) or None, optional.) – y limits for the density plot. (Default value = None)
ylimit_velofr ((float, float) or None, optional.) – y limits for the velocity plot. (Default value = None)
ylimit_dispvofr ((float, float) or None, optional.) – y limits for the velocity dispersion plot. (Default value = None)