Skip to content

Grids

grid

FourierGrid3D

Source code in src/xifu_cluster_sim/grid.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class FourierGrid3D:

    def __init__(self, spatial_grid):
        """
        Define 3D Fourier grid from spatial grid

        Parameters:
            spatial_grid (class): 3D spatial grid 

        """

        self.kx = fft.fftfreq(len(spatial_grid.x), d=spatial_grid.x[1] - spatial_grid.x[0])
        self.ky = fft.fftfreq(len(spatial_grid.y), d=spatial_grid.y[1] - spatial_grid.y[0])
        self.kz = fft.rfftfreq(len(spatial_grid.z), d=spatial_grid.z[1] - spatial_grid.z[0])
        KX, KY, KZ = jnp.meshgrid(self.kx, self.ky, self.kz, indexing='ij', sparse=True)
        self.K = jnp.sqrt(KX ** 2 + KY ** 2 + KZ ** 2)

        self.shape = self.K.shape

__init__(spatial_grid)

Define 3D Fourier grid from spatial grid

Parameters:

Name Type Description Default
spatial_grid class

3D spatial grid

required
Source code in src/xifu_cluster_sim/grid.py
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def __init__(self, spatial_grid):
    """
    Define 3D Fourier grid from spatial grid

    Parameters:
        spatial_grid (class): 3D spatial grid 

    """

    self.kx = fft.fftfreq(len(spatial_grid.x), d=spatial_grid.x[1] - spatial_grid.x[0])
    self.ky = fft.fftfreq(len(spatial_grid.y), d=spatial_grid.y[1] - spatial_grid.y[0])
    self.kz = fft.rfftfreq(len(spatial_grid.z), d=spatial_grid.z[1] - spatial_grid.z[0])
    KX, KY, KZ = jnp.meshgrid(self.kx, self.ky, self.kz, indexing='ij', sparse=True)
    self.K = jnp.sqrt(KX ** 2 + KY ** 2 + KZ ** 2)

    self.shape = self.K.shape

SpatialGrid3D

Source code in src/xifu_cluster_sim/grid.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class SpatialGrid3D:

    def __init__(self, 
                pixsize=8.71, 
                shape=(58, 58), 
                los_factor=5,
                x_off = 0, 
                y_off = 0, 
                z_off = 0):
        """
        Define 3D spatial grid

        Parameters:
            pixsize (float): Projected pixel size in kiloparsecs
            shape (tuple): Size of grid on the field of view (Nx,Ny)
            los_factor (int): Factor by which the z-axis is multiplied (Nz = los_factor * Nx) 
            x_off (int) : Offset along x, in pixels
            y_off (int) : Offset along x, in pixels
            z_off (int) : Offset along x, in pixels

        """

        self.pixsize = pixsize

        x_size, y_size = shape
        z_size = int(shape[0]*los_factor)

        self.x = jnp.linspace(self.pixsize * (-(x_size - 1)/2 + x_off), self.pixsize * ((x_size - 1)/2 + x_off), x_size) + pixsize/2
        self.y = jnp.linspace(self.pixsize * (-(y_size - 1)/2 + y_off), self.pixsize * ((y_size - 1)/2 + y_off), y_size) + pixsize/2
        self.z = jnp.linspace(self.pixsize * (-(z_size - 1)/2 + z_off), self.pixsize * ((z_size - 1)/2 + z_off), z_size)
        self.X, self.Y, self.Z = jnp.meshgrid(self.x, self.y, self.z, indexing='ij', sparse=True)
        self.y_i, self.x_i = jnp.indices(shape)
        self.R = jnp.sqrt(self.X**2 + self.Y**2 + self.Z**2)
        self.shape = (x_size, y_size, z_size)
        self.volume = np.prod(self.shape)*pixsize**3

__init__(pixsize=8.71, shape=(58, 58), los_factor=5, x_off=0, y_off=0, z_off=0)

Define 3D spatial grid

Parameters:

Name Type Description Default
pixsize float

Projected pixel size in kiloparsecs

8.71
shape tuple

Size of grid on the field of view (Nx,Ny)

(58, 58)
los_factor int

Factor by which the z-axis is multiplied (Nz = los_factor * Nx)

5
x_off int)

Offset along x, in pixels

0
y_off int)

Offset along x, in pixels

0
z_off int)

Offset along x, in pixels

0
Source code in src/xifu_cluster_sim/grid.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def __init__(self, 
            pixsize=8.71, 
            shape=(58, 58), 
            los_factor=5,
            x_off = 0, 
            y_off = 0, 
            z_off = 0):
    """
    Define 3D spatial grid

    Parameters:
        pixsize (float): Projected pixel size in kiloparsecs
        shape (tuple): Size of grid on the field of view (Nx,Ny)
        los_factor (int): Factor by which the z-axis is multiplied (Nz = los_factor * Nx) 
        x_off (int) : Offset along x, in pixels
        y_off (int) : Offset along x, in pixels
        z_off (int) : Offset along x, in pixels

    """

    self.pixsize = pixsize

    x_size, y_size = shape
    z_size = int(shape[0]*los_factor)

    self.x = jnp.linspace(self.pixsize * (-(x_size - 1)/2 + x_off), self.pixsize * ((x_size - 1)/2 + x_off), x_size) + pixsize/2
    self.y = jnp.linspace(self.pixsize * (-(y_size - 1)/2 + y_off), self.pixsize * ((y_size - 1)/2 + y_off), y_size) + pixsize/2
    self.z = jnp.linspace(self.pixsize * (-(z_size - 1)/2 + z_off), self.pixsize * ((z_size - 1)/2 + z_off), z_size)
    self.X, self.Y, self.Z = jnp.meshgrid(self.x, self.y, self.z, indexing='ij', sparse=True)
    self.y_i, self.x_i = jnp.indices(shape)
    self.R = jnp.sqrt(self.X**2 + self.Y**2 + self.Z**2)
    self.shape = (x_size, y_size, z_size)
    self.volume = np.prod(self.shape)*pixsize**3