Jammy2211 / PyAutoLens

PyAutoLens: Open Source Strong Gravitational Lensing
https://pyautolens.readthedocs.io/
MIT License
165 stars 32 forks source link

Grids module / approach - iterative grid in image plane #35

Closed Jammy2211 closed 5 years ago

Jammy2211 commented 6 years ago

I have moved grids and masked_image (now called lensing_image) to a new module, called the lensing module, which also contains ray_tracing, galaxy, galaxy prior. Deciding where to put the grids module is a pain, but I opted for the lensing module as it is the grids that we use to perform lensing, and the choice of grid will now depend on the tracer we use.

For lens plane + source plane systems, we have a lot of freedom to customize our grid, as (unlike multi-planes) we are not held-back by the need to compute many intensities on non-uniform lensed grids. Therefore, I believe we should:

Once we have traced a grid to a source-plane, it is non-uniform. An iterative grid is no longer possible, as it relies on the regularity of the square-pixels. One could iteratively compute the deflection angles in the image-plane and then intensities in the source-plane, but this is a computation nightmare. Therefore, for multi-plane ray tracing I recommend we just stick to a regular sub-grid and take the hit on light-profile accuracy. I can't think of a better approach that doesn't get horribly complicated.

For simulated images, we need to ensure our images do reach numerical accuracy and thus need to perform iterative deflection + intensity calculations until a threshold accuracy is met. Luckily, for simulated images, we can easily do this for the entire tracer-instance at once for one sub-grid size, and then perform another tracer at higher sub-grid and compare them. This approach could work for actual modeling - lets see how it plays out for simulated images.

Jammy2211 commented 6 years ago

I'm going to bump this, as I think the suggestion at the end is potentially powerful. We could use an iterative grid, but on a per-tracer basis. That is, we make a tracer with every pixel on a 1 x 1 -subgrid, then a 2 x 2 sub grid, then 4x4 etc - only inputing new pixels into a tracer if it didn't meet the precision threshold. This circumvents all issues with the non-uniformity of the grids after tracing, and should be easy to implement as we do so on the tracer level.

The only snag is that to end up with one final tracer with all grid points (in the same indexing as the image grid) we'll need to input the pixels as masked, or using some sort of a classmethod. Nevertheless... this idea is awesome.

Jammy2211 commented 5 years ago

Bumping again, might be time we actually implement this :O.

Lets start with the simplistic versioon for now, that is which assumes a uniform regular grid. Maybe we should add an boolean attribute to the Grid class called 'is_uniform' or something.

rhayes777 commented 5 years ago

We’re going to have so many decorators on our profile functions

On 15 Apr 2019, at 09:34, James Nightingale notifications@github.com wrote:

Bumping again, might be time we actually implement this :O.

Lets start with the simplistic versioon for now, that is which assumes a uniform regular grid. Maybe we should add an boolean attribute to the Grid class called 'is_uniform' or something.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Jammy2211/PyAutoLens/issues/35#issuecomment-483159436, or mute the thread https://github.com/notifications/unsubscribe-auth/AGETMs22xK8dHW38RzcVJLhpJBvYFE_Uks5vhDmLgaJpZM4WaVkz.

Jammy2211 commented 5 years ago

Every day is Christmas with PyAutoLens!

rhayes777 commented 5 years ago

We need to configure pycharm to highlight decorators alternately red and green

On 15 Apr 2019, at 09:39, James Nightingale notifications@github.com wrote:

Every day is Christmas with PyAutoLens!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Jammy2211/PyAutoLens/issues/35#issuecomment-483161230, or mute the thread https://github.com/notifications/unsubscribe-auth/AGETMqg2W6-1UOZl-bkb2NitdQX12Az6ks5vhDrNgaJpZM4WaVkz.

rhayes777 commented 5 years ago

The “Decorative Decorators” plugin

On 15 Apr 2019, at 09:40, richard hayes richardhayes777@gmail.com wrote:

We need to configure pycharm to highlight decorators alternately red and green

On 15 Apr 2019, at 09:39, James Nightingale <notifications@github.com mailto:notifications@github.com> wrote:

Every day is Christmas with PyAutoLens!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Jammy2211/PyAutoLens/issues/35#issuecomment-483161230, or mute the thread https://github.com/notifications/unsubscribe-auth/AGETMqg2W6-1UOZl-bkb2NitdQX12Az6ks5vhDrNgaJpZM4WaVkz.

Jammy2211 commented 5 years ago

This might actually be better implemented at the tracer level (albeit feels more suited to the profile module)... when you work lets do a call to discuss it.

rhayes777 commented 5 years ago

Sure

On 15 Apr 2019, at 09:41, James Nightingale notifications@github.com wrote:

This might actually be better implemented at the tracer level (albeit feels more suited to the profile module)... when you work lets do a call to discuss it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Jammy2211/PyAutoLens/issues/35#issuecomment-483161843, or mute the thread https://github.com/notifications/unsubscribe-auth/AGETMp-HXhSwZoklEGAtbQcqpUIcJg0-ks5vhDtAgaJpZM4WaVkz.

Jammy2211 commented 5 years ago

I have a better way to do this, which I will post in a new issues in due course.