Exemple #1
0
from transfer.spreadmetric import SpreadMetricCalculator
from transfer.frontends.swiftvr import SWIFTSnapshotData
from transfer.holder import SimulationData
import numpy

initial_snap = SWIFTSnapshotData('/cosma6/data/dp004/dc-borr1/swift-test-data/eagle_0000.hdf5', halo_filename = None)
final_snap = SWIFTSnapshotData('/cosma6/data/dp004/dc-borr1/swift-test-data/eagle_0037.hdf5', 
halo_filename = '/cosma6/data/dp004/dc-borr1/swift-test-data/halo_0037/halo_0037.properties')

data = SimulationData(initial_snap, final_snap)

cal = SpreadMetricCalculator(simulation = data)

cal.find_neighbour_distances()
dm_spread = cal.dark_matter_spread
gas_spread = cal.gas_spread
star_spread = cal.star_spread
numpy.savetxt('/cosma5/data/durham/dc-murr1/dm_spread.txt', dm_spread)
numpy.savetxt('/cosma5/data/durham/dc-murr1/gas_spread.txt', gas_spread)
numpy.savetxt('/cosma5/data/durham/dc-murr1/star_spread.txt', star_spread)



final_halo_filename = (
    "/cosma6/data/dp004/dc-borr1/simba-test-data/snap151Rpep..z0.000.AHF_halos"
)

initial = SIMBASnapshotData(initial_filename, initial_halo_filename)

truncate_ids = {
    0: initial.gas.particle_ids.max() + 1,
    1: None,
    4: initial.gas.particle_ids.max() + 1,
}

final = SIMBASnapshotData(final_filename,
                          final_halo_filename,
                          truncate_ids=truncate_ids)
cross = SimulationData(initial_snapshot=initial, final_snapshot=final)

for particle_type in ["dark_matter", "stars", "gas"]:
    x = {
        n: getattr(getattr(cross, f"{particle_type}_transfer"), n)
        for n in [
            "in_halo",
            "in_halo_from_own_lr",
            "in_halo_from_other_lr",
            "in_halo_from_outside_lr",
            "in_lr",
            "in_other_halo_from_lr",
            "outside_haloes",
        ]
    }
with open(f"{particle_type}.pickle", "wb") as handle: