Ejemplo n.º 1
0
def cv_plots(filenames,ncs,norms,xminmax,yminmax,which_elem):      
    #make 1 to 1 plots using CV results
    
    full_cv_predict,full_cv_samples,full_cv_truecomps,full_cv_folds,full_cv_spect=ccam.plots.readpredicts(filenames['cv_file']['full'],ncs['full'])
    low_cv_predict,low_cv_samples,low_cv_truecomps,low_cv_folds,low_cv_spect=ccam.plots.readpredicts(filenames['cv_file']['low'],ncs['low'])
    high_cv_predict,high_cv_samples,high_cv_truecomps,high_cv_folds,high_cv_spect=ccam.plots.readpredicts(filenames['cv_file']['high'],ncs['high'])
    mid_cv_predict,mid_cv_samples,mid_cv_truecomps,mid_cv_folds,mid_cv_spect=ccam.plots.readpredicts(filenames['cv_file']['mid'],ncs['mid'])
    
    
          
    RMSECV_full=round(numpy.sqrt(numpy.mean((full_cv_predict-full_cv_truecomps)**2)),2)
    RMSECV_low=round(numpy.sqrt(numpy.mean((low_cv_predict-low_cv_truecomps)**2)),2)
    RMSECV_mid=round(numpy.sqrt(numpy.mean((mid_cv_predict-mid_cv_truecomps)**2)),2)
    RMSECV_high=round(numpy.sqrt(numpy.mean((high_cv_predict-high_cv_truecomps)**2)),2)
    
    
    truecomps=[full_cv_truecomps,low_cv_truecomps,mid_cv_truecomps,high_cv_truecomps]
    predicts=[full_cv_predict,low_cv_predict,mid_cv_predict,high_cv_predict]
#    labels=['Full (nc='+str(ncs['full'])+', norm='+str(norms['full'])+', RMSECV='+str(RMSECV_full)+')','Low (nc='+str(ncs['low'])+',norm='+str(norms['low'])+', RMSECV='+str(RMSECV_low)+')','Mid (nc='+str(ncs['mid'])+',norm='+str(norms['mid'])+', RMSECV='+str(RMSECV_mid)+')','High (nc='+str(ncs['high'])+',norm='+str(norms['high'])+', RMSECV='+str(RMSECV_high)+')']
    labels=['Full (RMSECV='+str(RMSECV_full)+')','Low (RMSECV='+str(RMSECV_low)+')','Mid (RMSECV='+str(RMSECV_mid)+')','High (RMSECV='+str(RMSECV_high)+')']
    
    colors=['c','r','g','b']
    markers=['o','<','v','^']
    plot_title=which_elem+' Cross Validation'
    ccam.Plot1to1(truecomps,predicts,plot_title,labels,colors,markers,filenames['outfiles1to1']['all'],xminmax=xminmax,yminmax=yminmax)
    ccam.Plot1to1([truecomps[0]],[predicts[0]],plot_title,labels[0],colors[0],markers[0],filenames['outfiles1to1']['full'],xminmax=xminmax,yminmax=yminmax)
    ccam.Plot1to1([truecomps[1]],[predicts[1]],plot_title,labels[1],colors[1],markers[1],filenames['outfiles1to1']['low'],xminmax=xminmax,yminmax=yminmax)
    ccam.Plot1to1([truecomps[2]],[predicts[2]],plot_title,labels[2],colors[2],markers[2],filenames['outfiles1to1']['mid'],xminmax=xminmax,yminmax=yminmax)
    ccam.Plot1to1([truecomps[3]],[predicts[3]],plot_title,labels[3],colors[3],markers[3],filenames['outfiles1to1']['high'],xminmax=xminmax,yminmax=yminmax)
labels = [
    'Full (nc=' + str(nc_full) + ', norm=' + str(fullnorm) + ', RMSECV=' +
    str(RMSECV_full) + ')', 'Low (nc=' + str(nc_low) + ',norm=' +
    str(lownorm) + ', RMSECV=' + str(RMSECV_low) + ')',
    'Low (nc=' + str(nc_mid) + ',norm=' + str(midnorm) + ', RMSECV=' +
    str(RMSECV_mid) + ')', 'High (nc=' + str(nc_high) + ',norm=' +
    str(highnorm) + ', RMSECV=' + str(RMSECV_high) + ')'
]
colors = ['c', 'r', 'g', 'b']
markers = ['o', '<', 'v', '^']
plot_title = which_elem + ' Cross Validation'
ccam.Plot1to1(truecomps,
              predicts,
              plot_title,
              labels,
              colors,
              markers,
              outfile1to1,
              xminmax=xminmax,
              yminmax=yminmax)
ccam.Plot1to1(truecomps[0],
              predicts[0],
              plot_title,
              labels[0],
              colors[0],
              markers[0],
              outfile1to1_full,
              xminmax=xminmax,
              yminmax=yminmax)
ccam.Plot1to1(truecomps[1],
              predicts[1],
Ejemplo n.º 3
0
Casum_areas=numpy.array(uni_db[4],dtype='float')
Si288_areas=numpy.array(uni_db[5],dtype='float')
Sisum_areas=numpy.array(uni_db[6],dtype='float')
K766_areas=numpy.array(uni_db[7],dtype='float')
Mg285_areas=numpy.array(uni_db[8],dtype='float')
Mg448_areas=numpy.array(uni_db[9],dtype='float')
Alsum_areas=numpy.array(uni_db[10],dtype='float')
Ti335_areas=numpy.array(uni_db[11],dtype='float')
Fesum_areas=numpy.array(uni_db[12],dtype='float')

Uni_MgO=4080.43*Mg448_areas+0.35


#print 'Reading database'
#sys.stdout.flush()
#spectra,comps,spect_index,names,labels,wvl=ccam.read_db(dbfile,compcheck=True)
#oxides=labels[2:]
#compindex=numpy.where(oxides=='K2O')[0]

complist=ccam.target_comp_lookup(targetnames,dbfile,which_elem)

uni_complist=ccam.target_comp_lookup(uni_targetnames,dbfile,which_elem)

ccam.Plot1to1([complist],[K_scores],'',['K ICA Score'],['r'],['o'],r'C:\Users\rbanderson\Documents\MSL\ChemCam\DataProcessing\K_ICA_scores_vs_comp.png',yminmax=[0,numpy.max(K_scores)],xminmax=[0,20],ylabel='ICA Score',xlabel='wt.%',one_to_one=False)
ccam.Plot1to1([uni_complist],[K766_areas],'',['K 766 nm Peak Area'],['r'],['o'],r'C:\Users\rbanderson\Documents\MSL\ChemCam\DataProcessing\K_766nm_uni_areas_vs_comp.png',yminmax=[0,numpy.max(K766_areas)],xminmax=[0,20],ylabel='766 nm Peak Area',xlabel='wt.%',one_to_one=False)
#ccam.Plot1to1([uni_complist],[Uni_K2O],'',['K2O wt.%'],['r'],['o'],r'C:\Users\rbanderson\Documents\MSL\ChemCam\DataProcessing\K2O_uni_vs_comp.png',yminmax=[0,20],xminmax=[0,20],ylabel='Wt.%',xlabel='wt.%',one_to_one=True)

ccam.Plot1to1([complist],[Ti_scores],'',['Ti ICA Score'],['r'],['o'],r'C:\Users\rbanderson\Documents\MSL\ChemCam\DataProcessing\Ti_ICA_scores_vs_comp.png',yminmax=[0,numpy.max(Ti_scores)],xminmax=[0,20],ylabel='ICA Score',xlabel='wt.%',one_to_one=False)
ccam.Plot1to1([uni_complist],[Ti335_areas],'',['Ti 335 nm Peak Area'],['r'],['o'],r'C:\Users\rbanderson\Documents\MSL\ChemCam\DataProcessing\Ti_335nm_uni_areas_vs_comp.png',yminmax=[0,numpy.max(Ti335_areas)],xminmax=[0,20],ylabel='335 nm Peak Area',xlabel='wt.%',one_to_one=False)

print 'stop'
Ejemplo n.º 4
0
    row = ['File', which_elem]
    writer.writerow(row)

    for i in range(0, len(y_full)):
        row = [filelist[i], y_full[i]]
        writer.writerow(row)

#make 1 to 1 plots using CV results

full_cv_predict, full_cv_samples, full_cv_truecomps, full_cv_folds, full_cv_spect = ccam.plots.readpredicts(
    full_cv_file, nc_full)

RMSECV_full = numpy.sqrt(numpy.mean((full_cv_predict - full_cv_truecomps)**2))

truecomps = full_cv_truecomps
predicts = full_cv_predict
labels = 'Full (nc=' + str(nc_full) + ', norm=' + str(
    fullnorm) + ', RMSECV=' + str(RMSECV_full) + ')'
colors = 'c'
markers = 'o'
plot_title = which_elem + ' Cross Validation'
ccam.Plot1to1(truecomps,
              predicts,
              plot_title,
              labels,
              colors,
              markers,
              outfile1to1,
              xminmax=xminmax,
              yminmax=yminmax)
Ejemplo n.º 5
0
labels = [
    'Full (nc=' + str(nc_full) + ', norm=' + str(norm_full) + ', RMSECV=' +
    str(RMSECV_full) + ')', 'Low (nc=' + str(nc_low) + ',norm=' +
    str(norm_low) + ', RMSECV=' + str(RMSECV_low) + ')',
    'Mid (nc=' + str(nc_mid) + ',norm=' + str(norm_mid) + ', RMSECV=' +
    str(RMSECV_mid) + ')', 'High (nc=' + str(nc_high) + ',norm=' +
    str(norm_high) + ', RMSECV=' + str(RMSECV_high) + ')'
]
colors = ['c', 'r', 'g', 'b']
markers = ['o', 'v', 's', '^']
plot_title = 'MgO Cross Validation'
ccam.Plot1to1(truecomps,
              predicts,
              plot_title,
              labels,
              colors,
              markers,
              outfile1,
              xminmax=comprange1,
              yminmax=comprange1)
outfile = r'C:\Users\rbanderson\Documents\MSL\ChemCam\Data Processing\Working\Output\MgO_submodels_1to1_plot_full.png'
ccam.Plot1to1(truecomps[0],
              predicts[0],
              plot_title,
              labels[0],
              colors[0],
              markers[0],
              outfile,
              xminmax=comprange1,
              yminmax=comprange1)
outfile = r'C:\Users\rbanderson\Documents\MSL\ChemCam\Data Processing\Working\Output\MgO_submodels_1to1_plot_low.png'