From da9f9af01cbaccb7527f4ad7d67bb590478dc6c1 Mon Sep 17 00:00:00 2001 From: Andrea Zonca Date: Mon, 14 Oct 2024 23:55:40 -0700 Subject: [PATCH] feat: interpolating component, take freqs as inputs --- src/pysm3/models/interpolating.py | 14 ++++++++++---- src/pysm3/sky.py | 6 +++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/pysm3/models/interpolating.py b/src/pysm3/models/interpolating.py index 629c15de..bf1b61c3 100644 --- a/src/pysm3/models/interpolating.py +++ b/src/pysm3/models/interpolating.py @@ -24,6 +24,7 @@ def __init__( max_nside=None, interpolation_kind="linear", map_dist=None, + freqs = None, verbose=False, ): """PySM component interpolating between precomputed maps @@ -57,16 +58,21 @@ def __init__( """ super().__init__(nside=nside, max_nside=max_nside, map_dist=map_dist) - self.maps = {} - self.maps = self.get_filenames(path) + + if freqs is None: + self.maps = {} + self.maps = self.get_filenames(path) + self.freqs = np.array(list(self.maps.keys())) + self.freqs.sort() + else: + self.freqs = np.array(freqs) + self.maps = {freq:path + f"/{freq:05.1f}.fits" for freq in freqs} # use a numba typed Dict so we can used in JIT compiled code self.cached_maps = Dict.empty( key_type=types.float64, value_type=types.float32[:, :] ) - self.freqs = np.array(list(self.maps.keys())) - self.freqs.sort() self.input_units = input_units self.interpolation_kind = interpolation_kind self.verbose = verbose diff --git a/src/pysm3/sky.py b/src/pysm3/sky.py index 59568363..1e231506 100644 --- a/src/pysm3/sky.py +++ b/src/pysm3/sky.py @@ -171,11 +171,11 @@ def __init__( def add_component(self, component): self.components.append(component) - def get_emission(self, freq, weights=None): + def get_emission(self, freq, weights=None, **kwargs): """This function returns the emission at a frequency, set of frequencies, or over a bandpass. """ - output = self.components[0].get_emission(freq, weights=weights) + output = self.components[0].get_emission(freq, weights=weights, **kwargs) for comp in self.components[1:]: - output += comp.get_emission(freq, weights=weights) + output += comp.get_emission(freq, weights=weights, **kwargs) return output * bandpass_unit_conversion(freq, weights, self.output_unit)