Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 5 new models. #118

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions RMtools_1D/models_ns/m8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# =============================================================================#
# MODEL DEFINITION FILE #
# =============================================================================#
import bilby
import numpy as np


# -----------------------------------------------------------------------------#
# Function defining the model. #
# #
# pDict = Dictionary of parameters, created by parsing inParms, below. #
# lamSqArr_m2 = Array of lambda-squared values #
# quArr = Complex array containing the Re and Im spectra. #
# -----------------------------------------------------------------------------#
def model(pDict, lamSqArr_m2):
"""

Burn Slab with a Linear RM Grad (Gaussian) beam convolved Foreground

Ref:
Tribble (1991) Eq 16
Sokoloff et al. (1998) Eq 39

"""

# Calculate the complex fractional q and u spectra
pArr = pDict["fracPol"] * np.ones_like(lamSqArr_m2)
quArr = (
pArr
* np.exp(
2j
* (np.radians(pDict["psi0_deg"]) + (0.5 * pDict["RM_radm2"] * lamSqArr_m2))
)
* (np.sin(pDict["RM_radm2"] * lamSqArr_m2) / (pDict["RM_radm2"] * lamSqArr_m2))
* np.exp(
(2j * pDict["RM_screen_radm2"] * lamSqArr_m2)
- (2.0 * lamSqArr_m2 ** (2) * pDict["sigma_RM_2"] ** 2)
)
)

return quArr


# -----------------------------------------------------------------------------#
# Priors for the above model. #
# See https://lscsoft.docs.ligo.org/bilby/prior.html for details. #
# #
# -----------------------------------------------------------------------------#
priors = {
"fracPol": bilby.prior.Uniform(
minimum=0.0, maximum=1.0, name="fracPol", latex_label="$p$"
),
"psi0_deg": bilby.prior.Uniform(
minimum=0,
maximum=180.0,
name="psi0_deg",
latex_label="$\psi_0$ (deg)",
boundary="periodic",
),
"RM_radm2": bilby.prior.Uniform(
minimum=0.0,
maximum=100.0,
name="RM_radm2",
latex_label="$RM_{src}$ (rad m$^{-2}$)",
),
"RM_screen_radm2": bilby.prior.Uniform(
minimum=-1100.0,
maximum=1100.0,
name="RM_screen_radm2",
latex_label="$RM_{scr}$ (rad m$^{-2}$)",
),
"sigma_RM_2": bilby.prior.Uniform(
minimum=0.0,
maximum=100.0,
name="sigma_RM_radm2",
latex_label="sigma_RM (rad m$^{-2}$)",
),
}
75 changes: 75 additions & 0 deletions RMtools_1D/models_ns/m9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# =============================================================================#
# MODEL DEFINITION FILE #
# =============================================================================#
import bilby
import numpy as np


# -----------------------------------------------------------------------------#
# Function defining the model. #
# #
# pDict = Dictionary of parameters, created by parsing inParms, below. #
# lamSqArr_m2 = Array of lambda-squared values #
# quArr = Complex array containing the Re and Im spectra. #
# -----------------------------------------------------------------------------#
def model(pDict, lamSqArr_m2):
"""

Random Slab with a Linear RM Grad (Gaussian) beam convolved Foreground

Ref:
Burn (1966) Eq 17
Sokoloff et al. (1998) Eq 34,B1,A2

"""

# fmt: off

# Calculate the complex fractional q and u spectra
pArr = pDict["fracPol"] * np.ones_like(lamSqArr_m2)
para_S = (2. * lamSqArr_m2**2 * pDict["sigmaRM_slab_radm2"]**2)

quArr = (pArr * np.exp(2j * (np.radians(pDict["psi0_deg"]))) *
((1 - np.exp(-1.*para_S)) / para_S) *
np.exp((2j * pDict["RM_screen_radm2"] * lamSqArr_m2) - (2.0 * lamSqArr_m2**(2) * pDict["sigmaRM_fg_radm2"]**2)))

# fmt: on

return quArr


# -----------------------------------------------------------------------------#
# Priors for the above model. #
# See https://lscsoft.docs.ligo.org/bilby/prior.html for details. #
# #
# -----------------------------------------------------------------------------#
priors = {
"fracPol": bilby.prior.Uniform(
minimum=0.0, maximum=1.0, name="fracPol", latex_label=r"$p$"
),
"psi0_deg": bilby.prior.Uniform(
minimum=0,
maximum=180.0,
name="psi0_deg",
latex_label=r"$\psi_0$ (deg)",
boundary="periodic",
),
"sigmaRM_slab_radm2": bilby.prior.Uniform(
minimum=0.0,
maximum=100.0,
name="sigmaRM_SB_radm2",
latex_label=r"$\sigma_{SB,RM}$ (rad m$^{-2}$)",
),
"RM_screen_radm2": bilby.prior.Uniform(
minimum=-1100.0,
maximum=1100.0,
name="RM_screen_radm2",
latex_label="$RM_{scr}$ (rad m$^{-2}$)",
),
"sigmaRM_fg_radm2": bilby.prior.Uniform(
minimum=0.0,
maximum=100.0,
name="sigmaRM_FG_radm2",
latex_label=r"$\sigma_{FG,RM}$ (rad m$^{-2}$)",
),
}
66 changes: 66 additions & 0 deletions RMtools_1D/models_ns/m9_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# =============================================================================#
# MODEL DEFINITION FILE #
# =============================================================================#
import bilby
import numpy as np


# -----------------------------------------------------------------------------#
# Function defining the model. #
# #
# pDict = Dictionary of parameters, created by parsing inParms, below. #
# lamSqArr_m2 = Array of lambda-squared values #
# quArr = Complex array containing the Re and Im spectra. #
# -----------------------------------------------------------------------------#
def model(pDict, lamSqArr_m2):
"""

Random Slab with a Unif Foreground Screen

Ref:
Burn (1966) Eq 17
Sokoloff et al. (1998) Eq 34,B1,A2

"""

# fmt: off

# Calculate the complex fractional q and u spectra
pArr = pDict["fracPol"] * np.ones_like(lamSqArr_m2)
para_S = (2. * lamSqArr_m2**2 * pDict["sigmaRM_slab_radm2"]**2)

quArr = (pArr * np.exp(2j * (np.radians(pDict["psi0_deg"]) + pDict["RM_screen_radm2"] * lamSqArr_m2)) * ((1 - np.exp(-1.*para_S)) / para_S))
# fmt: on

return quArr


# -----------------------------------------------------------------------------#
# Priors for the above model. #
# See https://lscsoft.docs.ligo.org/bilby/prior.html for details. #
# #
# -----------------------------------------------------------------------------#
priors = {
"fracPol": bilby.prior.Uniform(
minimum=0.0, maximum=1.0, name="fracPol", latex_label=r"$p$"
),
"psi0_deg": bilby.prior.Uniform(
minimum=0,
maximum=180.0,
name="psi0_deg",
latex_label=r"$\psi_0$ (deg)",
boundary="periodic",
),
"sigmaRM_slab_radm2": bilby.prior.Uniform(
minimum=0.0,
maximum=100.0,
name="sigmaRM_SB_radm2",
latex_label=r"$\sigma_{SB,RM}$ (rad m$^{-2}$)",
),
"RM_screen_radm2": bilby.prior.Uniform(
minimum=-1100.0,
maximum=1100.0,
name="RM_screen_radm2",
latex_label="$RM_{scr}$ (rad m$^{-2}$)",
),
}
Loading