#subtract bias file (bias files are also Infragold calibrated)
for index, file in enumerate(sample_filenames):
	#data is stored in dictionary
	#define key based on file name
	key=file.split('tests/',1)[-1]
	key=key.rstrip('raw_.txt')
	#store wavelength and reflectance data in key
	data[key+'_wavelength']=[]
	data[key+'_reflectance']=[]
	###########################################################
	#comment these next 2 lines out if you are not using bias correction
	data_bias[key+'_wavelength']=[]
	data_bias[key+'_reflectance']=[]
	data_corr[key+'_reflectance']=[]
	#obtain Infragold calibrated data
	data[key+'_wavelength'], data[key+'_reflectance'] = IR_analysis.calibrate_data(file, IG_filenames[index])

	###########################################################
	#comment these next lines out if you are not using bias correction
	#obtain Infragold calibrated bias files
	data_bias[key+'_wavelength'], data_bias[key+'_reflectance'] = IR_analysis.calibrate_data(bias_filenames[index], IG_filenames[index])
	#bias correction
	data_corr[key+'_reflectance'] = IR_analysis.bias_correct(data[key+'_reflectance'], data_bias[key+'_reflectance'])
	print 'finished reading file: ', key

print 'plotting...'


#########################################################
#plot IR spectra
#read all data
#divide data by Infragold file
#subtract bias file (bias files are also Infragold calibrated)

#AOTF IR spectrometer benchtop (2012)
for index, file in enumerate(sample_filenames_H2O_corr):
	#data stored in dictionary
	#define key based on file name
	key=file.split('samples/',1)[-1]
	key=key.rstrip('.txt')
	#store wavelength and reflectance data in key
	data[key+'_wavelength']=[]
	data[key+'_reflectance']=[]
	#obtain Infragold calibrated data
	data[key+'_wavelength'], data[key+'_reflectance'] = IR_analysis.calibrate_data_H2O_corr(file)
	print 'finished reading file: ', key
	IR_analysis.write_file(key, data[key+'_wavelength'], data[key+'_reflectance'])

#GSFC AOTF, comma seperated txt files (2012 and later)
for index, file in enumerate(sample_filenames_GSFC_comma):
	#data stored in dictionary
	#define key based on file name
	key=file.split('samples/',1)[-1]
	key=key.rstrip('.txt')
	#store wavelength and reflectance data in key
	data[key+'_wavelength']=[]
	data[key+'_reflectance']=[]
	#obtain Infragold calibrated data
	data[key+'_wavelength'], data[key+'_reflectance'] = IR_analysis.calibrate_data(file, 1)
	print 'finished reading file: ', key