Skip to content

Commit

Permalink
feat: interpolating component, take freqs as inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
zonca committed Oct 15, 2024
1 parent b254fdf commit da9f9af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/pysm3/models/interpolating.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/pysm3/sky.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit da9f9af

Please sign in to comment.