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(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, 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 plot_hist(data, logscale=False, **kwargs): """ Plot a histogram of the data in a data cube. Parameters: * data (XfracFile, DensityFile, string or numpy array): the data to plot. The function will try to determine what type of data it's been given. * logscale = False (bool): whether to plot the logarithm of the data Kwargs: All kwargs are sent to matplotlib's hist function. Here, you can specify, for example, the bins keyword Returns: Nothing. """ import pylab as pl # Determine data type plot_data, datatype = get_data_and_type(data) # Fix bins if datatype == "xfrac" and not "bins" in kwargs.keys(): kwargs["bins"] = np.linspace(0, 1, 30) else: kwargs["bins"] = 30 # Plot if not "histtype" in kwargs.keys(): kwargs["histtype"] = "step" if not "color" in kwargs.keys(): kwargs["color"] = "k" pl.hist(plot_data.flatten(), log=logscale, **kwargs) # Labels if datatype == "xfrac": pl.xlabel("$x_i$") elif datatype == "density": pl.xlabel("$\\rho \; \mathrm{[g \; cm^{-3}]}$")
def plot_hist(data, logscale = False, **kwargs): ''' Plot a histogram of the data in a data cube. Parameters: * data (XfracFile, DensityFile, string or numpy array): the data to plot. The function will try to determine what type of data it's been given. * logscale = False (bool): whether to plot the logarithm of the data Kwargs: All kwargs are sent to matplotlib's hist function. Here, you can specify, for example, the bins keyword Returns: Nothing. ''' import pylab as pl #Determine data type plot_data, datatype = get_data_and_type(data) #Fix bins if datatype == 'xfrac' and not 'bins' in kwargs.keys(): kwargs['bins'] = np.linspace(0,1,30) else: kwargs['bins'] = 30 #Plot if not 'histtype' in kwargs.keys(): kwargs['histtype'] = 'step' if not 'color' in kwargs.keys(): kwargs['color'] = 'k' pl.hist(plot_data.flatten(), log = logscale, **kwargs) #Labels if datatype == 'xfrac': pl.xlabel('$x_i$') elif datatype == 'density': pl.xlabel('$\\rho \; \mathrm{[g \; cm^{-3}]}$')
def make_lightcone(filenames, z_low = None, z_high = None, file_redshifts = None, \ cbin_bits = 32, cbin_order = 'c', los_axis = 0, raw_density = False, interpolation='linear'): ''' Make a lightcone from xfrac, density or dT data. Replaces freq_box. Parameters: * filenames (string or array): The coeval cubes. Can be either any of the following: - An array with the file names - A text file containing the file names - The directory containing the files (must only contain one type of files) * z_low (float): the lowest redshift. If not given, the redshift of the lowest-z coeval cube is used. * z_high (float): the highest redshift. If not given, the redshift of the highest-z coeval cube is used. * file_redshifts (string or array): The redshifts of the coeval cubes. Can be any of the following types: - None: determine the redshifts from file names - array: array containing the redshift of each coeval cube - filename: the name of a data file to read the redshifts from * cbin_bits (int): If the data files are in cbin format, you may specify the number of bits. * cbin_order (char): If the data files are in cbin format, you may specify the order of the data. * los_axis (int): the axis to use as line-of-sight for the coeval cubes * raw_density (bool): if this is true, and the data is a density file, the raw (simulation units) density will be returned instead of the density in cgs units * interpolation (string): can be 'linear', 'step', 'sigmoid' or 'step_cell'. Determines how slices in between output redshifts are interpolated. Returns: (lightcone, z) tuple lightcone is the lightcone volume where the first two axes have the same size as the input cubes z is an array containing the redshifts along the line-of-sight .. note:: If z_low is given, that redshift will be the lowest one included, even if there is no coeval box at exactly that redshift. This can give results that are subtly different from results calculated with the old freq_box routine. ''' if not interpolation in ['linear', 'step', 'sigmoid', 'step_cell']: raise ValueError('Unknown interpolation type: %s' % interpolation) #Figure out output redshifts, file names and size of output filenames = _get_filenames(filenames) file_redshifts = _get_file_redshifts(file_redshifts, filenames) assert len(file_redshifts) == len(filenames) mesh_size = get_mesh_size(filenames[0]) output_z = _get_output_z(file_redshifts, z_low, z_high, mesh_size[0]) #Make the output 32-bit to save memory lightcone = np.zeros((mesh_size[0], mesh_size[1], len(output_z)), dtype='float32') comoving_pos_idx = 0 z_bracket_low = None; z_bracket_high = None data_low = None; data_high = None #Make the lightcone, one slice at a time print_msg('Making lightcone between %f < z < %f' % (output_z.min(), output_z.max())) for z in output_z: z_bracket_low_new = file_redshifts[file_redshifts <= z].max() z_bracket_high_new = file_redshifts[file_redshifts > z].min() #Do we need a new file for the low z? if z_bracket_low_new != z_bracket_low: z_bracket_low = z_bracket_low_new file_idx = np.argmin(np.abs(file_redshifts - z_bracket_low)) if data_high == None: data_low, datatype = get_data_and_type(filenames[file_idx], cbin_bits, cbin_order, raw_density) else: #No need to read the file again data_low = data_high #Do we need a new file for the high z? if z_bracket_high_new != z_bracket_high: z_bracket_high = z_bracket_high_new file_idx = np.argmin(np.abs(file_redshifts - z_bracket_high)) data_high, datatype = get_data_and_type(filenames[file_idx], cbin_bits, cbin_order, raw_density) #Make the slice by interpolating, then move to next index data_interp = _get_interp_slice(data_high, data_low, z_bracket_high, \ z_bracket_low, z, comoving_pos_idx, los_axis, interpolation) lightcone[:,:,comoving_pos_idx] = data_interp comoving_pos_idx += 1 return lightcone, output_z
def plot_slice(data, los_axis=0, slice_num=0, logscale=False, **kwargs): """ Plot a slice through a data cube. This function will produce a nicely formatted image plot with the correct units on the axes. Parameters: * data (XfracFile, DensityFile, string or numpy array): the data to plot. The function will try to determine what type of data it's been given. * los_axis = 0 (integer): the line of sight axis. Must be 0,1 or 2 * slice_num = 0 (integer): the point along los_axis where the slice will be taken. * logscale = False (bool): whether to plot the logarithm of the data Kwargs: All kwargs are sent to matplotlib's imshow function. This can be used to, for instance, change the colormap. Returns: Nothing. Example (plot an xfrac file with a custom color map): >>> xfile = c2t.XfracFile('xfrac3d_8.515.bin') >>> c2t.plot_slice(xfile, cmap = pl.cmap.hot) """ import pylab as pl # Determine data type plot_data, datatype = get_data_and_type(data) # Take care of different LOS axes assert los_axis == 0 or los_axis == 1 or los_axis == 2 if los_axis == 0: get_slice = lambda data, i: data[i, :, :] elif los_axis == 1: get_slice = lambda data, i: data[:, i, :] else: get_slice = lambda data, i: data[:, :, i] data_slice = get_slice(plot_data, slice_num) ext = [0, conv.LB, 0, conv.LB] if logscale: data_slice = np.log10(data_slice) # Plot pl.imshow(data_slice, extent=ext, **kwargs) cbar = pl.colorbar() pl.xlabel("$\mathrm{cMpc}$") pl.ylabel("$\mathrm{cMpc}$") # Make redshift string try: z_str = "$z = %.2f$" % data.z except Exception: z_str = "" # Set labels etc if datatype == "xfrac": if logscale: cbar.set_label("$\log_{10} x_i$") else: cbar.set_label("$x_i$") pl.title("Ionized fraction, %s" % z_str) elif datatype == "density": if logscale: cbar.set_label("$\log_{10} \\rho \; \mathrm{[g \; cm^{-3}]}$") else: cbar.set_label("$\\rho \; \mathrm{[g \; cm^{-3}]}$") pl.title("Density, %s" % z_str)
def make_lightcone(filenames, z_low = None, z_high = None, file_redshifts = None, \ cbin_bits = 32, cbin_order = 'c', los_axis = 0, raw_density = False, interpolation='linear'): ''' Make a lightcone from xfrac, density or dT data. Replaces freq_box. Parameters: * filenames (string or array): The coeval cubes. Can be either any of the following: - An array with the file names - A text file containing the file names - The directory containing the files (must only contain one type of files) * z_low (float): the lowest redshift. If not given, the redshift of the lowest-z coeval cube is used. * z_high (float): the highest redshift. If not given, the redshift of the highest-z coeval cube is used. * file_redshifts (string or array): The redshifts of the coeval cubes. Can be any of the following types: - None: determine the redshifts from file names - array: array containing the redshift of each coeval cube - filename: the name of a data file to read the redshifts from * cbin_bits (int): If the data files are in cbin format, you may specify the number of bits. * cbin_order (char): If the data files are in cbin format, you may specify the order of the data. * los_axis (int): the axis to use as line-of-sight for the coeval cubes * raw_density (bool): if this is true, and the data is a density file, the raw (simulation units) density will be returned instead of the density in cgs units * interpolation (string): can be 'linear', 'step', 'sigmoid' or 'step_cell'. Determines how slices in between output redshifts are interpolated. Returns: (lightcone, z) tuple lightcone is the lightcone volume where the first two axes have the same size as the input cubes z is an array containing the redshifts along the line-of-sight .. note:: If z_low is given, that redshift will be the lowest one included, even if there is no coeval box at exactly that redshift. This can give results that are subtly different from results calculated with the old freq_box routine. ''' if not interpolation in ['linear', 'step', 'sigmoid', 'step_cell']: raise ValueError('Unknown interpolation type: %s' % interpolation) #Figure out output redshifts, file names and size of output filenames = _get_filenames(filenames) file_redshifts = _get_file_redshifts(file_redshifts, filenames) assert len(file_redshifts) == len(filenames) mesh_size = get_mesh_size(filenames[0]) output_z = _get_output_z(file_redshifts, z_low, z_high, mesh_size[0]) #Make the output 32-bit to save memory lightcone = np.zeros((mesh_size[0], mesh_size[1], len(output_z)), dtype='float32') comoving_pos_idx = 0 z_bracket_low = None z_bracket_high = None data_low = None data_high = None #Make the lightcone, one slice at a time print_msg('Making lightcone between %f < z < %f' % (output_z.min(), output_z.max())) for z in output_z: z_bracket_low_new = file_redshifts[file_redshifts <= z].max() z_bracket_high_new = file_redshifts[file_redshifts > z].min() #Do we need a new file for the low z? if z_bracket_low_new != z_bracket_low: z_bracket_low = z_bracket_low_new file_idx = np.argmin(np.abs(file_redshifts - z_bracket_low)) if data_high == None: data_low, datatype = get_data_and_type(filenames[file_idx], cbin_bits, cbin_order, raw_density) else: #No need to read the file again data_low = data_high #Do we need a new file for the high z? if z_bracket_high_new != z_bracket_high: z_bracket_high = z_bracket_high_new file_idx = np.argmin(np.abs(file_redshifts - z_bracket_high)) data_high, datatype = get_data_and_type(filenames[file_idx], cbin_bits, cbin_order, raw_density) #Make the slice by interpolating, then move to next index data_interp = _get_interp_slice(data_high, data_low, z_bracket_high, \ z_bracket_low, z, comoving_pos_idx, los_axis, interpolation) lightcone[:, :, comoving_pos_idx] = data_interp comoving_pos_idx += 1 return lightcone, output_z
def make_lightcone(filenames, z_low = None, z_high = None, file_redshifts = None, \ cbin_bits = 32, cbin_order = 'c', los_axis = 0): ''' Make a lightcone from xfrac, density or dT data. Replaces freq_box. Parameters: * filenames (string or array): The coeval cubes. Can be either any of the following: - An array with the file names - A text file containing the file names - The directory containing the files (must only contain one type of files) * z_low (float): the lowest redshift. If not given, the redshift of the lowest-z coeval cube is used. * z_high (float): the highest redshift. If not given, the redshift of the highest-z coeval cube is used. * file_redshifts (string or array): The redshifts of the coeval cubes. Can be any of the following types: - None: determine the redshifts from file names - array: array containing the redshift of each coeval cube - filename: the name of a data file to read the redshifts from * cbin_bits (int): If the data files are in cbin format, you may specify the number of bits. * cbin_order (char): If the data files are in cbin format, you may specify the order of the data. * los_axis (int): the axis to use as line-of-sight for the coeval cubes Returns: (lightcone, z) tuple lightcone is the lightcone volume where the first two axes have the same size as the input cubes z is an array containing the redshifts along the line-of-sight .. note:: If z_low is given, that redshift will be the lowest one included, even if there is no coeval box at exactly that redshift. This can give results that are subtly different from results calculated with the old freq_box routine. ''' filenames = _get_filenames(filenames) file_redshifts = _get_file_redshifts(file_redshifts, filenames) assert(len(file_redshifts) == len(filenames)) mesh_size = get_mesh_size(filenames[0]) if z_low == None: z_low = file_redshifts.min() if z_high == None: z_high = file_redshifts.max() output_z = redshifts_at_equal_comoving_distance(z_low, z_high, box_grid_n=mesh_size[0]) if min(output_z) < min(file_redshifts) or max(output_z) > max(file_redshifts): print 'Warning! You have specified a redshift range of %.3f < z < %.3f' % (min(output_z), max(output_z)) print 'but you only have files for the range %.3f < z < %.3f.' % (min(file_redshifts), max(file_redshifts)) print 'The redshift range will be truncated.' output_z = output_z[output_z >= min(file_redshifts)] output_z = output_z[output_z <= max(file_redshifts)] if len(output_z) < 1: raise Exception('No valid redshifts in range!') lightcone = np.zeros((mesh_size[0], mesh_size[1], len(output_z))) comoving_pos_idx = 0 z_bracket_low = None; z_bracket_high = None for z in output_z: z_bracket_low_new = file_redshifts[file_redshifts < z].max() z_bracket_high_new = file_redshifts[file_redshifts > z].min() if z_bracket_low_new != z_bracket_low: z_bracket_low = z_bracket_low_new file_idx = np.argmin(np.abs(file_redshifts - z_bracket_low)) data_low, datatype = get_data_and_type(filenames[file_idx], cbin_bits, cbin_order) if z_bracket_high_new != z_bracket_high: z_bracket_high = z_bracket_high_new file_idx = np.argmin(np.abs(file_redshifts - z_bracket_high)) data_high, datatype = get_data_and_type(filenames[file_idx], cbin_bits, cbin_order) data_interp = _get_interp_slice(data_high, data_low, z_bracket_high, \ z_bracket_low, z, comoving_pos_idx, los_axis) lightcone[:,:,comoving_pos_idx] = data_interp comoving_pos_idx += 1 return lightcone, output_z
def plot_slice(data, los_axis = 0, slice_num = 0, logscale = False, **kwargs): ''' Plot a slice through a data cube. This function will produce a nicely formatted image plot with the correct units on the axes. Parameters: * data (XfracFile, DensityFile, string or numpy array): the data to plot. The function will try to determine what type of data it's been given. * los_axis = 0 (integer): the line of sight axis. Must be 0,1 or 2 * slice_num = 0 (integer): the point along los_axis where the slice will be taken. * logscale = False (bool): whether to plot the logarithm of the data Kwargs: All kwargs are sent to matplotlib's imshow function. This can be used to, for instance, change the colormap. Returns: Nothing. Example (plot an xfrac file with a custom color map): >>> xfile = c2t.XfracFile('xfrac3d_8.515.bin') >>> c2t.plot_slice(xfile, cmap = pl.cmap.hot) ''' import pylab as pl #Determine data type plot_data, datatype = get_data_and_type(data) #Take care of different LOS axes assert (los_axis == 0 or los_axis == 1 or los_axis == 2) if los_axis == 0: get_slice = lambda data, i : data[i,:,:] elif los_axis == 1: get_slice = lambda data, i : data[:,i,:] else: get_slice = lambda data, i : data[:,:,i] data_slice = get_slice(plot_data, slice_num) ext = [0, conv.LB, 0, conv.LB] if (logscale): data_slice = np.log10(data_slice) #Plot pl.imshow(data_slice, extent=ext, **kwargs) cbar = pl.colorbar() pl.xlabel('$\mathrm{cMpc}$') pl.ylabel('$\mathrm{cMpc}$') #Make redshift string try: z_str = '$z = %.2f$' % data.z except Exception: z_str = '' #Set labels etc if datatype == 'xfrac': if (logscale): cbar.set_label('$\log_{10} x_i$') else: cbar.set_label('$x_i$') pl.title('Ionized fraction, %s' % z_str) elif datatype == 'density': if (logscale): cbar.set_label('$\log_{10} \\rho \; \mathrm{[g \; cm^{-3}]}$') else: cbar.set_label('$\\rho \; \mathrm{[g \; cm^{-3}]}$') pl.title('Density, %s' % z_str)
def make_lightcone(filenames, z_low = None, z_high = None, file_redshifts = None, \ cbin_bits = 32, cbin_order = 'c', los_axis = 0): ''' Make a lightcone from xfrac, density or dT data. Replaces freq_box. Parameters: * filenames (string or array): The coeval cubes. Can be either any of the following: - An array with the file names - A text file containing the file names - The directory containing the files (must only contain one type of files) * z_low (float): the lowest redshift. If not given, the redshift of the lowest-z coeval cube is used. * z_high (float): the highest redshift. If not given, the redshift of the highest-z coeval cube is used. * file_redshifts (string or array): The redshifts of the coeval cubes. Can be any of the following types: - None: determine the redshifts from file names - array: array containing the redshift of each coeval cube - filename: the name of a data file to read the redshifts from * cbin_bits (int): If the data files are in cbin format, you may specify the number of bits. * cbin_order (char): If the data files are in cbin format, you may specify the order of the data. * los_axis (int): the axis to use as line-of-sight for the coeval cubes Returns: (lightcone, z) tuple lightcone is the lightcone volume where the first two axes have the same size as the input cubes z is an array containing the redshifts along the line-of-sight .. note:: If z_low is given, that redshift will be the lowest one included, even if there is no coeval box at exactly that redshift. This can give results that are subtly different from results calculated with the old freq_box routine. ''' filenames = _get_filenames(filenames) file_redshifts = _get_file_redshifts(file_redshifts, filenames) assert (len(file_redshifts) == len(filenames)) mesh_size = get_mesh_size(filenames[0]) if z_low == None: z_low = file_redshifts.min() if z_high == None: z_high = file_redshifts.max() output_z = redshifts_at_equal_comoving_distance(z_low, z_high, box_grid_n=mesh_size[0]) if min(output_z) < min(file_redshifts) or max(output_z) > max( file_redshifts): print 'Warning! You have specified a redshift range of %.3f < z < %.3f' % ( min(output_z), max(output_z)) print 'but you only have files for the range %.3f < z < %.3f.' % ( min(file_redshifts), max(file_redshifts)) print 'The redshift range will be truncated.' output_z = output_z[output_z >= min(file_redshifts)] output_z = output_z[output_z <= max(file_redshifts)] if len(output_z) < 1: raise Exception('No valid redshifts in range!') lightcone = np.zeros((mesh_size[0], mesh_size[1], len(output_z))) comoving_pos_idx = 0 z_bracket_low = None z_bracket_high = None for z in output_z: z_bracket_low_new = file_redshifts[file_redshifts < z].max() z_bracket_high_new = file_redshifts[file_redshifts > z].min() if z_bracket_low_new != z_bracket_low: z_bracket_low = z_bracket_low_new file_idx = np.argmin(np.abs(file_redshifts - z_bracket_low)) data_low, datatype = get_data_and_type(filenames[file_idx], cbin_bits, cbin_order) if z_bracket_high_new != z_bracket_high: z_bracket_high = z_bracket_high_new file_idx = np.argmin(np.abs(file_redshifts - z_bracket_high)) data_high, datatype = get_data_and_type(filenames[file_idx], cbin_bits, cbin_order) data_interp = _get_interp_slice(data_high, data_low, z_bracket_high, \ z_bracket_low, z, comoving_pos_idx, los_axis) lightcone[:, :, comoving_pos_idx] = data_interp comoving_pos_idx += 1 return lightcone, output_z