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

Projection returns wrong shape #178

Closed
Joeybraspenning opened this issue Nov 8, 2023 · 2 comments
Closed

Projection returns wrong shape #178

Joeybraspenning opened this issue Nov 8, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Joeybraspenning
Copy link

When using the project_gas() method, sometimes the returned shape is not square.
For FLAMINGO this seems to be the case for a fraction of the haloes. These do not cross the edge of the box, and the list provided to the 'region' keyword gives a square area.

Here's a working example for the 190th halo in the L1000N1800, we confirmed that for example halo 180 does not have this problem (and out of the few hundred we tried, only a handful fail). The 'flux' object returned by project_gas() has shape (64,63) in this case.

import h5py
import swiftsimio as sw
import unyt

soapfile = h5py.File('/cosma8/data/dp004/flamingo/Runs/L1000N1800/HYDRO_FIDUCIAL/SOAP/halo_properties_0077.hdf5', 'r')
mask = sw.mask("/cosma8/data/dp004/flamingo/Runs/L1000N1800/HYDRO_FIDUCIAL/snapshots/flamingo_0077/flamingo_0077.hdf5")
position = soapfile["SO/500_crit/CentreOfMass"][190] * unyt.Mpc
radius = soapfile["SO/500_crit/SORadius"][190] * unyt.Mpc
load_box = [[position[0] - radius, position[0] + radius], 
            [position[1] - radius, position[1] + radius],
            [position[2] - radius, position[2] + radius]]
mask.constrain_spatial(load_box)
halo_data = sw.load("/cosma8/data/dp004/flamingo/Runs/L1000N1800/HYDRO_FIDUCIAL/snapshots/flamingo_0077/flamingo_0077.hdf5", mask=mask)
halo_data.gas.flux = halo_data.gas.xray_luminosities.erosita_low
flux = sw.visualisation.projection.project_gas(
    halo_data, 
    resolution=64, 
    project="flux", 
    region=[position[0] - radius, position[0] + radius, position[1] - radius, position[1] + radius], 
    parallel = True
)
@MatthieuSchaller MatthieuSchaller added the bug Something isn't working label Nov 8, 2023
@JBorrow
Copy link
Member

JBorrow commented Nov 9, 2023

I honestly don't even know how this would happen

@JBorrow
Copy link
Member

JBorrow commented Nov 9, 2023

Ah - I think this must be related to the changes here where people wanted the ability to create non-square images:

# determine the effective number of pixels for each dimension
.

I am guessing there is some round-off error here and we probably want to be using math.ceil instead of int which takes the floor?

JBorrow added a commit that referenced this issue Nov 9, 2023
Addresses #178.

@Joeybraspenning can you give this branch a go?
@JBorrow JBorrow closed this as completed Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants