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_2dto3d(event)[source]
action_azim_0(event)[source]
action_azimminus90(event)[source]
action_azimplus90(event)[source]
action_cbar(event)[source]
action_cyl(event)[source]
action_dispvel(event)[source]
action_edge_on(event)[source]
action_elevini(event)[source]
action_elevminus90(event)[source]
action_elevplus90(event)[source]
action_face_on(event)[source]
action_fracini(event)[source]
action_fracon2(event)[source]
action_fract2(event)[source]
action_hist_comp(compstr, event)[source]
Parameters
  • compstr (str) – Member of self.outer_instance.snap.listcomps.

  • event

action_los_vel(event)[source]
action_nbini(event)[source]
action_nbon2(event)[source]
action_nbt2(event)[source]
action_nothing(event)[source]

Example, does nothing.

action_pause(event)[source]

Stops simulation from being played.

action_plot_3d(event)[source]
action_plot_fr(event)[source]
action_plot_u_rho(event)[source]
action_pv(event)[source]
action_quiv(event)[source]
action_rmav(event)[source]
action_save_azim(event)[source]
action_save_elev(event)[source]
action_set_azim(event)[source]
action_set_elev(event)[source]
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_sph(event)[source]
action_spher(event)[source]
action_step(event)[source]
action_stepon2(event)[source]
action_stept2(event)[source]
action_time(event)[source]

Performed when changing shown time by pressing one of the time-control buttons.

action_zoom_3d(event)[source]
action_zoom_ini(event)[source]
action_zoom_ini_3d(event)[source]
add_rem_all_stars(event)[source]
add_rem_bulge(event)[source]
add_rem_comp(compstr, but, event)[source]
Parameters
  • compstr (str) – Member of self.outer_instance.snap.listcomps.

  • but (matplotlib button) –

add_rem_dark_matter(event)[source]
add_rem_disc(event)[source]
add_rem_gas(event)[source]
add_rem_new_stars(event)[source]
add_rem_old_stars(event)[source]
classmethod but_cols(col, alphamax=0.75, alphamin=0.5)[source]
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_dark_matter(event)[source]

Executes action_hist_comp() for ‘DM’ when button ‘DM’ is pressed.

hist_disc(event)[source]

Executes action_hist_comp() for ‘disc stars’ when button ‘Disc *’ is pressed.

hist_gas(event)[source]

Executes action_hist_comp() for ‘gas’ when button ‘Gas’ 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.

next(event)[source]
play(event)[source]

Plays simulations, i.e. shows successive snapshots from current one.

Stopped by ~galaximview.galviewer.GalViewer.ButtonsActions.action_pause

prev(event)[source]
shade_buttons_absent_comps()[source]
to_tbeg(event)[source]
to_tend(event)[source]
calc_com_pv_of_particles_inside_2d_plot(list_comps)[source]
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)

plot_u_rho()[source]
write_frac()[source]

Fetches and writes fraction of particles plotted in 3D.

write_masses()[source]

Fetches and writes masses of components in text box.

write_step()[source]

Fetches and writes time step.