In the following sample code, output 1 gives 210 black holes. output 2 gives 0. output1 and output2 should match as they both correspond to number of black holes recovered using yt and caesar respectively.
output 3 gives length of metallicity string (=number of stars) = 2181832. output 4 results in an error KeyError: 'stellar'. This code uses snapshot 150 of the s25_512 SIMBA run and its respective caesarfile.
import yt
import caesar
snap = '/orange/narayanan/desika.narayanan/gizmo_runs/simba/m25n512/output/snapshot_150.hdf5'
ds = yt.load(snap)
obj = caesar.load('/orange/narayanan/desika.narayanan/gizmo_runs/simba/m25n512/output/Groups/caesar_0150_z2.262.hdf5')
ad = ds.all_data()
print("Number of particles of type 5:",len(ad['PartType5','ParticleIDs'])) #getting number of type5 particles by checking length of the ParticleID string using yt - output 1
print("Number of black holes:",obj.simulation.nbh) #simply printing number of black holes using the caesarfile - output 2
print(len(ad['PartType4','Metallicity_00']),ad['PartType4','Metallicity_00'][0:10]) #printing number of stellar metallicity values present using yt and also showing some sample values - output 3
for i in range(0,10):
print(obj.galaxies[i].metallicities['stellar']) #printing number of stellar metallicities using caesar for some sample galaxies - output 4