def calc_dt_lightcone(xfrac, dens, lowest_z, los_axis=2): """ Calculate the differential brightness temperature assuming T_s >> T_CMB for lightcone data. Parameters: * xfrac (string or numpy array): the name of the ionization fraction file (must be cbin), or the xfrac lightcone data * dens (string or numpy array): the name of the density file (must be cbin), or the density data * lowest_z (float): the lowest redshift of the lightcone volume * los_axis = 2 (int): the line-of-sight axis Returns: The differential brightness temperature as a numpy array with the same dimensions as xfrac. """ try: xfrac = read_cbin(xfrac) except Exception: pass try: dens = read_cbin(dens) except: pass dens = dens.astype("float64") cell_size = conv.LB / xfrac.shape[(los_axis + 1) % 3] cdist_low = cosmology.z_to_cdist(lowest_z) cdist = np.arange(xfrac.shape[los_axis]) * cell_size + cdist_low z = cosmology.cdist_to_z(cdist) return _dt(dens, xfrac, z)
def calc_dt_lightcone(xfrac, dens, lowest_z, los_axis=2): ''' Calculate the differential brightness temperature assuming T_s >> T_CMB for lightcone data. Parameters: * xfrac (string or numpy array): the name of the ionization fraction file (must be cbin), or the xfrac lightcone data * dens (string or numpy array): the name of the density file (must be cbin), or the density data * lowest_z (float): the lowest redshift of the lightcone volume * los_axis = 2 (int): the line-of-sight axis Returns: The differential brightness temperature as a numpy array with the same dimensions as xfrac. ''' try: xfrac = read_cbin(xfrac) except Exception: pass try: dens = read_cbin(dens) except: pass dens = dens.astype('float64') cell_size = conv.LB / xfrac.shape[(los_axis + 1) % 3] cdist_low = cosmology.z_to_cdist(lowest_z) cdist = np.arange(xfrac.shape[los_axis]) * cell_size + cdist_low z = cosmology.cdist_to_z(cdist) return _dt(dens, xfrac, z)
def make_pv_box(dT_filename, vel_filename, dens_filename, z, los=0, num_particles=10): ''' Convenience method to read files and make a distorted box. Parameters: * dT_filename (string): the name of the dT file * vel_filename (string): the name of the velocity file * dens_filename (string): the name of the density file * z (float): the redshift * los (integer): the line-of-sight axis * num_particles (integer): the number of particles to pass to get_distorted_dt Returns: The redshift space box ''' dT = read_cbin(dT_filename, bits=32, order='c') vfile = vel_file.VelocityFile(vel_filename) dfile = density_file.DensityFile(dens_filename) kms = vfile.get_kms_from_density(dfile) dT_pv = get_distorted_dt(dT, kms, redsh = z, los_axis = los, \ num_particles = num_particles) return dT_pv
def calc_dt_full_lightcone(xfrac, temp, dens, lowest_z, los_axis=2, 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) for lightcone data. UNTESTED Parameters: * xfrac (string or numpy array): the name of the ionization fraction file (must be cbin), or the xfrac lightcone data * temp (string or numpy array): the name of the temperature file (must be cbin), or the temp lightcone data * dens (string or numpy array): the name of the density file (must be cbin), or the density data * lowest_z (float): the lowest redshift of the lightcone volume * los_axis = 2 (int): the line-of-sight axis * 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. ''' try: xfrac = read_cbin(xfrac) except Exception: pass try: temp = read_cbin(temp) except Exception: pass try: dens = read_cbin(dens) except: pass dens = dens.astype('float64') cell_size = conv.LB / xfrac.shape[(los_axis + 1) % 3] cdist_low = cosmology.z_to_cdist(lowest_z) cdist = np.arange(xfrac.shape[los_axis]) * cell_size + cdist_low z = cosmology.cdist_to_z(cdist) print "Redshift: ", str(z) return _dt_full(dens, xfrac, temp, z, correct)
def calc_dt_full_lightcone(xfrac, temp, dens, lowest_z, los_axis = 2, 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) for lightcone data. UNTESTED Parameters: * xfrac (string or numpy array): the name of the ionization fraction file (must be cbin), or the xfrac lightcone data * temp (string or numpy array): the name of the temperature file (must be cbin), or the temp lightcone data * dens (string or numpy array): the name of the density file (must be cbin), or the density data * lowest_z (float): the lowest redshift of the lightcone volume * los_axis = 2 (int): the line-of-sight axis * 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. ''' try: xfrac = read_cbin(xfrac) except Exception: pass try: temp = read_cbin(temp) except Exception: pass try: dens = read_cbin(dens) except: pass dens = dens.astype('float64') cell_size = conv.LB/xfrac.shape[(los_axis+1)%3] cdist_low = cosmology.z_to_cdist(lowest_z) cdist = np.arange(xfrac.shape[los_axis])*cell_size + cdist_low z = cosmology.cdist_to_z(cdist) print "Redshift: ", str(z) return _dt_full(dens, xfrac,temp, z, correct)
def make_pv_box(dT_filename, vel_filename, dens_filename, z, los = 0, num_particles=10): ''' Convenience method to read files and make a distorted box. Parameters: * dT_filename (string): the name of the dT file * vel_filename (string): the name of the velocity file * dens_filename (string): the name of the density file * z (float): the redshift * los (integer): the line-of-sight axis * num_particles (integer): the number of particles to pass to get_distorted_dt Returns: The redshift space box ''' dT = read_cbin(dT_filename, bits=32, order='c') vfile = vel_file.VelocityFile(vel_filename) dfile = density_file.DensityFile(dens_filename) kms = vfile.get_kms_from_density(dfile) dT_pv = get_distorted_dt(dT, kms, redsh = z, los_axis = los, \ num_particles = num_particles) return dT_pv
def read_binary_with_meshinfo(filename, bits=32, order='C'): return read_cbin(filename, bits, order)
def read_binary_with_meshinfo(filename, bits=32, order="C"): return read_cbin(filename, bits, order)