Skip to content
Snippets Groups Projects
Commit 40bd9444 authored by Simon Ding's avatar Simon Ding
Browse files

Export SingleResponse; Added control over verbosity setting

parent c8d398b3
No related branches found
No related tags found
1 merge request!12Mpi likelihood
...@@ -18,7 +18,7 @@ from .plotter import MfPlotter, Plotter ...@@ -18,7 +18,7 @@ from .plotter import MfPlotter, Plotter
from .points import PointInserter from .points import PointInserter
from .polarization import polarization_matrix_exponential from .polarization import polarization_matrix_exponential
from .primary_beam import vla_beam from .primary_beam import vla_beam
from .response import MfResponse, ResponseDistributor, StokesIResponse from .response import MfResponse, ResponseDistributor, StokesIResponse, SingleResponse
from .simple_operators import * from .simple_operators import *
from .util import ( from .util import (
Reshaper, Reshaper,
......
...@@ -13,6 +13,7 @@ class AllreduceSum(ift.Operator): ...@@ -13,6 +13,7 @@ class AllreduceSum(ift.Operator):
# domain and target. In NIFTy, we generally support the addition of # domain and target. In NIFTy, we generally support the addition of
# operators that have different domains (not all keys need to be present # operators that have different domains (not all keys need to be present
# in all domains). This could be done here as well. # in all domains). This could be done here as well.
# TOASK: What domain would be picked if I have IRGSpaces with different freq_domains?
# FIXME If all operators in oplist are linear operators, we could # FIXME If all operators in oplist are linear operators, we could
# automatically instantiate AllreduceSumLinear. # automatically instantiate AllreduceSumLinear.
......
...@@ -100,7 +100,7 @@ class MfResponse(ift.LinearOperator): ...@@ -100,7 +100,7 @@ class MfResponse(ift.LinearOperator):
Contains the the :class:`nifty7.RGSpace` for the positions. Contains the the :class:`nifty7.RGSpace` for the positions.
""" """
def __init__(self, observation, frequency_domain, position_domain): def __init__(self, observation, frequency_domain, position_domain, verbose=True):
my_assert_isinstance(observation, Observation) my_assert_isinstance(observation, Observation)
# FIXME Add polarization support # FIXME Add polarization support
my_asserteq(observation.npol, 1) my_asserteq(observation.npol, 1)
...@@ -115,6 +115,7 @@ class MfResponse(ift.LinearOperator): ...@@ -115,6 +115,7 @@ class MfResponse(ift.LinearOperator):
data_freq = observation.freq data_freq = observation.freq
my_assert(np.all(np.diff(data_freq) > 0)) my_assert(np.all(np.diff(data_freq) > 0))
sky_freq = np.array(frequency_domain.coordinates) sky_freq = np.array(frequency_domain.coordinates)
# TOASK: Why is it necessary to construct band indices like this?
band_indices = [np.argmin(np.abs(ff - sky_freq)) for ff in data_freq] band_indices = [np.argmin(np.abs(ff - sky_freq)) for ff in data_freq]
# Make sure that no index is wasted # Make sure that no index is wasted
my_asserteq(len(set(band_indices)), frequency_domain.size) my_asserteq(len(set(band_indices)), frequency_domain.size)
...@@ -130,6 +131,7 @@ class MfResponse(ift.LinearOperator): ...@@ -130,6 +131,7 @@ class MfResponse(ift.LinearOperator):
observation.freq[sel], observation.freq[sel],
mask[0, :, sel].T, mask[0, :, sel].T,
sp, sp,
verbose
) )
self._r.append((band_index, sel, r)) self._r.append((band_index, sel, r))
# Double check that all channels are written to # Double check that all channels are written to
...@@ -203,7 +205,7 @@ class FullResponse(ift.LinearOperator): ...@@ -203,7 +205,7 @@ class FullResponse(ift.LinearOperator):
class SingleResponse(ift.LinearOperator): class SingleResponse(ift.LinearOperator):
def __init__(self, domain, uvw, freq, mask, single_precision): def __init__(self, domain, uvw, freq, mask, single_precision, verbose=True):
# FIXME Currently only the response uses single_precision if possible. # FIXME Currently only the response uses single_precision if possible.
# Could be rolled out to the whole likelihood # Could be rolled out to the whole likelihood
self._domain = ift.DomainTuple.make(domain) self._domain = ift.DomainTuple.make(domain)
...@@ -225,7 +227,7 @@ class SingleResponse(ift.LinearOperator): ...@@ -225,7 +227,7 @@ class SingleResponse(ift.LinearOperator):
self._vol = self._domain[0].scalar_dvol self._vol = self._domain[0].scalar_dvol
self._target_dtype = np.complex64 if single_precision else np.complex128 self._target_dtype = np.complex64 if single_precision else np.complex128
self._domain_dtype = np.float32 if single_precision else np.float64 self._domain_dtype = np.float32 if single_precision else np.float64
self._verbt, self._verbadj = True, True self._verbt, self._verbadj = verbose, verbose
def apply(self, x, mode): def apply(self, x, mode):
self._check_input(x, mode) self._check_input(x, mode)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment