Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Halobox memory improvements #380

Merged
merged 4 commits into from
Apr 22, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/py21cmfast/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3446,6 +3446,7 @@ def run_lightcone(
prev_coeval = None
st2 = None
hbox2 = None
hbox = None

if lightcone_filename and not Path(lightcone_filename).exists():
lightcone.save(lightcone_filename)
Expand All @@ -3471,9 +3472,9 @@ def run_lightcone(
**kw,
)
z_halos.append(z)
hboxes.append(hbox2)

if flag_options.USE_TS_FLUCT:
hboxes.append(hbox2)
xray_source_box = xray_source(
redshift=z,
z_halos=z_halos,
Expand Down Expand Up @@ -3587,7 +3588,18 @@ def run_lightcone(
except OSError:
pass

# we only need the SFR fields at previous redshifts for XraySourceBox
if hbox is not None:
try:
hbox.prepare(
keep=["halo_sfr", "halo_sfr_mini", "log10_Mcrit_LW_ave"],
force=always_purge,
)
except OSError:
pass

pf = pf2
hbox = hbox2

if z <= return_at_z:
# Optionally return when the lightcone is only partially filled
Expand Down
Loading