GithubHelp home page GithubHelp logo

Comments (5)

moustakas avatar moustakas commented on August 19, 2024

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.

sbailey avatar sbailey commented on August 19, 2024

At minimum there should be a counter that stops after N tries to avoid an infinite loop. Options after hitting that limit:

  1. raise an exception
  2. print a warning and then don't include that redshift in the output list (i.e. fewer outputs than inputs)
  3. 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.

dkirkby avatar dkirkby commented on August 19, 2024

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.

moustakas avatar moustakas commented on August 19, 2024

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.

sbailey avatar sbailey commented on August 19, 2024

close via PR #132

from desisim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.