Skip to content

structure

Functions for generating structure. This includes both cluster profiles and substructure.

a10(dx, dy, dz, theta, P0, c500, m500, gamma, alpha, beta, z, xyz)

gNFW pressure profile in 3d based on Arnaud2010. Compared to the function gnfw, this function fixes r1/r2/r3 to r500. This function does not include smoothing or declination stretch which should be applied at the end.

Arguments:

dx: RA of cluster center relative to grid origin

dy: Dec of cluster center relative to grid origin

dz: Line of sight offset of cluster center relative to grid origin

theta: Angle to rotate in xy-plane

P0: Amplitude of the pressure profile

c500: Concentration parameter at a density contrast of 500

m500: Mass at a density contrast of 500

gamma: The central slope

alpha: The intermediate slope

beta: The outer slope

z: Redshift of cluster

xyz: Coordinte grid to calculate model on

Returns:

model: The gnfw model
Source code in witch/structure.py
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
@jax.jit
def a10(dx, dy, dz, theta, P0, c500, m500, gamma, alpha, beta, z, xyz):
    """
    gNFW pressure profile in 3d based on Arnaud2010.
    Compared to the function gnfw, this function fixes r1/r2/r3 to r500.
    This function does not include smoothing or declination stretch
    which should be applied at the end.

    Arguments:

        dx: RA of cluster center relative to grid origin

        dy: Dec of cluster center relative to grid origin

        dz: Line of sight offset of cluster center relative to grid origin

        theta: Angle to rotate in xy-plane

        P0: Amplitude of the pressure profile

        c500: Concentration parameter at a density contrast of 500

        m500: Mass at a density contrast of 500

        gamma: The central slope

        alpha: The intermediate slope

        beta: The outer slope

        z: Redshift of cluster

        xyz: Coordinte grid to calculate model on

    Returns:

        model: The gnfw model
    """

    nz = get_nz(z)
    hz = get_hz(z)
    da = get_da(z)  # TODO pass these arguments rather than recompute them everytime???

    r500 = (m500 / (4.00 * jnp.pi / 3.00) / 5.00e02 / nz) ** (1.00 / 3.00)
    r_1, r_2, r_3 = r500 / da, r500 / da, r500 / da

    x, y, z = transform_grid(dx, dy, dz, r_1, r_2, r_3, theta, xyz)

    r = c500 * jnp.sqrt(x**2 + y**2 + z**2)
    denominator = (r**gamma) * (1 + r**alpha) ** ((beta - gamma) / alpha)

    P500 = (
        1.65e-03
        * (m500 / (3.00e14 / h70)) ** (2.00 / 3.00 + ap)
        * hz ** (8.00 / 3.00)
        * h70**2
    )

    return P500 * P0 / denominator

add_exponential(pressure, xyz, dx, dy, dz, r_1, r_2, r_3, theta, amp, xk, x0, yk, y0, zk, z0)

Add ellipsoid with exponential structure to 3d pressure profile.

Arguments:

pressure: The pressure profile

xyz: Coordinate grids, see make_grid for details

dx: RA of ellipsoid center relative to grid origin

dy: Dec of ellipsoid center relative to grid origin

dz: Line of sight offset of ellipsoid center relative to grid origin

r_1: Amount to scale ellipsoid along x-axis

r_2: Amount to scale ellipsoid along y-axis

r_3: Amount to scale ellipsoid along z-axis

theta: Angle to rotate ellipsoid in xy-plane

amp: Factor by which pressure is enhanced at peak of exponential

xk: Power of exponential in RA direction

x0: RA offset of exponential.
    Note that this is in transformed coordinates so x0=1 is at xs + sr_1.

yk: Power of exponential in Dec direction

y0: Dec offset of exponential.
    Note that this is in transformed coordinates so y0=1 is at ys + sr_2.

zk: Power of exponential along the line of sight

z0: Line of sight offset of exponential.
    Note that this is in transformed coordinates so z0=1 is at zs + sr_3.

Returns:

new_pressure: Pressure profile with ellipsoid added
Source code in witch/structure.py
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
@jax.jit
def add_exponential(
    pressure, xyz, dx, dy, dz, r_1, r_2, r_3, theta, amp, xk, x0, yk, y0, zk, z0
):
    """
    Add ellipsoid with exponential structure to 3d pressure profile.

    Arguments:

        pressure: The pressure profile

        xyz: Coordinate grids, see make_grid for details

        dx: RA of ellipsoid center relative to grid origin

        dy: Dec of ellipsoid center relative to grid origin

        dz: Line of sight offset of ellipsoid center relative to grid origin

        r_1: Amount to scale ellipsoid along x-axis

        r_2: Amount to scale ellipsoid along y-axis

        r_3: Amount to scale ellipsoid along z-axis

        theta: Angle to rotate ellipsoid in xy-plane

        amp: Factor by which pressure is enhanced at peak of exponential

        xk: Power of exponential in RA direction

        x0: RA offset of exponential.
            Note that this is in transformed coordinates so x0=1 is at xs + sr_1.

        yk: Power of exponential in Dec direction

        y0: Dec offset of exponential.
            Note that this is in transformed coordinates so y0=1 is at ys + sr_2.

        zk: Power of exponential along the line of sight

        z0: Line of sight offset of exponential.
            Note that this is in transformed coordinates so z0=1 is at zs + sr_3.

    Returns:

        new_pressure: Pressure profile with ellipsoid added
    """
    x, y, z = transform_grid(dx, dy, dz, r_1, r_2, r_3, theta, xyz)

    exponential = amp * jnp.exp(((x - x0) * xk) + ((y - y0) * yk) + ((z - z0) * zk))

    new_pressure = jnp.where(
        jnp.sqrt(x**2 + y**2 + z**2) > 1, pressure, (1 + exponential) * pressure
    )
    return new_pressure

add_powerlaw(pressure, xyz, dx, dy, dz, r_1, r_2, r_3, theta, amp, phi0, k_r, k_phi)

Add ellipsoid with power law structure to 3d pressure profile.

Arguments:

pressure: The pressure profile

xyz: Coordinate grids, see make_grid for details

dx: RA of ellipsoid center relative to grid origin

dy: Dec of ellipsoid center relative to grid origin

dz: Line of sight offset of ellipsoid center relative to grid origin

r_1: Amount to scale ellipsoid along x-axis

r_2: Amount to scale ellipsoid along y-axis

r_3: Amount to scale ellipsoid along z-axis

theta: Angle to rotate ellipsoid in xy-plane

amp: Factor by which pressure is enhanced at peak of power law

phi0: Polar angle of nose of power law

k_r: Slope of power law in radial dirction

k_phi: Slope of power law in polar direction

Returns:

new_pressure: Pressure profile with ellipsoid added
Source code in witch/structure.py
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
@jax.jit
def add_powerlaw(
    pressure, xyz, dx, dy, dz, r_1, r_2, r_3, theta, amp, phi0, k_r, k_phi
):
    """
    Add ellipsoid with power law structure to 3d pressure profile.

    Arguments:

        pressure: The pressure profile

        xyz: Coordinate grids, see make_grid for details

        dx: RA of ellipsoid center relative to grid origin

        dy: Dec of ellipsoid center relative to grid origin

        dz: Line of sight offset of ellipsoid center relative to grid origin

        r_1: Amount to scale ellipsoid along x-axis

        r_2: Amount to scale ellipsoid along y-axis

        r_3: Amount to scale ellipsoid along z-axis

        theta: Angle to rotate ellipsoid in xy-plane

        amp: Factor by which pressure is enhanced at peak of power law

        phi0: Polar angle of nose of power law

        k_r: Slope of power law in radial dirction

        k_phi: Slope of power law in polar direction

    Returns:

        new_pressure: Pressure profile with ellipsoid added
    """
    x, y, z = transform_grid(dx, dy, dz, r_1, r_2, r_3, theta, xyz)
    r = jnp.sqrt(x**2 + y**2 + z**2)
    phi = abs((jnp.arctan2(y, x) - phi0) % (2 * jnp.pi) - jnp.pi) / jnp.pi

    powerlaw = (
        amp
        * (1 - jnp.float_power(1 + r, -1.0 * k_r))
        * (1 - jnp.float_power(1 + phi, -1 * k_phi))
    )
    new_pressure = jnp.where(r > 1, pressure, (1 + powerlaw) * pressure)
    return new_pressure

add_powerlaw_cos(pressure, xyz, dx, dy, dz, r_1, r_2, r_3, theta, amp, phi0, k_r, omega)

Add ellipsoid with radial power law and angular cos dependant structure to 3d pressure profile.

Arguments:

pressure: The pressure profile

xyz: Coordinate grids, see make_grid for details

dx: RA of ellipsoid center relative to grid origin

dy: Dec of ellipsoid center relative to grid origin

dz: Line of sight offset of ellipsoid center relative to grid origin

r_1: Amount to scale ellipsoid along x-axis

r_2: Amount to scale ellipsoid along y-axis

r_3: Amount to scale ellipsoid along z-axis

theta: Angle to rotate ellipsoid in xy-plane

amp: Factor by which pressure is enhanced at peak of power law

phi0: Polar angle of nose of power law

k_r: Slope of power law in radial dirction

omega: Angular freqency if cos term

Returns:

new_pressure: Pressure profile with ellipsoid added
Source code in witch/structure.py
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
@jax.jit
def add_powerlaw_cos(
    pressure, xyz, dx, dy, dz, r_1, r_2, r_3, theta, amp, phi0, k_r, omega
):
    """
    Add ellipsoid with radial power law and angular cos dependant structure to 3d pressure profile.

    Arguments:

        pressure: The pressure profile

        xyz: Coordinate grids, see make_grid for details

        dx: RA of ellipsoid center relative to grid origin

        dy: Dec of ellipsoid center relative to grid origin

        dz: Line of sight offset of ellipsoid center relative to grid origin

        r_1: Amount to scale ellipsoid along x-axis

        r_2: Amount to scale ellipsoid along y-axis

        r_3: Amount to scale ellipsoid along z-axis

        theta: Angle to rotate ellipsoid in xy-plane

        amp: Factor by which pressure is enhanced at peak of power law

        phi0: Polar angle of nose of power law

        k_r: Slope of power law in radial dirction

        omega: Angular freqency if cos term

    Returns:

        new_pressure: Pressure profile with ellipsoid added
    """
    x, y, z = transform_grid(dx, dy, dz, r_1, r_2, r_3, theta, xyz)
    r = jnp.sqrt(x**2 + y**2 + z**2)
    phi = (jnp.arctan2(y, x) - phi0) % (2 * jnp.pi)

    powerlaw = amp * (1 - jnp.float_power(1 + r, -1.0 * k_r)) * jnp.cos(omega * phi)
    new_pressure = jnp.where(r > 1, pressure, (1 + powerlaw) * pressure)
    return new_pressure

add_uniform(pressure, xyz, dx, dy, dz, r_1, r_2, r_3, theta, amp)

Add ellipsoid with uniform structure to 3d pressure profile.

Arguments:

pressure: The pressure profile

xyz: Coordinate grids, see make_grid for details

dx: RA of ellipsoid center relative to grid origin

dy: Dec of ellipsoid center relative to grid origin

dz: Line of sight offset of ellipsoid center relative to grid origin

r_1: Amount to scale ellipsoid along x-axis

r_2: Amount to scale ellipsoid along y-axis

r_3: Amount to scale ellipsoid along z-axis

theta: Angle to rotate ellipsoid in xy-plane

amp: Factor by which pressure is enhanced at peak of exponential

Returns:

new_pressure: Pressure profile with ellipsoid added
Source code in witch/structure.py
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
@jax.jit
def add_uniform(pressure, xyz, dx, dy, dz, r_1, r_2, r_3, theta, amp):
    """
    Add ellipsoid with uniform structure to 3d pressure profile.

    Arguments:

        pressure: The pressure profile

        xyz: Coordinate grids, see make_grid for details

        dx: RA of ellipsoid center relative to grid origin

        dy: Dec of ellipsoid center relative to grid origin

        dz: Line of sight offset of ellipsoid center relative to grid origin

        r_1: Amount to scale ellipsoid along x-axis

        r_2: Amount to scale ellipsoid along y-axis

        r_3: Amount to scale ellipsoid along z-axis

        theta: Angle to rotate ellipsoid in xy-plane

        amp: Factor by which pressure is enhanced at peak of exponential

    Returns:

        new_pressure: Pressure profile with ellipsoid added
    """
    x, y, z = transform_grid(dx, dy, dz, r_1, r_2, r_3, theta, xyz)

    new_pressure = jnp.where(
        jnp.sqrt(x**2 + y**2 + z**2) > 1, pressure, (1 + amp) * pressure
    )
    return new_pressure

egaussian(dx, dy, dz, r_1, r_2, r_3, theta, sigma, amp, xyz)

Elliptical gaussian profile in 3d. This function does not include smoothing or declination stretch which should be applied at the end.

Arguments:

dx: RA of gaussian center relative to grid origin

dy: Dec of gaussian center relative to grid origin

dz: Line of sight offset of gaussian center relative to grid origin

r_1: Amount to scale along x-axis

r_2: Amount to scale along y-axis

r_3: Amount to scale along z-axis

theta: Angle to rotate in xy-plane

sigma: Sigma of the gaussian

amp: Amplitude of the gaussian

xyz: Coordinte grid to calculate model on

Returns:

model: The gaussian
Source code in witch/structure.py
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
@jax.jit
def egaussian(dx, dy, dz, r_1, r_2, r_3, theta, sigma, amp, xyz):
    """
    Elliptical gaussian profile in 3d.
    This function does not include smoothing or declination stretch
    which should be applied at the end.

    Arguments:

        dx: RA of gaussian center relative to grid origin

        dy: Dec of gaussian center relative to grid origin

        dz: Line of sight offset of gaussian center relative to grid origin

        r_1: Amount to scale along x-axis

        r_2: Amount to scale along y-axis

        r_3: Amount to scale along z-axis

        theta: Angle to rotate in xy-plane

        sigma: Sigma of the gaussian

        amp: Amplitude of the gaussian

        xyz: Coordinte grid to calculate model on

    Returns:

        model: The gaussian
    """
    x, y, z = transform_grid(dx, dy, dz, r_1, r_2, r_3, theta, xyz)

    rr = x**2 + y**2 + z**2
    power = -1 * rr / (2 * sigma**2)

    return amp * jnp.exp(power)

gaussian(dx, dy, sigma, amp, xyz)

Standard gaussian profile in 3d. This function does not include smoothing or declination stretch which should be applied at the end. The transform_grid call is awkward and can probably be removed/worked around. Function exists to match existing guassian interfaces.

Arguments:

dx: RA of gaussian center relative to grid origin

dy: Dec of gaussian center relative to grid origin

sigma: The effective, beam-convolved half-width of the point source.

amp: Amplitude of the gaussian

xyz: Coordinte grid to calculate model on

Returns:

model: The gaussian
Source code in witch/structure.py
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
@jax.jit
def gaussian(dx, dy, sigma, amp, xyz):
    """
    Standard gaussian profile in 3d.
    This function does not include smoothing or declination stretch
    which should be applied at the end. The transform_grid call is
    awkward and can probably be removed/worked around. Function exists
    to match existing guassian interfaces.

    Arguments:

        dx: RA of gaussian center relative to grid origin

        dy: Dec of gaussian center relative to grid origin

        sigma: The effective, beam-convolved half-width of the point source.

        amp: Amplitude of the gaussian

        xyz: Coordinte grid to calculate model on

    Returns:

        model: The gaussian
    """
    x, y, z = transform_grid(dx, dy, 0, 1, 1, 1, 0, xyz)
    rr = x[..., 0] ** 2 + y[..., 0] ** 2
    power = -1 * rr / (2 * sigma**2)

    return amp * jnp.exp(power)

gnfw(dx, dy, dz, r_1, r_2, r_3, theta, P0, c500, m500, gamma, alpha, beta, z, xyz)

Elliptical gNFW pressure profile in 3d. This function does not include smoothing or declination stretch which should be applied at the end.

Arguments:

dx: RA of cluster center relative to grid origin

dy: Dec of cluster center relative to grid origin

dz: Line of sight offset of cluster center relative to grid origin

r_1: Amount to scale along x-axis

r_2: Amount to scale along y-axis

r_3: Amount to scale along z-axis

theta: Angle to rotate in xy-plane

P0: Amplitude of the pressure profile

c500: Concentration parameter at a density contrast of 500

m500: Mass at a density contrast of 500

gamma: The central slope

alpha: The intermediate slope

beta: The outer slope

z: Redshift of cluster

xyz: Coordinte grid to calculate model on

Returns:

model: The gnfw model
Source code in witch/structure.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@jax.jit
def gnfw(dx, dy, dz, r_1, r_2, r_3, theta, P0, c500, m500, gamma, alpha, beta, z, xyz):
    """
    Elliptical gNFW pressure profile in 3d.
    This function does not include smoothing or declination stretch
    which should be applied at the end.

    Arguments:

        dx: RA of cluster center relative to grid origin

        dy: Dec of cluster center relative to grid origin

        dz: Line of sight offset of cluster center relative to grid origin

        r_1: Amount to scale along x-axis

        r_2: Amount to scale along y-axis

        r_3: Amount to scale along z-axis

        theta: Angle to rotate in xy-plane

        P0: Amplitude of the pressure profile

        c500: Concentration parameter at a density contrast of 500

        m500: Mass at a density contrast of 500

        gamma: The central slope

        alpha: The intermediate slope

        beta: The outer slope

        z: Redshift of cluster

        xyz: Coordinte grid to calculate model on

    Returns:

        model: The gnfw model
    """
    nz = get_nz(z)
    hz = get_hz(z)

    x, y, z = transform_grid(dx, dy, dz, r_1, r_2, r_3, theta, xyz)

    r500 = (m500 / (4.00 * jnp.pi / 3.00) / 5.00e02 / nz) ** (1.00 / 3.00)

    r = c500 * jnp.sqrt(x**2 + y**2 + z**2) / r500
    denominator = (r**gamma) * (1 + r**alpha) ** ((beta - gamma) / alpha)

    P500 = (
        1.65e-03
        * (m500 / (3.00e14 / h70)) ** (2.00 / 3.00 + ap)
        * hz ** (8.00 / 3.00)
        * h70**2
    )

    return P500 * P0 / denominator

isobeta(dx, dy, dz, r_1, r_2, r_3, theta, beta, amp, xyz)

Elliptical isobeta pressure profile in 3d. This function does not include smoothing or declination stretch which should be applied at the end.

Arguments:

dx: RA of cluster center relative to grid origin

dy: Dec of cluster center relative to grid origin

dz: Line of sight offset of cluster center relative to grid origin

r_1: Amount to scale along x-axis

r_2: Amount to scale along y-axis

r_3: Amount to scale along z-axis

theta: Angle to rotate in xy-plane

beta: Beta value of isobeta model

amp: Amplitude of isobeta model

xyz: Coordinte grid to calculate model on

Returns:

model: The isobeta model
Source code in witch/structure.py
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
@jax.jit
def isobeta(dx, dy, dz, r_1, r_2, r_3, theta, beta, amp, xyz):
    """
    Elliptical isobeta pressure profile in 3d.
    This function does not include smoothing or declination stretch
    which should be applied at the end.

    Arguments:

        dx: RA of cluster center relative to grid origin

        dy: Dec of cluster center relative to grid origin

        dz: Line of sight offset of cluster center relative to grid origin

        r_1: Amount to scale along x-axis

        r_2: Amount to scale along y-axis

        r_3: Amount to scale along z-axis

        theta: Angle to rotate in xy-plane

        beta: Beta value of isobeta model

        amp: Amplitude of isobeta model

        xyz: Coordinte grid to calculate model on

    Returns:

        model: The isobeta model
    """
    x, y, z = transform_grid(dx, dy, dz, r_1, r_2, r_3, theta, xyz)

    rr = 1 + x**2 + y**2 + z**2
    power = -1.5 * beta
    rrpow = rr**power

    return amp * rrpow