SWIFTSIM / swiftsimio

Python library for reading SWIFT data. Uses unyt and h5py.
GNU Lesser General Public License v3.0
18 stars 13 forks source link

Intersect spatial masks #171

Closed kyleaoman closed 1 year ago

kyleaoman commented 1 year ago

A student here was asking whether it was possible to select multiple spatial regions - basically wanting to make repeated calls to constrain_spatial to build up a more complicated region. On inspection this wasn't supported but seems to be very easy to implement. I just added an optional intersect argument to constrain_spatial and set the default to False (the previous behaviour). If it's True then the new region is intersected with any existing spatial mask. I checked carefully that there are no other member variables of SWIFTMask that need special treatment if a user does this - as far as I can tell it's a nearly trivial change that works seamlessly with the existing code. I added test coverage and a mention in the narrative docs.