def test_sensitivity_w_rednoise(): '''Test making sensitivity curves with complex RN.''' psrs2 = hsim.sim_pta(timespan=timespan, cad=23, sigma=1e-7, phi=phi, theta=theta, A_rn=6e-16, alpha=-2 / 3., freqs=freqs) psrs3 = hsim.sim_pta(timespan=timespan, cad=23, sigma=1e-7, phi=phi, theta=theta, A_rn=A_rn, alpha=alphas, freqs=freqs) spectra2 = [] for p in psrs2: sp = hsen.Spectrum(p, freqs=freqs) _ = sp.NcalInv spectra2.append(sp) spectra3 = [] for p in psrs3: sp = hsen.Spectrum(p, freqs=freqs) _ = sp.NcalInv spectra3.append(sp) spec = spectra3[0] spec.Tf spec.S_I spec.S_R spec.h_c spec.Omega_gw sigma = spec.toaerrs.mean() dt = hsen.get_dt(spec.toas).to('s').value spec.add_white_noise_power(sigma, dt) spec.add_red_noise_power(A=6.8e-16, gamma=13 / 3.) spec.psd_prefit spec.psd_postfit spec.add_noise_power(spec.psd_prefit) hsen.corr_from_psd(freqs, spec.psd_prefit, spec.toas) sc2a = hsen.GWBSensitivityCurve(spectra2) sc2b = hsen.DeterSensitivityCurve(spectra2) sc3a = hsen.GWBSensitivityCurve(spectra3) sc3b = hsen.DeterSensitivityCurve(spectra3) sc3a.h_c sc3a.Omega_gw sc3a.S_effIJ sc3b.h_c sc3b.Omega_gw
def sc_simple(): '''Test and keep a simple sensitivity curve''' psrs = hsim.sim_pta(timespan=timespan, cad=23, sigma=1e-7, phi=phi, theta=theta) psr = psrs[0] hsen.R_matrix(psr.designmatrix, psr.N) hsen.G_matrix(psr.designmatrix) hsen.quantize_fast(psr.toas, psr.toaerrs) hsen.get_Tf(psr.designmatrix, psr.toas, psr.N, from_G=True, exact_astro_freqs=True) spectra = [] for p in psrs: sp = hsen.Spectrum(p, freqs=freqs) _ = sp.NcalInv spectra.append(sp) sc1a = hsen.GWBSensitivityCurve(spectra) sc1b = hsen.DeterSensitivityCurve(spectra) return sc1a, sc1b
def test_get_NcalInvIJ(): psrs = hsim.sim_pta(timespan=timespan, cad=23, sigma=1e-7, phi=phi, theta=theta) hsen.get_NcalInvIJ(psrs, 1e-15, freqs)
def Init_PTA(self): """Initializes a PTA in hasasia Notes ----- See Hazboun, Romano, Smith (2019) <https://arxiv.org/abs/1907.04341> for details """ #Random Sky Locations of Pulsars phi = np.random.uniform(0, 2 * np.pi, size=self.N_p) cos_theta = np.random.uniform(-1, 1, size=self.N_p) theta = np.arccos(cos_theta) if hasattr(self, 'A_GWB'): if not hasattr(self, 'alpha_GWB'): self.alpha_GWB = -2 / 3. #Make a set of psrs with the same parameters with a GWB as red noise psrs = hassim.sim_pta(timespan=self.T_obs.value,cad=self.cadence.value,sigma=self.sigma.value,\ phi=phi, theta=theta, Npsrs=self.N_p,A_rn=self.A_GWB,alpha=self.alpha_GWB,freqs=self.fT.value) elif hasattr(self, 'A_rn_min') or hasattr(self, 'alpha_rn_min'): if not hasattr(self, 'A_rn_min'): A_rn = np.random.uniform(1e-16, 1e-12, size=self.N_p) else: A_rn = np.random.uniform(self.A_rn_min, self.A_rn_max, size=self.N_p) if not hasattr(self, 'alpha_rn_min'): alphas = np.random.uniform(-3 / 4, 1, size=self.N_p) else: alphas = np.random.uniform(self.alpha_rn_min, self.alpha_rn_max, size=self.N_p) #Make a set of psrs with uniformly sampled red noise psrs = hassim.sim_pta(timespan=self.T_obs.value,cad=self.cadence.value,sigma=self.sigma.value,\ phi=phi, theta=theta, Npsrs=self.N_p,A_rn=A_rn,alpha=alphas,freqs=self.fT.value) else: #Make a set of psrs with the same parameters psrs = hassim.sim_pta(timespan=self.T_obs.value,cad=self.cadence.value,sigma=self.sigma.value,\ phi=phi, theta=theta, Npsrs=self.N_p,freqs=self.fT.value) #Get Spectra of pulsars spectra = [] for p in psrs: sp = hassens.Spectrum(p, freqs=self.fT.value) spectra.append(sp) self._sensitivitycurve = hassens.DeterSensitivityCurve(spectra)
def test_nonGR(): psrs = hsim.sim_pta(timespan=timespan, cad=23, sigma=1e-7, phi=phi,theta=theta) spectra = [] for p in psrs: sp = hsen.Spectrum(p, freqs=freqs) _ = sp.NcalInv spectra.append(sp) hsen.GWBSensitivityCurve(spectra, orf='st') hsen.GWBSensitivityCurve(spectra, orf='dipole') hsen.GWBSensitivityCurve(spectra, orf='monopole')
def sm_simple(): '''Test and keep a simple sensitivity skymap''' #Make a set of random sky positions phi = np.random.uniform(0, 2 * np.pi, size=33) cos_theta = np.random.uniform(-1, 1, size=33) theta = np.arccos(cos_theta) #Adding one well-placed sky position for plots. phi = np.append(np.array(np.deg2rad(60)), phi) theta = np.append(np.array(np.deg2rad(50)), theta) #Define the timsespans and TOA errors for the pulsars timespans = np.random.uniform(3.0, 11.4, size=34) Tspan = timespans.max() * 365.25 * 24 * 3600 sigma = 1e-7 # 100 ns #Simulate a set of identical pulsars, with different sky positions. psrs = hsim.sim_pta(timespan=11.4, cad=23, sigma=sigma, phi=phi, theta=theta) freqs = np.logspace(np.log10(1 / (5 * Tspan)), np.log10(2e-7), 500) spectra = [] for p in psrs: sp = hsen.Spectrum(p, freqs=freqs) sp.NcalInv spectra.append(sp) #Normally use the healpy functions to get the sky coordinates #Here just pull random coordinates using numpy to avoid needing healpy phi_gw = np.random.uniform(0, 2 * np.pi, size=1000) cos_theta_gw = np.random.uniform(-1, 1, size=1000) theta_gw = np.arccos(cos_theta_gw) SM = hsky.SkySensitivity(spectra, theta_gw, phi_gw) return SM
import matplotlib.pyplot as plt import numpy as np from hasasia.sim import sim_pta from hasasia.sensitivity import GWBSensitivityCurve, Spectrum, Pulsar, DeterSensitivityCurve phi = np.random.uniform(0, 2*np.pi,size=34) theta = np.random.uniform(0, np.pi,size=34) freqs = np.logspace(np.log10(5e-10),np.log10(5e-7),400) psrs = sim_pta(timespan=11.4,cad=23,sigma=1e-7, phi=phi, theta=theta, Npsrs=34) spectra = [] for p in psrs: sp = Spectrum(p, freqs=freqs) sp.NcalInv spectra.append(sp) scGWB=GWBSensitivityCurve(spectra) scDeter=DeterSensitivityCurve(spectra) plt.loglog(freqs,scGWB.h_c,label='Stochastic') plt.loglog(freqs,scDeter.h_c,label='Deterministic') plt.xlabel('Frequency [Hz]') plt.ylabel('Characteristic Strain, $h_c$') plt.legend() plt.show()
import matplotlib.pyplot as plt import numpy as np from hasasia.sim import sim_pta from hasasia.sensitivity import GWBSensitivityCurve, Spectrum, Pulsar, DeterSensitivityCurve phi = np.random.uniform(0, 2 * np.pi, size=34) theta = np.random.uniform(0, np.pi, size=34) freqs = np.logspace(np.log10(5e-10), np.log10(5e-7), 400) psrs = sim_pta(timespan=15, cad=23, sigma=1e-7, phi=phi, theta=theta, Npsrs=34) psrs3 = sim_pta(timespan=3, cad=23, sigma=1e-7, phi=phi, theta=theta, Npsrs=34) spectra = [] spectra3 = [] for p in psrs: sp = Spectrum(p, freqs=freqs) sp.NcalInv spectra.append(sp) for p in psrs3: sp = Spectrum(p, freqs=freqs) sp.NcalInv spectra3.append(sp) scGWB1 = GWBSensitivityCurve(spectra) scGWB2 = GWBSensitivityCurve(spectra3) plt.loglog(freqs, scGWB1.h_c, label='15-year Baseline') plt.loglog(freqs, scGWB2.h_c, label='3-year Baseline') plt.xlabel('Frequency [Hz]') plt.ylabel('Characteristic Strain, $h_c$') plt.legend() plt.show()
def pta_heter(): """ Sample set of pulsars for testing. """ return hsim.sim_pta(timespan=timespans,cad=23,sigma=1e-7, phi=phi,theta=theta)
def pta_simple(): """ Sample set of pulsars for testing. All Tspan=11.4 yrs """ return hsim.sim_pta(timespan=11.4, cad=23, sigma=1e-7, phi=phi, theta=theta, Npsrs=34)