Geometry¶
Spatial grids¶
-
class
jjmodel.geometry.Grid(zmax, dz, rmax, rnum, **kwargs)[source]¶ Class for creating (r,l,z) grids (e.g. for the Solar neighbourhood modeling).
-
__init__(zmax, dz, rmax, rnum, **kwargs)[source]¶ Initialization.
- Parameters
zmax (scalar) -- Maximal height, pc.
dz (scalar) -- Step in height, pc.
rmax (scalar) -- Maximal distance from z-axis in xy-plane, pc.
rnum (int) -- Number of bins along r axis (in xy plane).
rlog (boolean) -- Optional. If True, binning along r axis is in log space.
dl (scalar) -- Optional. Step in angle (longitude), deg.
-
ind_part(zcent, zwidth)[source]¶ Returns indices corresponding to a z-slice.
- Parameters
zcent (scalar) -- Mean z of the slice, pc.
zwidth (scalar) -- Half-width of the slice, pc.
- Returns
Index array of the full z-grid corresponding to the selected slice.
- Return type
1d-array
-
indl(lmin, lmax, **kwargs)[source]¶ Generates indices of the part of l-array (indices correspond to the full l-grid).
- Parameters
lmin (scalar) -- Minimal longitude, deg.
lmax (scalar) -- Maximal longitude, deg.
- Dl
Optional. Step in angle, deg.
- Returns
Index array.
- Return type
1d-array
-
indr(rmin, rmax)[source]¶ Generates indices of the part of r-array (indices correspond to the full r-grid).
- Parameters
rmin (scalar) -- Minimal r, pc.
rmax (scalar) -- Maximal r, pc.
- Returns
Index array.
- Return type
1d-array
-
Modeling volumes¶
-
class
jjmodel.geometry.Volume(p, a)[source]¶ Class for calculating volumes of the different spatial cells.
-
__init__(p, a)[source]¶ Class instance is initialized by collections of parameters and useful arrays.
- Parameters
p (namedtuple) -- Set of model parameters from the parameter file.
a (namedtuple) -- Collection of the fixed model parameters, useful quantities, and arrays.
-
local_cylinder(r_min, r_max, z_min, z_max)[source]¶ Returns z-grid with volume of the cells for the local cylinder with an inner hole. For testing, do:
import numpy as np from jjmodel.input_ import p,a from jjmodel.geometry import Volume V = Volume(p,a) v2 = V.local_cylinder(100,800,0,500) print(np.sum(v2[0])/(2*np.pi*(800**2-100**2)*500))
- Parameters
r_min (scalar) -- Inner radius of the cylinder, pc.
r_max (scalar) -- Outer radius of the cylinder, pc.
z_min (scalar) -- Minimal absolute z, pc.
z_max (scalar) -- Maximal absolute z, pc.
- Returns
Three quantities are calculated:
z-grid with volumes of the cells, \(\mathrm{pc}^3\). If the outer radius of the cylinder is larger than the model radial resolution
p.dR, then the cylinder will be splitted over several radial bins, and z-grid with volumes will be given separately for each radial bin.Indices of the radial bins for which z-grids are calculated (to get radii, use these indices with
a.Rarray).Reference line with information about the input parameters.
- Return type
[array-like, array-like, str]
-
local_sphere(r_min, r_max)[source]¶ Returns z-grid with volume of the cells for the local sphere with an inner hole. For testing, do:
import numpy as np from jjmodel.input_ import p,a from jjmodel.geometry import Volume V = Volume(p,a) v1 = V.local_sphere(0,850) print(np.sum(v1[0])/(4/3*np.pi*850**3))
- Parameters
r_min (scalar) -- Inner radius of the spherical shell, pc.
r_max (scalar) -- Outer radius of the spherical shell, pc.
- Returns
Three quantities are calculated:
z-grid with volumes of the cells, \(\mathrm{pc}^3\). If the outer radius of the sphere is larger than the model radial resolution
p.dR, then the sphere will be splitted over several radial bins, and z-grid with volumes will be given separately for each radial bin.Indices of radial bins for which z-grids are calculated (to get the radii, use these indices with
a.Rarray).Reference line with information about the input parameters.
- Return type
[array-like, array-like, str]
-
none()[source]¶ Useful when the volume does not need to be taken into account, but equation is kept general with the volume term. In this case, the volume array can be simply filled with ones.
- Retrun
z-grid array of the length
a.nfilled with ones.- Return type
1d-array
-
rphiz_box(R_min, R_max, dphi, z_min, z_max)[source]¶ Returns volume z-grid for the 'box' in the Galactic cylindrical coordinates (R,:math:phi,z). For testing, do:
import numpy as np from jjmodel.input_ import p,a from jjmodel.geometry import Volume V = Volume(p,a) v3 = V.rphiz_box(8.15,8.25,360,100,250) print(np.sum(v3[0])/(2*np.pi*(8250**2-8150**2)*150))
- Parameters
R_min (scalar) -- Minimal Galactocentric radius, kpc.
R_max (scalar) -- Maximal Galactocentric radius, kpc.
dphi (scalar) -- Galactocentric(? not sure how it's called..) angle, deg.
z_min (scalar) -- Minimal absolute z, pc.
z_max (scalar) -- Maximal absolute z, pc.
- Returns
Three quantities:
z-grid with volumes of the cells, \(\mathrm{pc}^3\). If the radial span of the volume is larger than the model radial resolution
p.dR, then it will be splitted over several radial bins, and z-grid with volumes will be given separately for each radial bin.Indices of the radial bins for which z-grids are calculated (to get radii, use these indices with
a.Rarray).Reference line with information about the input parameters.
- Return type
[array-like, array-like, str]
-
zcut(v, zlim)[source]¶ Fills z-cells laying outside of the chosen range with zeros.
- Parameters
v (1d-array) -- z-grid with volume of the cells. z-grid has length
a.n(absolute z from 0 top.zmaxwith a step ofp.dz).zlim (list) -- Minimal and maximal absolute z.
- Returns
z-grid with volume of the cells.
- Return type
1d-array
-