simonsobs / fgspectra Goto Github PK
View Code? Open in Web Editor NEWForeground SED and power spectrum library for building cross frequency power spectrum models
License: BSD 3-Clause "New" or "Revised" License
Foreground SED and power spectrum library for building cross frequency power spectrum models
License: BSD 3-Clause "New" or "Revised" License
Hey guys,
I have written the simplest script for fgspectra:
from fgspectra import cross as fgc
from fgspectra import power as fgp
from fgspectra import frequency as fgf
ksz = fgc.FactorizedCrossSpectrum(fgf.UnitSED(), fgp.kSZ_bat())
it works when I run it in the fgspectra folder, but not when I try to run it from somewhere else.
It seems that the error is in: power.py, pkg_resources.resource_filename('fgspectra', 'data/')
Cheers,
Thibaut
I should make a notebook which plots the SEDs and power spectra shapes.
I think this should take two frequency functions and two power spectrum functions?
Currently it takes callables with shape (comp, ... freqs) and (...,comp,comp,ell) but we dont have anything to generate those.
I thought it might be useful to support a power spectrum class corresponding to an arbitrary linear combination of input templates with free coefficients.
Not necessarily super urgent.
Need to add a constant / empty SED function so that kSZ works with the FactorizedCrossSpectrum?
I'm trying to get correlated tSZ x CIB following Zack's notebook: https://github.com/simonsobs/fgspectra/blob/master/notebooks/ACT_Models.ipynb
The output of
# joint tSZ, CIB, and their correlation
tSZ_and_CIB(
{'kwseq': (
{'nu':freqs, 'nu_0':par['nu_0']},
{'nu': freqs, 'nu_0':par['nu_0'], 'temp':par['T_d'], 'beta':par['beta_c']}
)},
{'kwseq': (
{'ell':ells, 'ell_0':par['ell_0'],
'amp':par['a_tSZ']},
{'ell':ells, 'ell_0':par['ell_0'],
'alpha':2-par['n_CIBC'], 'amp':par['a_c']},
{'ell':ells, 'ell_0':par['ell_0'],
'amp': -par['xi'] * np.sqrt(par['a_tSZ'] * par['a_c'])}
)})
however seems to be a tuple with one element whose shape is (1, 2998)
where I've asked for 2998 multipoles. Shouldn't this be at least a (2,2,2998) array? @xzackli
Accidentally installed with python 2 before switching environments to 3 and there is the warning:
Found existing installation: fgspectra 0.1
Can't uninstall 'fgspectra'. No files were found to uninstall.
FYI
We received the request to provide tools that reproduce the spectra in the map-based simulations. There are two ways of accomplishing this.
File-based
Model based
In spite of the number of steps, the former is much easier and quicker to carry out. The main downside is that it would not implement true models: there would not be any free parameter.
I'd like to propose a tutorial page for creating a new foreground model in fgspectra. I'm hoping to get some feedback on this, before making a branch and trying to write this up.
I'm thinking the radio sources flux cut PR example sounds like it could be turned into a tutorial. I'm also thinking of making up a silly example involving a cross-correlation between i.e. Poisson sources and tSZ.
Currently get deprecation warnings - switch to importlib.resources
Where do we add in amplitudes of these things?
The user just tacks it on at the end?
We have received a request for this model, but details are not clear.
To potential users, please express any need that could be not obvious (or feel free to mark down also the obvious ones).
To radio sources experts, please provide information about the functional form (and, of course, the parameters) that we should use in the implementation
Thanks!
What new components do we need?
Current SEDs:
Power law, MBB, free-free, constant
Current power spectrum models:
Power law, arb template file (existing templates: tSZ_150_bat template, kSZ_bat, tSZxCIB)
Spinning dust SED? Power spectrum shape?
Add requests here
The numpy broadcasting is potentially confusing, might be good to have some examples which use np.meshgrid
instead. Consider what I had to write for tSZxCIB
for example,
return (2 * (ThermalSZ.f(nu_1, T_CMB)[...,np.newaxis] * CIB.mu(nu_2, beta, T_d, T_CMB) +
CIB.mu(nu_1, beta, T_d, T_CMB)[...,np.newaxis] * ThermalSZ.f(nu_2, T_CMB))
/ (2 * ThermalSZ.f(nu_0, T_CMB) * CIB.mu(nu_0, beta, T_d, T_CMB)))
The [..., np.newaxis]
is very numpy but kind of tricky to work with / understand.
Hi!
We are hoping to package SOLikeT for PyPI in the next few weeks, but at the moment we are dependent on fgspectra for the foregrounds. At the moment our requirements.txt points to a specfic branch on the github repo:
fgspectra @ git+https://github.com/simonsobs/fgspectra@act_sz_x_cib#egg=fgspectra
For SOLikeT to go on PyPI having requirements like this is forbidden, though. We could solve this by having fgspectra on PyPI too so the depedency just becomes fgspectra
.
Would you be able to do this? Or if we do it would you accept the PR? Or some combination?
Did we ever define a set of defaults? For example for nu_0s? Or do we leave this completely to the user?
Paraphrased from @damonge,
fgspectra can include bandpass convolution, as long as
- it does it at the SED level, and
- the code that does it lives in a separate module that other pipelines can also use.
and from @dpole
integration functions don’t take a list of file names as arguments but rather a list of arrays
Probably a good first attempt should be just to copy over the tile-c bandpass module. The default behavior should be to have a delta function bandpass.
How should we treat default parameters in here?
And can we have the user set some params (e.g. nu0 and ell0) when initializing the class?
When you build the tSZ cross spectrum you have to pass a nested list for the frequencies: [[nu0, nu1]] because there are no SED parameters and it unpacks the list automatically assuming there are. Just to be aware
I periodically open this issue in any repo I work on. We've got several branches open that I think we can delete.
handle_defaults
add_the_models_back_in
exploit_correlated_factorized
polarization_models
@xzackli and @mabitbol please say "ok" if you agree or let me know the branches that are actually still active. Thanks!
Decide and implement how to deal with units.
We'd like to have a function that takes the SED of X and Y and produces an SED of (X1Y2 + X2Y1) for the CorrelatedFactorizedCrossSpectrum class. But we need to be careful that things aren't going to be double counted (e.g. is there an issue when nu1=nu2?).
Add a license!
I'm wondering if we can add support to the cross spectrum class that will allow us to see and access the SED and power spectrum parameters easily, like how it is done in FGBuster.
Hi, I tried running the code from Basic_Example.ipynb and got an error on In [6]: "TypeError: ThermalSZ object argument after ** must be a mapping, not tuple."
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.