Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use galsim as realistic source galaxy generator #48

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

aymgal
Copy link

@aymgal aymgal commented Feb 21, 2020

Hi!
I am currently playing with your very useful code to generate a training set for a project, and have been working on implementing realistic source into your pipeline.
The way I implemented it can be summarised as follows :

  • a new pair prior/config has been added, that supports the new 'GALSIM' source profile. It can easily be generalised to other realistic galaxy generators. New sampled parameters has been defined accordingly.
  • the generated galaxy is then casted to the 'INTERPOL' profile of lenstronomy, with the best resolution possible (depending on supersampling_factor), to avoid at maximum accuracies with the interpolation. This requires my last lenstronomy PR to be merged in your lenstronomy package.
  • the rest of the procedure remains the same, except that 'INTERPOL' is replacing 'SERSIC_ELLIPSE'.
  • for a clearer use of galsim, some additional parameters (on top of the sampled ones) should be accessible to the user. For that reason, I created a very general cfg.external field in the config file, where the user can specific some settings corresponding to the source/lens profiles being used.

The script generate_pixel.py is an adaptation of the original generate.py, that supports this new prior.

As a first step, this PR is only intended to start discussion about this feature that I think should be useful, and may not be merged into the master right now.

I would be very interested to hear about your remarks/comments please. Especially concerning the implementation, if this is or not on the right spirit regarding of your current implementation (especially last point above).

Thanks!

PS : Travis CI tests might failed in the beginning, because of galsim installation issues...let's see.

@jiwoncpark
Copy link
Owner

Hi @aymgal, thank you for proposing this feature -- I'm very much on board with the idea of using GalSim for realistic sources. From what I can gather from a first-pass scan, your implementation interfaces with the prior and config classes in just the way I intended. (Sorry for the scant documentation with the config files!) I don't have particular objections to using cfg.external; I can brainstorm ways to make the config fields more intuitive for users though. Let me spend some more time looking at your commits, but here are some tangential comments I had so far:

  • I was toying with the idea of having Baobab generate noiseless images (which is why the add_noise field was removed from the configs and the relevant lines in generate_image commented out) and instead provide classes that can add noise online (during training) in baobab/data_augmentation. There, you'll find noise modules for PyTorch, TensorFlow, and numpy (wrapper around the default lenstronomy noise module). My thinking was that most users would opt for having different noise realizations for the same base image. Of course, it's no problem to enable the option to generate noised images. Just wanted to let you know that there are tools for adding noise online.
  • Travis is crashing for other reasons as well, mostly my laziness in updating some tests... GalSim pip installation tends to crash for many systems, so setup may be our only recourse for Travis!

Once again, thank you for working on this very helpful feature. Looking forward to discussing this more soon :)

@aymgal
Copy link
Author

aymgal commented Mar 3, 2020

Happy that the implementation is ok on your side! Got it for the noise generation, indeed I'm learning that it's best practice to introduce noise in an online fashion.

I'm currently on "stand by" for the development of this pull request, but feel free to merge it if you would like to use / improve it. I will likely be doing some adjustments before the end of the month though.

Finally, what do you mean by setup to make the travis build to succeed ?

@jiwoncpark
Copy link
Owner

For some reason, python setup.py seems to work when pip fails. I'll see if I can fix it!

I haven't been making significant changes to Baobab as I'm finishing up my other project, so this PR won't diverge too much. I can wait until whenever you get a chance to work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants