stellar_Wave, obj_input_flux, stellar_flux, fit_output = sw.load_starlight_output(starlight2012_folder/outputFile) z_gp = obsData['sample_data']['z_array'][i] Mcor, Mint = fit_output['Mcor_tot'], fit_output['Mini_tot'] mass_galaxy = computeSSP_galaxy_mass(Mcor, 1, z_gp) massProcess_galaxy = computeSSP_galaxy_mass(Mint, 1, z_gp) idcs_below_20Myr = fit_output['DF'].age_j < 2*10**7 mass_galaxy_20Myr_percent = np.sum(fit_output['DF'].loc[idcs_below_20Myr, 'Mcor_j'].values) # Store starlight configuration values for linux runy rc = pn.RedCorr(R_V=RV, E_BV=fit_output['Av_min'] / RV, law=red_law) cHbeta_star = rc.cHbetaFromEbv(fit_output['Av_min']/RV) starlight_cfg = {'gridFileName': outputFile, 'outputFile': outputFile, 'saveFolder': starlight2012_folder.as_posix(), 'Galaxy_mass_Current': mass_galaxy, 'Galaxy_mass_Prosessed': massProcess_galaxy, 'Galaxy_mass_Percentbelow20Myr': mass_galaxy_20Myr_percent, 'Chi2': fit_output['Chi2'], 'A_V_stellarr': fit_output['Av_min'], 'cHbeta_stellar': cHbeta_star, 'PixelMeanDevPer': fit_output['SumXdev'], 'SN': fit_output['SignalToNoise_magnitudeWave']} sr.parseConfDict(results_file, starlight_cfg, f'Starlight_run_{cycle}', clear_section=True) # Plot the results plot_label = f'{obj} spectrum' if ext == '_BR' else f'{obj} blue arm spectrum' sw.population_fraction_plots(fit_output, plot_label, 'Mass_fraction', massFracPlotFile, mass_galaxy=mass_galaxy) sw.population_fraction_plots(fit_output, plot_label, 'Light_fraction', LightFracPlotFile) sw.mask_plot(fit_output, obj, lm.wave, lm.flux, stellar_Wave, stellar_flux, obj_input_flux)#, outputAddress=maskPlotFile)
reddening_results = compute_cHbeta(extCorrDict, linesDF, red_law, RV, Te_low, ne, plot_address=plot_address) # Save dictionary with the measurements for cHbeta_label, inputLines in extCorrDict.items(): cHbeta, cHbeta_err = reddening_results[cHbeta_label][ 'cHbeta'], reddening_results[cHbeta_label]['cHbeta_err'] extinction_data[cHbeta_label] = (f'{cHbeta:0.3f}', f'{cHbeta_err:0.3f}') sr.parseConfDict(results_file, extinction_data, f'Extinction_{cycle}', clear_section=True) # -------------------------------------- Apply extinction correction ------------------------------------- # Get favoured physical conditions for extinction calculation results_dict = sr.loadConfData(results_file, group_variables=False) cHbeta_label = obsData[obj]['cHbeta_label'] cHbeta = np.array(results_dict[f'Extinction_{cycle}'][cHbeta_label], dtype=float) print(f'-- Using {cHbeta_label}: {cHbeta}') print(f'-- Wdiv: {w_div_array[i]}\n') # Add new columns to dataframe for column in [
# Declare input files print(f'- Treating object ({i}): {obj}') objFolder = resultsFolder / f'{obj}' fits_file = dataFolder / f'{obj}_{ext}.fits' objMask = dataFolder / f'{obj}_{ext}_mask.txt' results_file = objFolder / f'{obj}_{ext}_measurements.txt' lineLog_file = objFolder / f'{obj}_{ext}_linesLog_{cycle}.txt' # Declare output files outputDb = objFolder / f'{obj}_{ext}_fitting_{cycle}.db' outputTxt = objFolder / f'{obj}_{ext}_fitting_{cycle}.txt' simConf = dataFolder / f'{obj}_config.txt' # Load data objParams = sr.loadConfData(simConf, group_variables=False) objLinesDF = sr.import_emission_line_data( lineLog_file, include_lines=objParams[obj]['input_lines']) # Plot the results objChem = sr.DirectMethod() table_file = objFolder / f'{obj}_elementalabundances' objChem.abundances_from_db(outputDb, save_results_address=table_file) mean_abund_dict = {} for element, trace in objChem.element_traces.items(): mean_abund_dict[element] = np.array([trace.mean(), trace.std()]) sr.parseConfDict(results_file, mean_abund_dict, f'Elemental_abundances_{cycle}', clear_section=True)
fits_address = papaderos_fittings_folder / ssp_lib data, header = sr.import_fits_data(fits_address, instrument=None, frame_idx=0) for param in list_params: # print(f'{param} = {header[param]}') fado_measurements[param] = header[param] # for param in header: # print(f'{param} = {header[param]}') # Store the results section_label = f'Large_FADO_fit' sr.parseConfDict(results_file, fado_measurements, section_label, clear_section=True) # papaderos_fittings_folder = Path('D:/Dropbox/Astrophysics/Papers/gtc_greenpeas/data/Papaderos_Full/6March2021/BCall_z03') # ssp_lib_list = ['ChabP94Z5N295', 'midChab94', 'Z3SalpP00', 'Z4P00'] # # # Reading spectrum # for i, obj in enumerate(objList): # # # Declare input files # objFolder = resultsFolder / f'{obj}' # results_file = objFolder / f'{obj}_{ext}_measurements.txt' # fits_file = dataFolder / f'{obj}_{ext}.fits' # ext_fit = '1D' # fado_file = f'{obj}_FD.cxt.FADO_{ext_fit}.fits' # previousCycle = cycle.replace('3', '2')