Пример #1
0
                  xycoords='axes fraction',
                  color='red')
#write the MAD in the plot
"""
look into residplot - appears residual not propotrional to error (see SGD plot)
"""

print i
i += 1

test_index = sp.argmax(abs(error))

print i
i += 1

spectrum = Spectrum('/data2/cpb405/DR1_3/' +
                    test.filename.tolist()[test_index])  ###filename###
spectrum.plotFlux(ax=ax[1][1],
                  Tpred=final[test_index],
                  Teff=y_test[test_index])

print i
i += 1

ax[1][1].set_xlabel('Wavelength \ Angstroms')
ax[1][1].set_ylabel('Flux')
ax[1][1].set_title('Spectra and model blackbody curve\nfor greatest outlier')
ax[1][1].legend()

plt.tight_layout()

plt.show()
Пример #2
0
    sns.residplot(temp, final[-1], lowess = True, ax = ax[1][0], line_kws={'color': 'red'})
    ax[1][0].set_title('Residuals of Prediction')
    ax[1][0].set_xlabel('Actual Temperature \ K')
    ax[1][0].set_ylabel('Prediction Residual \ K')
        #plot the residuals of the predicted temperatures
    ax[1][0].annotate('MAD = {0:.2f}'.format(MAD[-1]), xy = (0.05, 0.90), xycoords = 'axes fraction', color = 'red')
        #write the MAD in the plot
        
    """
    look into residplot - appears residual not propotrional to error (see SGD plot)
    """
        
    index = sp.argmax(abs(error))
    df_index = df.loc[df.designation==designation[index]].index[0]
        
    spectrum = Spectrum('/data2/mrs493/DR1/' + df.get_value(df_index,'filename'))
    spectrum.plotFlux(ax = ax[1][1], Tpred = final[-1][index], Teff = temp[index])
    
    ax[1][1].set_xlabel('Wavelength \ Angstroms')
    ax[1][1].set_ylabel('Flux')
    ax[1][1].set_title('Spectra and model blackbody curve\nfor greatest outlier')
    ax[1][1].legend()
        
    plt.tight_layout()
    
    plt.show()
    
    #spectrum.plotFlux(Tpred = final[-1][index], Teff = temp[index])
    #plt.show()
    
'''
Пример #3
0
    bp = sns.barplot([i[1] for i in imp][:hyp['max_features']],
                     [i[0] for i in imp][:hyp['max_features']],
                     ax=ax[1][0])
    ax[1][0].set_xlabel('Features')
    ax[1][0].set_ylabel('Importance')
    ax[1][0].set_title('Feature Importance')
    for tick in ax[1][0].get_xticklabels():
        tick.set_rotation(90)
    '''    
    for x in range(len(imp)):
        bp.text(x,imp[x][0], '{:.2f}'.format(imp[x][0]), color='black', ha='center')
    '''
    test_index = sp.argmax(abs(error))

    spectrum = Spectrum('/data2/mrs493/DR1_3/' +
                        test.filename.tolist()[test_index])  ###filename###

    ax[1][1].set_xlabel('Wavelength \ Angstroms')
    ax[1][1].set_ylabel('Flux')
    ax[1][1].set_title('Spectra of Greatest Outlier')
    if parameter == 'teff':
        spectrum.plotFlux(ax=ax[1][1],
                          Tpred=final[test_index],
                          Teff=y_test[test_index],
                          label='Outlier',
                          log=False)
        ax[1][1].legend()
    else:
        spectrum.plotFlux(ax=ax[1][1], label='Outlier', log=False)

    plt.tight_layout()
Пример #4
0
ax1[1][0].set_title('Residuals of Prediction')
ax1[1][0].set_xlabel('Actual Temperature \ K')
ax1[1][0].set_ylabel('Prediction Residual \ K')
#plot the residuals of the predicted temperatures
ax1[1][0].annotate('MAD = {0:.2f}'.format(MADc),
                   xy=(0.05, 0.90),
                   xycoords='axes fraction',
                   color='red')
#write the MAD in the plot
"""
look into residplot - appears residual not propotrional to error (see SGD plot)
"""

test_index = sp.argmax(abs(errorc))

spectrum = Spectrum('/data2/mrs493/DR1/' + test.filename.tolist()[test_index])
spectrum.plotFlux(ax=ax1[1][1],
                  Tpred=finalc[test_index],
                  Teff=y_test[test_index])

ax1[1][1].set_xlabel('Wavelength \ Angstroms')
ax1[1][1].set_ylabel('Flux')
ax1[1][1].set_title('Spectra and model blackbody curve\nfor greatest outlier')
ax1[1][1].legend()

plt.tight_layout()

plt.show()

ft = ['BV', 'BR', 'BI', 'VR', 'VI', 'RI']
imp = clfc.feature_importances_
Пример #5
0
from fits import Spectrum

import glob

for fitsName in glob.glob('/data2/mrs493/DR1/*.fits')[:20]:
    spectra = Spectrum(fitsName)

    spectra.plotFlux()
    plt.xlim([5750, 5850])
    plt.show()
Пример #6
0
#!/usr/bin/env python3

import pandas as pd
import scipy as sp
import glob
from astropy.io import fits
from astropy.convolution import convolve, Box1DKernel
from scipy.interpolate import interp1d

import matplotlib.pyplot as plt

from fits import Spectrum

dataExample = Spectrum('/data2/cpb405/DR1/spec-55862-B6212_sp06-003.fits')

dataWavelength = dataExample.wavelength

width = 10

SDSS = pd.DataFrame(columns=[
    'totalCounts', 'B', 'V', 'R', 'I', 'BV', 'BR', 'BI', 'VR', 'VI', 'RI',
    'Ha', 'Hb', 'Hg'
])

letters = {
    "B": [3980, 4920],
    "V": [5070, 5950],
    "R": [5890, 7270],
    "I": [7310, 8810]
}
Пример #7
0
    ax[1][0].set_title('Residuals of Prediction')
    ax[1][0].set_xlabel('Actual Temperature \ K')
    ax[1][0].set_ylabel('Prediction Residual \ K')
    #plot the residuals of the predicted temperatures
    ax[1][0].annotate('MAD = {0:.2f}'.format(MAD[-1]),
                      xy=(0.05, 0.90),
                      xycoords='axes fraction',
                      color='red')
    #write the MAD in the plot
    """
    look into residplot - appears residual not propotrional to error (see SGD plot)
    """

    test_index = sp.argmax(abs(error))

    spectrum = Spectrum('/data2/mrs493/DR1/' +
                        test.filename.tolist()[test_index])
    spectrum.plotFlux(ax=ax[1][1],
                      Tpred=final[-1][test_index],
                      Teff=y_test[test_index])

    ax[1][1].set_xlabel('Wavelength \ Angstroms')
    ax[1][1].set_ylabel('Flux')
    ax[1][1].set_title(
        'Spectra and model blackbody curve\nfor greatest outlier')
    ax[1][1].legend()

    plt.tight_layout()

    plt.show()

    #spectrum.plotFlux(Tpred = final[-1][index], Teff = temp[index])
Пример #8
0
from fits import Spectrum
import scipy as sp
import pandas as pd
import matplotlib.pyplot as plt

spectra = pd.read_csv('Files/error.csv')

for spectrum in spectra['file'].tolist():
    try:
        spec = Spectrum(spectrum)
        fig, ax = plt.subplots()
        spec.plotFlux(ax=ax)
        ax.set_xlabel('Wavelength \ Angstrom')
        ax.set_ylabel('Flux')
        ax.set_title(spectrum[:-5])
        plt.show()
    except:
        print('error opening ' + spectrum)