In [1]:
import numpy as np
import os
import pysynphot as s
import pandas as pd
import matplotlib.pyplot as plt


/usr/local/lib/python2.7/dist-packages/pysynphot/locations.py:44: UserWarning: PYSYN_CDBS is undefined; functionality will be SEVERELY crippled.
  warnings.warn("PYSYN_CDBS is undefined; functionality will be SEVERELY "
/usr/local/lib/python2.7/dist-packages/pysynphot/locations.py:119: UserWarning: Extinction files should be moved to $PYSYN_CDBS/extinction for compatibility with future versions of pysynphot.
  warnings.warn('Extinction files should be moved to '
/usr/local/lib/python2.7/dist-packages/pysynphot/locations.py:155: UserWarning: Extinction files not found in grid/extinction
  warnings.warn('Extinction files not found in %s' % (extdir,))
/usr/local/lib/python2.7/dist-packages/pysynphot/locations.py:133: UserWarning: PYSYN_CDBS is undefined; cannot find mtab/*_tmg.fits file
  warnings.warn("PYSYN_CDBS is undefined; cannot find %s file" % template)
/usr/local/lib/python2.7/dist-packages/pysynphot/locations.py:133: UserWarning: PYSYN_CDBS is undefined; cannot find mtab/*_tmc.fits file
  warnings.warn("PYSYN_CDBS is undefined; cannot find %s file" % template)
/usr/local/lib/python2.7/dist-packages/pysynphot/locations.py:133: UserWarning: PYSYN_CDBS is undefined; cannot find mtab/*_tmt.fits file
  warnings.warn("PYSYN_CDBS is undefined; cannot find %s file" % template)

In [2]:
results_path       = '/home/mldantas/Dropbox/DoutoradoIAG/Challenge/Sanity_Check/Results'
jpas_filters_path  = '/home/mldantas/Dropbox/DoutoradoIAG/Challenge/Filters/JPAS_filters'
test_specs         = '/home/mldantas/Dropbox/DoutoradoIAG/Challenge/Sanity_Check/Specs'
jpas_filters_list  = np.loadtxt('/home/mldantas/Dropbox/DoutoradoIAG/Challenge/Filters/jpas_filters_list.txt', dtype=str)
specs_list         = np.loadtxt('/home/mldantas/Dropbox/DoutoradoIAG/Challenge/Sanity_Check/specslist2.txt', dtype=str)

In [3]:
# Constants --------------------------------------------------------------------------------------------------------
c = 2.99792458E18                  # Light Speed in Angstrom s^-1

In [4]:
# Setting the T80 M1 effective area in cm^2 ------------------------------------------------------------------------
s.setref(area=4400)

In [5]:
%matplotlib inline

In [10]:
# JPAS -------------------------------------------------------------------------------------------------------------
all_jpas = []
for each_spectrum in specs_list:
    # Transforming the specs from f_lambda to f_nu -----------------------------------------------------------------
    wavelength = np.loadtxt(os.path.join(test_specs, each_spectrum), usecols=[0])
    f_lambda   = np.loadtxt(os.path.join(test_specs, each_spectrum), usecols=[1])
    
    # Simulating the photometry for each J-PAS band ----------------------------------------------------------------
    print each_spectrum
    filter_name     = []
    photometry      = []
    photometry_flam = []
    lambda_eff      = []
    for jpas_filters in jpas_filters_list:
        filter_name_i          = jpas_filters.split('.')[0]
        filter_name.append(filter_name_i)
        jpas_filter_bandpass = s.FileBandpass(os.path.join(jpas_filters_path, jpas_filters))      
        sdss_spectrum = s.FileSpectrum(os.path.join(test_specs, each_spectrum))
        
        # Correcting for the effects of flux = 0: ----------------------------------------------------------------------
        index = np.where(sdss_spectrum.flux > 0)
        sdss_spectrum2 = s.ArraySpectrum(wave=sdss_spectrum.wave[index], flux=sdss_spectrum.flux[index], 
                                         fluxunits=sdss_spectrum.fluxunits, waveunits=sdss_spectrum.waveunits)
        
        # Adapting the binset for each spectrum --------------------------------------------------------------------
        binset = np.arange(sdss_spectrum2.wave.min().round(), sdss_spectrum2.wave.max().round())
        
        # Calculating the simulated photometry ---------------------------------------------------------------------
        photometry_i = s.Observation(sdss_spectrum2, jpas_filter_bandpass, binset=jpas_filter_bandpass.wave, 
                                     force='extrap')
        photometry.append(photometry_i.effstim('abmag'))
        photometry_flam_i = photometry_i.effstim('flam')
        photometry_flam.append(photometry_flam_i)
        
        # Calculating the effective wavelength ---------------------------------------------------------------------
        lambda_eff_i = photometry_i.efflam()
        lambda_eff.append(lambda_eff_i)

    # Transforming everything into an array ------------------------------------------------------------------------
    filter_name       = np.array(filter_name)
    photometry        = np.array(photometry)
    lambda_eff        = np.array(lambda_eff) 
    photometry_flam   = np.array(photometry_flam)
    photometry_fnu    = 10**(-0.4*(photometry + 48.60))
    
#     numerator_sum   = 0
#     denominator_sum = 0
#     ratio = []
#     for j in range(lambda_eff.size):
#         index = np.abs(lambda_eff[j] - wavelength).argmin()
#         numerator_sum   = numerator_sum + (photometry_flam[j] * f_lambda[index])
#         denominator_sum = denominator_sum + (photometry_flam[j] ** 2.)
#         correction_factor = (numerator_sum / denominator_sum)
#         ratio_i = photometry_flam[j]/f_lambda[index]
#         ratio.append(ratio_i)
#     photometry_flam = photometry_flam * correction_factor
    
    plot01 = plt.plot(wavelength, f_lambda, '-')
    plot02 = plt.plot(lambda_eff, photometry_flam, 'o')
    plt.savefig(os.path.join(results_path, os.path.split(each_spectrum)[-1][0:14]+'_JPAS.png'), dpi = 100)
    plt.show()
    
#     galaxy_simulation_abmag = np.vstack((filter_name, photometry))
#     galaxy_simulation_abmag = pd.DataFrame(galaxy_simulation_abmag)
#     galaxy_simulation_abmag.to_csv(os.path.join(results_path, os.path.split(each_spectrum)[-1][0:14]+'_JPAS_abmag.csv'), 
#                                    sep=',', header=None, index=False)
#     galaxy_simulation_fnu = np.vstack((filter_name, photometry_fnu))
#     galaxy_simulation_fnu = pd.DataFrame(galaxy_simulation_fnu)
#     galaxy_simulation_fnu.to_csv(os.path.join(results_path, os.path.split(each_spectrum)[-1][0:14]+'_JPAS_fnu.csv'), 
#                                  sep=',', header=None, index=False)


0443.51873.152_nozeroes.txt
1019.52707.261.txt
1180.52995.637.txt
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
1665.52976.514_nozeroes.txt
2231.53816.545.txt

In [9]:
# JPAS -------------------------------------------------------------------------------------------------------------
all_jpas = []
for each_spectrum in specs_list:
    # Transforming the specs from f_lambda to f_nu -----------------------------------------------------------------
    wavelength = np.loadtxt(os.path.join(test_specs, each_spectrum), usecols=[0])
    f_lambda   = np.loadtxt(os.path.join(test_specs, each_spectrum), usecols=[1])
    
    # Simulating the photometry for each J-PAS band ----------------------------------------------------------------
    print each_spectrum
    filter_name     = []
    photometry      = []
    photometry_flam = []
    lambda_eff      = []
    for jpas_filters in jpas_filters_list:
        filter_name_i          = jpas_filters.split('.')[0]
        filter_name.append(filter_name_i)
        jpas_filter_bandpass = s.FileBandpass(os.path.join(jpas_filters_path, jpas_filters))      
        sdss_spectrum = s.FileSpectrum(os.path.join(test_specs, each_spectrum))
        
        # Correcting for the effects of flux = 0: ----------------------------------------------------------------------
        index = np.where(sdss_spectrum.flux > 0)
        sdss_spectrum2 = s.ArraySpectrum(wave=sdss_spectrum.wave[index], flux=sdss_spectrum.flux[index], 
                                         fluxunits=sdss_spectrum.fluxunits, waveunits=sdss_spectrum.waveunits)
        
        # Adapting the binset for each spectrum --------------------------------------------------------------------
        binset = np.arange(sdss_spectrum2.wave.min().round(), sdss_spectrum2.wave.max().round())
        
        # Calculating the simulated photometry ---------------------------------------------------------------------
        photometry_i = s.Observation(sdss_spectrum2, jpas_filter_bandpass, binset=binset, 
                                     force='extrap')
        photometry.append(photometry_i.effstim('abmag'))
        photometry_flam_i = photometry_i.effstim('flam')
        photometry_flam.append(photometry_flam_i)
        
        # Calculating the effective wavelength ---------------------------------------------------------------------
        lambda_eff_i = photometry_i.efflam()
        lambda_eff.append(lambda_eff_i)

        # Setting the filters throughput ---------------------------------------------------------------------------
        fmax = sdss_spectrum.flux.max()
        plt.plot(jpas_filter_bandpass.wave, jpas_filter_bandpass.throughput * fmax, label='%s' % each_spectrum, 
                 color='red')

    # Transforming everything into an array ------------------------------------------------------------------------
    filter_name       = np.array(filter_name)
    photometry        = np.array(photometry)
    lambda_eff        = np.array(lambda_eff) 
    photometry_flam   = np.array(photometry_flam)
    photometry_fnu    = 10**(-0.4*(photometry + 48.60))
    
#     numerator_sum   = 0
#     denominator_sum = 0
#     ratio = []
#     for j in range(lambda_eff.size):
#         index = np.abs(lambda_eff[j] - wavelength).argmin()
#         numerator_sum   = numerator_sum + (photometry_flam[j] * f_lambda[index])
#         denominator_sum = denominator_sum + (photometry_flam[j] ** 2.)
#         correction_factor = (numerator_sum / denominator_sum)
#         ratio_i = photometry_flam[j]/f_lambda[index]
#         ratio.append(ratio_i)
#     photometry_flam = photometry_flam * correction_factor
    
    plot01 = plt.plot(wavelength, f_lambda, '-')
    plot02 = plt.plot(lambda_eff, photometry_flam, 'o')
    plt.savefig(os.path.join(results_path, os.path.split(each_spectrum)[-1][0:14]+'_JPAS.png'), dpi = 100)
    plt.show()
    
#     galaxy_simulation_abmag = np.vstack((filter_name, photometry))
#     galaxy_simulation_abmag = pd.DataFrame(galaxy_simulation_abmag)
#     galaxy_simulation_abmag.to_csv(os.path.join(results_path, os.path.split(each_spectrum)[-1][0:14]+'_JPAS_abmag.csv'), 
#                                    sep=',', header=None, index=False)
#     galaxy_simulation_fnu = np.vstack((filter_name, photometry_fnu))
#     galaxy_simulation_fnu = pd.DataFrame(galaxy_simulation_fnu)
#     galaxy_simulation_fnu.to_csv(os.path.join(results_path, os.path.split(each_spectrum)[-1][0:14]+'_JPAS_fnu.csv'), 
#                                  sep=',', header=None, index=False)


filter_name = []
for jpas_filters in jpas_filters_list:
    filter_name_i          = jpas_filters.split('.')[0]
    filter_name.append(filter_name_i)
    jpas_filter_bandpass = s.FileBandpass(os.path.join(jpas_filters_path, jpas_filters))
    plt.plot(jpas_filter_bandpass.wave, jpas_filter_bandpass.throughput * fmax, label='%s' % each_spectrum, 
                 color=np.random.rand(3,1))
plt.show()


0443.51873.152_nozeroes.txt
1019.52707.261.txt
1180.52995.637.txt
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
1665.52976.514_nozeroes.txt
2231.53816.545.txt

In [8]:
# JPAS -------------------------------------------------------------------------------------------------------------
all_jpas = []
for each_spectrum in specs_list:
    # Transforming the specs from f_lambda to f_nu -----------------------------------------------------------------
    wavelength = np.loadtxt(os.path.join(test_specs, each_spectrum), usecols=[0])
    f_lambda   = np.loadtxt(os.path.join(test_specs, each_spectrum), usecols=[1])
    
    # Simulating the photometry for each J-PAS band ----------------------------------------------------------------
    print each_spectrum
    filter_name     = []
    photometry      = []
    photometry_flam = []
    lambda_eff      = []
    for jpas_filters in jpas_filters_list:
        filter_name_i          = jpas_filters.split('.')[0]
        filter_name.append(filter_name_i)
        jpas_filter_bandpass = s.FileBandpass(os.path.join(jpas_filters_path, jpas_filters))      
        sdss_spectrum = s.FileSpectrum(os.path.join(test_specs, each_spectrum))
        
        # Correcting for the effects of flux = 0: ----------------------------------------------------------------------
        index = np.where(sdss_spectrum.flux > 0)
        sdss_spectrum2 = s.ArraySpectrum(wave=sdss_spectrum.wave[index], flux=sdss_spectrum.flux[index], 
                                         fluxunits=sdss_spectrum.fluxunits, waveunits=sdss_spectrum.waveunits)
        
        # Adapting the binset for each spectrum --------------------------------------------------------------------
        binset = np.arange(sdss_spectrum2.wave.min().round(), sdss_spectrum2.wave.max().round())
        
        # Calculating the simulated photometry ---------------------------------------------------------------------
        photometry_i = s.Observation(sdss_spectrum2, jpas_filter_bandpass, binset=binset, 
                                     force='extrap')
        photometry.append(photometry_i.effstim('abmag'))
        photometry_flam_i = photometry_i.effstim('flam')
        photometry_flam.append(photometry_flam_i)
        
        # Calculating the effective wavelength ---------------------------------------------------------------------
        lambda_eff_i = photometry_i.efflam()
        lambda_eff.append(lambda_eff_i)

        # Setting the filters throughput ---------------------------------------------------------------------------
        fmax = sdss_spectrum.flux.max()
        plt.plot(jpas_filter_bandpass.wave, jpas_filter_bandpass.throughput * fmax, label='%s' % each_spectrum, 
                 color='red')

    # Transforming everything into an array ------------------------------------------------------------------------
    filter_name       = np.array(filter_name)
    photometry        = np.array(photometry)
    lambda_eff        = np.array(lambda_eff) 
    photometry_flam   = np.array(photometry_flam)
    photometry_fnu    = 10**(-0.4*(photometry + 48.60))
    
    numerator_sum   = 0
    denominator_sum = 0
    ratio = []
    for j in range(lambda_eff.size):
        index = np.abs(lambda_eff[j] - wavelength).argmin()
        numerator_sum   = numerator_sum + (photometry_flam[j] * f_lambda[index])
        denominator_sum = denominator_sum + (photometry_flam[j] ** 2.)
        correction_factor = (numerator_sum / denominator_sum)
        ratio_i = photometry_flam[j]/f_lambda[index]
        ratio.append(ratio_i)
        print (filter_name[j], ratio_i)
    photometry_flam = photometry_flam * correction_factor

    
    plot01 = plt.plot(wavelength, f_lambda, '-')
    plot02 = plt.plot(lambda_eff, photometry_flam, 'o')
#     plt.savefig(os.path.join(results_path, os.path.split(each_spectrum)[-1][0:14]+'_JPAS.png'), dpi = 100)
    plt.show()
    
#     galaxy_simulation_abmag = np.vstack((filter_name, photometry))
#     galaxy_simulation_abmag = pd.DataFrame(galaxy_simulation_abmag)
#     galaxy_simulation_abmag.to_csv(os.path.join(results_path, os.path.split(each_spectrum)[-1][0:14]+'_JPAS_abmag.csv'), 
#                                    sep=',', header=None, index=False)
#     galaxy_simulation_fnu = np.vstack((filter_name, photometry_fnu))
#     galaxy_simulation_fnu = pd.DataFrame(galaxy_simulation_fnu)
#     galaxy_simulation_fnu.to_csv(os.path.join(results_path, os.path.split(each_spectrum)[-1][0:14]+'_JPAS_fnu.csv'), 
#                                  sep=',', header=None, index=False)


filter_name = []
for jpas_filters in jpas_filters_list:
    filter_name_i          = jpas_filters.split('.')[0]
    filter_name.append(filter_name_i)
    jpas_filter_bandpass = s.FileBandpass(os.path.join(jpas_filters_path, jpas_filters))
    plt.plot(jpas_filter_bandpass.wave, jpas_filter_bandpass.throughput * fmax, label='%s' % each_spectrum, 
                 color=np.random.rand(3,1))
plt.show()


0443.51873.152_nozeroes.txt
('g_JPAS_0915', 0.87460795752808784)
('Jv0915_3495', 1.5375881139108425)
('Jv0915_3781', 0.59979697711267388)
('Jv0915_3900', 0.52208042457564252)
('Jv0915_4000', 0.88733283709119293)
('Jv0915_4100', 1.085462205279728)
('Jv0915_4200', 0.8788659148323249)
('Jv0915_4301', 0.79966526952859385)
('Jv0915_4400', 1.0035664653711101)
('Jv0915_4501', 0.99877247933761504)
('Jv0915_4600', 1.0373354427271801)
('Jv0915_4701', 0.95784616125214717)
('Jv0915_4801', 1.1027992139321301)
('Jv0915_4900', 0.98524596744546844)
('Jv0915_5001', 1.0804622247395939)
('Jv0915_5101', 1.0635323618533969)
('Jv0915_5201', 1.0339187096794891)
('Jv0915_5300', 0.99263144854705454)
('Jv0915_5400', 1.0998505406127876)
('Jv0915_5500', 1.0039382706894489)
('Jv0915_5600', 1.0524282325294618)
('Jv0915_5700', 1.0132415035365105)
('Jv0915_5799', 1.0095915671023457)
('Jv0915_5898', 1.0605923348739053)
('Jv0915_5999', 1.0551479304951787)
('Jv0915_6098', 1.0418225937393684)
('Jv0915_6199', 1.0310193916595403)
('Jv0915_6300', 1.007001413544595)
('Jv0915_6401', 1.0195779359663855)
('Jv0915_6500', 1.066043931297616)
('Jv0915_6600', 1.0433903894257941)
('Jv0915_6700', 1.0397262295251728)
('Jv0915_6800', 1.0472937257691504)
('Jv0915_6900', 1.0018048521181737)
('Jv0915_7000', 1.0400604171968659)
('Jv0915_7100', 1.0152055107924891)
('Jv0915_7200', 1.050601675415505)
('Jv0915_7300', 1.0139863825449111)
('Jv0915_7400', 1.0578711445851607)
('Jv0915_7500', 1.0266805340951801)
('Jv0915_7600', 1.0124814089534757)
('Jv0915_7700', 1.0169452287910017)
('Jv0915_7800', 1.0444060402025916)
('Jv0915_7900', 1.0563686749573593)
('Jv0915_8000', 1.0913335826490407)
('Jv0915_8100', 1.0837280412736476)
('Jv0915_8201', 1.1059749018970044)
('Jv0915_8300', 1.099648403462653)
('Jv0915_8400', 1.0880097159303348)
('Jv0915_8500', 1.0752614804899094)
('Jv0915_8600', 1.0649920541208402)
('Jv0915_8700', 1.0545795300049021)
('Jv0915_8800', 1.0408305468266374)
('Jv0915_8900', 1.035472182519807)
('Jv0915_9000', 1.027479961094089)
('Jv0915_9100', 1.0132142024725717)
('Jv0915_9669', 0.94332821572689363)
('r_JPAS_0915', 1.0290526081914513)
('u_JPAS_0915', 1.5492847950121176)
1019.52707.261.txt
('g_JPAS_0915', 1.0207373177873258)
('Jv0915_3495', 1.0927742877705375)
('Jv0915_3781', 0.88565920504973195)
('Jv0915_3900', 1.0212017974593257)
('Jv0915_4000', 1.1139150314658284)
('Jv0915_4100', 1.0698105997398937)
('Jv0915_4200', 1.1507311985059234)
('Jv0915_4301', 1.1333456662998644)
('Jv0915_4400', 1.0873538781031922)
('Jv0915_4501', 1.0908747861015569)
('Jv0915_4600', 1.023310457602904)
('Jv0915_4701', 1.1145762488666249)
('Jv0915_4801', 1.278761986271989)
('Jv0915_4900', 0.95749597947432852)
('Jv0915_5001', 1.2920186089838528)
('Jv0915_5101', 1.1328071297755384)
('Jv0915_5201', 1.0364102503931232)
('Jv0915_5300', 1.0677825932346863)
('Jv0915_5400', 1.0940601461044264)
('Jv0915_5500', 1.059875150113194)
('Jv0915_5600', 1.0713460576466767)
('Jv0915_5700', 1.0545283984728155)
('Jv0915_5799', 1.0515373977399367)
('Jv0915_5898', 1.069670946484776)
('Jv0915_5999', 1.0533691619788468)
('Jv0915_6098', 1.0512233224621867)
('Jv0915_6199', 1.0447582540909564)
('Jv0915_6300', 1.0588301862657477)
('Jv0915_6401', 1.0650189287365404)
('Jv0915_6500', 1.332077532021321)
('Jv0915_6600', 1.5096209447677824)
('Jv0915_6700', 1.2690701100916084)
('Jv0915_6800', 1.1494340318290042)
('Jv0915_6900', 1.0505905426206188)
('Jv0915_7000', 1.0705782396221668)
('Jv0915_7100', 1.0208528382252573)
('Jv0915_7200', 1.0533748553989526)
('Jv0915_7300', 1.0576540332552657)
('Jv0915_7400', 1.0758821199154975)
('Jv0915_7500', 1.0230415111411579)
('Jv0915_7600', 1.0318290657716205)
('Jv0915_7700', 1.0612355103028004)
('Jv0915_7800', 1.0467277989113644)
('Jv0915_7900', 1.0299500693188315)
('Jv0915_8000', 1.0659708616512322)
('Jv0915_8100', 1.0557424194275185)
('Jv0915_8201', 1.0298313568418518)
('Jv0915_8300', 1.0144737766469616)
('Jv0915_8400', 1.0566622169753437)
('Jv0915_8500', 1.0045035507844275)
('Jv0915_8600', 1.171813378491974)
('Jv0915_8700', 1.0419831452941151)
('Jv0915_8800', 1.0419007414925818)
('Jv0915_8900', 1.0259354246772681)
('Jv0915_9000', 1.1836535337531275)
('Jv0915_9100', 1.1611406602896661)
('Jv0915_9669', 0.99780829475953792)
('r_JPAS_0915', 1.1106185551869416)
('u_JPAS_0915', 0.94937308219492067)
1180.52995.637.txt
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
Warning, 9 of 6001 bins contained negative fluxes; they have been set to zero.
('g_JPAS_0915', 2.5896319663684531)
('Jv0915_3495', 1.4145992004509051)
('Jv0915_3781', 1.0548584843082982)
('Jv0915_3900', 1.1488541683605007)
('Jv0915_4000', 0.36724004586241232)
('Jv0915_4100', 0.086151605886268107)
('Jv0915_4200', 1.3372837493639194)
('Jv0915_4301', 1.065576429221885)
('Jv0915_4400', 1.1211050236274329)
('Jv0915_4501', 1.2922382976663089)
('Jv0915_4600', 0.92836580409136749)
('Jv0915_4701', 0.781718821287406)
('Jv0915_4801', 1.4250078814854148)
('Jv0915_4900', 1.2530790123625812)
('Jv0915_5001', 0.92665968820968625)
('Jv0915_5101', 0.70475192647446505)
('Jv0915_5201', 1.3093314481785061)
('Jv0915_5300', 0.71283169678810665)
('Jv0915_5400', 1.1052021230609952)
('Jv0915_5500', 38.631703494733166)
('Jv0915_5600', 30.431532468365816)
('Jv0915_5700', 29.930022944895317)
('Jv0915_5799', 29.445363735759464)
('Jv0915_5898', 28.934191402589171)
('Jv0915_5999', 28.490597067631015)
('Jv0915_6098', 28.093811638580625)
('Jv0915_6199', 27.649227872132727)
('Jv0915_6300', 27.156252571407499)
('Jv0915_6401', 26.790973172881625)
('Jv0915_6500', 26.39584408915556)
('Jv0915_6600', 26.041105541727994)
('Jv0915_6700', 25.708678565164213)
('Jv0915_6800', 25.346837148632687)
('Jv0915_6900', 25.027046654974392)
('Jv0915_7000', 24.608333271223785)
('Jv0915_7100', 24.308349907746102)
('Jv0915_7200', 24.033904746079052)
('Jv0915_7300', 23.715166592874397)
('Jv0915_7400', 23.389521010585977)
('Jv0915_7500', 23.012554617100722)
('Jv0915_7600', 23.069758930942122)
('Jv0915_7700', 22.478450527378236)
('Jv0915_7800', 22.268507385000309)
('Jv0915_7900', 21.948751905836158)
('Jv0915_8000', 21.723494107091415)
('Jv0915_8100', 21.505318141188763)
('Jv0915_8201', 21.155125767885213)
('Jv0915_8300', 21.0401132468768)
('Jv0915_8400', 20.817607663573376)
('Jv0915_8500', 20.572840290791678)
('Jv0915_8600', 20.377368517861708)
('Jv0915_8700', 20.178760556047866)
('Jv0915_8800', 19.913510900002539)
('Jv0915_8900', 19.8149377847792)
('Jv0915_9000', 19.66383553803589)
('Jv0915_9100', 19.387917647032225)
('Jv0915_9669', 18.03187323877113)
('r_JPAS_0915', 51.59972821659732)
('u_JPAS_0915', 3.3944736528594008)
1665.52976.514_nozeroes.txt
('g_JPAS_0915', 0.88363484586562258)
('Jv0915_3495', 0.18980822552444707)
('Jv0915_3781', 0.36046609629715792)
('Jv0915_3900', 0.39648535829219284)
('Jv0915_4000', 0.72861339879876785)
('Jv0915_4100', 0.86501882326356683)
('Jv0915_4200', 0.74852588459518032)
('Jv0915_4301', 0.77734134521325626)
('Jv0915_4400', 0.85182674191097718)
('Jv0915_4501', 1.0058947770852986)
('Jv0915_4600', 0.99073443222951429)
('Jv0915_4701', 1.0955873546230217)
('Jv0915_4801', 1.0777636913502471)
('Jv0915_4900', 1.0900894858000969)
('Jv0915_5001', 1.1659071781877626)
('Jv0915_5101', 1.0568154356806998)
('Jv0915_5201', 0.93385302484216859)
('Jv0915_5300', 1.0167510411602494)
('Jv0915_5400', 1.0745753245199787)
('Jv0915_5500', 1.03921017262003)
('Jv0915_5600', 1.0469018660845872)
('Jv0915_5700', 1.021736895869364)
('Jv0915_5799', 0.99884352376362084)
('Jv0915_5898', 1.0092931312249349)
('Jv0915_5999', 1.0275389180687091)
('Jv0915_6098', 1.0621951017430509)
('Jv0915_6199', 1.0807580163742461)
('Jv0915_6300', 1.0378115127073635)
('Jv0915_6401', 1.0365089108258643)
('Jv0915_6500', 1.032908831613049)
('Jv0915_6600', 1.04588861721377)
('Jv0915_6700', 1.0537305382872224)
('Jv0915_6800', 1.0430112801360665)
('Jv0915_6900', 1.0251710388233404)
('Jv0915_7000', 1.0180504032188544)
('Jv0915_7100', 1.0426399679299867)
('Jv0915_7200', 1.0502762574692017)
('Jv0915_7300', 1.0753601290044514)
('Jv0915_7400', 1.0203782500573595)
('Jv0915_7500', 1.0422771297102842)
('Jv0915_7600', 0.99561900368946865)
('Jv0915_7700', 1.0449931085296049)
('Jv0915_7800', 1.0315620675760564)
('Jv0915_7900', 1.0162581139239459)
('Jv0915_8000', 1.0426756106077313)
('Jv0915_8100', 1.0306139803789727)
('Jv0915_8201', 0.9890173987926234)
('Jv0915_8300', 1.0045491023634916)
('Jv0915_8400', 1.0349434505106652)
('Jv0915_8500', 1.0087206056772076)
('Jv0915_8600', 1.1300707010759763)
('Jv0915_8700', 1.0176788510934578)
('Jv0915_8800', 1.0217540586231328)
('Jv0915_8900', 1.0063615781296595)
('Jv0915_9000', 1.0565397824196112)
('Jv0915_9100', 1.0941832507431342)
('Jv0915_9669', 1.0563845967258754)
('r_JPAS_0915', 1.0082562019001544)
('u_JPAS_0915', 0.48985489719192715)
2231.53816.545.txt
('g_JPAS_0915', 0.99734036439483553)
('Jv0915_3495', 0.96275064358527696)
('Jv0915_3781', 1.0647858658666893)
('Jv0915_3900', 1.096128648098659)
('Jv0915_4000', 1.075536170352011)
('Jv0915_4100', 1.0538523360176677)
('Jv0915_4200', 1.0665906881749929)
('Jv0915_4301', 1.0653571372341175)
('Jv0915_4400', 1.0698751621547953)
('Jv0915_4501', 1.0517163463459061)
('Jv0915_4600', 1.0488628238916027)
('Jv0915_4701', 1.0348109887359194)
('Jv0915_4801', 1.0478654464985504)
('Jv0915_4900', 1.0448757402558126)
('Jv0915_5001', 1.0696664929705721)
('Jv0915_5101', 1.0468758139267478)
('Jv0915_5201', 1.0521418810303329)
('Jv0915_5300', 1.0457593728305161)
('Jv0915_5400', 1.0530070984870701)
('Jv0915_5500', 1.0413427957750976)
('Jv0915_5600', 1.0578786967009473)
('Jv0915_5700', 1.0557929410554354)
('Jv0915_5799', 1.0434006520159735)
('Jv0915_5898', 1.0484492278219457)
('Jv0915_5999', 1.0484167995862366)
('Jv0915_6098', 1.0543712312914981)
('Jv0915_6199', 1.0401242784400031)
('Jv0915_6300', 1.0335483649273502)
('Jv0915_6401', 1.0389090681040536)
('Jv0915_6500', 1.047538186998427)
('Jv0915_6600', 1.0427082446559612)
('Jv0915_6700', 1.0330536443905753)
('Jv0915_6800', 1.0605228747836166)
('Jv0915_6900', 1.0274656749935174)
('Jv0915_7000', 1.0242798765303187)
('Jv0915_7100', 1.027485975969026)
('Jv0915_7200', 1.052703699135487)
('Jv0915_7300', 1.0397906077871109)
('Jv0915_7400', 1.0277435509815622)
('Jv0915_7500', 1.0168771951990805)
('Jv0915_7600', 1.0400006445628645)
('Jv0915_7700', 1.0188219608369027)
('Jv0915_7800', 1.0419118645555494)
('Jv0915_7900', 1.0399715102371216)
('Jv0915_8000', 1.0466415461713858)
('Jv0915_8100', 1.0164365676355362)
('Jv0915_8201', 1.027716119575069)
('Jv0915_8300', 1.0357353644450229)
('Jv0915_8400', 0.93706353838241008)
('Jv0915_8500', 0.73641306512020643)
('Jv0915_8600', 0.7299002694270158)
('Jv0915_8700', 0.72308460728876844)
('Jv0915_8800', 0.71254090403889836)
('Jv0915_8900', 0.7109015546662365)
('Jv0915_9000', 0.70635983084939158)
('Jv0915_9100', 0.6950606036892556)
('Jv0915_9669', 0.63746446719002348)
('r_JPAS_0915', 0.99720208579190961)
('u_JPAS_0915', 1.0069550024530192)

In [ ]: