Skip to content

Instantly share code, notes, and snippets.

@tisaconundrum2
Last active March 20, 2018 20:43
Show Gist options
  • Save tisaconundrum2/ee85d5a3f28fbaf5cf64073823a8aa84 to your computer and use it in GitHub Desktop.
Save tisaconundrum2/ee85d5a3f28fbaf5cf64073823a8aa84 to your computer and use it in GitHub Desktop.
filename = "smal.tsv"
keyname = "someKeyname"
self.data[keyname] = spectral_data(pd.read_csv(filename, header=[0, 1], verbose=True))
class spectral_data(object):
def __init__(self, df):
try:
uppercols = df.columns.levels[0]
lowercols = list(df.columns.levels[1].values)
except:
df.columns = pd.MultiIndex.from_tuples(list(df.columns))
uppercols = df.columns.levels[0]
lowercols = list(df.columns.levels[1].values)
for i, val in enumerate(lowercols):
try:
lowercols[i] = float(val)
except:
lowercols[i] = val
levels = [uppercols, lowercols]
df.columns.set_levels(levels, inplace=True)
self.df = df
meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp comp meta wvl wvl wvl wvl wvl wvl wvl wvl wvl wvl wvl
Sample XRF # Sample ID LIBS ID loc lab gas pressure Laser Identifier Laser System Wavelength (nm) Rep Rate (Hz) laser_power Exp Identifier Scan Length (s) Scans Averaged Number of Saved Scans Collection Delay time1 time2 SiO2 TiO2 Al2O3 Cr2O3 Fe2O3T MnO MgO CaO Na2O K2O P2O5 SO3 LOI Residue Total Total Includes %LOI FeO Fe2O3 SO3 Actual Fe(3+)/Fe(Total) Rb (ug/g) Sr (ug/g) Y (ug/g) Zr (ug/g) V (ug/g) Ni (ug/g) Cr (ug/g) Nb (ug/g) Ga (ug/g) Cu (ug/g) Zn (ug/g) Co (ug/g) Ba (ug/g) La (ug/g) Ce (ug/g) U (ug/g) Th (ug/g) Sc (ug/g) Pb (ug/g) Ge (ug/g) As (ug/g) Cl (ug/g) Scan # 224.336 224.391 224.446 224.501 224.556 224.611 224.666 224.721 224.776 224.831 224.886
1 Unknown LIB00001 2 J B 7.29 A New Wave Tempest 10 Nd:YAG (model 11293) 1064 10 12.48 A 1 0 3 not auto 49:43.0 1.45E+12 0 18.11 18.11 18.11 12.11 -21.89 4.11 -5.89 1.11 -8.89 -12.89 -7.89
2 Unknown LIB00001 2 J B 7.29 A New Wave Tempest 10 Nd:YAG (model 11293) 1064 10 12.48 A 1 0 3 not auto 49:44.0 1.45E+12 1 -16.56 -16.56 -16.56 14.44 7.44 -9.56 11.44 14.44 -11.56 10.44 19.44
3 Unknown LIB00001 2 J B 7.29 A New Wave Tempest 10 Nd:YAG (model 11293) 1064 10 12.48 A 1 0 3 not auto 49:45.0 1.45E+12 2 -13.06 -13.06 -13.06 3.94 -13.06 -12.06 7.94 17.94 -14.06 1.94 22.94
4 Unknown LIB00001 3 J B 7.29 A New Wave Tempest 10 Nd:YAG (model 11293) 1064 10 12.48 A 1 0 3 not auto 50:18.0 1.45E+12 0 -3.06 -3.06 -3.06 -6.06 24.94 9.94 -7.06 2.94 13.94 30.94 7.94
5 Unknown LIB00001 3 J B 7.29 A New Wave Tempest 10 Nd:YAG (model 11293) 1064 10 12.48 A 1 0 3 not auto 50:19.0 1.45E+12 1 2.22 2.22 2.22 -4.78 18.22 6.22 -8.78 -11.78 20.22 38.22 -11.78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment