21cmfast / 21cmFAST

Official repository for 21cmFAST: a code for generating fast simulations of the cosmological 21cm signal
MIT License
56 stars 37 forks source link

The new Lightconer mode does not support setting USE_TS_FLUCT=True or INHOMO_RECO=True [BUG] #378

Closed bohuarolandli closed 1 month ago

bohuarolandli commented 3 months ago

Describe the bug: I recently updated my 21cmfast to the latest version which has the new Lightconer subclass (version=3.3.2.dev118+gef480dc). In this new mode, I tried to generate lightcones that take into account the spin temperature evolution (setting USE_TS_FLUCT=True). And this runs into the following error (I run 21cmfast in a Jupyter notebook):


File [.../src/py21cmfast/wrapper.py:2943], in run_lightcone(redshift, max_redshift, lightcone_quantities, lightconer, user_params, cosmo_params, astro_params, flag_options, regenerate, write, global_quantities, direc, init_box, perturb, random_seed, coeval_callback, coeval_callback_redshifts, use_interp_perturb_field, cleanup, hooks, always_purge, lightcone_filename, return_at_z, **global_kwargs) 2939 for quantity, idx, this_lc in lightconer.make_lightcone_slices( 2940 coeval, prev_coeval 2941 ): 2942 if this_lc is not None: -> 2943 lightcone.lightcones[quantity][..., idx] = this_lc 2944 lc_index = idx 2946 if lightcone_filename:

KeyError: None


The "lightcone.lightcones[quantity]" part is highlighted in the above error message.

The same error occurs if I turn on INHOMO_RECO.

To Reproduce: Steps to reproduce the behavior:

  1. Setting up a Lightconer instance (e.g., a standard RectilinearLightconer) as instructed in the tutorial and pass it to the run_lightcone function.
  2. Setting flag_options = {"USE_TS_FLUCT": True} in the run_lightcone function.

Expected behavior: In this version of 21cmFAST, I also tried to run lightcones with TsBox on by the original way, e.g, setting 'redshift', 'max_redshift' and 'lightcone_quantities' arguments directly in the run_lightcone function, instead of using a Lightconer. It worked out well as expected. So I guess this is only an issue with the new Lightconer subclass.

Details:

steven-murray commented 3 months ago

Hi @bohuarolandli, thank you for reporting this! I will check it out ASAP. If you see a fix for it yourself, feel free to submit a PR!

daviesje commented 1 month ago

I believe this may be fixed by #394