idx = np.where(lineLabels == old_label) lineLatex[idx] = new_label # Data location cube_address = fitsFolder / fileList[i] objFolder = resultsFolder / obj voxelFolder = resultsFolder / obj / 'voxel_data' db_addresss = objFolder / f'{obj}_database.fits' maskFits_address = objFolder / f'{obj}_masks.fits' idx_j, idx_i = voxel_cords wave, cube, header = import_muse_fits(cube_address) flux_voxel = cube[:, idx_j, idx_i].data.data / 1000 flux_err = np.sqrt(cube[:, idx_j, idx_i].var.data) / 1000 voxel = lime.Spectrum(wave, flux_voxel, input_err=flux_err, redshift=z_objs[i]) # voxel.plot_spectrum(spec_label=f'{obj} voxel {idx_j}-{idx_i}', log_scale=True) STANDARD_PLOT = { 'figure.figsize': (16, 5), 'axes.titlesize': 10, 'axes.labelsize': 6, 'legend.fontsize': 12, 'xtick.labelsize': 6, 'ytick.labelsize': 6 } rcParams.update(STANDARD_PLOT) fig = plt.figure(dpi=300) gs = fig.add_gridspec(nrows=1, ncols=1) gs_obj = gs[i].subgridspec(2,
return W, F, E # file_address = Path('/home/vital/Dropbox/Astrophysics/Data/CGCG007_mike/CGCG007_redArm_v2.fits') file_address = Path( '/home/vital/Dropbox/Astrophysics/Data/CGCG007_mike/CGCG007_redArm_v3.fits' ) # file_address = Path('/home/vital/Dropbox/Astrophysics/Data/CGCG007_mike/CGCG007_redArm_v4.fits') ext = 15 with fits.open(file_address) as hdu_list: wave_m = hdu_list[1].data[ext] flux_m = hdu_list[2].data[ext] err_m = hdu_list[3].data[ext] spec_order = lime.Spectrum(wave_m, flux_m, err_m, redshift=0.004691) spec_order.plot_spectrum(frame='rest') line = 'H1_6563A_b' lineWaves = np.array([6539, 6545, 6548, 6587, 6589, 6597]) fit_conf = { 'H1_6563A_b': 'H1_6563A-H1_6563A_w1-H1_6563A_w2-N2_6584A-N2_6548A', 'H1_6563A_w1_sigma': { 'expr': '>2*H1_6563A_sigma' }, 'H1_6563A_w2_sigma': { 'expr': '>3*H1_6563A_w1_sigma' }, 'H1_6563A_cont_slope': { 'vary': False },
frame_idx = 0 with fits.open(file_address) as hdul: data, header = hdul[frame_idx].data, hdul[frame_idx].header w_min = header['CRVAL3'] dw = header['CD3_3'] # dw = 0.862936 INDEF (Wavelength interval per pixel) pixels = header['NAXIS3'] # nw = 3801 number of output pixels w_max = w_min + dw * pixels wave = np.linspace(w_min, w_max, pixels, endpoint=False) print(data.shape) region_Halpha = np.array([7732.0, 7764.0]) idcsHalpha = np.searchsorted(wave, region_Halpha) wave_Halpha, fluxHalpha = wave[idcsHalpha[0]:idcsHalpha[1]], data[ idcsHalpha[0]:idcsHalpha[1], :, :] fig = plt.figure(figsize=(10, 10)) ax = fig.add_subplot() im = ax.imshow(fluxHalpha.sum(axis=1), aspect=0.5) print(fluxHalpha.sum(axis=1).shape) ax.update({'title': r'J0926 galaxy', 'xlabel': r'X', 'ylabel': r'Y'}) plt.show() j_idx, i_idx = 10, 10 voxel_spec = lime.Spectrum(wave, data[:, j_idx, i_idx]) voxel_spec.plot_spectrum() ext = f'coord-{coord_y}-{coord_x}'
n_lines = 0 n_voxels = idcs_voxels.shape[0] for idx_voxel in np.arange(n_voxels): idx_j, idx_i = idcs_voxels[idx_voxel] voxel_dict = {} local_mask = voxelFolder / f'{idx_j}-{idx_i}_mask_{obj}.txt' local_lineslog = voxelFolder / f'{idx_j}-{idx_i}_lineslog_{obj}.txt' grid_address_i = voxelFolder / f'{idx_j}-{idx_i}_LineGrid_{obj}.png' # Voxel data flux_voxel = cube[:, idx_j, idx_i] voxel = lime.Spectrum(wave, flux_voxel, norm_flux=norm_flux, crop_waves=(4515, 9500)) # lime.MaskInspector(mask_address, mask_df, wave, flux_voxel, norm_flux=norm_flux) # Locate the line fluxes peaks_table, matched_DF = voxel.match_line_mask( mask_df, noise_region, line_type='absorption', width_tol=6, width_mode='fix') if verbose: voxel.plot_spectrum(spec_label=f'{obj} voxel {idx_j}-{idx_i}', peaks_table=peaks_table,