idx_wave = (wave_rest >= wmin_array[i]) & (wave_rest <= wmax_array[i])
            flux = flux_array[idx_band][0] if ext in ('_B', '_R') else flux_array

            # Load the data
            obsWave, obsFlux = wave_rest[idx_wave], flux[idx_wave]
            specWave, specFlux = np.loadtxt(nebFluxNoNebCompFile, unpack=True)

            # Measuring objects
            lm = sr.LineMesurer(specWave, specFlux, lineLog_file, normFlux=flux_norm)
            sw = SSPsynthesizer()

            # Generate starlight files
            idcs_lines = ~lm.linesDF.index.str.contains('_b')
            gridFileName, outputFile, saveFolder, waveResample, fluxResample = sw.generate_starlight_files(starlightFolder,
                                                                                                             f'{obj}{ext}',
                                                                                                             specWave,
                                                                                                             specFlux,
                                                                                                             lm.linesDF.loc[idcs_lines])

            # # Launch starlight
            # print(f'\n-Initiating starlight: {obj}')
            # sw.starlight_launcher(gridFileName, starlightFolder)
            # print('\n-Starlight finished succesfully ended')

            # Read output data
            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)
    for j, label_mask in enumerate(labels):
        linesDF.loc[labels[j], ['w3', 'w4']] = ini_mask[j], end_points[j]

    # Remove nebular component spectra
    specFlux = lm.flux - nebFlux

    # Starlight wrapper
    sw = SSPsynthesizer()

    # Generate starlight files
    clip_value = obsData[obj]['starlight_clipping']
    idcs_lines = ~linesDF.index.str.contains('_b')
    gridFileName, outputFile, saveFolder, waveResample, fluxResample = sw.generate_starlight_files(
        starlight_folder,
        f'{obj}_{ext}_{cycle}',
        lm.wave,
        specFlux,
        linesDF.loc[idcs_lines],
        clip_value=clip_value)

    if os.name != 'nt':
        # Launch starlight
        print(f'\n-Initiating starlight: {obj}')
        sw.starlight_launcher(gridFileName, starlight_folder)
        print('\n-Starlight finished succesfully ended')

    # Read output data
    stellar_Wave, obj_input_flux, stellar_flux, fit_output = sw.load_starlight_output(
        saveFolder / outputFile)
    z_gp = obsData['sample_data']['z_array'][i]
    Mcor, Mint = fit_output['Mcor_tot'], fit_output['Mini_tot']
Ejemplo n.º 3
0
    idx_wave = (wave_rest >= wmin_array[i]) & (wave_rest <= wmax_array[i])

    # Load the data
    obsWave, obsFlux = wave_rest[idx_wave], flux[idx_wave]
    specWave, specFlux = np.loadtxt(lineLogFolder / nebFluxNoNebCompFile,
                                    unpack=True)

    # Measuring objects
    lm = sr.LineMesurer(specWave,
                        specFlux,
                        lineLogFolder / lineLogFile,
                        normFlux=flux_norm)
    sw = SSPsynthesizer()

    # Generate starlight files
    gridFileName, outputFile, outputFolder, waveResample, fluxResample = sw.generate_starlight_files(
        starlightFolder, objName, specWave, specFlux, lm.linesDF)

    # Compute the galaxy mass

    # # Launch starlight
    # print(f'\n-Initiating starlight: {objName}')
    # sw.starlight_launcher(gridFileName, starlightFolder)
    # print('\n-Starlight finished succesfully ended')

    # Read output data
    Input_Wavelength, Input_Flux, Output_Flux, fit_output = sw.load_starlight_output(
        outputFolder / outputFile)
    z_gp = obsData['sample_data']['z_array'][i]
    Mcor = fit_output['Mcor_tot']
    Mint = fit_output['Mini_tot']
    mass_galaxy = computeSSP_galaxy_mass(Mcor, 1, z_gp)