Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # the minimal saving code
- analysis_fields = [
- ("all", "metallicity_fraction"),
- ("deposit", "all_mass"),
- ("gas", "H2_mass"),
- ("gas", "H2_fraction"),
- ("gas", "temperature")
- ]
- def save_halo_spheres(ts, halo_position_data):
- ts_redshifts = get_ts_redshifts(ts)
- for halo_id, position_data in halo_position_data.items():
- for redshift, position in position_data.items():
- for ds_t in ts.piter():
- sp = ds_t.sphere([position[1], position[2], position[3]], position[0])
- sp_dataset_name = str(halo_id).zfill(4)
- sp_dataset_num = str(r).zfill(4) # str(ts_redshift).replace(".", "-")
- sp.save_as_dataset(fn=f"./halo_data/halo_{sp_dataset_name}_{sp_dataset_num}",fields=analysis_fields) # save the data
- # the minimal loading code
- def plotting():
- halos_all = []
- for h in range(1091):
- try:
- halo_id = str(h).zfill(4)
- halo_ts = yt.load(f"./halo_data/halo_{halo_id}_****.h5") # load the data
- halos_all.append(halo_ts)
- except FileNotFoundError:
- print(f"No halo timeseries saved for halo {h}")
- figure_1(halos=halos_all)
- def figure_1(halos):
- for halo_ts in halos:
- for halo_ds in halo_ts:
- # both of these return errors
- gas_density = halo_ds.r["gas", "density"]
- ad = halo_ds.all_data()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement