Skip to content

integrated new shape based array triangles - #300

Merged
Jammy2211 merged 2 commits into
mainfrom
feature/shape
Sep 14, 2024
Merged

integrated new shape based array triangles#300
Jammy2211 merged 2 commits into
mainfrom
feature/shape

Conversation

@rhayes777

@rhayes777 rhayes777 commented Sep 6, 2024

Copy link
Copy Markdown
Collaborator

It's now possible to perform triangle upsampling on Points, Circles, Triangles, Squares and Polygons.

from autoarray.structures.triangles.shape import Polygon, Triangle, Square
from autolens.point.solver.shape_solver import ShapeSolver

solver = ShapeSolver.for_grid(
    grid=grid,
    pixel_scale_precision=0.01,
)

result = solver.solve(
    tracer=tracer
    shape=Circle(
        0.0,
        0.0,
        radius=0.01,
    ),
)

square = Square(
    top=0.0,
    left=0.0,
    bottom=0.1,
    left=0.1,
)

triangle = Triangle(
    (0.0, 0.0), 
    (0.1, 0.0), 
    (0.0, 0.1), 
)

polygon = Polygon([
    (0.0, 0.0), 
    (0.1, 0.0), 
    (0.0, 0.1), 
])

@Jammy2211

Copy link
Copy Markdown
Collaborator
def test_solver_basic(solver):
    result = solver.solve(
        tracer=NullTracer(),
        shape=Circle(
            0.0,
            0.0,
            radius=0.01,
        ),
    )
    assert list(map(tuple, result)) == [
        (-0.0029826688901819823, -0.0078125),
        (-0.0029826688901819823, 0.0078125),
    ]

What exactly does this result mean?

I guess I mean what is the result of a ShapeSolver?

@rhayes777

Copy link
Copy Markdown
Collaborator Author
def test_solver_basic(solver):
    result = solver.solve(
        tracer=NullTracer(),
        shape=Circle(
            0.0,
            0.0,
            radius=0.01,
        ),
    )
    assert list(map(tuple, result)) == [
        (-0.0029826688901819823, -0.0078125),
        (-0.0029826688901819823, 0.0078125),
    ]

What exactly does this result mean?

I guess I mean what is the result of a ShapeSolver?

Yeah it's the means of the triangles that intersect the circle at that resolution. Not a great assertion.

@Jammy2211

Copy link
Copy Markdown
Collaborator

Does the result contain information on the image-plane coordinates?

For a PointSolver, the solve function returns a Grid2DIrregular of the (y,x) coordinates in the image-plane that map to the source-plane centre.

Intuitively I would expect the ShapeSolver's solve function to return a Grid2DIrregular of all (y,x) coordinates in the image-plane that are at the centres of pixels which map within the shape, maybe? To compute a magnification you would use the ratio of this with the shape's source-plane area.

@rhayes777

Copy link
Copy Markdown
Collaborator Author

Does the result contain information on the image-plane coordinates?

For a PointSolver, the solve function returns a Grid2DIrregular of the (y,x) coordinates in the image-plane that map to the source-plane centre.

Intuitively I would expect the ShapeSolver's solve function to return a Grid2DIrregular of all (y,x) coordinates in the image-plane that are at the centres of pixels which map within the shape, maybe? To compute a magnification you would use the ratio of this with the shape's source-plane area.

Yeah we should return a richer object I guess. It should certainly be possible to compute the area of the triangles in the image plane and the area of the shape in the source plane then take the ratio

@Jammy2211

Copy link
Copy Markdown
Collaborator

Yeah, if something that makes that simple is included in this PR I have a user I can immediate ask to test the code lol.

@rhayes777

Copy link
Copy Markdown
Collaborator Author

Yeah, if something that makes that simple is included in this PR I have a user I can immediate ask to test the code lol.

Cool working on something

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants