def calc_dt(xfrac, dens, z=-1): ''' Calculate the differential brightness temperature assuming T_s >> T_CMB Parameters: * xfrac (XfracFile object, string or numpy array): the ionization fraction * dens (DensityFile object, string or numpy array): density in cgs units * z = -1 (float): The redshift (if < 0 this will be figured out from the files) Returns: The differential brightness temperature as a numpy array with the same dimensions as xfrac. ''' xi, xi_type = get_data_and_type(xfrac) rho, rho_type = get_data_and_type(dens) xi = xi.astype('float64') rho = rho.astype('float64') if z < 0: z = determine_redshift_from_filename(xfrac) if z < 0: z = determine_redshift_from_filename(dens) if z < 0: raise Exception( 'No redshift specified. Could not determine from file.') print_msg('Making dT box for z=%f' % z) #Calculate dT return _dt(rho, xi, z)
def calc_dt(xfrac, dens, z=-1): """ Calculate the differential brightness temperature assuming T_s >> T_CMB Parameters: * xfrac (XfracFile object, string or numpy array): the ionization fraction * dens (DensityFile object, string or numpy array): density in cgs units * z = -1 (float): The redshift (if < 0 this will be figured out from the files) Returns: The differential brightness temperature as a numpy array with the same dimensions as xfrac. """ xi, xi_type = get_data_and_type(xfrac) rho, rho_type = get_data_and_type(dens) xi = xi.astype("float64") rho = rho.astype("float64") if z < 0: z = determine_redshift_from_filename(xfrac) if z < 0: z = determine_redshift_from_filename(dens) if z < 0: raise Exception("No redshift specified. Could not determine from file.") print_msg("Making dT box for z=%f" % z) # Calculate dT return _dt(rho, xi, z)
def calc_dt_full(xfrac, dens, temp, z = -1, correct=True): ''' Calculate the differential brightness temperature assuming only that Lyman alpha is fully coupled so T_s = T_k (NOT T_s >> T_CMB) Parameters: * xfrac (XfracFile object, string or numpy array): the ionization fraction * dens (DensityFile object, string or numpy array): density in cgs units * temp (TemperFile object, string or numpy array): the temperature in K * z = -1 (float): The redshift (if < 0 this will be figured out from the files) * correct = True (bool): if true include a correction for partially ionized cells. Returns: The differential brightness temperature as a numpy array with the same dimensions as xfrac. ''' xi, xi_type = get_data_and_type(xfrac) Ts, Ts_type = get_data_and_type(temp) rho, rho_type = get_data_and_type(dens) xi = xi.astype('float64') Ts = Ts.astype('float64') rho = rho.astype('float64') if z < 0: z = determine_redshift_from_filename(xfrac) if z < 0: z = determine_redshift_from_filename(dens) if z < 0: z = determine_redshift_from_filename(temp) if z < 0: raise Exception('No redshift specified. Could not determine from file.') print_msg('Making full dT box for z=%f' % z) print "Calculating corrected dbt" return _dt_full(rho, xi, Ts, z, correct)
def calc_dt_full(xfrac, temp, dens, z=-1): """ Calculate the differential brightness temperature assuming only that Lyman alpha is fully coupled so T_s = T_k (NOT T_s >> T_CMB) Parameters: * xfrac (XfracFile object, string or numpy array): the ionization fraction * temp (TemperFile object, string or numpy array): the temperature in K * dens (DensityFile object, string or numpy array): density in cgs units * z = -1 (float): The redshift (if < 0 this will be figured out from the files) Returns: The differential brightness temperature as a numpy array with the same dimensions as xfrac. """ xi, xi_type = get_data_and_type(xfrac) Ts, Ts_type = get_data_and_type(temp) rho, rho_type = get_data_and_type(dens) xi = xi.astype("float64") Ts = Ts.astype("float64") rho = rho.astype("float64") if z < 0: z = determine_redshift_from_filename(xfrac) if z < 0: z = determine_redshift_from_filename(dens) if z < 0: z = determine_redshift_from_filename(temp) if z < 0: raise Exception("No redshift specified. Could not determine from file.") print_msg("Making full dT box for z=%f" % z) # Calculate dT print "calculating corrected dbt" return _dt_full_corrected(dens, xfrac, temp, z) # rho, Ts, xi, z)
def calc_dt_full(xfrac, dens, temp, z=-1, correct=True): ''' Calculate the differential brightness temperature assuming only that Lyman alpha is fully coupled so T_s = T_k (NOT T_s >> T_CMB) Parameters: * xfrac (XfracFile object, string or numpy array): the ionization fraction * dens (DensityFile object, string or numpy array): density in cgs units * temp (TemperFile object, string or numpy array): the temperature in K * z = -1 (float): The redshift (if < 0 this will be figured out from the files) * correct = True (bool): if true include a correction for partially ionized cells. Returns: The differential brightness temperature as a numpy array with the same dimensions as xfrac. ''' xi, xi_type = get_data_and_type(xfrac) Ts, Ts_type = get_data_and_type(temp) rho, rho_type = get_data_and_type(dens) xi = xi.astype('float64') Ts = Ts.astype('float64') rho = rho.astype('float64') if z < 0: z = determine_redshift_from_filename(xfrac) if z < 0: z = determine_redshift_from_filename(dens) if z < 0: z = determine_redshift_from_filename(temp) if z < 0: raise Exception( 'No redshift specified. Could not determine from file.') print_msg('Making full dT box for z=%f' % z) print "Calculating corrected dbt" return _dt_full(rho, xi, Ts, z, correct)
def _get_file_redshifts(redshifts_in, filenames): ''' If redshifts_in is None, try to determine from file names If it's a directory, read the redshifts Else, return as is ''' if hasattr(redshifts_in, '__iter__'): redshifts_out = redshifts_in elif redshifts_in == None: redshifts_out = [determine_redshift_from_filename(f) for f in filenames] redshifts_out = np.array(redshifts_out) elif os.path.exists(redshifts_in): redshifts_out = np.loadtxt(redshifts_in) else: raise Exception('Invalid data for file redshifts.') return redshifts_out
def _get_file_redshifts(redshifts_in, filenames): ''' If redshifts_in is None, try to determine from file names If it's a directory, read the redshifts Else, return as is ''' if hasattr(redshifts_in, '__iter__'): redshifts_out = redshifts_in elif redshifts_in == None: redshifts_out = [ determine_redshift_from_filename(f) for f in filenames ] redshifts_out = np.array(redshifts_out) elif os.path.exists(redshifts_in): redshifts_out = np.loadtxt(redshifts_in) else: raise Exception('Invalid data for file redshifts.') return redshifts_out