galaximview.coords module

class galaximview.coords.Coords[source]

Bases: object

Class grouping methods to project basis vectors on other bases.

classmethod cartesian_basis_vects_in_cyl_basis(phi_angles)[source]

Projects cartesian basis vectors on cylindrical basis.

Parameters

phi_angles (array_like) – cylindrical phi angle.

Returns

(3,N), (3,N), (3,N) ex, ey and ez in cylindrical basis.

Return type

(ndarray, ndarray, ndarray)

classmethod cartesian_basis_vects_in_spher_basis(theta_angles, phi_angles)[source]

Projects cartesian basis vectors on spherical basis.

Parameters
  • theta_angles (array_like) – spherical theta angle

  • phi_angles (array_like) – cylindrical phi angle.

Returns

(3,N), (3,N), (3,N) ex, ey and ez in spherical basis.

Return type

(ndarray, ndarray, ndarray)

classmethod cylindrical_basis_vects_in_cart_basis(phi_angles)[source]

Projects cylindrical basis vectors on cartesian basis.

Parameters

phi_angles (array_like) – (N,) cylindrical phi angles.

Returns

(3,N), (3,N), (3,N) ercyl, ephi and ez in cartesian basis.

Return type

(ndarray, ndarray, ndarray)

classmethod cylindrical_basis_vects_in_spher_basis(theta_angles)[source]

Projects cylindrical basis vectors on spherical basis.

Parameters

theta_angles (array_like) – spherical theta angle

Returns

(3,N), (3,N), (3,N) ercyl, ephi and ez in spherical basis.

Return type

(ndarray, ndarray, ndarray)

classmethod spherical_basis_vects_in_cart_basis(theta_angles, phi_angles)[source]

Projects spherical basis vectors on cartesian basis.

Parameters
  • theta_angles (array_like) – spherical theta angle

  • phi_angles (array_like) – cylindrical phi angle.

Returns

(3,N), (3,N), (3,N) erspher, ethetaspher and ephi in cartesian basis.

Return type

(ndarray, ndarray, ndarray)

classmethod spherical_basis_vects_in_cyl_basis(theta_angles)[source]

Projects spherical basis vectors on cylindrical basis.

Parameters

theta_angles (array_like) – spherical theta angle

Returns

(3,N), (3,N), (3,N) erspher, ethetaspher and ephi in cylindrical basis.

Return type

(ndarray, ndarray, ndarray)

class galaximview.coords.DynamicsFromCart(pos, vel, mass, ctre_pos=array([0., 0., 0.]), ctre_vel=array([0., 0., 0.]))[source]

Bases: galaximview.coords.VelCoordsFromCart

Performs computations of angular momentum, kinetic and gravitational potential energy of particles. Initialized with positions, velocities and masses.

Parameters
  • pos (ndarray) – (N,3) Positions.

  • vel (ndarray) – (N,3) Velocities.

  • mass (ndarray) – (N,) Masses.

  • ctre_pos (ndarray, optional) – (3,) 3D position to be removed from all the particles positions, if desired (to compute cylindrical and spherical positions with a different coordinates centre)

  • ctre_vel (ndarray, optional) – (3,) 3D velocity to be removed from all the particles velocitiess, if desired (to compute cylindrical and spherical coordinates with a different coordinates centre)

angular_momentum_3d()[source]

Returns individual angular momenta m r vect v. Overwritten for cylindrical or spherical coordinates. :returns: (N,3) angular momenta. :rtype: ndarray

angular_momentum_norm()[source]

Returns individual norms of angular momenta m * r vect v.

eigenvalues_of_inertia_tensor()[source]

Returns eigenvalues and eigenvectors of inertia tensor.

gravitational_potential_energy(pot)[source]

Returns gravitational potential energies.

Parameters

pot (ndarray) – (N,) Gravitational potential.

Returns

(N,) Gravitational potential energies.

Return type

ndarray

inertia_tensor()[source]

Returns inertia tensor.

Returns

(3,3) inertia tensor.

Return type

ndarray

kinetic_energy()[source]
specific_angular_momentum_3d()[source]

Returns individual specific angular momenta r vect v. Overwritten for cylindrical or spherical coordinates.

Returns

(N,3) specific angular momenta.

Return type

ndarray

specific_angular_momentum_norm()[source]

Returns individual norms of angular momenta m * r vect v.

spin()[source]

Returns spin, i.e. angular momentum normalised to unity.

tocyl_dyn_obj()[source]

Returns DynamicsFromCyl object.

Returns

Return type

DynamicsFromCyl object.

tospher_dyn_obj()[source]

Returns DynamicsFromSpher object.

Returns

Return type

DynamicsFromSpher object.

total_angular_momentum_3d()[source]

Returns total angular momentum.

total_angular_momentum_norm()[source]
total_specific_angular_momentum_3d()[source]

Returns total specific angular momentum.

total_specific_angular_momentum_norm()[source]
class galaximview.coords.DynamicsFromCyl(pos, vel, mass)[source]

Bases: galaximview.coords.VelCoordsFromCyl

Parameters
  • pos (ndarray) – (N,3) Positions.

  • vel (ndarray) – (N,3) Velocities.

  • mass (ndarray) – (N,) Masses.

angular_momentum_3d()[source]

Returns individual angular momenta m r vect v.

Returns

(N,3) angular momenta.

Return type

ndarray

specific_angular_momentum_3d()[source]

Returns individual specific angular momenta r vect v.

Returns

(N,3) specific angular momenta.

Return type

ndarray

tocart_dyn_obj()[source]

Returns DynamicsFromCart object.

Returns

Return type

DynamicsFromCart object.

tospher_dyn_obj()[source]

Returns DynamicsFromSpher object.

Returns

Return type

DynamicsFromSpher object.

class galaximview.coords.DynamicsFromSpher(pos, vel, mass)[source]

Bases: galaximview.coords.VelCoordsFromSpher

Parameters
  • pos (ndarray) – (N,3) Positions.

  • vel (ndarray) – (N,3) Velocities.

  • mass (ndarray) – (N,) Masses.

angular_momentum_3d()[source]

Returns individual angular momenta m r vect v.

Returns

(N,3) angular momenta.

Return type

ndarray

specific_angular_momentum_3d()[source]

Returns individual specific angular momenta r vect v.

Returns

(N,3) specific angular momenta.

Return type

ndarray

tocart_dyn_obj()[source]

Returns DynamicsFromCart object.

Returns

Return type

DynamicsFromCart object.

tocyl_dyn_obj()[source]

Returns DynamicsFromCyl object.

Returns

Return type

DynamicsFromCyl object.

class galaximview.coords.SpatialCoordsFromCart(pos, ctre_pos=array([0., 0., 0.]))[source]

Bases: object

Performs computations of cylindrical or spherical coordinates and bases from cartesian positions.

Parameters
  • pos (ndarray) – (N,3) Positions x, y and z.

  • ctre_pos (ndarray, optional) – (3,) central position to be removed from all the particles positions, if desired (to compute cylindrical and spherical coordinates with a different coordinates centre)

average_pos_coords(weights)[source]

Returns the (weighted) averaged x, y and z.

Parameters

weights (ndarray, optional) – (N,) weights (e.g. masses).

Returns

(Weighted) average x, y and z.

Return type

(float, float, float)

cartesian_base_vects_in_cyl_base()[source]

Returns cartesian basis vectors projected on cylindrical basis.

cartesian_base_vects_in_spher_base()[source]

Returns cartesian basis vectors projected on spherical basis.

cylindrical_base_vects_in_cart_base()[source]

Returns cylindrical basis vectors projected on cartesian basis.

cylindrical_radius()[source]
Returns

(N,) Cylindrical radii.

Return type

ndarray

disp_of_pos(weights)[source]

Returns the (weighted) dispersions of x, y and z.

Parameters

weights (ndarray, optional) – (N,) weights (e.g. masses).

Returns

(Weighted) dispersions of x, y and z.

Return type

(float, float, float)

phi()[source]
Returns

(N,) Phi angles of both cylindrical and spherical coordinates.

Return type

ndarray

spherical_base_vects_in_cart_base()[source]

Returns spherical basis vectors projected on cartesian basis.

spherical_radius()[source]
Returns

(N,) Spherical radii.

Return type

ndarray

spherical_theta()[source]
Returns

(N,) Theta angles of spherical coordinates.

Return type

ndarray

tocyl_pos()[source]
Returns

(N,3) Cylindrical coordinates array cylpos with cylpos[:,0] the cylindrical radii, cylpos[:,1] the phi cylindrical coordinates and cylpos[:,2] the z ooordinates.

Return type

ndarray

tocyl_sp_object()[source]

Returns SpatialCoordsFromCyl object.

Returns

Return type

SpatialCoordsFromCyl object.

tospher_pos()[source]
Returns

(N,3) Spherical coordinates array spherpos with spherpos[:,0] the spherical radii, spherpos[:,1] the theta spherical angles and spherpos[:,2] the phi spherical angles.

Return type

ndarray

tospher_sp_object()[source]

Returns SpatialCoordsFromSpher object.

Returns

Return type

SpatialCoordsFromSpher object.

class galaximview.coords.SpatialCoordsFromCyl(cylpos)[source]

Bases: object

Performs computations of cartesian or spherical coordinates from cylindrical positions.

Cylindrical positions are cylpos[:,0] = cyl radius, cylpos[:,1] = cyl phi angle and cylpos[:,2] = z position.

Parameters

cylpos (ndarray) – (N,3) cylpos[:,0] = cyl radius, cylpos[:,1] = cyl phi angle and cylpos[:,2] = z position.

cartesian_base_vects_in_cyl_base()[source]

Returns cartesian basis vectors projected on cylindrical basis.

cylindrical_base_vects_in_cart_base()[source]

Returns cylindrical basis vectors projected on cartesian basis.

cylindrical_base_vects_in_spher_base()[source]

Returns cylindrical basis vectors projected on spherical basis.

phi()[source]

Returns cyindrical or spherical phi.

spherical_base_vects_in_cyl_base()[source]

Returns spherical basis vectors projected on cylindrical basis.

spherical_radius()[source]

Returns spherical radius.

spherical_theta()[source]

Return spherical theta.

tocart_pos()[source]
Returns

(N,3) Cartesian positions.

Return type

ndarray

tocart_sp_object()[source]

Returns SpatialCoordsFromCart object.

Returns

Return type

SpatialCoordsFromCart object.

tospher_pos()[source]
Returns

(N,3) Spherical positions.

Return type

ndarray

tospher_sp_object()[source]

Returns SpatialCoordsFromSpher object.

Returns

Return type

SpatialCoordsFromSpher object.

xcart()[source]

Returns cartesian x.

ycart()[source]

Returns cartesian y.

zcart()[source]

Returns cartesian z.

class galaximview.coords.SpatialCoordsFromSpher(spherpos)[source]

Bases: object

Performs computations of cartesian or spherical coordinates from spherrical positions

Spherical positions are spherpos[:,0] = spher radius, spherpos[:,1] = spher theta angle and spherpos[:, 2] = phi angle.

Parameters

spherpos (ndarray) – (N,3) Positions. pherpos[:,0] = spher radius, spherpos[:,1] = spher theta angle and spherpos[:, 2] = phi angle.

cartesian_base_vects_in_spher_base()[source]

Returns cartesian basis vectors projected on spherical basis.

cylindrical_base_vects_in_spher_base()[source]

Returns cylindrical basis vectors projected on spherical basis.

cylindrical_radius()[source]

Returns cylindrical radius.

phi()[source]

Returns cylindrical or spherical phi.

spherical_base_vects_in_cart_base()[source]

Returns spherical basis vectors projected on cartesian basis.

spherical_base_vects_in_cyl_base()[source]

Returns spherical basis vectors projected on cylindrical basis.

tocart_pos()[source]

Returns cartesian positions.

Returns

(3,N) Cartesian positions.

Return type

ndarray

tocart_sp_object()[source]

Returns SpatialCoordsFromartl object.

Returns

Return type

SpatialCoordsFromCart object.

tocyl_pos()[source]

Returns cylindrical positions.

Returns

(N,3) Cylindrical positions.

Return type

ndarray

tocyl_sp_object()[source]

Returns SpatialCoordsFromCyl object.

Returns

Return type

SpatialCoordsFromCyl object.

xcart()[source]

Returns cartesian x.

ycart()[source]

Returns cartesian y.

zcart()[source]

Returns cartesian z.

class galaximview.coords.VelCoordsFromCart(pos, vel, ctre_pos=array([0., 0., 0.]), ctre_vel=array([0., 0., 0.]))[source]

Bases: galaximview.coords.SpatialCoordsFromCart

Performs computations of cylindrical or spherical velocity coordinates.

Parameters
  • pos (ndarray) – (N,3) Positions.

  • vel (ndarray) – (N,3) Velocities.

  • ctre_pos (ndarray, optional) – (3,) 3D position to be removed from all the particles positions, if desired (to compute cylindrical and spherical positions with a different coordinates centre)

  • ctre_vel (ndarray, optional) – (3,) 3D velocity to be removed from all the particles velocitiess, if desired (to compute cylindrical and spherical coordinates with a different coordinates centre)

average_vel_coords(weights)[source]

Returns (weighted) average velocity componants.

Parameters

weights (ndarray, optional) – (N,) weights (e.g. masses).

Returns

Average velocity componants.

Return type

(float, float, float)

cylindrical_radial_vel()[source]

Returns cylindrical radial velocity.

Returns

(N,) Cylindrical radial velocity.

Return type

ndarray

disp_of_vel(weights)[source]

Returns (weighted) dispersions of velocity componants.

Parameters

weights (ndarray, optional) – (N,) weights (e.g. masses).

Returns

Average velocity componants.

Return type

(float, float, float)

norm_of_vel()[source]

Returns norm of velocity.

phi_vel()[source]

Returns velocity projected on phi unit vector of both cylindrical and spherical bases.

Returns

(N,) Phi spherical or cylindrical velocity.

Return type

ndarray

spherical_radial_vel()[source]

Returns spherical radial velocity.

Returns

(N,) Radial spherical velocity.

Return type

ndarray

spherical_theta_vel()[source]

Returns spherical velocity along etheta vector.

Returns

(N,) Theta spherical velocity.

Return type

ndarray

tocyl_vel()[source]

Returns cylindrical velocities.

Returns

(N,3) Cylindrical velocities.

Return type

ndarray

tocyl_velc_object()[source]

Returns VelCoordsFromCyl object.

Returns

Return type

VelCoordsFromCyl object.

tospher_vel()[source]

Returns spherical velocities.

Returns

(N,3) Spherical velocities.

Return type

ndarray

tospher_velc_object()[source]

Returns VelCoordsFromSpher object.

Returns

Return type

VelCoordsFromSpher object.

class galaximview.coords.VelCoordsFromCyl(pos, vel)[source]

Bases: galaximview.coords.SpatialCoordsFromCyl

Performs computations of cylindrical or spherical velocity coordinates.

Parameters
  • pos (ndarray) – (N,3) Positions.

  • vel (ndarray) – (N,3) Velocities.

average_vel_coords(weights)[source]

Returns (weighted) average velocity componants.

Parameters

weights (ndarray, optional) – (N,) weights (e.g. masses).

Returns

Average velocity componants.

Return type

(float, float, float)

disp_of_vel(weights)[source]

Returns (weighted) dispersions of velocity componants.

Parameters

weights (ndarray, optional) – (N,) weights (e.g. masses).

Returns

Average velocity componants.

Return type

(float, float, float)

norm_of_vel()[source]

Returns norm of velocity.

spherical_radial_vel()[source]

Returns spherical radial velocity.

spherical_theta_vel()[source]

Returns spherical theta velocity.

tocart_vel()[source]

Returns cartesian velocities. :returns: (3,N) Cartesian velocities. :rtype: ndarray

tocart_velc_object()[source]

Returns VelCoordsFromCart object.

Returns

Return type

VelCoordsFromCart object.

tospher_vel()[source]

Returns spherical velocities.

Returns

(3,N) Spherical velocities.

Return type

ndarray

tospher_velc_object()[source]

Returns VelCoordsFromSpher object.

Returns

Return type

VelCoordsFromSpher object.

vel_xcart()[source]

Returns cartesian x velocity.

vel_ycart()[source]

Returns cartesian y velocity.

class galaximview.coords.VelCoordsFromSpher(pos, vel)[source]

Bases: galaximview.coords.SpatialCoordsFromSpher

Performs computations of cylindrical or spherical velocity coordinates.

Parameters
  • pos (ndarray) – (N,3) Positions.

  • vel (ndarray) – (N,3) Velocities.

Returns

VelCoordsFromSpher object.

Return type

Object

average_vel_coords(weights)[source]

Returns (weighted) average velocity componants.

Parameters

weights (ndarray, optional) – (N,) weights (e.g. masses).

Returns

Average velocity componants.

Return type

(float, float, float)

cylindrical_radial_vel()[source]

Returns cylindrical vr.

disp_of_vel(weights)[source]

Returns (weighted) dispersions of velocity componants.

Parameters

weights (ndarray, optional) – (N,) weights (e.g. masses).

Returns

Average velocity componants.

Return type

(float, float, float)

norm_of_vel()[source]

Returns norm of velocity.

tocart_vel()[source]

Returns cartesian velocities.

Returns

(3,N) Cartesian velocities.

Return type

ndarray

tocart_velc_object()[source]

Returns VelCoordsFromCart object.

Returns

Return type

VelCoordsFromCart object.

tocyl_vel()[source]

Returns cylindrical velocities.

Returns

(3,N) Cylindrical velocities.

Return type

ndarray

tocyl_velc_object()[source]

Returns VelCoordsFromCyl object.

Returns

Return type

VelCoordsFromCyl object.

vel_xcart()[source]

Returns cartesian vx.

vel_ycart()[source]

Returns cartesian vy.

vel_zcart()[source]

Returns cartesian vz.