import py21cmfast as p21c

def Run_21cmFAST(fR,LX,Zcut):
  redshift = 10
  max_redshift = 35
  LC_Quantities = ('brightness_temp','Ts_box','xH_box','Tk_box','Trad_box')
  GLB_Quantities = ('brightness_temp','Ts_box','xH_box','dNrec_box','z_re_box','Gamma12_box','J_21_LW_box','density','Trad_box','Tk_box','Fcoll')

  user_params = p21c.UserParams(
    HII_DIM = 20,
    N_THREADS = 15,
    USE_INTERPOLATION_TABLES = True,
    BOX_LEN = 150,
    )

  astro_params = p21c.AstroParams(
    fR = fR,
    F_STAR10 = -0.8,
    F_STAR7_MINI = -2.0,
    L_X = LX,
    Radio_Zmin = Zcut,
    NU_X_THRESH = 200.0,
    t_STAR = 0.3,
    M_TURN = 7.1,
    )

  flag_options = p21c.FlagOptions(
    USE_RADIO_ACG = True,
    USE_MASS_DEPENDENT_ZETA = True,
    INHOMO_RECO = True,
    USE_TS_FLUCT = True,
  )

  lc = p21c.run_lightcone(
    redshift=redshift, 
    max_redshift=max_redshift,
    astro_params=astro_params, 
    flag_options=flag_options,
    user_params = user_params,
    lightcone_quantities=LC_Quantities,
    global_quantities=GLB_Quantities
    )
  z = lc.node_redshifts
  T21 = lc.global_brightness_temp
  Trad = lc.global_Trad
  return z, T21, Trad
