Input_Wavelength, Input_Flux, Output_Flux, fit_output = sw.load_starlight_output(starlightFolder/'Output'/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)

            if ext == ('_BR'):
                objPlotLabel = f'{obj} full spectrum'
            else:
                objPlotLabel = f'{obj} blue spectrum'


            # Plot the results
            sw.population_fraction_plots(fit_output, objPlotLabel, 'Mass_fraction', massFracPlotFile, mass_galaxy=mass_galaxy)
            sw.population_fraction_plots(fit_output, objPlotLabel, 'Light_fraction', LightFracPlotFile)
            sw.stellar_fit_comparison_plot(objPlotLabel, Input_Wavelength, Input_Flux, Output_Flux, stellarPlotFile)
            print(f'-- Mass fraction {massFracPlotFile}')

            # labelsDict = {'xlabel': r'Wavelength $(\AA)$',
            #               'ylabel': r'Flux $(erg\,cm^{-2} s^{-1} \AA^{-1})\cdot10^{20}$',
            #               'title': f'Galaxy {objName} stellar continuum fitting'}
            #
            # idcs_plot = Input_Flux > 0.0
            #
            # fig, ax = plt.subplots(figsize=(12, 8))
            # ax.plot(wave, flux, label='--- Observed fits file')
            # ax.plot(Input_Wavelength[idcs_plot], Input_Flux[idcs_plot], label='--- Input starlight flux')
            # ax.plot(Input_Wavelength[idcs_plot], Output_Flux[idcs_plot], label='--- Output starlight fitting')
            # ax.update(labelsDict)
            # ax.legend()
            # ax.set_yscale('log')
    Int_StellarExtension = np.zeros(len(Wave_StellarExtension))

    #Increase the range of Wave_S so it is greater than the observational range
    Wave_S = np.hstack((Wave_StellarExtension, stellar_Wave))
    Int_S = np.hstack((Int_StellarExtension, stellar_flux))

    #Resampling stellar spectra
    Interpolation = interp1d(Wave_S, Int_S, kind='slinear')
    flux_Stellar_Resampled = Interpolation(lm.wave)

    # Save the non object spectrum without stellar component
    stellarFlux = flux_Stellar_Resampled
    np.savetxt(stellarFluxFile,
               np.transpose(np.array([lm.wave, stellarFlux])),
               fmt="%7.1f %10.4e")

    # 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.stellar_fit_comparison_plot(f'{obj}_{ext}_{cycle}', lm.wave, lm.flux,
                                   nebCompFile, stellarFluxFile,
                                   stellarPlotFile)
    sw.mask_plot(fit_output, obj, lm.wave, specFlux, stellar_Wave,
                 stellar_flux, obj_input_flux, maskFile, maskPlotFile)
Beispiel #3
0
    Mcor = fit_output['Mcor_tot']
    Mint = fit_output['Mini_tot']
    mass_galaxy = computeSSP_galaxy_mass(Mcor, 1, z_gp)
    massProcess_galaxy = computeSSP_galaxy_mass(Mint, 1, z_gp)

    print(objName, z_gp, mass_galaxy, massProcess_galaxy)
    # computeSSP_galaxy_mass()

    # Plot the results
    sw.population_fraction_plots(fit_output, objName, 'Mass_fraction',
                                 lineLogFolder / f'{objName}_SSP_MasFrac.png')
    sw.population_fraction_plots(
        fit_output, objName, 'Light_fraction',
        lineLogFolder / f'{objName}_SSP_LightFrac.png')
    sw.stellar_fit_comparison_plot(objName, Input_Wavelength, Input_Flux,
                                   Output_Flux,
                                   lineLogFolder / stellarPlotFile)

    # labelsDict = {'xlabel': r'Wavelength $(\AA)$',
    #               'ylabel': r'Flux $(erg\,cm^{-2} s^{-1} \AA^{-1})\cdot10^{20}$',
    #               'title': f'Galaxy {objName} stellar continuum fitting'}
    #
    # idcs_plot = Input_Flux > 0.0
    #
    # fig, ax = plt.subplots(figsize=(12, 8))
    # ax.plot(wave, flux, label='--- Observed fits file')
    # ax.plot(Input_Wavelength[idcs_plot], Input_Flux[idcs_plot], label='--- Input starlight flux')
    # ax.plot(Input_Wavelength[idcs_plot], Output_Flux[idcs_plot], label='--- Output starlight fitting')
    # ax.update(labelsDict)
    # ax.legend()
    # ax.set_yscale('log')