Comments (5)
I have this basically implemented, although there's a potential infinite-loop trap I'm not sure how to deal with. It's possible -- and indeed likely -- that the user will pass a redshift which will never pass the color cuts for a given spectral class. For example, none of the 8000 ELG basis templates will ever pass the nominal grz color-cuts if they are told to be placed at z=0.1 (and indeed anything below z0.5 is highly unlikely, by design).
@sbailey, @ladosamushia How should we deal with this in the context of #110?
from desisim.
At minimum there should be a counter that stops after N tries to avoid an infinite loop. Options after hitting that limit:
- raise an exception
- print a warning and then don't include that redshift in the output list (i.e. fewer outputs than inputs)
- print a warning, grab another random redshift from the list and keep going, even if that means that it replicates that redshift.
I think I prefer (3) as default, with an option to do (1) instead. (2) smells like trouble.
from desisim.
Once the templates and cuts are fixed, you can precompute exactly which templates pass the cuts on a grid of redshifts and save the results in a boolean array pass[ntemplates,nz]
.
This array is actually quick to compute using speclite.filters
since you can do the magnitude calculations in parallel for all templates. Once you have precomputed the pass
array, you can simulate any given redshift z ~ z[iz]
without any iteration by randomly selecting an it
where pass[it, iz]
is True
. You can also immediately detect an impossible redshift when !np.any(pass[:,iz])
and raise an appropriate exception.
from desisim.
Thanks for the suggestion, @dkirkby. In detail, what you describe is what I had originally implemented in the IDL (v1.0) version of the ELG templates. However, those templates had static emission lines on them, whereas in the current template code each continuum template gets a unique emission-line spectrum (according to a physical model). And this is why the templates are built in a for
loop, which is not terribly slow but slightly annoying.
I could do what you suggest to 'pre-select' a set of templates that satisfy the color-cuts and redshift inputs based on just the continuum (this is only an issue for the ELGs), which would also allow impossible redshifts to be captured. Then the code could go into the loop for the full template construction. It's possible, however, that the emission lines could be strong enough to push the template into an "impossible" part of color-redshift space. I can capture this rare occurrence, however, as @sbailey suggests by stopping the infinite loop after N iterations, where N might be a few hundred attempts.
from desisim.
close via PR #132
from desisim.
Related Issues (20)
- Change default pixel width of DESI mocks to 0.8A HOT 8
- desisim sky level test failure HOT 16
- new problem with how the spectral templates are being normalized HOT 3
- desisim.templates should fail if a template that satisfies the colorcuts cannot be generated HOT 1
- quicktransients should catch failed template generation HOT 1
- Save true continuum in quickquasars
- TestPixsim negative flux failure
- desisim.templates failing with new version of desitarget HOT 2
- Formalize basis_templates tagging procedure HOT 3
- Modify specsim / quickquasars to mimic how the real pipeline estimates the noise variance HOT 1
- "Refraction model is inaccurate for altitudes below 5.0 deg" warning in test_quickquasars unit test HOT 6
- several quickgen unit tests are failing HOT 1
- RuntimeWarning: numpy.ndarray size changed, may indicate binary incompatibility. Expected 80 from C header, got 88 from PyObject
- Test failure at NERSC due to basis template configuration HOT 3
- argument type error in pixsim HOT 2
- desisim.simexp.simulate_spectra not varying exposure time HOT 9
- problem interpolating atmosphere in desisim.specsim.get_simulator HOT 1
- Error while running redrock in mock spectra HOT 1
- Failure on jupyter at nersc trying to run redrock on desisim outputs HOT 2
- io.py find_basis_template does not select most recent template file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from desisim.