21cmfast / 21cmFAST

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

p21c.run_lightcone get stuck in the middle #246

Closed acnhwang closed 3 years ago

acnhwang commented 3 years ago

Hello, I encounter a problem in running the code. Can anyone help me please? Thank you very much. Describe the bug:

When I just follow the tutorial guide under the section "Fiducial and lightcones", I copied and paste the code to reproduce the result. The jupyterlab produced some .h5 files, but then it is stuck. No figures and new .h5 files are produced.

To Reproduce: Steps to reproduce the behavior: Just follow the code in tutorial, section "Fiducial and lightcones".

import numpy as np
import matplotlib
%matplotlib inline
import matplotlib.pyplot as plt
import py21cmfast as p21c

#import logging
#logger = logging.getLogger("21cmFAST")
#logger.setLevel(logging.INFO)

random_seed = 1993

EoR_colour = matplotlib.colors.LinearSegmentedColormap.from_list('mycmap',\
             [(0, 'white'),(0.33, 'yellow'),(0.5, 'orange'),(0.68, 'red'),\
              (0.83333, 'black'),(0.9, 'blue'),(1, 'cyan')])
plt.register_cmap(cmap=EoR_colour)
output_dir = '/home/yqin/aida/hybrid/mini-halos/'
HII_DIM = 128
BOX_LEN = 250

# USE_FFTW_WISDOM make FFT faster
user_params = {"HII_DIM":HII_DIM, "BOX_LEN": BOX_LEN, "USE_FFTW_WISDOM": True}

initial_conditions = p21c.initial_conditions(user_params=user_params,random_seed=random_seed, direc=output_dir)
# the lightcones we want to plot later together with their color maps and min/max
lightcone_quantities = ('brightness_temp','Ts_box','xH_box',"dNrec_box",'z_re_box','Gamma12_box','J_21_LW_box',"density")
cmaps = [EoR_colour,'Reds','magma','magma','magma','cubehelix','cubehelix','viridis']
vmins = [-150, 1e1, 0, 0, 5, 0, 0, -1]
vmaxs = [  30, 1e3, 1, 2, 9, 1,10,  1]

# set necessary flags for using minihalos and astro parameter
astro_params_fid = {'ALPHA_ESC': 0.0, 'F_ESC10': -1.222, 'F_ESC7_MINI' : -2.222,
                    'ALPHA_STAR': 0.5,'F_STAR10': -1.25, 'F_STAR7_MINI': -1.75,
                    'L_X': 40.5, 'L_X_MINI': 40.5, 'NU_X_THRESH': 500.0, 'F_H2_SHIELD': 0.0}
flag_options_fid = {"INHOMO_RECO":True, 'USE_MASS_DEPENDENT_ZETA':True, 'USE_TS_FLUCT':True, 'USE_MINI_HALOS':True}

lightcone_fid = p21c.run_lightcone(
        redshift = 5.5,
        init_box = initial_conditions,
        flag_options = flag_options_fid,
        astro_params = astro_params_fid,
        lightcone_quantities=lightcone_quantities,
        global_quantities=lightcone_quantities,
        random_seed = random_seed,
        direc = output_dir
)

fig, axs = plt.subplots(len(lightcone_quantities),1,
            figsize=(getattr(lightcone_fid, lightcone_quantities[0]).shape[2]*0.01,
                     getattr(lightcone_fid, lightcone_quantities[0]).shape[1]*0.01*len(lightcone_quantities)))
for ii, lightcone_quantity in enumerate(lightcone_quantities):
    axs[ii].imshow(getattr(lightcone_fid, lightcone_quantity)[1],
                   vmin=vmins[ii], vmax=vmaxs[ii],cmap=cmaps[ii])
    axs[ii].text(1, 0.05, lightcone_quantity,horizontalalignment='right',verticalalignment='bottom',
            transform=axs[ii].transAxes,color = 'red',backgroundcolor='white',fontsize = 15)
    axs[ii].xaxis.set_tick_params(labelsize=0)
    axs[ii].yaxis.set_tick_params(labelsize=0)
plt.tight_layout()
fig.subplots_adjust(hspace = 0.01)

After running the above code, the following messages are produced


Bad key "text.kerning_factor" on line 4 in
/root/anaconda3/envs/21cm/lib/python3.8/site-packages/matplotlib/mpl-data/stylelib/_classic_test_patch.mplstyle.
You probably need to get an updated matplotlibrc file from
https://github.com/matplotlib/matplotlib/blob/v3.1.2/matplotlibrc.template
or from the matplotlib source distribution
/root/anaconda3/envs/21cm/lib/python3.8/site-packages/py21cmfast/_cfg.py:49: UserWarning: Your configuration file is out of date. Updating...
  warnings.warn(
/root/anaconda3/envs/21cm/lib/python3.8/site-packages/py21cmfast/_cfg.py:33: UserWarning: Your configuration file is out of date. Updating...
  warnings.warn("Your configuration file is out of date. Updating...")
2021-07-14 08:28:22,224 | WARNING | inputs.py::__init__() | USE_MINI_HALOS needs USE_RELATIVE_VELOCITIES to get the right evolution!
/root/anaconda3/envs/21cm/lib/python3.8/site-packages/py21cmfast/_utils.py:801: UserWarning: Trying to remove array that isn't yet created: hires_vx
  warnings.warn(f"Trying to remove array that isn't yet created: {k}")
/root/anaconda3/envs/21cm/lib/python3.8/site-packages/py21cmfast/_utils.py:801: UserWarning: Trying to remove array that isn't yet created: hires_vy
  warnings.warn(f"Trying to remove array that isn't yet created: {k}")
/root/anaconda3/envs/21cm/lib/python3.8/site-packages/py21cmfast/_utils.py:801: UserWarning: Trying to remove array that isn't yet created: hires_vz
  warnings.warn(f"Trying to remove array that isn't yet created: {k}")
/root/anaconda3/envs/21cm/lib/python3.8/site-packages/py21cmfast/_utils.py:801: UserWarning: Trying to remove array that isn't yet created: hires_vx_2LPT
  warnings.warn(f"Trying to remove array that isn't yet created: {k}")
/root/anaconda3/envs/21cm/lib/python3.8/site-packages/py21cmfast/_utils.py:801: UserWarning: Trying to remove array that isn't yet created: hires_vy_2LPT
  warnings.warn(f"Trying to remove array that isn't yet created: {k}")
/root/anaconda3/envs/21cm/lib/python3.8/site-packages/py21cmfast/_utils.py:801: UserWarning: Trying to remove array that isn't yet created: hires_vz_2LPT
  warnings.warn(f"Trying to remove array that isn't yet created: {k}")
2021-07-14 08:28:23,600 | WARNING | inputs.py::__init__() | USE_MINI_HALOS needs USE_RELATIVE_VELOCITIES to get the right evolution!
2021-07-14 08:28:23,626 | WARNING | inputs.py::__init__() | USE_MINI_HALOS needs USE_RELATIVE_VELOCITIES to get the right evolution!
2021-07-14 08:28:23,989 | WARNING | inputs.py::__init__() | USE_MINI_HALOS needs USE_RELATIVE_VELOCITIES to get the right evolution!

It is then stuck and keep running but no any more outputs.

Expected behavior:

Multiple lightcones should be produced as shown in tutorial guide, section"Fiducial and lightcones"

Details:

qyx268 commented 3 years ago

The tutorial is a bit out of date, pleaes add USE_INTERPOLATION_TABLES=True in user_params and retry.

By the way, you might also want to use your own output_dir and consider adding USE_RELATIVE_VELOCITIES in user_params to get rid of the warning about USE_MINI_HALOS needs USE_RELATIVE_VELOCITIES.

acnhwang commented 3 years ago

It works now. Thank you very much for your help!