Пример #1
0
 def split(self,xcol,func=None):
     """Splits the current AnalyseFile object into multiple AnalyseFile objects where each one contains the rows
     from the original object which had the same value of a given column.
     
     @param xcol The index of the column to look for values in. This can be a list in which case a DataFolder with groups
     with subfiles is built up by applying each item in the xcol list recursively.
     @param func A callable function that can be evaluated to find the value to determine which output object
     each row belongs in. If this is left as the default None then the column value is converted to a string and that is used.
     The function to be of the form f(x,r) where x is a single float value and r is a list of floats representing the complete row.
     The return value should be a hashable value. @a func can also be a list if @A xcol is a list, in which the @a func values are used along
     with the @a xcol values.
     @return A DataFolder object containing the individual AnalyseFile objects
     """
     from Stoner.Folders import DataFolder
     out=DataFolder(nolist=True)
     files=dict()
     morecols=[]
     morefuncs=None
     if isinstance(xcol,list) and len(xcol)<=1:
         xcol=xcol[0]
     elif isinstance(xcol,list):
         morecols=xcol[1:]
         xcol=xcol[0]
     if isinstance(func,list) and len(func)<=1:
         func=func[0]
     elif isinstance(func,list):
         morefuncs=func[1:]
         func=func[0]
     if func is None:
         for val in numpy.unique(self.column(xcol)):
             files[str(val)]=self.clone
             files[str(val)].data=self.search(xcol,val)
     else:
         xcol=self.find_col(xcol)
         for r in self.rows():
             x=r[xcol]
             key=func(x,r)
             if key not in files:
                 files[key]=self.clone
                 files[key].data=numpy.array([r])
             else:
                 files[key]=files[key]+r
     for k in files:
         files[k].filename="{}={}".format(xcol,k)
     if len(morecols)>0:
         for k in sorted(files.keys()):
             out.groups[k]=files[k].split(morecols,morefuncs)
     else:
         out.files=[files[k] for k in sorted(files.keys())]
     return out
# Import and interpolate the resistivity data
Py = Analysis.AnalyseFile('/Volumes/data/Projects/Spincurrents/Joe Batley/Measurements/SC004/Transport/Reference Data/Py Res/RN200_1um_rhovT_.txt')
Py.sort('Temperature')
Py.mulitply(r'$\rho$ ($\mu \Omega$ cm)',1e-8,replace=True,header=r'$\rho$ ($\Omega$ m)')
print Py.column_headers
PyR = interpolate.interp1d(Py.column('Temperature'),Py.column(r'$\rho$ ($\Omega$ m)'))

Cu = Stoner.DataFile('/Volumes/data/Projects/Spincurrents/Joe Batley/Measurements/SC004/Transport/Reference Data/Cu spacer resistance/Resistivity/SC004_2_T_Cu_resistivity_vs_T.txt')
Cu.sort('T (K)')
print Cu.column_headers
CuR = interpolate.interp1d(Cu.column('T (K)'),Cu.column(r'$\rho$ ($\Omega$m)'))

# Import Delta R vs T data and group
pattern = re.compile('SC004_(?P<L>\d*)_(?P<Device>\w*)_DeltaRvsT')
folder = DataFolder('/Volumes/data/Projects/Spincurrents/Joe Batley/Measurements/SC004/Transport/DeltaR_vs_Sep/Plot',pattern = pattern)
folder.group('L')
#T = folder[0].column('Sample Temp')
# Walk groups and interpolate
Spinsig = []
Spinsigerr = []
Sep = []
folder.walk_groups(interpSig,group=True,replace_terminal=True)
print Sep



# create a set of Parameters
params = Parameters()
#params.add('Lambda_N',   value = 500e-9,min=0)
params.add('Alpha', value = 0.4,min=0,max=1)
    avg['state']=f['state']
    avg['IVtemp']=f['IVtemp']
  avg.apply(row_avg, 1, replace = False, header = 'Mean Coef')
  avg.apply(err, 1, replace = False, header = 'Err Coef')
  return avg
  
def P_AP_col(folder,keys):
  coef = Stoner.DataFile()
  for f in folder:
    coef.add_column(f.column('Mean Coef'),str(f['IVtemp']))
    coef.add_column(f.column('Err Coef'),str(f['IVtemp'])+' Err')
  print coef
  return coef

pattern = re.compile('_(?P<IVtemp>\d*)K_NLDCIV_300uA_DigFilt10rep_(?P<state>\w*)_')
folder = DataFolder('/Users/Joe/PhD/Measurements/RN0151_4T/NLIVvsT/Both/',pattern = pattern)
folder.group(['state','IVtemp'])

folder.walk_groups(IV_group_Avg,group=True,replace_terminal=True)

folder.walk_groups(P_AP_col,group=True,replace_terminal=True)

print folder['AP']
  
for f in folder:
  
  for column in f.column_headers:
    plt.title(r'NL IV offset vs Temperature for Parallel (red) and Antiparallel (blue) State')
    plt.xlabel(r'Temperature (K)')
    plt.ylabel(r'$\alpha$ ($\mu$V/A) ')
    plt.ticklabel_format(style='plain', scilimits=(3 ,3))
  return a*x*x+b*x+c

def IV_group_Avg(folder,keys):
  avg = Analysis.AnalyseFile(folder[0])
  avg.del_column('Voltage')
  avg.del_column('Current')
  avg.del_column('Column 2')
  for f in folder:
    avg.add_column(f.Voltage,str(f.metadata['iterator']))
  avg.apply(func, 1, replace = False, header = 'Mean NLVoltage')
  avg.add_column(folder[1].column('Current'),'Current')
  return avg


pattern = re.compile('_(?P<IVtemp>\d*)K_')
folder = DataFolder('/Users/Joe/PhD/Measurements/RN0151_4T/NLIVvsT/70K-PandAP/',pattern = pattern)
folder.group('IVtemp')
folder.walk_groups(IV_group_Avg,group=True,replace_terminal=True)


for f in folder:
  offset = f.column('Mean')[0]
  Voltage = f.column('Mean') - offset
  plt.title(r'')
  plt.xlabel(r'Current ($\mu$A)')
  plt.ylabel(r'Non Local Voltage ($\mu$V)')
  plt.ticklabel_format(style='plain', scilimits=(3 ,3))
  plt.hold(True)
  plt.plot(1e6*f.column('Current'),1e6*Voltage,label = str(f['IVtemp']) + 'K')
  plt.grid(False)
plt.legend()
Пример #5
0
              3:525e-9,
              4:625e-9,
              5:725e-9,
              6:925e-9,
              7:1125e-9,
              8:1325e-9,
              9:1525e-9,}

  
  
  

#################### IMPORTDATA AND WALK GROUPS ####################

pattern = re.compile('_(?P<state>\d*)_(?P<IVtemp>\d*)K_(?P<Inj>\w*)_NLIV_300uA_')
folder = DataFolder('/Volumes/data/Projects/Spincurrents/Joe Batley/Measurements/SC004/Transport/SC004_3_T/NLIVvsHvsT_V_Inj',pattern = pattern)
#folder.group(['IVtemp','Inj'])
print folder[0]

Spinsig = []
Spinsig_error = []
beta = []
betaerr = []
Temp = []
heatdata = []
RSP=[]
RSAP=[]

Output = Stoner.DataFile()
Output['Sample ID'] = folder[0]['Sample ID']
folder.group('IVtemp')
Пример #6
0
import Stoner.Analysis as Analysis
import matplotlib.pyplot as plt # pylab imports numpy namespace as well, use pyplot in scripts
import Stoner.PlotFormats as SPF
import Stoner.Plot as SP
from Stoner.Folders import DataFolder
from lmfit import minimize, Parameters, Parameter, report_fit

class workfile(Analysis.AnalyseFile,SP.PlotFile):
    """A class that combines AnalyseFile and PlotFile together"""
    pass
 
def quad(x,a,b,c,d,e):
  return (a*x**2)+(b*x)+c+(d*x**4)+(e*x**3)

pattern = re.compile('_(?P<state>\d*)_(?P<IVtemp>\d*)K_(?P<Inj>\w*)_NLIV_300uA_')
folder = DataFolder('/Volumes/data/Projects/Spincurrents/Joe Batley/Measurements/SC004/Transport/SC004_8_B/NLIVvsHvsT_Py_Inj/', pattern = pattern,type=workfile) 


output = workfile()
output.metadata=folder[0].metadata
output['Sample ID'] = folder[0]['Sample ID']
output.column_headers=["T","P","P.err","AP","AP.err","DR","DR.err","beta","beta.err","quad","quad.err",'tri','tri.err']
#Use the labels attribute to store plot labels that are differnt from column names
output.labels=[r'T (K)',r'$R_s(P)$ (V/A)','Perr',r'$R_s(AP)$ (V/A)','APerr',r'$\Delta R_s$ (V/A)','DRerr ',r"\beta","beta_err",r"x^4","x^4 err",r"x^3","x^3 err"]



############ Calculate Delta R with error ############

APiterator = [5,10]
folder.group(['IVtemp'])
Пример #7
0
              8:'1325 nm',
              9:'1525 nm',}
              
Marker = {1:'325 nm',
          2:'o',
          3:'x',
          4:'s',
          5:'v',
          6:'^',
          7:'>',
          8:'D',
          9:'<',}
              

pattern = '*_DeltaRvsT.txt'
folder = DataFolder('/Volumes/data/Projects/Spincurrents/Joe Batley/Measurements/SC004/Transport/DeltaR_vs_Sep/Plot',pattern = pattern)
folder.sort()
for f in folder:
  
  f=Analysis.AnalyseFile(f)
  print f.column_headers
  f.rename('DeltaR err','Error')
  f.rename('Sample Temp','Temperature (K)')
  f.mulitply('DeltaR',1e3,replace=True,header=r'$\Delta \alpha$ (mV/A)')
  
  pattern = re.compile('_')     
  label = pattern.split(f['Sample ID'])  
  
  
  p=SP.PlotFile(f)
  p.setas="y.x"
class workfile(Analysis.AnalyseFile,SP.PlotFile):
    """A class that combines AnalyseFile and PlotFile together"""
    pass

def func(x):
  return numpy.mean(x)

def quad(x,a,b,c,d):
  return (a*x**4)+(b*x**2)+(c*x)+d
  
Seperation = {1:'325 nm',2:'425 nm',3:'525 nm',4:'625 nm', 5:'725 nm', 6:'925 nm',7:'1125 nm', 8:'1325 nm', 9:'1525 nm',} 

### Read in Data ###  
pattern = '*DeltaRsvsT.txt'
folder = DataFolder('/Volumes/stonerlab.leeds.ac.uk - -storage/data/Projects/Spincurrents/Joe Batley/Measurements/SC004/Transport/DeltaRvsT',pattern = pattern,type=workfile)  
folder.sort('Sample ID')  
plot = [2,4,6,7]
for Rs in folder:
    if int(Rs['Sample ID'].split('_')[1]) in plot:
        print Rs.column_headers
        Rs.template=SPF.JTBPlotStyle
        Rs.figure(1) # Creating new figures like this means we don;t reuse windows from run to run
        f=plt.gcf()
        f.set_size_inches((5.5,3.75),forward=True) # Set for A4 - will make wrapper for this someday
    
        #Rs.title = ''
        label = Seperation[int(Rs['Sample ID'].split('_')[1])]
        Rs.plot_xy("T","Voff",label =label ,linestyle='',marker='o',linewidth=2,markersize=5)
        #Rs.ylabel = r"$\Delta R_s$ (mV/A)"
        Rs.ylabel=r"$\frac{R_{s}^P + R_{s}^{AP}}{2}\ $ (mV/A)"
Пример #9
0
from Stoner.Util import format_error
import Stoner
from Stoner.Folders import DataFolder
import Stoner.Analysis as Analysis
import scipy.optimize
from lmfit import minimize, Parameters, Parameter, report_fit
import Stoner.PlotFormats as SPF
import Stoner.Plot as SP


 
def quad(x,a,b,c):
  return (a*x**2)+(b*x)+c


folder = DataFolder('/Volumes/data/Projects/Spincurrents/Joe Batley/Measurements/SC004/Transport/SC004_2_T/NLIVvsHat5K', pattern = '*.txt') 


############ Calculate Delta R with error ############

Rs = []
F = []
folder.sort('iterator')
for f in folder:
  a = Analysis.AnalyseFile(f)
  fit = a.curve_fit(quad,'Current','Voltage',p0=[20.0,1e-7,0.0], result=True, replace=False, header="fit",asrow=True)
  Rs.append(fit[2])
  F.append(a['Magnet Output']*1e-12)
  
Mean = (max(Rs)+min(Rs))/2
offset = (max(Rs)+min(Rs))/2
Пример #10
0
CuRvt.sort("Sample Temp")

Res_Cu = interpolate.interp1d(CuRvt[:, 3], CuRvt[:, 2])
Res_V = interpolate.interp1d(InjV[:, 3], InjV[:, 2])
Res_Py = interpolate.interp1d(InjPy[:, 3], InjPy[:, 2])

Acu = 130e-9 * 150e-9
Asi = 150e-9 * 16e-6
dz = 1000e-9
dx = 425e-9

Seperation = {1: 325e-9, 2: 425e-9, 3: 525e-9, 4: 625e-9, 5: 725e-9, 6: 925e-9, 7: 1125e-9, 8: 1325e-9, 9: 1525e-9}


#################### IMPORTDATA AND WALK GROUPS ####################

pattern = re.compile("_(?P<state>\d*)_(?P<IVtemp>\d*)K_(?P<Inj>\w*)_NLIV_300uA_")
folder = DataFolder(
    "/Volumes/data/Projects/Spincurrents/Joe Batley/Measurements/SC004/Transport/SC004_3_T/NLIVvsHvsT_BOTH",
    pattern=pattern,
)


Output = Stoner.DataFile()
Output["Sample ID"] = folder[0]["Sample ID"]
folder.group("IVtemp")
# print folder


folder.walk_groups(Py_V, group=True, replace_terminal=True)
    for i in fit.search('b',lambda x,y:x<mid,columns='b_err'):
        APerr+=i**2
    APerr = numpy.sqrt(APerr)
    temperature = fit.mean('T')
    
    alpha = 1e3
    row = numpy.array([temperature,P*alpha,Perr*alpha,AP*alpha,APerr*alpha,(P-AP)*alpha,alpha*numpy.sqrt((Perr**2)+(APerr**2)),mid*alpha,P-mid,AP-mid])    
    tmp+=row
    return tmp   
    
####### IMPORT DATA ######
sample = 'SC004_8_B'

filedir = '/Volumes/data/Projects/Spincurrents/Joe Batley/Measurements/'+sample.split('_')[0]+'/Transport/'+sample+'/NLIVvsHvsT_Py_Inj/'
filename = re.compile(sample+'_6221-2182 DC IV_Magnet Power Supply Multi-segment_(?P<iterator>\d*)_(?P<IV_Temp>\d*)K_(?P<inj>\w*)_NLIV_300uA_.txt')
folder = DataFolder(filedir, pattern = filename,type=workfile) # Use type to preset the DataFile subclass




####### CREATE OUTPUT FILE ######
DeltaR = workfile() #Avoid creating temporary python lists, use the final DataFile like object to hold the data
DeltaR.metadata=folder[0].metadata
DeltaR['Sample ID'] = folder[0]['Sample ID']
DeltaR.column_headers=["T","P","Perr","AP","APerr","DR mV","DRerr","Voff","Ptest","APtest"]
#Use the labels attribute to store plot labels that are differnt from column names
DeltaR.labels=[r'T (K)',r'$R_s(P)$ (mV/A)','Perr',r'$R_s(AP)$ (mV/A)','APerr',r'$\Delta R_s$ (mV/A)','DRerr mV',r'$R_s$ offset (mV/A)',"Test Columns"]


####### Group into Temp - walk group and colapse each temp into one file ######
folder.group('IV_Temp')