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

Generalisable networks #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion examples/Nell_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.8.5"
}
},
"nbformat": 4,
Expand Down
5 changes: 3 additions & 2 deletions schnell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
NoiseCorrelationConstantIdentity,
NoiseCorrelationConstantR,
NoiseCorrelationFromFunctions,
NoiseCorrelationLISA)
NoiseCorrelationLISA,
NoiseCorrelationBoxDiagonal)
from .detector import ( # noqa
Detector, GroundDetectorTriangle,
GroundDetector, LISADetector)
__version__ = '0.2.0'
__version__ = '0.3.0'
35 changes: 34 additions & 1 deletion schnell/correlation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
from scipy.linalg import block_diag
from .detector import LISADetector


Expand All @@ -9,7 +10,7 @@ class NoiseCorrelationBase(object):
Do not use the bare class.
"""
def __init__(self, ndet):
self.ndet
self.ndet = ndet

def _get_corrmat(self, f):
raise NotImplementedError("Don't use the NoiseCorrelationBase class")
Expand Down Expand Up @@ -81,6 +82,38 @@ def __init__(self, ndet, r):
np.full([self.ndet, self.ndet], r))


class NoiseCorrelationBoxDiagonal(NoiseCorrelationBase):
""" This implements a correlation matrix from a set of
noise correlation objects. The resulting matrix will be
the combination of all correlation matrices in a
block-diagonal way.

Args:
corrs: list of `NoiseCorrelationBase` objects.
"""
def __init__(self, corrs):
if not isinstance(corrs, list):
raise TypeError("`corr` must be a list of "
"`NoiseCorrelation` objects.")
self.ncorrs = len(corrs)
for c in corrs:
if not isinstance(c, NoiseCorrelationBase):
raise TypeError("`corr` must be a list of "
"`NoiseCorrelation` objects.")
self.corrs = corrs
self.ndet = np.sum([c.ndet for c in self.corrs])

def _get_corrmat(self, f):
f_use = np.atleast_1d(f)
mats = np.array([c.get_corrmat(f_use)
for c in self.corrs])
mat = np.zeros([len(f_use), self.ndet, self.ndet])
for i, freq in enumerate(f_use):
ms = mats[:, i, :, :]
mat[i, :, :] = block_diag(*ms)
return mat


class NoiseCorrelationFromFunctions(NoiseCorrelationBase):
""" This implements a correlation matrix that has
the same auto-correlation PSD for all detectors and
Expand Down
8 changes: 5 additions & 3 deletions schnell/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,15 @@ class LISADetector(Detector):
static (bool): if `True`, a static configuration corresponding
to a perfect equilateral triangle in the x-y plane will
be assumed.
kappa (float): initial longitude (degrees).
lambd (float): initial orientation angle (degrees).
"""
trans_freq_earth = 2 * np.pi / (365 * 24 * 3600)
R_AU = 1.496E11
kap = 0 # initial longitude
lam = 0 # initial orientation
clight = 299792458.

def __init__(self, detector_id, is_L5Gm=False,
static=False):
static=False, kappa=0, lambd=0):
self.i_d = detector_id % 3
self.name = 'LISA_%d' % self.i_d
self.get_transfer = self._get_transfer_LISA
Expand All @@ -384,6 +384,8 @@ def __init__(self, detector_id, is_L5Gm=False,
self.L = 2.5E9
self.e = 0.00482419
self.static = static
self.kap = np.radians(kappa) # initial longitude
self.lam = np.radians(lambd) # Orientation angle

def _get_transfer_LISA(self, u, f, nv):
# Eq. 48 in astro-ph/0105374
Expand Down