Loading autocnet/fileio/header_parser.py 0 → 100644 +22 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- """ Created on Tue Nov 24 13:35:56 2015 @author: rbanderson """ def header_parser(row,delim): #get rid of various unwanted characters badlist=['#','^',"'",'*','/'] for i in badlist: row=row.replace(i,'') row.strip() if delim in row: tmp=row.split(delim) label=tmp[0].strip().lower().replace(' ','_').replace(' ','_') data=row.split(tmp[0]+delim)[1].strip() headinfo={label:data} else: headinfo={} return headinfo No newline at end of file autocnet/fileio/io_ccs.py +2 −2 Original line number Diff line number Diff line Loading @@ -5,8 +5,8 @@ import os import numpy as np import pandas as pd import scipy from pysat.fileio.header_parser import header_parser from pysat.fileio.utils import file_search from autocnet.fileio.header_parser import header_parser from autocnet.fileio.utils import file_search def CCS(input_data): df = pd.DataFrame.from_csv(input_data, header=14) Loading autocnet/fileio/io_edr.py +1 −1 Original line number Diff line number Diff line import pandas as pd from pysat.fileio.header_parser import header_parser from autocnet.fileio.header_parser import header_parser def EDR(input_data): with open(input_data, 'r') as f: Loading autocnet/fileio/io_jsc.py +3 −3 Original line number Diff line number Diff line Loading @@ -5,9 +5,9 @@ import re import numpy as np import pandas as pd from pysat.spectral.spectra import Spectra from pysat.fileio.header_parser import header_parser from pysat.fileio.utils import file_search from autocnet.spectral.spectra import Spectra from autocnet.fileio.header_parser import header_parser from autocnet.fileio.utils import file_search #This function reads the lookup tables used to expand metadata from the file names #This is separated from parsing the filenames so that for large lists of files the Loading autocnet/fileio/lookup.py 0 → 100644 +22 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- """ Created on Mon Nov 30 09:51:51 2015 @author: rbanderson This function uses the pandas merge ability to look up metadata for an existing dataframe in a csv file If lookupfile is a list, then each file will be read and concatenated together The default settings are for looking up ChemCam CCS csv data in the ChemCam master list files, matching on sclock value """ import pandas as pd def lookup(df,lookupfile,sep=',',skiprows=1,left_on='sclock',right_on='Spacecraft Clock'): #this loop concatenates together multiple lookup files if provided (mostly to handle the three different master lists for chemcam) for x in lookupfile: try: tmp=pd.read_csv(x,sep=sep,skiprows=skiprows) lookupdf=pd.concat([lookupdf,tmp]) except: lookupdf=pd.read_csv(x, sep=sep,skiprows=skiprows) combined=pd.merge(df,lookupdf,left_on=left_on,right_on=right_on,how='inner') return combined Loading
autocnet/fileio/header_parser.py 0 → 100644 +22 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- """ Created on Tue Nov 24 13:35:56 2015 @author: rbanderson """ def header_parser(row,delim): #get rid of various unwanted characters badlist=['#','^',"'",'*','/'] for i in badlist: row=row.replace(i,'') row.strip() if delim in row: tmp=row.split(delim) label=tmp[0].strip().lower().replace(' ','_').replace(' ','_') data=row.split(tmp[0]+delim)[1].strip() headinfo={label:data} else: headinfo={} return headinfo No newline at end of file
autocnet/fileio/io_ccs.py +2 −2 Original line number Diff line number Diff line Loading @@ -5,8 +5,8 @@ import os import numpy as np import pandas as pd import scipy from pysat.fileio.header_parser import header_parser from pysat.fileio.utils import file_search from autocnet.fileio.header_parser import header_parser from autocnet.fileio.utils import file_search def CCS(input_data): df = pd.DataFrame.from_csv(input_data, header=14) Loading
autocnet/fileio/io_edr.py +1 −1 Original line number Diff line number Diff line import pandas as pd from pysat.fileio.header_parser import header_parser from autocnet.fileio.header_parser import header_parser def EDR(input_data): with open(input_data, 'r') as f: Loading
autocnet/fileio/io_jsc.py +3 −3 Original line number Diff line number Diff line Loading @@ -5,9 +5,9 @@ import re import numpy as np import pandas as pd from pysat.spectral.spectra import Spectra from pysat.fileio.header_parser import header_parser from pysat.fileio.utils import file_search from autocnet.spectral.spectra import Spectra from autocnet.fileio.header_parser import header_parser from autocnet.fileio.utils import file_search #This function reads the lookup tables used to expand metadata from the file names #This is separated from parsing the filenames so that for large lists of files the Loading
autocnet/fileio/lookup.py 0 → 100644 +22 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- """ Created on Mon Nov 30 09:51:51 2015 @author: rbanderson This function uses the pandas merge ability to look up metadata for an existing dataframe in a csv file If lookupfile is a list, then each file will be read and concatenated together The default settings are for looking up ChemCam CCS csv data in the ChemCam master list files, matching on sclock value """ import pandas as pd def lookup(df,lookupfile,sep=',',skiprows=1,left_on='sclock',right_on='Spacecraft Clock'): #this loop concatenates together multiple lookup files if provided (mostly to handle the three different master lists for chemcam) for x in lookupfile: try: tmp=pd.read_csv(x,sep=sep,skiprows=skiprows) lookupdf=pd.concat([lookupdf,tmp]) except: lookupdf=pd.read_csv(x, sep=sep,skiprows=skiprows) combined=pd.merge(df,lookupdf,left_on=left_on,right_on=right_on,how='inner') return combined