SWIFTSIM / swiftsimio

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

TotalAccretedMasses L1000N1800 HYDRO_JETS_published units issue #191

Open Em-Costello opened 1 week ago

Em-Costello commented 1 week ago

I'm currently looking at the ratio between the total_subgrid vs total_accreted BH masses from the snapshots. I'm reading these quantities using swiftsimio in the following way:

import pandas as pd
import numpy as np
from swiftsimio import load as load_snap

sim = 'HYDRO_FIDUCIAL' #sim = 'HYDRO_JETS_published' 
snap = 77 #77 or 78 for high res fiducial
run = 'L1000N1800'

#Snapshots data
run_directory = f'/cosma8/data/dp004/flamingo/Runs/{run}/{sim}/' #simulation directory
snapshot_name = f'snapshots/flamingo_00{snap}/flamingo_0077.hdf5' #snapshot file

snap = load_snap(run_directory + '/' + snapshot_name)

# #Reading in BH particle data
print('Reading BH data...')
data = load_snap(run_directory + '/' + snapshot_name)

df_BH = pd.DataFrame()    
df_BH['BH_subgrid_mass'] = data.black_holes.subgrid_masses.to('Msun').value 
print(data.black_holes.total_accreted_masses.units)
df_BH['BH_accretion_mass'] = data.black_holes.total_accreted_masses.to('Msun').value
df_BH['BH_accretion_rate'] = data.black_holes.accretion_rates.to('Msun/Gyr').value
df_BH['BH_particle_ID'] = data.black_holes.particle_ids.value

print(df_BH)

For the int res fiducial model, this is working fine. But for the int res jets model, swiftsimio seems to think the TotalAccretedMass quantity is given in Msun/Gyr and so I can't read it in. The units listed in the actual snapshots are correct, so I'm not sure what's going on. Could you look into this please?

The actual error it gives me is this: UnitConversionError: Cannot convert between '10227144.8879616*Msun/Gyr' (dim '(mass)/(time)') and 'Msun' (dim '(mass)').

MatthieuSchaller commented 1 week ago

@robjmcgibbon any thoughts on this? (I ping you as you are looking at units for SOAP too....)

robjmcgibbon commented 1 week ago

Thanks for catching this Emily. The problem is due to incorrect metadata stored in the swift snapshot, rather than a problem with swiftsimio. We can got through the snapshots and correct the metadata. I'll leave this issue open until we've done that.