def form_spectral_feedstock_youngmars():
    """
	Purpose of this code is to form the spectral feedstock file (TOA solar flux) to explore formally the dependence of UV surface radiance on various factors.
	"""
    #Define spectral bins.
    bin_left_edges = np.arange(100., 500., 1.)
    bin_right_edges = np.arange(101., 501., 1.)
    bin_centers = 0.5 * (bin_left_edges + bin_right_edges)

    #load solar spectrum at 3.9 Ga from Claire et al (2012) models, normalized to 1 AU. These are really TOA intensities. Multiply by mu_0 to get TOA fluxes.
    importeddata = np.genfromtxt(
        './Raw_Data/Claire_Model/claire_youngsun_highres.dat',
        skip_header=1,
        skip_footer=0)
    claire_wav = importeddata[:, 0]  #nm, 0.01 nm resolution, 100-900 nm.
    claire_fluxes = importeddata[:, 1] * (
        1. / 1.524
    )**2  #Scale the flux to the Martian semimajor axis, units of erg/s/cm2/nm

    #rebin claire spectrum
    claire_fluxes_rebinned = cookbook.rebin_uneven(
        np.arange(99.995, 900.005, 0.01), np.arange(100.005, 900.015, 0.01),
        claire_fluxes, bin_left_edges, bin_right_edges)

    #Plot to make sure rebinning worked correctly
    fig, ax1 = plt.subplots(1, figsize=(6, 4))
    ax1.plot(claire_wav,
             claire_fluxes,
             marker='s',
             color='black',
             label='Claire Fluxes')
    ax1.plot(bin_centers,
             claire_fluxes_rebinned,
             marker='s',
             color='blue',
             label='Binned Claire Fluxes')
    ax1.set_yscale('log')
    ax1.set_ylim([1.e-2, 1.e4])
    ax1.set_xlim([100., 500.])
    ax1.set_xlabel('nm')
    ax1.set_ylabel('erg/s/cm2/nm')
    ax1.legend(loc=0)
    plt.show()

    #Let's print out the results
    spectable = np.zeros([len(bin_left_edges), 4])
    spectable[:, 0] = bin_left_edges
    spectable[:, 1] = bin_right_edges
    spectable[:, 2] = bin_centers
    spectable[:, 3] = claire_fluxes_rebinned

    header = 'Left Bin Edge (nm)	Right Bin Edge (nm)	Bin Center (nm)		Top of Atm Intensity (erg/s/nm/cm2)\n'

    f = open('./Solar_Input/general_youngsun_mars_spectral_input.dat', 'w')
    f.write(header)
    np.savetxt(f, spectable, delimiter='		', fmt='%1.7e', newline='\n')
    f.close()
コード例 #2
0
def form_spectral_feedstock_ourwork():
	"""
	Purpose of this code is to form the spectral feedstock file to explore formally the dependence of UV surface intensity on various factors. The mixing ratio and TP profiles vary in each case though.
	"""
	import cookbook
	#Extract spectra to match and TOA intensity
	#Define spectral bins.
	bin_left_edges=np.arange(100.,500.,1.)
	bin_right_edges=np.arange(101.,501.,1.)
	bin_centers=0.5*(bin_left_edges+bin_right_edges)
	
	
	#There are no literature intensity values for this file, since at this point we are not comparing against any other datasets but are rather running our code internally. However, we can use the Rugheimer et al base case (60 degrees, 0.2) as a reference
	literature_intensities=np.zeros(np.shape(bin_centers))
	importeddata=np.genfromtxt('./TwoStreamOutput/AlbZen/rugheimer_earth_epoch0_a=0.2_z=60.dat', skip_header=1, skip_footer=0)
	basecase_wav=importeddata[:,2] #nm,
	basecase_surface_intensities=importeddata[:,6] #erg/s/cm2/nm
	
	#load solar spectrum from Claire et al (2012) models, normalized to 1 au. These are really TOA intensities. Multiply by mu_0 to get TOA fluxes. 
	importeddata=np.genfromtxt('./Raw_Data/Claire_Model/claire_youngsun_highres.dat', skip_header=1, skip_footer=0)
	claire_wav=importeddata[:,0] #nm, 0.01 nm resolution, 100-900 nm.
	claire_fluxes=importeddata[:,1]#erg/s/cm2/nm
	
	#rebin claire spectrum
	claire_fluxes_rebinned=cookbook.rebin_uneven(np.arange(99.995,900.005,0.01), np.arange(100.005, 900.015,0.01),claire_fluxes,bin_left_edges, bin_right_edges)   
	
	#Plot to make sure rebinning worked correctly
	fig, ax1=plt.subplots(1, figsize=(6,4))
	ax1.plot(claire_wav, claire_fluxes, marker='s', color='black', label='Claire Fluxes')
	ax1.plot(bin_centers, claire_fluxes_rebinned, marker='s', color='blue', label='Binned Claire Fluxes')	
	ax1.set_yscale('log')
	ax1.set_ylim([1.e-2, 1.e4])
	ax1.set_xlim([100.,500.])
	ax1.set_xlabel('nm')
	ax1.set_ylabel('erg/s/cm2/nm')
	ax1.legend(loc=0)
	plt.show()	
	
	#Let's print out the results
	spectable=np.zeros([len(bin_left_edges),5])
	spectable[:,0]=bin_left_edges
	spectable[:,1]=bin_right_edges
	spectable[:,2]=bin_centers
	spectable[:,3]=claire_fluxes_rebinned
	spectable[:,4]=basecase_surface_intensities
	
	header='Left Bin Edge (nm)	Right Bin Edge (nm)	Bin Center (nm)		Top of Atm Intensity (erg/s/nm/cm2)		3.9 Ga R+2015 Surface Intensity (erg/s/nm/cm2)\n'

	f=open('./LiteratureSpectra/general_spectral_input.dat', 'w')
	f.write(header)
	np.savetxt(f, spectable, delimiter='		', fmt='%1.7e', newline='\n')
	f.close()
コード例 #3
0
def form_profiles_woudc():
	"""
	Purpose of this code is to form the feedstock files to replicate the irradiance measurements from the WOUDC website for Toronto (June 21 2003, SZA=20.376, O3=354, Brewer no. 145)
	""" 
	########First, form the spectral file.
	#load measured irradiances	
	importeddata=np.genfromtxt('./Raw_Data/UV_Surface_Measurements/woudc_toronto_2003_145_cut.dat', skip_header=1, skip_footer=0, delimiter='	')
	woudc_wav=importeddata[:,0] #nm
	woudc_flux=importeddata[:,1]*1.e3 #W/m2/nm=1000 erg/s/cm2/nm
	#woudc_func=interp.interp1d(woudc_wav, woudc_flux, kind='linear')
	#woudc_flux_interp=dif_func(bin_centers)

	#Define spectral bins.
	bin_centers=woudc_wav
	bin_left_edges=woudc_wav-0.25
	bin_right_edges=woudc_wav+0.25
	
	#load solar spectrum from Claire et al (2012) models, normalized to 1 au 
	importeddata2=np.genfromtxt('/home/sranjan/IDL/UV/YoungSun/claire_modernsun_highres.dat', skip_header=1, skip_footer=0)
	claire_wav=importeddata2[:,0] #nm, 0.1 nm resolution, 100-900 nm.
	claire_fluxes=importeddata2[:,1]#erg/s/cm2/nm

	#rebin claire spectrum
	claire_fluxes_rebinned=cookbook.rebin_uneven(np.arange(99.995,900.005,0.01), np.arange(100.005, 900.015,0.01),claire_fluxes,bin_left_edges, bin_right_edges)   
	
	#Plot to make sure rebinning worked correctly
	fig, ax1=plt.subplots(1, figsize=(6,4))
	ax1.plot(claire_wav, claire_fluxes, marker='s', color='black', label='Claire Fluxes')
	ax1.plot(bin_centers, claire_fluxes_rebinned, marker='s', color='blue', label='Binned Claire Fluxes')	
	ax1.set_yscale('log')
	ax1.set_ylim([1.e-2, 1.e4])
	ax1.set_xlim([280.,360.])
	ax1.set_xlabel('nm')
	ax1.set_ylabel('erg/s/cm2/nm')
	ax1.legend(loc=0)
	plt.show()	
	
	#Let's print out the results
	spectable=np.zeros([len(bin_left_edges),5])
	spectable[:,0]=bin_left_edges
	spectable[:,1]=bin_right_edges
	spectable[:,2]=bin_centers
	spectable[:,3]=claire_fluxes_rebinned
	spectable[:,4]=woudc_flux
	
	header='Left Bin Edge (nm)	Right Bin Edge (nm)	Bin Center (nm)		Top of Atm Flux (erg/s/nm/cm2)		Surface Flux (erg/s/nm/cm2)\n'

	f=open('./LiteratureSpectra/woudc.dat', 'w')
	f.write(header)
	np.savetxt(f, spectable, delimiter='		', fmt='%1.7e', newline='\n')
	f.close()
	
	###########################################################################################
	###########################################################################################
	###########################################################################################
	#####Second, form the mixing ratio files
	#####Form by replicating the Rugheimer modern Earth profile, then scaling down the H2O level and scaling up the O3 level.
	mixingratios=np.genfromtxt('./MixingRatios/rugheimer_earth_modern_mixingratios_v2.dat', skip_header=2, skip_footer=0)
	mixingratios[:,7]=mixingratios[:,7]*1.77 #scale up ozone by factor of 1.25
	header0='Based on Rugheimer+2013 Modern Earth Model\n'
	header1='Z (cm)		N2	CO2	H2O	CH4	SO2	O2	O3	H2S\n'

	f=open('./MixingRatios/woudc_mixingratios_v2.dat', 'w')
	f.write(header0)
	f.write(header1)
	np.savetxt(f, mixingratios, delimiter='	', fmt='%1.7e', newline='\n')
	f.close()
	###########################################################################################
	###########################################################################################
	###########################################################################################
	#####Finally, form TP profile
	#####Form by duplicating Rugheimer+2013 modern Earth profile
	tpprofile=np.genfromtxt('./TPProfiles/rugheimer_earth_modern_atmosphereprofile.dat', skip_header=2, skip_footer=0)
	header0='Based on Rugheimer+2013 Modern Earth Model\n'
	header1='Z (cm)	T (K)	DEN (cm**-3)	P (bar) \n'

	f=open('./TPProfiles/woudc_atmosphereprofile.dat', 'w')
	f.write(header0)
	f.write(header1)
	np.savetxt(f, tpprofile, delimiter='		', fmt='%1.7e', newline='\n')
	f.close()
コード例 #4
0
def form_profiles_wuttke():
	"""
	Purpose of this code is to form the feedstock files to replicat the Wuttke+2006 Antarctic diffuse radiance measurements
	"""
	import cookbook
	#First, form the spectral file.
	#Define spectral bins. 0.25 nm from 280-500 nm, 1 nm from 500-1000 nm. We just go to 900 since that's what our data is good to. Also we start at 292.75 because that's where our graphclicked data starts
	bin_left_edges=np.concatenate((np.arange(292.75,500.,0.25),np.arange(500., 900.,1.)))
	bin_right_edges=np.concatenate((np.arange(293.,500.25,0.25),np.arange(501., 901.,1.)))
	bin_centers=0.5*(bin_left_edges+bin_right_edges)
	
	
	#load BOA diffuse zenith flux from Wuttke+2006 (extracted via GraphClick)	
	importeddata=np.genfromtxt('./Raw_Data/UV_Surface_Measurements/wuttke.csv', skip_header=0, skip_footer=0, delimiter=',')
	dif_wav=importeddata[:,0] #nm
	dif_flux=importeddata[:,1]*2.*np.pi #mW/m2/nm/sr=erg/s/cm2/nm/sr; multiply by 2pi to convert to hemisphere-integrated total surface diffuse radiances
	dif_func=interp.interp1d(dif_wav, dif_flux, kind='linear')
	dif_flux_interp=dif_func(bin_centers)
	
	#load solar spectrum from Claire et al (2012) models, normalized to 1 au 
	importeddata=np.genfromtxt('./Raw_Data/Claire_Model/claire_modernsun_highres.dat', skip_header=1, skip_footer=0)
	claire_wav=importeddata[:,0] #nm, 0.1 nm resolution, 100-900 nm.
	claire_fluxes=importeddata[:,1]#erg/s/cm2/nm
	
	#rebin claire spectrum
	claire_fluxes_rebinned=cookbook.rebin_uneven(np.arange(99.995,900.005,0.01), np.arange(100.005, 900.015,0.01),claire_fluxes,bin_left_edges, bin_right_edges)   
	
	#Plot to make sure rebinning worked correctly
	fig, ax1=plt.subplots(1, figsize=(6,4))
	ax1.plot(claire_wav, claire_fluxes, marker='s', color='black', label='Claire Fluxes')
	ax1.plot(bin_centers, claire_fluxes_rebinned, marker='s', color='blue', label='Binned Claire Fluxes')	
	ax1.set_yscale('log')
	ax1.set_ylim([1.e-2, 1.e4])
	ax1.set_xlim([280.,900.])
	ax1.set_xlabel('nm')
	ax1.set_ylabel('erg/s/cm2/nm')
	ax1.legend(loc=0)
	plt.show()	
	
	#Let's print out the results
	spectable=np.zeros([len(bin_left_edges),5])
	spectable[:,0]=bin_left_edges
	spectable[:,1]=bin_right_edges
	spectable[:,2]=bin_centers
	spectable[:,3]=claire_fluxes_rebinned
	spectable[:,4]=dif_flux_interp
	
	header='Left Bin Edge (nm)	Right Bin Edge (nm)	Bin Center (nm)		Top of Atm Flux (erg/s/nm/cm2)		Zenith Diffuse Flux (erg/s/nm/cm2)\n'

	f=open('./LiteratureSpectra/wuttke2006.dat', 'w')
	f.write(header)
	np.savetxt(f, spectable, delimiter='		', fmt='%1.7e', newline='\n')
	f.close()
	
	###########################################################################################
	###########################################################################################
	###########################################################################################
	#####Second, form the mixing ratio files
	#####Form by replicating the Rugheimer modern Earth profile, then scaling down the H2O level and scaling up the O3 level.
	mixingratios=np.genfromtxt('./MixingRatios/rugheimer_earth_modern_mixingratios_v2.dat', skip_header=2, skip_footer=0)
	mixingratios[:,3]=mixingratios[:,3]*0.1 #scale down h2o by factor of 10
	mixingratios[:,7]=mixingratios[:,7]*1.25 #scale up ozone by factor of 1.25
	header0='Based on Rugheimer+2013 Modern Earth Model\n'
	header1='Z (cm)		N2	CO2	H2O	CH4	SO2	O2	O3	H2S\n'

	f=open('./MixingRatios/wuttke2006_mixingratios_v2.dat', 'w')
	f.write(header0)
	f.write(header1)
	np.savetxt(f, mixingratios, delimiter='	', fmt='%1.7e', newline='\n')
	f.close()
	###########################################################################################
	###########################################################################################
	###########################################################################################
	#####Finally, form TP profile
	#####Form by duplicating Rugheimer+2013 modern Earth profile
	tpprofile=np.genfromtxt('./TPProfiles/rugheimer_earth_modern_atmosphereprofile.dat', skip_header=2, skip_footer=0)
	header0='Based on Rugheimer+2013 Modern Earth Model\n'
	header1='Z (cm)	T (K)	DEN (cm**-3)	P (bar) \n'

	f=open('./TPProfiles/wuttke2006_atmosphereprofile.dat', 'w')
	f.write(header0)
	f.write(header1)
	np.savetxt(f, tpprofile, delimiter='		', fmt='%1.7e', newline='\n')
	f.close()
コード例 #5
0
def form_spectral_feedstock_ourwork():
    """
	Purpose of this code is to form the spectral feedstock file to explore formally the dependence of UV surface intensity on various factors. The mixing ratio and TP profiles vary in each case though.
	"""
    import cookbook
    #Extract spectra to match and TOA intensity
    #Define spectral bins.
    bin_left_edges = np.arange(100., 500., 1.)
    bin_right_edges = np.arange(101., 501., 1.)
    bin_centers = 0.5 * (bin_left_edges + bin_right_edges)

    #There are no literature intensity values for this file, since at this point we are not comparing against any other datasets but are rather running our code internally. However, we can use the Rugheimer et al base case (60 degrees, 0.2) as a reference
    literature_intensities = np.zeros(np.shape(bin_centers))
    importeddata = np.genfromtxt(
        './TwoStreamOutput/AlbZen/rugheimer_earth_epoch0_a=0.2_z=60.dat',
        skip_header=1,
        skip_footer=0)
    basecase_wav = importeddata[:, 2]  #nm,
    basecase_surface_intensities = importeddata[:, 6]  #erg/s/cm2/nm

    #load solar spectrum from Claire et al (2012) models, normalized to 1 au. These are really TOA intensities. Multiply by mu_0 to get TOA fluxes.
    importeddata = np.genfromtxt(
        './Raw_Data/Claire_Model/claire_youngsun_highres.dat',
        skip_header=1,
        skip_footer=0)
    claire_wav = importeddata[:, 0]  #nm, 0.01 nm resolution, 100-900 nm.
    claire_fluxes = importeddata[:, 1]  #erg/s/cm2/nm

    #rebin claire spectrum
    claire_fluxes_rebinned = cookbook.rebin_uneven(
        np.arange(99.995, 900.005, 0.01), np.arange(100.005, 900.015, 0.01),
        claire_fluxes, bin_left_edges, bin_right_edges)

    #Plot to make sure rebinning worked correctly
    fig, ax1 = plt.subplots(1, figsize=(6, 4))
    ax1.plot(claire_wav,
             claire_fluxes,
             marker='s',
             color='black',
             label='Claire Fluxes')
    ax1.plot(bin_centers,
             claire_fluxes_rebinned,
             marker='s',
             color='blue',
             label='Binned Claire Fluxes')
    ax1.set_yscale('log')
    ax1.set_ylim([1.e-2, 1.e4])
    ax1.set_xlim([100., 500.])
    ax1.set_xlabel('nm')
    ax1.set_ylabel('erg/s/cm2/nm')
    ax1.legend(loc=0)
    plt.show()

    #Let's print out the results
    spectable = np.zeros([len(bin_left_edges), 5])
    spectable[:, 0] = bin_left_edges
    spectable[:, 1] = bin_right_edges
    spectable[:, 2] = bin_centers
    spectable[:, 3] = claire_fluxes_rebinned
    spectable[:, 4] = basecase_surface_intensities

    header = 'Left Bin Edge (nm)	Right Bin Edge (nm)	Bin Center (nm)		Top of Atm Intensity (erg/s/nm/cm2)		3.9 Ga R+2015 Surface Intensity (erg/s/nm/cm2)\n'

    f = open('./LiteratureSpectra/general_spectral_input.dat', 'w')
    f.write(header)
    np.savetxt(f, spectable, delimiter='		', fmt='%1.7e', newline='\n')
    f.close()
コード例 #6
0
def form_profiles_woudc():
    """
	Purpose of this code is to form the feedstock files to replicate the irradiance measurements from the WOUDC website for Toronto (June 21 2003, SZA=20.376, O3=354, Brewer no. 145)
	"""
    ########First, form the spectral file.
    #load measured irradiances
    importeddata = np.genfromtxt(
        './Raw_Data/UV_Surface_Measurements/woudc_toronto_2003_145_cut.dat',
        skip_header=1,
        skip_footer=0,
        delimiter='	')
    woudc_wav = importeddata[:, 0]  #nm
    woudc_flux = importeddata[:, 1] * 1.e3  #W/m2/nm=1000 erg/s/cm2/nm
    #woudc_func=interp.interp1d(woudc_wav, woudc_flux, kind='linear')
    #woudc_flux_interp=dif_func(bin_centers)

    #Define spectral bins.
    bin_centers = woudc_wav
    bin_left_edges = woudc_wav - 0.25
    bin_right_edges = woudc_wav + 0.25

    #load solar spectrum from Claire et al (2012) models, normalized to 1 au
    importeddata2 = np.genfromtxt(
        '/home/sranjan/IDL/UV/YoungSun/claire_modernsun_highres.dat',
        skip_header=1,
        skip_footer=0)
    claire_wav = importeddata2[:, 0]  #nm, 0.1 nm resolution, 100-900 nm.
    claire_fluxes = importeddata2[:, 1]  #erg/s/cm2/nm

    #rebin claire spectrum
    claire_fluxes_rebinned = cookbook.rebin_uneven(
        np.arange(99.995, 900.005, 0.01), np.arange(100.005, 900.015, 0.01),
        claire_fluxes, bin_left_edges, bin_right_edges)

    #Plot to make sure rebinning worked correctly
    fig, ax1 = plt.subplots(1, figsize=(6, 4))
    ax1.plot(claire_wav,
             claire_fluxes,
             marker='s',
             color='black',
             label='Claire Fluxes')
    ax1.plot(bin_centers,
             claire_fluxes_rebinned,
             marker='s',
             color='blue',
             label='Binned Claire Fluxes')
    ax1.set_yscale('log')
    ax1.set_ylim([1.e-2, 1.e4])
    ax1.set_xlim([280., 360.])
    ax1.set_xlabel('nm')
    ax1.set_ylabel('erg/s/cm2/nm')
    ax1.legend(loc=0)
    plt.show()

    #Let's print out the results
    spectable = np.zeros([len(bin_left_edges), 5])
    spectable[:, 0] = bin_left_edges
    spectable[:, 1] = bin_right_edges
    spectable[:, 2] = bin_centers
    spectable[:, 3] = claire_fluxes_rebinned
    spectable[:, 4] = woudc_flux

    header = 'Left Bin Edge (nm)	Right Bin Edge (nm)	Bin Center (nm)		Top of Atm Flux (erg/s/nm/cm2)		Surface Flux (erg/s/nm/cm2)\n'

    f = open('./LiteratureSpectra/woudc.dat', 'w')
    f.write(header)
    np.savetxt(f, spectable, delimiter='		', fmt='%1.7e', newline='\n')
    f.close()

    ###########################################################################################
    ###########################################################################################
    ###########################################################################################
    #####Second, form the mixing ratio files
    #####Form by replicating the Rugheimer modern Earth profile, then scaling down the H2O level and scaling up the O3 level.
    mixingratios = np.genfromtxt(
        './MixingRatios/rugheimer_earth_modern_mixingratios_v2.dat',
        skip_header=2,
        skip_footer=0)
    mixingratios[:,
                 7] = mixingratios[:,
                                   7] * 1.77  #scale up ozone by factor of 1.25
    header0 = 'Based on Rugheimer+2013 Modern Earth Model\n'
    header1 = 'Z (cm)		N2	CO2	H2O	CH4	SO2	O2	O3	H2S\n'

    f = open('./MixingRatios/woudc_mixingratios_v2.dat', 'w')
    f.write(header0)
    f.write(header1)
    np.savetxt(f, mixingratios, delimiter='	', fmt='%1.7e', newline='\n')
    f.close()
    ###########################################################################################
    ###########################################################################################
    ###########################################################################################
    #####Finally, form TP profile
    #####Form by duplicating Rugheimer+2013 modern Earth profile
    tpprofile = np.genfromtxt(
        './TPProfiles/rugheimer_earth_modern_atmosphereprofile.dat',
        skip_header=2,
        skip_footer=0)
    header0 = 'Based on Rugheimer+2013 Modern Earth Model\n'
    header1 = 'Z (cm)	T (K)	DEN (cm**-3)	P (bar) \n'

    f = open('./TPProfiles/woudc_atmosphereprofile.dat', 'w')
    f.write(header0)
    f.write(header1)
    np.savetxt(f, tpprofile, delimiter='		', fmt='%1.7e', newline='\n')
    f.close()
コード例 #7
0
def form_profiles_wuttke():
    """
	Purpose of this code is to form the feedstock files to replicat the Wuttke+2006 Antarctic diffuse radiance measurements
	"""
    import cookbook
    #First, form the spectral file.
    #Define spectral bins. 0.25 nm from 280-500 nm, 1 nm from 500-1000 nm. We just go to 900 since that's what our data is good to. Also we start at 292.75 because that's where our graphclicked data starts
    bin_left_edges = np.concatenate(
        (np.arange(292.75, 500., 0.25), np.arange(500., 900., 1.)))
    bin_right_edges = np.concatenate(
        (np.arange(293., 500.25, 0.25), np.arange(501., 901., 1.)))
    bin_centers = 0.5 * (bin_left_edges + bin_right_edges)

    #load BOA diffuse zenith flux from Wuttke+2006 (extracted via GraphClick)
    importeddata = np.genfromtxt(
        './Raw_Data/UV_Surface_Measurements/wuttke.csv',
        skip_header=0,
        skip_footer=0,
        delimiter=',')
    dif_wav = importeddata[:, 0]  #nm
    dif_flux = importeddata[:,
                            1] * 2. * np.pi  #mW/m2/nm/sr=erg/s/cm2/nm/sr; multiply by 2pi to convert to hemisphere-integrated total surface diffuse radiances
    dif_func = interp.interp1d(dif_wav, dif_flux, kind='linear')
    dif_flux_interp = dif_func(bin_centers)

    #load solar spectrum from Claire et al (2012) models, normalized to 1 au
    importeddata = np.genfromtxt(
        './Raw_Data/Claire_Model/claire_modernsun_highres.dat',
        skip_header=1,
        skip_footer=0)
    claire_wav = importeddata[:, 0]  #nm, 0.1 nm resolution, 100-900 nm.
    claire_fluxes = importeddata[:, 1]  #erg/s/cm2/nm

    #rebin claire spectrum
    claire_fluxes_rebinned = cookbook.rebin_uneven(
        np.arange(99.995, 900.005, 0.01), np.arange(100.005, 900.015, 0.01),
        claire_fluxes, bin_left_edges, bin_right_edges)

    #Plot to make sure rebinning worked correctly
    fig, ax1 = plt.subplots(1, figsize=(6, 4))
    ax1.plot(claire_wav,
             claire_fluxes,
             marker='s',
             color='black',
             label='Claire Fluxes')
    ax1.plot(bin_centers,
             claire_fluxes_rebinned,
             marker='s',
             color='blue',
             label='Binned Claire Fluxes')
    ax1.set_yscale('log')
    ax1.set_ylim([1.e-2, 1.e4])
    ax1.set_xlim([280., 900.])
    ax1.set_xlabel('nm')
    ax1.set_ylabel('erg/s/cm2/nm')
    ax1.legend(loc=0)
    plt.show()

    #Let's print out the results
    spectable = np.zeros([len(bin_left_edges), 5])
    spectable[:, 0] = bin_left_edges
    spectable[:, 1] = bin_right_edges
    spectable[:, 2] = bin_centers
    spectable[:, 3] = claire_fluxes_rebinned
    spectable[:, 4] = dif_flux_interp

    header = 'Left Bin Edge (nm)	Right Bin Edge (nm)	Bin Center (nm)		Top of Atm Flux (erg/s/nm/cm2)		Zenith Diffuse Flux (erg/s/nm/cm2)\n'

    f = open('./LiteratureSpectra/wuttke2006.dat', 'w')
    f.write(header)
    np.savetxt(f, spectable, delimiter='		', fmt='%1.7e', newline='\n')
    f.close()

    ###########################################################################################
    ###########################################################################################
    ###########################################################################################
    #####Second, form the mixing ratio files
    #####Form by replicating the Rugheimer modern Earth profile, then scaling down the H2O level and scaling up the O3 level.
    mixingratios = np.genfromtxt(
        './MixingRatios/rugheimer_earth_modern_mixingratios_v2.dat',
        skip_header=2,
        skip_footer=0)
    mixingratios[:,
                 3] = mixingratios[:, 3] * 0.1  #scale down h2o by factor of 10
    mixingratios[:,
                 7] = mixingratios[:,
                                   7] * 1.25  #scale up ozone by factor of 1.25
    header0 = 'Based on Rugheimer+2013 Modern Earth Model\n'
    header1 = 'Z (cm)		N2	CO2	H2O	CH4	SO2	O2	O3	H2S\n'

    f = open('./MixingRatios/wuttke2006_mixingratios_v2.dat', 'w')
    f.write(header0)
    f.write(header1)
    np.savetxt(f, mixingratios, delimiter='	', fmt='%1.7e', newline='\n')
    f.close()
    ###########################################################################################
    ###########################################################################################
    ###########################################################################################
    #####Finally, form TP profile
    #####Form by duplicating Rugheimer+2013 modern Earth profile
    tpprofile = np.genfromtxt(
        './TPProfiles/rugheimer_earth_modern_atmosphereprofile.dat',
        skip_header=2,
        skip_footer=0)
    header0 = 'Based on Rugheimer+2013 Modern Earth Model\n'
    header1 = 'Z (cm)	T (K)	DEN (cm**-3)	P (bar) \n'

    f = open('./TPProfiles/wuttke2006_atmosphereprofile.dat', 'w')
    f.write(header0)
    f.write(header1)
    np.savetxt(f, tpprofile, delimiter='		', fmt='%1.7e', newline='\n')
    f.close()