In [1]:
import splat
import wisps
from astropy.io import fits, ascii
import matplotlib.pyplot as plt
import glob
import pandas as pd
import numpy as np

%matplotlib inline

In [2]:
data='/Users/caganze/research/wisps/data/manjavacas/final_data_journal/*.csv'

In [3]:
spectra=[]
for f in glob.glob(data):
    d=ascii.read(f).to_pandas()
    s=wisps.Spectrum(wave=d.col1, flux=d.col2, noise=d.col3)
    s._filename=f.split('/')[-1].split('.csv')[0]
    spectra.append(s)

In [4]:
indices=pd.DataFrame([s.indices for s in spectra])
snr1=[s.snr['snr1'] for s in spectra]
snr2=[s.snr['snr2'] for s in spectra]
ftests=pd.DataFrame([s.f_test() for s in spectra])

In [5]:
df=pd.DataFrame()
for k in indices.columns: df[k]=indices[k]
for k in ftests.columns: df[k]=ftests[k]
df['snr1']=snr1
df['snr2']=snr2
df['name']=[s.filename for s in spectra]

In [6]:
#wisps.datasets['spex']

In [7]:
df.to_pickle(wisps.LIBRARIES+'/manjavacas.pkl')

In [8]:
for s in spectra:
    s.splat_spectrum.plot(ylabel=s.filename)


No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.

In [9]:
#ghjkla
#spex=wisps.spex_sample_ids(stype='spex_sample',  from_file=False)
#spexids=pd.DataFrame([x for x in spex['Indices']])
#for k in spexids.columns: spex[k]=spexids[k]
#ref=wisps.Annotator.reformat_table(spexids)
df['spectra']=spectra
df=wisps.Annotator.reformat_table(df)

In [10]:
f=df[(df['CH_4/H-Cont'] <0.5) & (df['H-cont/J-Cont'] >0.6)].spectra.apply(lambda x: x.splat_spectrum.plot(ylabel=x.filename))


No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.
No handles with labels found to put in legend.

In [11]:
ydwarfs=df[df['spt'].apply(lambda x: splat.typeToNum(x))>37]
#df[(df['CH_4/H-Cont'] <0.5) & (df['H-cont/J-Cont'] >0.6)]

In [25]:
schn='/Users/caganze/research/wisps/data/schneider/*.txt'

In [ ]:
spectra_schn=[]
for f in glob.glob(data):
    d=ascii.read(f).to_pandas()
    s=wisps.Spectrum(wave=d.col1, flux=d.col2, noise=d.col3)
    s._filename=f.split('/')[-1].split('.csv')[0]
    spectra_schn.append(s)

In [31]:
ascii.read(glob.glob(schn)[0]).to_pandas()


Out[31]:
col1 col2 col3
0 0.90230 2.860352e-19 3.044938e-19
1 0.90470 2.934565e-19 3.046443e-19
2 0.90710 1.651078e-20 3.036695e-19
3 0.90950 3.380522e-20 2.972527e-19
4 0.91190 2.930665e-19 2.884913e-19
5 0.91430 1.455297e-19 2.843399e-19
6 0.91670 -3.543762e-20 2.781602e-19
7 0.91910 1.008964e-19 2.754531e-19
8 0.92150 3.678952e-19 2.755927e-19
9 0.92390 1.362608e-19 2.718159e-19
10 0.92630 -7.353148e-20 2.734799e-19
11 0.92870 -3.390282e-20 2.713987e-19
12 0.93110 -1.189348e-19 2.671180e-19
13 0.93350 -9.357668e-20 2.595199e-19
14 0.93590 -9.358729e-20 2.607940e-19
15 0.93830 -3.829133e-20 2.533677e-19
16 0.94070 1.527981e-20 2.576087e-19
17 0.94310 1.973343e-20 2.513552e-19
18 0.94550 -1.224149e-20 2.479845e-19
19 0.94790 -5.527852e-20 2.597678e-19
20 0.95030 1.110159e-19 2.443284e-19
21 0.95270 -2.650457e-20 2.423128e-19
22 0.95510 3.150410e-20 2.386399e-19
23 0.95750 1.159953e-19 2.462010e-19
24 0.95990 1.821607e-19 2.436327e-19
25 0.96230 -8.348786e-20 2.392813e-19
26 0.96470 -5.316521e-20 2.337132e-19
27 0.96710 1.034372e-19 2.494008e-19
28 0.96950 6.836219e-20 2.387689e-19
29 0.97190 1.803518e-19 2.307238e-19
... ... ... ...
182 1.56335 1.555061e-19 5.163507e-20
183 1.56800 2.477530e-19 5.178506e-20
184 1.57265 2.740602e-19 5.173149e-20
185 1.57730 3.025988e-19 5.149504e-20
186 1.58195 3.759114e-19 5.138869e-20
187 1.58660 3.554327e-19 5.117265e-20
188 1.59125 3.459346e-19 5.149163e-20
189 1.59590 3.056864e-19 5.273607e-20
190 1.60055 2.740269e-19 5.218169e-20
191 1.60520 1.544560e-19 5.088746e-20
192 1.60985 7.959328e-20 5.174660e-20
193 1.61450 -4.059700e-21 5.098301e-20
194 1.61915 4.065024e-20 5.101415e-20
195 1.62380 9.280885e-20 5.138326e-20
196 1.62845 -1.406259e-20 5.213086e-20
197 1.63310 1.065893e-20 5.208593e-20
198 1.63775 5.834112e-20 5.237655e-20
199 1.64240 4.947092e-21 5.290942e-20
200 1.64705 2.333367e-20 5.464748e-20
201 1.65170 3.732316e-20 5.432908e-20
202 1.65635 3.803485e-20 5.650728e-20
203 1.66100 1.918231e-20 5.847693e-20
204 1.66565 -5.316814e-20 6.391293e-20
205 1.67030 -9.083588e-20 7.353628e-20
206 1.67495 -4.864580e-20 8.830118e-20
207 1.67960 1.333804e-19 1.114926e-19
208 1.68425 -1.428563e-19 1.462558e-19
209 1.68890 -2.295263e-19 1.893736e-19
210 1.69355 -1.441694e-20 2.398571e-19
211 1.69820 -1.975820e-19 2.939378e-19

212 rows × 3 columns


In [ ]: