Skip to content

Commit

Permalink
Quick and dirty workaround for a bug in soap.
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleaoman committed Dec 3, 2024
1 parent 0a6fc4d commit dfd9a0f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion swiftgalaxy/iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy as np
import unyt as u
from swiftsimio import mask, cosmo_array
from swiftsimio.objects import a, cosmo_factor # FOR MONKEY PATCH
from .reader import SWIFTGalaxy
from .halo_catalogues import _HaloCatalogue
from warnings import warn
Expand Down Expand Up @@ -608,7 +609,22 @@ def __iter__(self) -> Generator:
)
elif self.auto_recentre:
swift_galaxy.recentre(self.halo_catalogue.centre)
swift_galaxy.recentre_velocity(self.halo_catalogue.velocity_centre)
# MONKEY PATCH DUE TO BUG IN SOAP
self.halo_catalogue.velocity_centre # make sure it's loaded
scale_factor = (
self.halo_catalogue.velocity_centre.cosmo_factor.scale_factor
)
cf = cosmo_factor(
a**0,
scale_factor=scale_factor,
)
values = self.halo_catalogue.velocity_centre.to_value(u.km / u.s)
vcentre = cosmo_array(
values, u.km / u.s, cosmo_factor=cf, comoving=True
)
swift_galaxy.recentre_velocity(vcentre)
# END MONKEY PATCH
# swift_galaxy.recentre_velocity(self.halo_catalogue.velocity_centre)
swift_galaxy._initialised = True
yield swift_galaxy
self.halo_catalogue._unmask_multi_galaxy()
Expand Down

0 comments on commit dfd9a0f

Please sign in to comment.