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.

See the docstring for gnfw for more details.

Parameters:

Name Type Description Default
dx float

RA of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dy float

Dec of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dz float

Line of sight offset of cluster center relative to grid origin. Passed to utils.transform_grid.

required
theta float

Angle to rotate in xy-plane. Passed to utils.transform_grid.

required
P0 float

Amplitude of the pressure profile

required
c500 float

Concentration parameter at a density contrast of 500

required
m500 float

Mass at a density contrast of 500

required
gamma float

The central slope

required
alpha float

The intermediate slope

required
beta float

The outer slope

required
z float

Redshift of cluster

required
xyz tuple[Array, Array, Array, float, float]

Coordinte grid to calculate model on. See containers.Model.xyz for details.

required

Returns:

Name Type Description
model Array

The gnfw model evaluated on the grid.

Source code in witch/structure.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@jax.jit
def a10(
    dx: float,
    dy: float,
    dz: float,
    theta: float,
    P0: float,
    c500: float,
    m500: float,
    gamma: float,
    alpha: float,
    beta: float,
    z: float,
    xyz: tuple[jax.Array, jax.Array, jax.Array, float, float],
) -> jax.Array:
    r"""
    gNFW pressure profile in 3d based on [Arnaud2010](https://ui.adsabs.harvard.edu/abs/2010A%26A...517A..92A/).
    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.

    See the docstring for `gnfw` for more details.

    Parameters
    ----------
    dx : float
        RA of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dy : float
        Dec of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dz : float
        Line of sight offset of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    theta : float
        Angle to rotate in xy-plane.
        Passed to `utils.transform_grid`.
    P0 : float
        Amplitude of the pressure profile
    c500 : float
        Concentration parameter at a density contrast of 500
    m500 : float
        Mass at a density contrast of 500
    gamma : float
        The central slope
    alpha : float
        The intermediate slope
    beta : float
        The outer slope
    z : float
        Redshift of cluster
    xyz : tuple[jax.Array, jax.Array, jax.Array, float, float]
        Coordinte grid to calculate model on.
        See `containers.Model.xyz` for details.

    Returns
    -------
    model : jax.Array
        The gnfw model evaluated on the grid.
    """

    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.

After transforming the grid the region where \(\sqrt{x^2 + y^2 + z^2} \leq 1\) will be multiplied by a factor of \(1 + P_{0} e^{x_k(x-x_0) + y_k(y-y_0) + z_k(z-z_0)}\) where \(P_{0}\) is amp.

Parameters:

Name Type Description Default
pressure Array

The pressure profile to modify with this ellipsoid. Should be evaluated on the same grid as xyz.

required
xyz tuple[Array, Array, Array, float, float]

Coordinte grid to calculate model on. See containers.Model.xyz for details.

required
dx float

RA of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dy float

Dec of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dz float

Line of sight offset of cluster center relative to grid origin. Passed to utils.transform_grid.

required
r_1 float

Amount to scale along x-axis. Passed to utils.transform_grid.

required
r_2 float

Amount to scale along y-axis. Passed to utils.transform_grid.

required
r_3 float

Amount to scale along z-axis. Passed to utils.transform_grid.

required
theta float

Angle to rotate in xy-plane. Passed to utils.transform_grid.

required
amp float

Factor by which pressure is enhanced at the peak of ellipsoid.

required
xk float

Power of exponential in RA direction

required
x0 float

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

required
yk float

Power of exponential in Dec direction

required
y0 float

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

required
zk float

Power of exponential along the line of sight

required
z0 float

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

required

Returns:

Name Type Description
new_pressure Array

Pressure profile with ellipsoid added.

Source code in witch/structure.py
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
@jax.jit
def add_exponential(
    pressure: jax.Array,
    xyz: tuple[jax.Array, jax.Array, jax.Array, float, float],
    dx: float,
    dy: float,
    dz: float,
    r_1: float,
    r_2: float,
    r_3: float,
    theta: float,
    amp: float,
    xk: float,
    x0: float,
    yk: float,
    y0: float,
    zk: float,
    z0: float,
) -> jax.Array:
    r"""
    Add ellipsoid with exponential structure to 3d pressure profile.

    After transforming the grid the region where $\sqrt{x^2 + y^2 + z^2} \leq 1$
    will be multiplied by a factor of $1 + P_{0} e^{x_k(x-x_0) + y_k(y-y_0) + z_k(z-z_0)}$
    where $P_{0}$ is `amp`.

    Parameters
    ----------
    pressure : jax.Array
        The pressure profile to modify with this ellipsoid.
        Should be evaluated on the same grid as `xyz`.
    xyz : tuple[jax.Array, jax.Array, jax.Array, float, float]
        Coordinte grid to calculate model on.
        See `containers.Model.xyz` for details.
    dx : float
        RA of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dy : float
        Dec of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dz : float
        Line of sight offset of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    r_1 : float
        Amount to scale along x-axis.
        Passed to `utils.transform_grid`.
    r_2 : float
        Amount to scale along y-axis.
        Passed to `utils.transform_grid`.
    r_3 : float
        Amount to scale along z-axis.
        Passed to `utils.transform_grid`.
    theta : float
        Angle to rotate in xy-plane.
        Passed to `utils.transform_grid`.
    amp : float
        Factor by which pressure is enhanced at the peak of ellipsoid.
    xk : float
        Power of exponential in RA direction
    x0 : float
        RA offset of exponential.
        Note that this is in transformed coordinates so x0=1 is at xs + sr_1.
    yk : float
        Power of exponential in Dec direction
    y0 : float
        Dec offset of exponential.
        Note that this is in transformed coordinates so y0=1 is at ys + sr_2.
    zk : float
        Power of exponential along the line of sight
    z0 : float
        Line of sight offset of exponential.
        Note that this is in transformed coordinates so z0=1 is at zs + sr_3.

    Returns
    -------
    new_pressure : Array
        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.

After transforming the grid the region where \(\sqrt{x^2 + y^2 + z^2} \leq 1\) will be multiplied by a factor of \(1 + P_{0}(1 - {1 + r}^{-k_r})(1 - {1 + \phi}^{-k_{\phi}})\). Where \(r\) and \(\phi\) are the usual polar coordinates and \(P_{0}\) is amp.

Parameters:

Name Type Description Default
pressure Array

The pressure profile to modify with this ellipsoid. Should be evaluated on the same grid as xyz.

required
xyz tuple[Array, Array, Array, float, float]

Coordinte grid to calculate model on. See containers.Model.xyz for details.

required
dx float

RA of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dy float

Dec of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dz float

Line of sight offset of cluster center relative to grid origin. Passed to utils.transform_grid.

required
r_1 float

Amount to scale along x-axis. Passed to utils.transform_grid.

required
r_2 float

Amount to scale along y-axis. Passed to utils.transform_grid.

required
r_3 float

Amount to scale along z-axis. Passed to utils.transform_grid.

required
theta float

Angle to rotate in xy-plane. Passed to utils.transform_grid.

required
amp float

Factor by which pressure is enhanced within the ellipsoid.

required
phi0 float

Polar angle of nose of power law.

required
k_r float

Slope of power law in radial direction.

required
k_phi float

Slope of power law in polar direction.

required

Returns:

Name Type Description
new_pressure Array

Pressure profile with ellipsoid added.

Source code in witch/structure.py
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
@jax.jit
def add_powerlaw(
    pressure: jax.Array,
    xyz: tuple[jax.Array, jax.Array, jax.Array, float, float],
    dx: float,
    dy: float,
    dz: float,
    r_1: float,
    r_2: float,
    r_3: float,
    theta: float,
    amp: float,
    phi0: float,
    k_r: float,
    k_phi: float,
) -> jax.Array:
    r"""
    Add ellipsoid with power law structure to 3d pressure profile.

    After transforming the grid the region where $\sqrt{x^2 + y^2 + z^2} \leq 1$
    will be multiplied by a factor of $1 + P_{0}(1 - {1 + r}^{-k_r})(1 - {1 + \phi}^{-k_{\phi}})$.
    Where $r$ and $\phi$ are the usual polar coordinates and $P_{0}$ is `amp`.

    Parameters
    ----------
    pressure : jax.Array
        The pressure profile to modify with this ellipsoid.
        Should be evaluated on the same grid as `xyz`.
    xyz : tuple[jax.Array, jax.Array, jax.Array, float, float]
        Coordinte grid to calculate model on.
        See `containers.Model.xyz` for details.
    dx : float
        RA of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dy : float
        Dec of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dz : float
        Line of sight offset of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    r_1 : float
        Amount to scale along x-axis.
        Passed to `utils.transform_grid`.
    r_2 : float
        Amount to scale along y-axis.
        Passed to `utils.transform_grid`.
    r_3 : float
        Amount to scale along z-axis.
        Passed to `utils.transform_grid`.
    theta : float
        Angle to rotate in xy-plane.
        Passed to `utils.transform_grid`.
    amp : float
        Factor by which pressure is enhanced within the ellipsoid.
    phi0 : float
        Polar angle of nose of power law.
    k_r : float
        Slope of power law in radial direction.
    k_phi : float
        Slope of power law in polar direction.

    Returns
    -------
    new_pressure : Array
        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 cosine dependant structure to 3d pressure profile.

After transforming the grid the region where \(\sqrt{x^2 + y^2 + z^2} \leq 1\) will be multiplied by a factor of \(1 + P_{0} ({1 + r}^{-k_r}) \left| cos(\omega\phi) \right|\). Where \(r\) and \(\phi\) are the usual polar coordinates and \(P_{0}\) is amp.

Parameters:

Name Type Description Default
pressure Array

The pressure profile to modify with this ellipsoid. Should be evaluated on the same grid as xyz.

required
xyz tuple[Array, Array, Array, float, float]

Coordinte grid to calculate model on. See containers.Model.xyz for details.

required
dx float

RA of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dy float

Dec of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dz float

Line of sight offset of cluster center relative to grid origin. Passed to utils.transform_grid.

required
r_1 float

Amount to scale along x-axis. Passed to utils.transform_grid.

required
r_2 float

Amount to scale along y-axis. Passed to utils.transform_grid.

required
r_3 float

Amount to scale along z-axis. Passed to utils.transform_grid.

required
theta float

Angle to rotate in xy-plane. Passed to utils.transform_grid.

required
amp float

Factor by which pressure is enhanced within the ellipsoid.

required
phi0 float

Polar angle of nose of power law.

required
k_r float

Slope of power law in radial direction.

required
omega float

Angular freqency of the cosine term.

required

Returns:

Name Type Description
new_pressure Array

Pressure profile with ellipsoid added.

Source code in witch/structure.py
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
@jax.jit
def add_powerlaw_cos(
    pressure: jax.Array,
    xyz: tuple[jax.Array, jax.Array, jax.Array, float, float],
    dx: float,
    dy: float,
    dz: float,
    r_1: float,
    r_2: float,
    r_3: float,
    theta: float,
    amp: float,
    phi0: float,
    k_r: float,
    omega: float,
) -> jax.Array:
    r"""
    Add ellipsoid with radial power law and angular cosine dependant structure to 3d pressure profile.

    After transforming the grid the region where $\sqrt{x^2 + y^2 + z^2} \leq 1$
    will be multiplied by a factor of $1 + P_{0} ({1 + r}^{-k_r}) \left| cos(\omega\phi) \right|$.
    Where $r$ and $\phi$ are the usual polar coordinates and $P_{0}$ is `amp`.

    Parameters
    ----------
    pressure : jax.Array
        The pressure profile to modify with this ellipsoid.
        Should be evaluated on the same grid as `xyz`.
    xyz : tuple[jax.Array, jax.Array, jax.Array, float, float]
        Coordinte grid to calculate model on.
        See `containers.Model.xyz` for details.
    dx : float
        RA of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dy : float
        Dec of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dz : float
        Line of sight offset of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    r_1 : float
        Amount to scale along x-axis.
        Passed to `utils.transform_grid`.
    r_2 : float
        Amount to scale along y-axis.
        Passed to `utils.transform_grid`.
    r_3 : float
        Amount to scale along z-axis.
        Passed to `utils.transform_grid`.
    theta : float
        Angle to rotate in xy-plane.
        Passed to `utils.transform_grid`.
    amp : float
        Factor by which pressure is enhanced within the ellipsoid.
    phi0 : float
        Polar angle of nose of power law.
    k_r : float
        Slope of power law in radial direction.
    omega : float
        Angular freqency of the cosine term.

    Returns
    -------
    new_pressure : Array
        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 * jnp.abs(jnp.cos(omega * phi)) * jnp.float_power(r, k_r)
    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.

After transforming the grid the region where \(\sqrt{x^2 + y^2 + z^2} \leq 1\) will be multiplied by a factor of \(1 + P_{0}\) where \(P_{0}\) is amp.

Parameters:

Name Type Description Default
pressure Array

The pressure profile to modify with this ellipsoid. Should be evaluated on the same grid as xyz.

required
xyz tuple[Array, Array, Array, float, float]

Coordinte grid to calculate model on. See containers.Model.xyz for details.

required
dx float

RA of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dy float

Dec of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dz float

Line of sight offset of cluster center relative to grid origin. Passed to utils.transform_grid.

required
r_1 float

Amount to scale along x-axis. Passed to utils.transform_grid.

required
r_2 float

Amount to scale along y-axis. Passed to utils.transform_grid.

required
r_3 float

Amount to scale along z-axis. Passed to utils.transform_grid.

required
theta float

Angle to rotate in xy-plane. Passed to utils.transform_grid.

required
amp float

Factor by which pressure is enhanced within the ellipsoid.

required

Returns:

Name Type Description
new_pressure Array

Pressure profile with ellipsoid added.

Source code in witch/structure.py
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
@jax.jit
def add_uniform(
    pressure: jax.Array,
    xyz: tuple[jax.Array, jax.Array, jax.Array, float, float],
    dx: float,
    dy: float,
    dz: float,
    r_1: float,
    r_2: float,
    r_3: float,
    theta: float,
    amp: float,
) -> jax.Array:
    r"""
    Add ellipsoid with uniform structure to 3d pressure profile.

    After transforming the grid the region where $\sqrt{x^2 + y^2 + z^2} \leq 1$
    will be multiplied by a factor of $1 + P_{0}$ where $P_{0}$ is `amp`.

    Parameters
    ----------
    pressure : jax.Array
        The pressure profile to modify with this ellipsoid.
        Should be evaluated on the same grid as `xyz`.
    xyz : tuple[jax.Array, jax.Array, jax.Array, float, float]
        Coordinte grid to calculate model on.
        See `containers.Model.xyz` for details.
    dx : float
        RA of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dy : float
        Dec of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dz : float
        Line of sight offset of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    r_1 : float
        Amount to scale along x-axis.
        Passed to `utils.transform_grid`.
    r_2 : float
        Amount to scale along y-axis.
        Passed to `utils.transform_grid`.
    r_3 : float
        Amount to scale along z-axis.
        Passed to `utils.transform_grid`.
    theta : float
        Angle to rotate in xy-plane.
        Passed to `utils.transform_grid`.
    amp : float
        Factor by which pressure is enhanced within the ellipsoid.

    Returns
    -------
    new_pressure : Array
        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

cylindrical_beta(dx, dy, dz, L, theta, P0, r_c, beta, xyz)

This function does not include smoothing or declination stretch which should be applied at the end.

Once the grid is transformed the profile is computed as:

\[ P_{0}\left( 1 + \frac{y^2 + z^2}{{r_c}^2} \right)^{-1.5\beta} \]

Parameters:

Name Type Description Default
dx float

RA of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dy float

Dec of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dz float

Line of sight offset of cluster center relative to grid origin. Passed to utils.transform_grid.

required
L float

Length of the cylinder. Aligned with the x-axis. Note that we consider anything where \(\left| x \right| \\leq L\) to be in the profile, so the actual length is \(2L\).

required
theta float

Angle to rotate in xy-plane. Passed to utils.transform_grid.

required
P0 float

Amplitude of the pressure profile.

required
r_c float

The critical radius of the cylindrical profile.

required
beta float

Beta value of isobeta model.

required
xyz tuple[Array, Array, Array, float, float]

Coordinte grid to calculate model on. See containers.Model.xyz for details.

required

Returns:

Name Type Description
model Array

The cylindrical beta model evaluated on the grid.

Source code in witch/structure.py
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
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
@jax.jit
def cylindrical_beta(
    dx: float,
    dy: float,
    dz: float,
    L: float,
    theta: float,
    P0: float,
    r_c: float,
    beta: float,
    xyz: tuple[jax.Array, jax.Array, jax.Array, float, float],
) -> jax.Array:
    r"""

    This function does not include smoothing or declination stretch
    which should be applied at the end.

    Once the grid is transformed the profile is computed as:

    $$
    P_{0}\left( 1 + \frac{y^2 + z^2}{{r_c}^2} \right)^{-1.5\beta}
    $$

    Parameters
    ----------
    dx : float
        RA of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dy : float
        Dec of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dz : float
        Line of sight offset of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    L : float
        Length of the cylinder.
        Aligned with the x-axis.
        Note that we consider anything where $\left| x \right| \\leq L$
        to be in the profile, so the actual length is $2L$.
    theta : float
        Angle to rotate in xy-plane.
        Passed to `utils.transform_grid`.
    P0 : float
        Amplitude of the pressure profile.
    r_c : float
        The critical radius of the cylindrical profile.
    beta : float
        Beta value of isobeta model.
    xyz : tuple[jax.Array, jax.Array, jax.Array, float, float]
        Coordinte grid to calculate model on.
        See `containers.Model.xyz` for details.

    Returns
    -------
    model : jax.Array
        The cylindrical beta model evaluated on the grid.
    """
    x, y, z, *_ = transform_grid(dx, dy, dz, 1.0, 1.0, 1.0, theta, xyz)
    r = jnp.sqrt(y**2 + z**2)
    powerlaw = P0 / (1.0 + (r / r_c) ** 2) ** (3.0 / 2.0 * beta)

    pressure = jnp.where(jnp.abs(x) >= L / 2.0, 0, powerlaw)

    return pressure

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

Eliptical gNFW pressure profile in 3d based on Arnaud2010. r_ell is computed in the usual way for an a10 profile, then the axes are scaled according to r_1, r_2, r_3, with a normalization applied. This function does not include smoothing or declination stretch which should be applied at the end.

See the docstring for gnfw for more details.

Parameters:

Name Type Description Default
dx float

RA of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dy float

Dec of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dz float

Line of sight offset of cluster center relative to grid origin. Passed to utils.transform_grid.

required
r_1 float

Amount to scale along x-axis. Units are arbitrary, only ratio of r_1/r_2, r_1/r_3, r_2/r_3 matters Passed to utils.transform_grid.

required
r_2 float

Amount to scale along y-axis. Passed to utils.transform_grid.

required
r_3 float

Amount to scale along z-axis. Passed to utils.transform_grid.

required
theta float

Angle to rotate in xy-plane. Passed to utils.transform_grid.

required
P0 float

Amplitude of the pressure profile

required
c500 float

Concentration parameter at a density contrast of 500

required
m500 float

Mass at a density contrast of 500

required
gamma float

The central slope

required
alpha float

The intermediate slope

required
beta float

The outer slope

required
z float

Redshift of cluster

required
xyz tuple[Array, Array, Array, float, float]

Coordinte grid to calculate model on. See containers.Model.xyz for details.

required

Returns:

Name Type Description
model Array

The gnfw model evaluated on the grid.

Source code in witch/structure.py
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
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
252
253
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
@jax.jit
def ea10(
    dx: float,
    dy: float,
    dz: float,
    r_1: float,
    r_2: float,
    r_3: float,
    theta: float,
    P0: float,
    c500: float,
    m500: float,
    gamma: float,
    alpha: float,
    beta: float,
    z: float,
    xyz: tuple[jax.Array, jax.Array, jax.Array, float, float],
) -> jax.Array:
    r"""
    Eliptical gNFW pressure profile in 3d based on Arnaud2010.
    r_ell is computed in the usual way for an a10 profile, then the axes are
    scaled according to r_1, r_2, r_3, with a normalization applied.
    This function does not include smoothing or declination stretch
    which should be applied at the end.

    See the docstring for `gnfw` for more details.

    Parameters
    ----------
    dx : float
        RA of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dy : float
        Dec of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dz : float
        Line of sight offset of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    r_1 : float
        Amount to scale along x-axis.
        Units are arbitrary, only ratio of r_1/r_2, r_1/r_3, r_2/r_3 matters
        Passed to `utils.transform_grid`.
    r_2 : float
        Amount to scale along y-axis.
        Passed to `utils.transform_grid`.
    r_3 : float
        Amount to scale along z-axis.
        Passed to `utils.transform_grid`.
    theta : float
        Angle to rotate in xy-plane.
        Passed to `utils.transform_grid`.
    P0 : float
        Amplitude of the pressure profile
    c500 : float
        Concentration parameter at a density contrast of 500
    m500 : float
        Mass at a density contrast of 500
    gamma : float
        The central slope
    alpha : float
        The intermediate slope
    beta : float
        The outer slope
    z : float
        Redshift of cluster
    xyz : tuple[jax.Array, jax.Array, jax.Array, float, float]
        Coordinte grid to calculate model on.
        See `containers.Model.xyz` for details.

    Returns
    -------
    model : jax.Array
        The gnfw model evaluated on the grid.
    """
    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_ell = r500 / da
    r_norm = (r_1 * r_2 * r_3) ** (1 / 3)

    r_1 *= r_ell / r_norm
    r_2 *= r_ell / r_norm
    r_3 *= r_ell / r_norm

    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

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.

Once the grid is transformed the profile is computed as:

\[ P_{0} e^{-\frac{x^2 + y^2 + z^2}{2\sigma^2}} \]

where \(P_{0}\) is amp.

Parameters:

Name Type Description Default
dx float

RA of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dy float

Dec of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dz float

Line of sight offset of cluster center relative to grid origin. Passed to utils.transform_grid.

required
r_1 float

Amount to scale along x-axis. Passed to utils.transform_grid.

required
r_2 float

Amount to scale along y-axis. Passed to utils.transform_grid.

required
r_3 float

Amount to scale along z-axis. Passed to utils.transform_grid.

required
theta float

Angle to rotate in xy-plane. Passed to utils.transform_grid.

required
sigma float

Sigma value of gaussian model.

required
amp float

Amplitude of gaussian model.

required
xyz tuple[Array, Array, Array, float, float]

Coordinte grid to calculate model on. See containers.Model.xyz for details.

required

Returns:

Name Type Description
model Array

The gaussain model evaluated on the grid.

Source code in witch/structure.py
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
@jax.jit
def egaussian(
    dx: float,
    dy: float,
    dz: float,
    r_1: float,
    r_2: float,
    r_3: float,
    theta: float,
    sigma: float,
    amp: float,
    xyz: tuple[jax.Array, jax.Array, jax.Array, float, float],
) -> jax.Array:
    r"""
    Elliptical gaussian profile in 3d.
    This function does not include smoothing or declination stretch
    which should be applied at the end.

    Once the grid is transformed the profile is computed as:

    $$
    P_{0} e^{-\frac{x^2 + y^2 + z^2}{2\sigma^2}}
    $$

    where $P_{0}$ is `amp`.

    Parameters
    ----------
    dx : float
        RA of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dy : float
        Dec of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dz : float
        Line of sight offset of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    r_1 : float
        Amount to scale along x-axis.
        Passed to `utils.transform_grid`.
    r_2 : float
        Amount to scale along y-axis.
        Passed to `utils.transform_grid`.
    r_3 : float
        Amount to scale along z-axis.
        Passed to `utils.transform_grid`.
    theta : float
        Angle to rotate in xy-plane.
        Passed to `utils.transform_grid`.
    sigma : float
        Sigma value of gaussian model.
    amp : float
        Amplitude of gaussian model.
    xyz : tuple[jax.Array, jax.Array, jax.Array, float, float]
        Coordinte grid to calculate model on.
        See `containers.Model.xyz` for details.

    Returns
    -------
    model : jax.Array
        The gaussain model evaluated on the grid.
    """
    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 2d. 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.

Once the grid is transformed the profile is computed as:

\[ P_{0} e^{-\frac{x^2 + y^2}{2\sigma^2}} \]

where \(P_{0}\) is amp.

Parameters:

Name Type Description Default
dx float

RA of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dy float

Dec of cluster center relative to grid origin. Passed to utils.transform_grid.

required
sigma float

Sigma value of gaussian model.

required
amp float

Amplitude of gaussian model.

required
xyz tuple[Array, Array, Array, float, float]

Coordinte grid to calculate model on. We only care about x and y here. See containers.Model.xyz for details.

required

Returns:

Name Type Description
model Array

The gaussian model evaluated on only the 2d xy grid.

Source code in witch/structure.py
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
@jax.jit
def gaussian(
    dx: float,
    dy: float,
    sigma: float,
    amp: float,
    xyz: tuple[jax.Array, jax.Array, jax.Array, float, float],
) -> jax.Array:
    r"""
    Standard gaussian profile in 2d.
    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.

    Once the grid is transformed the profile is computed as:

    $$
    P_{0} e^{-\frac{x^2 + y^2}{2\sigma^2}}
    $$

    where $P_{0}$ is `amp`.

    Parameters
    ----------
    dx : float
        RA of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dy : float
        Dec of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    sigma : float
        Sigma value of gaussian model.
    amp : float
        Amplitude of gaussian model.
    xyz : tuple[jax.Array, jax.Array, jax.Array, float, float]
        Coordinte grid to calculate model on.
        We only care about x and y here.
        See `containers.Model.xyz` for details.

    Returns
    -------
    model : jax.Array
        The gaussian model evaluated on only the 2d xy grid.
    """
    x, y, *_ = 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. TODO: Add units to add parameters!

Once the grid is transformed the profile is computed as:

\[ \dfrac{P_{500} * P_{0}}{{\left( r^{\gamma}\left( 1 + r^{\alpha} \right) \right)}^{\dfrac{\beta - \gamma}{\alpha}}} \]

where:

\[ r = c_{500} \sqrt{x^2 + y^2 + z^2} {\frac{3m_{500}}{2000 \pi n_z}}^{-\frac{1}{3}} \]
\[ P_{500} = 1.65 \times 10^{-3} {\frac{m_{500}*h_{70}}{3 \times 10^{14}}}^{\frac{2}{3} + ap}{h_z}^{\frac{8}{3}}{h_{70}}^2 \]

\(n_z\) is the critical density at the cluster redshift and \(h_z\) is the Hubble constant at the cluster redshift.

Parameters:

Name Type Description Default
dx float

RA of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dy float

Dec of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dz float

Line of sight offset of cluster center relative to grid origin. Passed to utils.transform_grid.

required
r_1 float

Amount to scale along x-axis. Passed to utils.transform_grid.

required
r_2 float

Amount to scale along y-axis. Passed to utils.transform_grid.

required
r_3 float

Amount to scale along z-axis. Passed to utils.transform_grid.

required
theta float

Angle to rotate in xy-plane. Passed to utils.transform_grid.

required
P0 float

Amplitude of the pressure profile.

required
c500 float

Concentration parameter at a density contrast of 500.

required
m500 float

Mass at a density contrast of 500.

required
gamma float

The central slope.

required
alpha float

The intermediate slope.

required
beta float

The outer slope.

required
z float

Redshift of cluster.

required
xyz tuple[Array, Array, Array, float, float]

Coordinte grid to calculate model on. See containers.Model.xyz for details.

required

Returns:

Name Type Description
model Array

The gnfw model evaluated on the grid.

Source code in witch/structure.py
 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
 76
 77
 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
@jax.jit
def gnfw(
    dx: float,
    dy: float,
    dz: float,
    r_1: float,
    r_2: float,
    r_3: float,
    theta: float,
    P0: float,
    c500: float,
    m500: float,
    gamma: float,
    alpha: float,
    beta: float,
    z: float,
    xyz: tuple[jax.Array, jax.Array, jax.Array, float, float],
) -> jax.Array:
    r"""
    Elliptical gNFW pressure profile in 3d.
    This function does not include smoothing or declination stretch
    which should be applied at the end.
    TODO: Add units to add parameters!

    Once the grid is transformed the profile is computed as:

    $$
    \dfrac{P_{500} * P_{0}}{{\left( r^{\gamma}\left( 1 + r^{\alpha} \right) \right)}^{\dfrac{\beta - \gamma}{\alpha}}}
    $$

    where:

    $$
    r = c_{500} \sqrt{x^2 + y^2 + z^2} {\frac{3m_{500}}{2000 \pi n_z}}^{-\frac{1}{3}}
    $$

    $$
    P_{500} = 1.65 \times 10^{-3} {\frac{m_{500}*h_{70}}{3 \times 10^{14}}}^{\frac{2}{3} + ap}{h_z}^{\frac{8}{3}}{h_{70}}^2
    $$

    $n_z$ is the critical density at the cluster redshift and $h_z$ is the Hubble constant at the cluster redshift.

    Parameters
    ----------
    dx : float
        RA of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dy : float
        Dec of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dz : float
        Line of sight offset of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    r_1 : float
        Amount to scale along x-axis.
        Passed to `utils.transform_grid`.
    r_2 : float
        Amount to scale along y-axis.
        Passed to `utils.transform_grid`.
    r_3 : float
        Amount to scale along z-axis.
        Passed to `utils.transform_grid`.
    theta : float
        Angle to rotate in xy-plane.
        Passed to `utils.transform_grid`.
    P0 : float
        Amplitude of the pressure profile.
    c500 : float
        Concentration parameter at a density contrast of 500.
    m500 : float
        Mass at a density contrast of 500.
    gamma : float
        The central slope.
    alpha : float
        The intermediate slope.
    beta : float
        The outer slope.
    z : float
        Redshift of cluster.
    xyz : tuple[jax.Array, jax.Array, jax.Array, float, float]
        Coordinte grid to calculate model on.
        See `containers.Model.xyz` for details.

    Returns
    -------
    model : jax.Array
        The gnfw model evaluated on the grid.
    """
    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.

Once the grid is transformed the profile is computed as:

\[ P_{0}\left( 1 + x**2 + y**2 + z**2 \right)^{-1.5\beta} \]

where \(P_{0}\) is amp.

Parameters:

Name Type Description Default
dx float

RA of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dy float

Dec of cluster center relative to grid origin. Passed to utils.transform_grid.

required
dz float

Line of sight offset of cluster center relative to grid origin. Passed to utils.transform_grid.

required
r_1 float

Amount to scale along x-axis. Passed to utils.transform_grid.

required
r_2 float

Amount to scale along y-axis. Passed to utils.transform_grid.

required
r_3 float

Amount to scale along z-axis. Passed to utils.transform_grid.

required
theta float

Angle to rotate in xy-plane. Passed to utils.transform_grid.

required
beta float

Beta value of isobeta model.

required
amp float

Amplitude of isobeta model.

required
xyz tuple[Array, Array, Array, float, float]

Coordinte grid to calculate model on. See containers.Model.xyz for details.

required

Returns:

Name Type Description
model Array

The jax.isobeta model evaluated on the grid.

Source code in witch/structure.py
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
349
350
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
@jax.jit
def isobeta(
    dx: float,
    dy: float,
    dz: float,
    r_1: float,
    r_2: float,
    r_3: float,
    theta: float,
    beta: float,
    amp: float,
    xyz: tuple[jax.Array, jax.Array, jax.Array, float, float],
) -> jax.Array:
    r"""
    Elliptical isobeta pressure profile in 3d.
    This function does not include smoothing or declination stretch
    which should be applied at the end.

    Once the grid is transformed the profile is computed as:

    $$
    P_{0}\left( 1 + x**2 + y**2 + z**2 \right)^{-1.5\beta}
    $$

    where $P_{0}$ is `amp`.

    Parameters
    ----------
    dx : float
        RA of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dy : float
        Dec of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    dz : float
        Line of sight offset of cluster center relative to grid origin.
        Passed to `utils.transform_grid`.
    r_1 : float
        Amount to scale along x-axis.
        Passed to `utils.transform_grid`.
    r_2 : float
        Amount to scale along y-axis.
        Passed to `utils.transform_grid`.
    r_3 : float
        Amount to scale along z-axis.
        Passed to `utils.transform_grid`.
    theta : float
        Angle to rotate in xy-plane.
        Passed to `utils.transform_grid`.
    beta : float
        Beta value of isobeta model.
    amp : float
        Amplitude of isobeta model.
    xyz : tuple[jax.Array, jax.Array, jax.Array, float, float]
        Coordinte grid to calculate model on.
        See `containers.Model.xyz` for details.

    Returns
    -------
    model : Array
        The jax.isobeta model evaluated on the grid.
    """
    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