Exemplo n.º 1
0
def keep_spectra(keepfile,spectra,names,spect_index,comps):
    keepdata,keepcols=ccam.read_csv_cols(keepfile,1,labelrow=True)    
    keepindex=numpy.array(keepdata[0],dtype='int')-1
    fullindex=range(len(names))
    matchindex=numpy.in1d(fullindex,keepindex)
    spectra=spectra[matchindex,:]
    comps=comps[matchindex,:]
    names=names[matchindex]
    spect_index=spect_index[matchindex]
    
    return spectra,names,spect_index,comps
Exemplo n.º 2
0
def remove_spectra(removefile, spectra, names, spect_index, comps):
    #read the list of sample names and spectrum indices from the file
    data = ccam.read_csv_cols(removefile, 0, labelrow=False)
    removenames = numpy.array(data[0], dtype='string')
    removeinds = numpy.array(data[1], dtype='int')
    #define an array to hold the indices for each row in the file
    index = numpy.empty([len(names), len(removenames)])
    for i in range(len(removenames)):
        #for each row, find the indices that correspond to the matching
        #name AND spectral index
        index[:,
              i] = (names == removenames[i]) & (spect_index == removeinds[i])
    #combine the indices for each row to a single array that indicates which
    #spectra to remove, then invert it to indicate which spectra to keep
    index = numpy.invert(numpy.any(index, axis=1))

    spectra = spectra[index, :]
    names = names[index]
    spect_index = spect_index[index]
    comps = comps[index, :]

    return spectra, names, spect_index, comps
imgfile_full = outpath + '\\' + which_elem + '_final_model_predictions_1to1_' + str(
    xminmax[0]) + '-' + str(
        xminmax[1]) + '_full (' + str(fullmin) + '-' + str(fullmax) + ').png'
imgfile_low = outpath + '\\' + which_elem + '_final_model_predictions_1to1_' + str(
    xminmax[0]) + '-' + str(
        xminmax[1]) + '_low (' + str(lowmin) + '-' + str(lowmax) + ').png'
imgfile_mid = outpath + '\\' + which_elem + '_final_model_predictions_1to1_' + str(
    xminmax[0]) + '-' + str(
        xminmax[1]) + '_mid (' + str(midmin) + '-' + str(midmax) + ').png'
imgfile_high = outpath + '\\' + which_elem + '_final_model_predictions_1to1_' + str(
    xminmax[0]) + '-' + str(
        xminmax[1]) + '_high (' + str(highmin) + '-' + str(highmax) + ').png'

print 'Making outlier check plots'
Q_res_full, Q_labels_full = ccam.read_csv_cols(full_Qres_file,
                                               0,
                                               labelrow=True)
Q_res_low, Q_labels_low = ccam.read_csv_cols(low_Qres_file, 0, labelrow=True)
Q_res_mid, Q_labels_mid = ccam.read_csv_cols(mid_Qres_file, 0, labelrow=True)
Q_res_high, Q_labels_high = ccam.read_csv_cols(high_Qres_file,
                                               0,
                                               labelrow=True)
Q_res_full = numpy.array(Q_res_full[4:], dtype='float')
Q_res_low = numpy.array(Q_res_low[4:], dtype='float')
Q_res_mid = numpy.array(Q_res_mid[4:], dtype='float')
Q_res_high = numpy.array(Q_res_high[4:], dtype='float')

T2_res_full, T2_labels_full = ccam.read_csv_cols(full_T2_file,
                                                 0,
                                                 labelrow=True)
T2_res_low, T2_labels_low = ccam.read_csv_cols(low_T2_file, 0, labelrow=True)
Exemplo n.º 4
0
"""
Created on Tue Feb 10 10:31:21 2015

@author: rbanderson
"""
import ccam
import numpy
ica_db_file=r'C:\Users\rbanderson\Documents\MSL\ChemCam\DataProcessing\ICA_1500mm_db.csv'
uni_db_file=r'C:\Users\rbanderson\Documents\MSL\ChemCam\DataProcessing\Univariate_1500mm_db.csv'

dbfile='C:\\Users\\rbanderson\\Documents\\MSL\\ChemCam\\DataProcessing\\Working\\Input\\full_db_mars_corrected.csv'

which_elem='K2O'


ica_db=ccam.read_csv_cols(ica_db_file,0,labelrow=False)

targetnames=numpy.array(ica_db[0],dtype='string')
Si_scores=numpy.array(ica_db[1],dtype='float')
Ti_scores=numpy.array(ica_db[2],dtype='float')
Al_scores=numpy.array(ica_db[3],dtype='float')
Fe_scores=numpy.array(ica_db[4],dtype='float')
Mg_scores=numpy.array(ica_db[5],dtype='float')
Ca_scores=numpy.array(ica_db[6],dtype='float')
Na_scores=numpy.array(ica_db[7],dtype='float')
K_scores=numpy.array(ica_db[8],dtype='float')

ICA_MgO=0.2943*numpy.exp(8.5948*Mg_scores)

uni_db=ccam.read_csv_cols(uni_db_file,1,labelrow=False)
uni_targetnames=numpy.array(uni_db[0],dtype='string')