In [1]:
import os
import numpy as np
from astropy.io import ascii
from scipy.interpolate import interp1d
import xidplus
temps=os.listdir('/Users/pdh21/astrodata/SEDs/Berta2013/templates_berta_norm_LIR/')
In [2]:
for i,t in enumerate(temps):
print(i,t)
Generate Redshift Grid and convert to denominator for flux conversion (e.g. $4 \pi D_l^2)$
In [11]:
red=np.arange(0,8,0.01)
red[0]=0.000001
from astropy.cosmology import Planck13
import astropy.units as u
div=(4.0*np.pi * np.square(Planck13.luminosity_distance(red).cgs))
div=div.value
Get appropriate filters
In [12]:
from xidplus import filters
filter=filters.FilterFile(file=xidplus.__path__[0]+'/../test_files/filters.res')
In [13]:
filter.names()
In [14]:
SPIRE_250=filter.filters[215]
SPIRE_350=filter.filters[216]
SPIRE_500=filter.filters[217]
MIPS_24=filter.filters[201]
PACS_100=filter.filters[250]
PACS_160=filter.filters[251]
bands=[SPIRE_250,SPIRE_350,SPIRE_500,MIPS_24,PACS_100,PACS_160]
eff_lam=[250.0,350.0,500.0,24.0, 100.0,160.0]
In [15]:
for b in bands:
print(b.name)
In [16]:
import pandas as pd
template=ascii.read('/Users/pdh21/astrodata/SEDs/Berta2013/templates_berta_norm_LIR/'+temps[0])
df=pd.DataFrame(template['col1'].data/1E4,columns=['wave'])
print(template['col1'].data/1E4)
SEDs=np.empty((len(temps),len(bands),red.size))
for i in range(0,len(temps)):
template=ascii.read('/Users/pdh21/astrodata/SEDs/Berta2013/templates_berta_norm_LIR/'+temps[i])
df[temps[i]]=1E30*3.826E33*template['col2']*((template['col1']/1E4)**2)/3E14
flux=template['col2']*((template['col1']/1E4)**2)/3E14
wave=template['col1']/1E4
for z in range(0,red.size):
sed=interp1d((red[z]+1.0)*wave, flux)
for b in range(0,len(bands)):
SEDs[i,b,z]=1E30*3.826E33*(1.0+red[z])*filters.fnu_filt(sed(bands[b].wavelength/1E4),3E8/(bands[b].wavelength/1E10),bands[b].transmission,3E8/(eff_lam[b]*1E-6),sed(eff_lam[b]))/div[z]
In [ ]:
In [17]:
import pylab as plt
%matplotlib inline
plt.semilogy(red,SEDs[0,0,:]*np.power(10.0,12))
plt.semilogy(red,SEDs[0,1,:]*np.power(10.0,12),c='g')
plt.semilogy(red,SEDs[0,2,:]*np.power(10.0,12),c='r')
plt.semilogy(red,SEDs[0,3,:]*np.power(10.0,12),c='m')
plt.ylim(1E-4,1E4)
Out[17]:
In [36]:
np.save('SED_IR', SEDs)
In [10]:
ls
In [37]:
df.to_pickle('SEDS_IR_full.pkl')
In [18]:
from bokeh.io import output_notebook, show
from bokeh.layouts import gridplot, column
from bokeh.plotting import figure
from bokeh.io import push_notebook
output_notebook()
from bokeh.models import HoverTool, Range1d
from bokeh.models import ColumnDataSource, DataSource
from bokeh.models import CustomJS, ColumnDataSource, Slider
In [19]:
from ipywidgets import interact
import numpy as np
from bokeh.io import push_notebook, show, output_notebook
from bokeh.plotting import figure
output_notebook()
plot_options = dict(width=250, plot_height=250)
LIR=12
# create a new plot
source = ColumnDataSource(
data=dict(
x=SEDs[:,0,200]*10.0**LIR,
y=SEDs[:,1,200]*10.0**LIR,
z=SEDs[:,2,200]*10.0**LIR,
width=(SEDs[:,0,200]*10.0**LIR)/5.0,
height=(SEDs[:,1,200]*10.0**LIR)/5.0,
depth=(SEDs[:,2,200]*10.0**LIR)/5.0,
desc=temps,
)
)
hover1 = HoverTool(
tooltips=[
("SED", "@desc"),
]
)
hover2 = HoverTool(
tooltips=[
("SED", "@desc"),
]
)
hover3 = HoverTool(
tooltips=[
("SED", "@desc"),
]
)
s1 = figure(**plot_options,tools=[hover1, 'pan', 'wheel_zoom'])
s1.circle('x', 'y', size=10, source=source,color="navy", alpha=0.0)
s1.ellipse('x', 'y', height='height',width='width', source=source,color="navy", alpha=0.2)
s1.yaxis.axis_label = r'350'
# create a new plot and share both ranges
s2 = figure(x_range=s1.x_range, **plot_options,tools=[hover2, 'pan', 'wheel_zoom'])
s2.circle('x', 'z', size=10, source=source,color="navy", alpha=0.0)
s2.ellipse('x', 'z',height='depth',width='width' , source=source,color="navy", alpha=0.2)
s2.yaxis.axis_label = r'500'
s2.xaxis.axis_label = r'250'
# create a new plot and share only one range
s3 = figure(x_range=s1.y_range,y_range=s2.y_range, **plot_options,tools=[hover3, 'pan', 'wheel_zoom'])
s3.circle('y', 'z', size=10, source=source,color="navy", alpha=0.0)
s3.ellipse('y', 'z',height='depth',width='height', source=source,color="navy", alpha=0.2)
s3.xaxis.axis_label = r'350'
p = gridplot([[s1,],[s2, s3]])
def update(LIR=12,z=red[200]):
ind=np.long(z*100)
print(ind)
source.data['x']=SEDs[:,0,ind]*10.0**LIR
source.data['y']=SEDs[:,1,ind]*10.0**LIR
source.data['z']=SEDs[:,2,ind]*10.0**LIR
source.data['width']=np.full(SEDs.shape[0],np.std(SEDs[:,0,ind]*10.0**LIR))
source.data['depth']=np.full(SEDs.shape[0],np.std(SEDs[:,1,ind]*10.0**LIR))
source.data['height']=np.full(SEDs.shape[0],np.std(SEDs[:,2,ind]*10.0**LIR))
push_notebook()
show(p, notebook_handle=True)
interact(update,LIR=(8,14,0.01),z=(red[0],red[-1],0.01))
Out[19]:
In [26]:
from ipywidgets import interact
import numpy as np
from bokeh.io import push_notebook, show, output_notebook, output_file
from bokeh.plotting import figure
output_notebook()
output_file('SEDs', title='Bokeh Plot', mode='cdn')
plot_options = dict(width=250, plot_height=250)
LIR=12
# create a new plot
source = ColumnDataSource(
data=dict(
s250=SEDs[:,0,200]*10.0**LIR,
s350=SEDs[:,1,200]*10.0**LIR,
s500=SEDs[:,2,200]*10.0**LIR,
s24=SEDs[:,3,200]*10.0**LIR,
s100=SEDs[:,4,200]*10.0**LIR,
s160=SEDs[:,5,200]*10.0**LIR,
s250_sig=0.3*SEDs[:,0,200]*10.0**LIR,
s350_sig=0.3*SEDs[:,1,200]*10.0**LIR,
s500_sig=0.3*SEDs[:,2,200]*10.0**LIR,
s24_sig=0.3*SEDs[:,3,200]*10.0**LIR,
s100_sig=0.3*SEDs[:,4,200]*10.0**LIR,
s160_sig=0.3*SEDs[:,5,200]*10.0**LIR,
desc=temps,
)
)
hover=[]
for i in range(0,15):
hover.append(HoverTool(
tooltips=[
("SED", "@desc"),
]
))
s0_0 = figure(**plot_options,tools=[hover[0], 'pan', 'wheel_zoom'])
s0_0.circle('s24', 's100', size=10, source=source,color="navy", alpha=0.0)
s0_0.ellipse('s24', 's100', height='s100_sig',width='s24_sig', source=source,color="navy", alpha=0.2)
s0_0.yaxis.axis_label = r'100'
s0_1 = figure(x_range=s0_0.x_range,**plot_options,tools=[hover[1], 'pan', 'wheel_zoom'])
s0_1.circle('s24', 's160', size=10, source=source,color="navy", alpha=0.0)
s0_1.ellipse('s24', 's160', height='s160_sig',width='s24_sig', source=source,color="navy", alpha=0.2)
s0_1.yaxis.axis_label = r'160'
s0_2 = figure(x_range=s0_0.x_range,**plot_options,tools=[hover[2], 'pan', 'wheel_zoom'])
s0_2.circle('s24', 's250', size=10, source=source,color="navy", alpha=0.0)
s0_2.ellipse('s24', 's250', height='s250_sig',width='s24_sig', source=source,color="navy", alpha=0.2)
s0_2.yaxis.axis_label = r'250'
s0_3 = figure(x_range=s0_0.x_range,**plot_options,tools=[hover[3], 'pan', 'wheel_zoom'])
s0_3.circle('s24', 's100', size=10, source=source,color="navy", alpha=0.0)
s0_3.ellipse('s24', 's350', height='s350_sig',width='s24_sig', source=source,color="navy", alpha=0.2)
s0_3.yaxis.axis_label = r'350'
s0_4 = figure(x_range=s0_0.x_range,**plot_options,tools=[hover[4], 'pan', 'wheel_zoom'])
s0_4.circle('s24', 's500', size=10, source=source,color="navy", alpha=0.0)
s0_4.ellipse('s24', 's500', height='s500_sig',width='s24_sig', source=source,color="navy", alpha=0.2)
s0_4.yaxis.axis_label = r'500'
s0_4.xaxis.axis_label = r'24'
# create a new plot and share both ranges
s1_1 = figure(xrange=s0_0.yrange,yrange=s0_1.yrange,**plot_options,tools=[hover[5], 'pan', 'wheel_zoom'])
s1_1.circle('s100', 's160', size=10, source=source,color="navy", alpha=0.0)
s1_1.ellipse('s100', 's160', height='s160_sig',width='s100_sig', source=source,color="navy", alpha=0.2)
s1_1.yaxis.axis_label = r'160'
s1_2 = figure(x_range=s0_0.y_range,y_range=s0_2.y_range **plot_options,tools=[hover[6], 'pan', 'wheel_zoom'])
s1_2.circle('s100', 's250', size=10, source=source,color="navy", alpha=0.0)
s1_2.ellipse('s100', 's250',height='s250_sig',width='s100_sig' , source=source,color="navy", alpha=0.2)
s1_2.yaxis.axis_label = r'250'
s1_3 = figure(x_range=s0_0.y_range, **plot_options,tools=[hover[7], 'pan', 'wheel_zoom'])
s1_3.circle('s100', 's350', size=10, source=source,color="navy", alpha=0.0)
s1_3.ellipse('s100', 's350',height='s350_sig',width='s100_sig' , source=source,color="navy", alpha=0.2)
s1_3.yaxis.axis_label = r'350'
s1_4 = figure(x_range=s0_0.y_range, **plot_options,tools=[hover[8], 'pan', 'wheel_zoom'])
s1_4.circle('s100', 's500', size=10, source=source,color="navy", alpha=0.0)
s1_4.ellipse('s100', 's500',height='s500_sig',width='s100_sig' , source=source,color="navy", alpha=0.2)
s1_4.yaxis.axis_label = r'500'
s1_4.xaxis.axis_label = r'100'
s2_2 = figure(x_range=s1_1.y_range,y_range=s0_1.y_range, **plot_options,tools=[hover[9], 'pan', 'wheel_zoom'])
s2_2.circle('s160', 's250', size=10, source=source,color="navy", alpha=0.0)
s2_2.ellipse('s160', 's250',height='s250_sig',width='s160_sig' , source=source,color="navy", alpha=0.2)
s2_2.yaxis.axis_label = r'250'
s2_3 = figure(x_range=s1_1.y_range,y_range=s0_2.y_range, **plot_options,tools=[hover[10], 'pan', 'wheel_zoom'])
s2_3.circle('s160', 's350', size=10, source=source,color="navy", alpha=0.0)
s2_3.ellipse('s160', 's350',height='s350_sig',width='s160_sig' , source=source,color="navy", alpha=0.2)
s2_3.yaxis.axis_label = r'350'
s2_4 = figure(x_range=s1_1.y_range,y_range=s0_3.y_range, **plot_options,tools=[hover[11], 'pan', 'wheel_zoom'])
s2_4.circle('s160', 's500', size=10, source=source,color="navy", alpha=0.0)
s2_4.ellipse('s160', 's500',height='s500_sig',width='s160_sig' , source=source,color="navy", alpha=0.2)
s2_4.yaxis.axis_label = r'500'
s2_4.xaxis.axis_label = r'160'
s3_3 = figure(x_range=s_1.y_range,y_range=s0_2.y_range, **plot_options,tools=[hover[12], 'pan', 'wheel_zoom'])
s3_3.circle('s250', 's350', size=10, source=source,color="navy", alpha=0.0)
s3_3.ellipse('s250', 's350',height='s350_sig',width='s250_sig' , source=source,color="navy", alpha=0.2)
s3_3.yaxis.axis_label = r'350'
s3_4 = figure(x_range=s0_1.y_range,y_range=s0_3.y_range, **plot_options,tools=[hover[13], 'pan', 'wheel_zoom'])
s3_4.circle('s250', 's500', size=10, source=source,color="navy", alpha=0.0)
s3_4.ellipse('s250', 's500',height='s500_sig',width='s250_sig' , source=source,color="navy", alpha=0.2)
s3_4.yaxis.axis_label = r'500'
s3_4.xaxis.axis_label = r'250'
s4_4 = figure(x_range=s0_2.y_range,y_range=s0_3.y_range, **plot_options,tools=[hover[14], 'pan', 'wheel_zoom'])
s4_4.circle('s350', 's500', size=10, source=source,color="navy", alpha=0.0)
s4_4.ellipse('s350', 's500',height='s500_sig',width='s350_sig' , source=source,color="navy", alpha=0.2)
s4_4.yaxis.axis_label = r'500'
s4_4.xaxis.axis_label = r'350'
p = gridplot([[s0_0,],[s0_1,s1_1,],[s0_2,s1_2,s2_2,],[s0_3,s1_3,s2_3,s3_3],[s0_4,s1_4,s2_4,s3_4,s4_4]])
def update(LIR=12,z=red[200]):
ind=np.long(z*100)
print(ind)
source.data['s250']=SEDs[:,0,ind]*10.0**LIR
source.data['s350']=SEDs[:,1,ind]*10.0**LIR
source.data['s500']=SEDs[:,2,ind]*10.0**LIR
source.data['s100']=SEDs[:,4,ind]*10.0**LIR
source.data['s160']=SEDs[:,5,ind]*10.0**LIR
source.data['s250_sig']=0.3*SEDs[:,0,ind]*10.0**LIR
source.data['s350_sig']=0.3*SEDs[:,1,ind]*10.0**LIR
source.data['s500_sig']=0.3*SEDs[:,2,ind]*10.0**LIR
source.data['s100_sig']=0.3*SEDs[:,4,ind]*10.0**LIR
source.data['s160_sig']=0.3*SEDs[:,5,ind]*10.0**LIR
push_notebook()
show(p, notebook_handle=True)
interact(update,LIR=(8,14,0.01),z=(red[0],red[-1],0.01))
Out[26]:
In [84]:
####log 10 version
from ipywidgets import interact
import numpy as np
from bokeh.io import push_notebook, show, output_notebook
from bokeh.plotting import figure
output_notebook()
plot_options = dict(width=250, plot_height=250)
LIR=12
# create a new plot
source = ColumnDataSource(
data=dict(
s250=np.log10(SEDs[:,0,200]*10.0**LIR),
s350=np.log10(SEDs[:,1,200]*10.0**LIR),
s500=np.log10(SEDs[:,2,200]*10.0**LIR),
s100=np.log10(SEDs[:,3,200]*10.0**LIR),
s160=np.log10(SEDs[:,4,200]*10.0**LIR),
s250_sig=np.full(SEDs.shape[0],sig[0,200]),
s350_sig=np.full(SEDs.shape[0],sig[1,200]),
s500_sig=np.full(SEDs.shape[0],sig[2,200]),
s100_sig=np.full(SEDs.shape[0],sig[3,200]),
s160_sig=np.full(SEDs.shape[0],sig[4,200]),
desc=temps,
)
)
hover=[]
for i in range(0,10):
hover.append(HoverTool(
tooltips=[
("SED", "@desc"),
]
))
s0_0 = figure(**plot_options,tools=[hover[0], 'pan', 'wheel_zoom'])
s0_0.circle('s100', 's160', size=10, source=source,color="navy", alpha=0.0)
s0_0.ellipse('s100', 's160', height='s160_sig',width='s100_sig', source=source,color="navy", alpha=0.2)
s0_0.yaxis.axis_label = r'160'
# create a new plot and share both ranges
s0_1 = figure(x_range=s0_0.x_range, **plot_options,tools=[hover[1], 'pan', 'wheel_zoom'])
s0_1.circle('s100', 's250', size=10, source=source,color="navy", alpha=0.0)
s0_1.ellipse('s100', 's250',height='s250_sig',width='s100_sig' , source=source,color="navy", alpha=0.2)
s0_1.yaxis.axis_label = r'250'
s0_2 = figure(x_range=s0_0.x_range, **plot_options,tools=[hover[2], 'pan', 'wheel_zoom'])
s0_2.circle('s100', 's350', size=10, source=source,color="navy", alpha=0.0)
s0_2.ellipse('s100', 's350',height='s350_sig',width='s100_sig' , source=source,color="navy", alpha=0.2)
s0_2.yaxis.axis_label = r'350'
s0_3 = figure(x_range=s0_0.x_range, **plot_options,tools=[hover[3], 'pan', 'wheel_zoom'])
s0_3.circle('s100', 's500', size=10, source=source,color="navy", alpha=0.0)
s0_3.ellipse('s100', 's500',height='s500_sig',width='s100_sig' , source=source,color="navy", alpha=0.2)
s0_3.yaxis.axis_label = r'500'
s0_3.xaxis.axis_label = r'100'
s1_1 = figure(x_range=s0_0.y_range,y_range=s0_1.y_range, **plot_options,tools=[hover[4], 'pan', 'wheel_zoom'])
s1_1.circle('s160', 's250', size=10, source=source,color="navy", alpha=0.0)
s1_1.ellipse('s160', 's250',height='s250_sig',width='s160_sig' , source=source,color="navy", alpha=0.2)
s1_1.yaxis.axis_label = r'250'
s1_2 = figure(x_range=s0_0.y_range,y_range=s0_2.y_range, **plot_options,tools=[hover[5], 'pan', 'wheel_zoom'])
s1_2.circle('s160', 's350', size=10, source=source,color="navy", alpha=0.0)
s1_2.ellipse('s160', 's350',height='s350_sig',width='s160_sig' , source=source,color="navy", alpha=0.2)
s1_2.yaxis.axis_label = r'350'
s1_3 = figure(x_range=s0_0.y_range,y_range=s0_3.y_range, **plot_options,tools=[hover[6], 'pan', 'wheel_zoom'])
s1_3.circle('s160', 's500', size=10, source=source,color="navy", alpha=0.0)
s1_3.ellipse('s160', 's500',height='s500_sig',width='s160_sig' , source=source,color="navy", alpha=0.2)
s1_3.yaxis.axis_label = r'500'
s1_3.xaxis.axis_label = r'160'
s2_2 = figure(x_range=s0_1.y_range,y_range=s0_2.y_range, **plot_options,tools=[hover[7], 'pan', 'wheel_zoom'])
s2_2.circle('s250', 's350', size=10, source=source,color="navy", alpha=0.0)
s2_2.ellipse('s250', 's350',height='s350_sig',width='s250_sig' , source=source,color="navy", alpha=0.2)
s2_2.yaxis.axis_label = r'350'
s2_3 = figure(x_range=s0_1.y_range,y_range=s0_3.y_range, **plot_options,tools=[hover[8], 'pan', 'wheel_zoom'])
s2_3.circle('s250', 's500', size=10, source=source,color="navy", alpha=0.0)
s2_3.ellipse('s250', 's500',height='s500_sig',width='s250_sig' , source=source,color="navy", alpha=0.2)
s2_3.yaxis.axis_label = r'500'
s2_3.xaxis.axis_label = r'250'
s3_3 = figure(x_range=s0_2.y_range,y_range=s0_3.y_range, **plot_options,tools=[hover[9], 'pan', 'wheel_zoom'])
s3_3.circle('s350', 's500', size=10, source=source,color="navy", alpha=0.0)
s3_3.ellipse('s350', 's500',height='s500_sig',width='s350_sig' , source=source,color="navy", alpha=0.2)
s3_3.yaxis.axis_label = r'500'
s3_3.xaxis.axis_label = r'350'
p = gridplot([[s0_0,],[s0_1,s1_1,],[s0_2,s1_2,s2_2,],[s0_3,s1_3,s2_3,s3_3]])
def update(LIR=12,z=red[200]):
ind=np.long(z*100)
print(ind)
source.data['s250']=np.log10(SEDs[:,0,ind]*10.0**LIR)
source.data['s350']=np.log10(SEDs[:,1,ind]*10.0**LIR)
source.data['s500']=np.log10(SEDs[:,2,ind]*10.0**LIR)
source.data['s100']=np.log10(SEDs[:,3,ind]*10.0**LIR)
source.data['s160']=np.log10(SEDs[:,4,ind]*10.0**LIR)
source.data['s250_sig']=np.full(SEDs.shape[0],sig[0,ind])#+LIR
source.data['s350_sig']=np.full(SEDs.shape[0],sig[1,ind])#+LIR
source.data['s500_sig']=np.full(SEDs.shape[0],sig[2,ind])#+LIR
source.data['s100_sig']=np.full(SEDs.shape[0],sig[3,ind])#+LIR
source.data['s160_sig']=np.full(SEDs.shape[0],sig[4,ind])#+LIR
push_notebook()
show(p, notebook_handle=True)
interact(update,LIR=(8,14,0.01),z=(red[0],red[-1],0.01))
Out[84]:
In [77]:
np.full(SEDs.shape[0],sig[0,200])
Out[77]:
In [20]:
for t in range(0,SEDs.shape[0]):
cov=np.zeros((SEDs.shape[1],SEDs.shape[1]))
for i in range(0,SEDs.shape[1]):
cov[i,i]=0.3*SEDs[t,i,200]*10.0**LIR
if t ==0:
normal=np.random.multivariate_normal(SEDs[t,:,200]*10.0**LIR,cov, 100)
else:
normal=np.vstack((normal,np.random.multivariate_normal(SEDs[t,:,200]*10.0**LIR,cov, 100)))
In [81]:
for t in range(0,SEDs.shape[0]):
cov=np.zeros((SEDs.shape[1],SEDs.shape[1]))
for i in range(0,SEDs.shape[1]):
cov[i,i]=0.3*np.std(np.log10(SEDs[:,i,200]*10.0**LIR))
if t ==0:
log_normal=np.random.multivariate_normal(np.log10(SEDs[t,:,200]*10.0**LIR),cov, 100)
else:
log_normal=np.vstack((log_normal,np.random.multivariate_normal(np.log10(SEDs[t,:,200]*10.0**LIR),cov, 100)))
In [39]:
LIR
Out[39]:
In [22]:
normal.shape
Out[22]:
In [82]:
df=pd.DataFrame(normal,columns=['250','350','500','24', '100', '160'])
In [83]:
import seaborn as sns
import pylab as plt
%matplotlib inline
g=sns.PairGrid(df)
g.map_diag(sns.kdeplot)
g.map_lower(sns.kdeplot,n_levels=20, shade=True,shade_lowest=False)
g.map_upper(plt.scatter, alpha=0.1)
g.data=pd.DataFrame(np.power(10.0,log_normal),columns=['250','350','500','24', '100', '160'])
g.map_diag(sns.kdeplot)
g.map_lower(sns.kdeplot,n_levels=20, shade=True,shade_lowest=False, cmap="Reds", alpha=0.3)
g.map_upper(plt.scatter, alpha=0.1, color='r')
Out[83]:
In [64]:
g=sns.PairGrid(pd.DataFrame(log_normal,columns=['250','350','500','24', '100', '160']))
g.map_diag(sns.kdeplot)
g.map_lower(sns.kdeplot,n_levels=20, shade=True,shade_lowest=False)
g.map_upper(plt.scatter, alpha=0.1)
Out[64]:
In [50]:
from sklearn.neighbors import NearestNeighbors
import numpy as np
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
nbrs = NearestNeighbors(n_neighbors=3, algorithm='ball_tree').fit(X)
distances, indices = nbrs.kneighbors(X)
indices
Out[50]:
In [28]:
SEDs.shape
Out[28]:
In [51]:
sig=np.empty((SEDs.shape[0],SEDs.shape[2]))
for i in range(0,SEDs.shape[2]):
nbrs = NearestNeighbors(n_neighbors=3, algorithm='ball_tree').fit(SEDs[:,:,i])
distances, indices = nbrs.kneighbors(SEDs[:,:,i])
sig[:,i]=distances[:,1]
In [ ]:
for i in range(0,SEDs.shape[2]):
sig[:,i]=0.3*np.std(SEDs[:,0,ind]*10.0**LIR,
sig[:,i]=0.3*np.std(np.log10(SEDs[:,:,i]*10.0**LIR),axis=0)
In [54]:
LIR=8
sig[0,:]*np.power(10.0,10)
Out[54]:
In [79]:
sig=np.empty((SEDs.shape[1],SEDs.shape[2]))
for i in range(0,SEDs.shape[2]):
sig[:,i]=0.3*np.std(np.log10(SEDs[:,:,i]*10.0**LIR),axis=0)
In [70]:
np.save('log10_SED_IR_sig', sig)
In [12]:
np.trapz(df['Blue_SF_glx.norm_LIR'][(df['wave']>8) & (df['wave']<1000)][::-1],x=3.0E8/(df['wave'][(df['wave']>8) & (df['wave']<1000)][::-1]*1E-6))*1E-26/1E4
Out[12]:
In [13]:
df['wave']
Out[13]:
In [14]:
template=ascii.read('/Users/pdh21/astrodata/SEDs/Berta2013/templates_berta_norm_LIR/'+temps[0])
In [25]:
np.trapz(template['col2'][(template['col1']>8E3) & (template['col1']<1E6)],x=template['col1'][(template['col1']>8E3) & (template['col1']<1E6)])
Out[25]:
In [23]:
template['col1']
Out[23]:
In [29]:
print(np.trapz(template['col2'][(template['col1']<8E3)],x=template['col1'][(template['col1']<8E3)]))
print(np.trapz(template['col2'][(template['col1']>8E3) & (template['col1']<1E6)],x=template['col1'][(template['col1']>8E3) & (template['col1']<1E6)]))
print(np.trapz(template['col2'][(template['col1']<1E6)],x=template['col1'][(template['col1']<1E6)]))
In [17]:
plt.loglog(df['wave'],df['Blue_SF_glx.norm_LIR'])
Out[17]:
In [27]:
print(np.trapz(df['Blue_SF_glx.norm_LIR'][(df['wave']>8) & (df['wave']<1000)][::-1]
,x=3.0E8/(df['wave'][(df['wave']>8) & (df['wave']<1000)][::-1]*1E-6))*1E-26/1E4)
print(np.trapz(df['Blue_SF_glx.norm_LIR'][(df['wave']<8)][::-1]
,x=3.0E8/(df['wave'][(df['wave']<8)][::-1]*1E-6))*1E-26/1E4)
In [21]:
Out[21]:
In [ ]: