Closed steven-murray closed 6 years ago
Hmmm, it seems that this:
init, perturb, ionize, brightness_temp = p21c.run_coeval(
redshift = [8.0, 9.0, 10.0],
user_params = {"HII_DIM":50, "BOX_LEN":100},
z_step_factor = 1.05,
do_spin_temp = True
)
raises this:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-3fa3f344de4f> in <module>
4 user_params = {"HII_DIM":50, "BOX_LEN":100},
5 z_step_factor = 1.05,
----> 6 do_spin_temp = True
7 )
~/Documents/Projects/EOR/ParameterEstimation/Hybrid21CM/src/py21cmmc/_21cmfast/wrapper.py in run_coeval(redshift, user_params, cosmo_params, astro_params, flag_options, do_spin_temp, regenerate, write, direc, match_seed, z_step_factor, z_heat_max, init_box, perturb)
1328 spin_temp=st2 if do_spin_temp else None,
1329 regenerate=regenerate,
-> 1330 write=write, direc=direc, match_seed=True
1331 )
1332
~/Documents/Projects/EOR/ParameterEstimation/Hybrid21CM/src/py21cmmc/_21cmfast/wrapper.py in ionize_box(astro_params, flag_options, redshift, perturbed_field, previous_ionize_box, z_step_factor, z_heat_max, do_spin_temp, spin_temp, init_boxes, cosmo_params, user_params, regenerate, write, direc, match_seed)
799 if spin_temp is not None or perturbed_field is not None or init_boxes is not None:
800 match_seed = True
--> 801 _check_compatible_inputs(spin_temp, perturbed_field, init_boxes)
802 _check_compatible_inputs(spin_temp, previous_ionize_box, ignore_redshift=True)
803
~/Documents/Projects/EOR/ParameterEstimation/Hybrid21CM/src/py21cmmc/_21cmfast/wrapper.py in _check_compatible_inputs(ignore_redshift, *datasets)
469
470 if inp in d2._inputs and getattr(d, inp) != getattr(d2, inp):
--> 471 raise ValueError("%s and %s are incompatible" % (d.__class__.__name__, d2.__class__.__name__))
472 done += [inp]
473
ValueError: TsBox and PerturbedField are incompatible
I have been able to replicate it, but I haven't yet fixed it. Though, you might have an easier time than me. Also, its the end of the day here.
What I think is happening is that when you are trying to create the z = 10 spin temperature box, the redshift of the previous spin temperature box being passed is z = 8. Not z = 12.5 which is probably needed for the computation of the spin temperature. This is why they are incompatible, as I think it just takes the z=8 spin temperature box which doesn't agree with the z = 10 perturb field box.
As an aside, while I was debugging I noticed you are not consistent in your usage of z_step_factor. If you change it at the top, it doesn't carry all the way through. i.e. to make it run faster I set z_step_factor = 1.5, but it still sampled at z = 1.02 as this is the default argument. When you don't pass z_step_factor, it flips to that.
This is solved now. You're right, it was a stupid error. At some point I changed the default behaviour when both redshift and perturb_field were passed. Initially, the explicit redshift would win, but now the redshift included in the perturb_field wins. This is more in line with what happens throughout the different functions. I should probably issue a warning for it though hey...
I have also fixed the z_step_factor issue, thanks!
When running the following code:
in a Jupyter notebook, my kernel dies. It seems to run through ok if I don't use the pre-computed initial conditions.