vc.inclMin = 10  # if set to 0 will not add values close to 0 Ib
folder1 = fname + 'ON//'
vc.filein1 = folder1 + fname + 'CovMat_cI1I1.mtx'
vc.filein2 = folder1 + fname + 'CovMat_cQ1Q1.mtx'
vc.filein3 = folder1 + fname + 'CovMat_cI2I2.mtx'
vc.filein4 = folder1 + fname + 'CovMat_cQ2Q2.mtx'
vc.filein6 = folder1 + fname + 'CovMat_cI1I2.mtx'
vc.filein7 = folder1 + fname + 'CovMat_cI1Q2.mtx'
vc.filein8 = folder1 + fname + 'CovMat_cQ1I2.mtx'
vc.filein9 = folder1 + fname + 'CovMat_cQ1Q2.mtx'
vc.filein10 = folder1 + fname + 'CovMat_cI1Q1.mtx'
vc.filein11 = folder1 + fname + 'CovMat_cI2Q2.mtx'
vc.filein5 = fname + 'Vx1k.mtx'
vc.RTR = 1012 * 1e3  # RT resistor for
vc.load_and_go()
crop_within = sn.find_nearest(vc.I, -6.0e-6), sn.find_nearest(vc.I, 6.0e-6)
crop_outside = sn.find_nearest(vc.I, -19e-6), sn.find_nearest(vc.I, 20e-6)
vc.crop = [crop_within, crop_outside]

fname2 = '1150_'
vc2 = sn.variable_carrier()
vc2.resultfolder = fname2+'//'
folder = '/Volumes/QDP-Backup-2/BenS/DCE2015-16/data_May20/'
vc2.fifolder = folder
vc2.snr = 4.5
vc2.cpt = 5
vc2.LP = 0.0
vc2.T = 0.007
vc2.Tn1 = 3.9
vc2.Tn2 = 4.6
vc2.G1 = 6.45e9
vc.resultfolder = 'f2//'

pathf1 = '/Volumes/QDP-Backup-2/BenS/DCE2015-16/data_Jul15/1206_SN22_1/'
savename = '1150_LogN.mtx'
savename2 = '1150_ineqSq.mtx'
vc.fifolder = ''
vc.filein1 = pathf1 + '1206_SN22_1ON//1206_SN22_1CovMat_cI1I1.mtx'
vc.filein2 = pathf1 + '1206_SN22_1ON//1206_SN22_1CovMat_cQ1Q1.mtx'
vc.filein3 = pathf1 + '1206_SN22_1ON//1206_SN22_1CovMat_cI2I2.mtx'
vc.filein4 = pathf1 + '1206_SN22_1ON//1206_SN22_1CovMat_cQ2Q2.mtx'
vc.filein6 = pathf1 + '1206_SN22_1ON//1206_SN22_1CovMat_cI1I2.mtx'
vc.filein7 = pathf1 + '1206_SN22_1ON//1206_SN22_1CovMat_cI1Q2.mtx'
vc.filein8 = pathf1 + '1206_SN22_1ON//1206_SN22_1CovMat_cQ1I2.mtx'
vc.filein9 = pathf1 + '1206_SN22_1ON//1206_SN22_1CovMat_cQ1Q2.mtx'
vc.filein10 = pathf1 + '1206_SN22_1ON//1206_SN22_1CovMat_cI1Q1.mtx'
vc.filein11 = pathf1 + '1206_SN22_1ON//1206_SN22_1CovMat_cI2Q2.mtx'
vc.filein5 = pathf1 + '1206_SN22_1Vx1k.mtx'
vc.RTR = 1012 * 1e3  # RT resistor for
vc.load_and_go()

# create crop vector for the fitting
crop_within = SNfit.find_nearest(vc.I, -6.0e-6), SNfit.find_nearest(vc.I, 6.0e-6)
print 'crop_within', crop_within
crop_outside = SNfit.find_nearest(vc.I, -19e-6), SNfit.find_nearest(vc.I, 20e-6)
print 'crop_outside', crop_outside
vc.crop = [crop_within, crop_outside]
print 'vc.crop', vc.crop

snd, r1, r2, r3, r4 = SNfit.DoSNfits(vc, True)  # run fits