@@ -37,6 +37,7 @@ def _up_down(data):
3737 for d in f [grp ][1 :]:
3838 ret [i ]= ret [i ]+ d
3939 ret [i ].sort (data .setas ._get_cols ('xcol' ))
40+ ret [i ].setas = data .setas .clone
4041 return ret
4142
4243
@@ -166,12 +167,11 @@ def split_up_down(data, col=None, folder=None):
166167 """
167168 if col is None :
168169 col = data .setas ["x" ]
169- a = _AF_ (data )
170- width = len (a ) / 10
170+ width = len (data ) / 10
171171 if width % 2 == 0 : # Ensure the window for Satvisky Golay filter is odd
172172 width += 1
173- peaks = list (a .peaks (col , width ,xcol = False , peaks = True , troughs = False ))
174- troughs = list (a .peaks (col , width , xcol = False , peaks = False , troughs = True ))
173+ peaks = list (data .peaks (col , width ,xcol = False , peaks = True , troughs = False ))
174+ troughs = list (data .peaks (col , width , xcol = False , peaks = False , troughs = True ))
175175 if len (peaks ) > 0 and len (troughs ) > 0 : #Ok more than up down here
176176 order = peaks [0 ] < troughs [0 ]
177177 elif len (peaks ) > 0 : #Rise then fall
@@ -180,7 +180,7 @@ def split_up_down(data, col=None, folder=None):
180180 order = False
181181 else : #No peaks or troughs so just return a single rising
182182 return ([data ], [])
183- splits = [0 , len (a )]
183+ splits = [0 , len (data )]
184184 splits .extend (peaks )
185185 splits .extend (troughs )
186186 splits .sort ()
@@ -348,7 +348,7 @@ def hysteresis_correct(data, **kargs):
348348 #Get xcol and ycols from kargs if specified
349349 xc = kargs .pop ("xcol" ,data .find_col (data .setas ["x" ]))
350350 yc = kargs .pop ("ycol" ,data .find_col (data .setas ["y" ]))
351- setas = data .setas
351+ setas = data .setas . clone
352352 setas [xc ]= "x"
353353 setas [yc ]= "y"
354354 data .setas = setas
@@ -385,6 +385,8 @@ def hysteresis_correct(data, **kargs):
385385 Ms = array ([p1 [0 ],p2 [0 ]])
386386 Ms = list (Ms - mean (Ms ))
387387
388+
389+
388390 data ["Ms" ] = Ms #mean(Ms)
389391 data ["Ms Error" ] = perr [0 ]/ 2
390392 data ["Offset Moment" ] = pm [0 ]
@@ -406,6 +408,7 @@ def hysteresis_correct(data, **kargs):
406408 m_sat = [p1 [0 ]+ perr [0 ],p2 [0 ]- perr [0 ]]
407409 Mr = [None ,None ]
408410 Mr_err = [None ,None ]
411+
409412 for i ,(d ,sat ) in enumerate (zip ([up ,down ],m_sat )):
410413 hc = d .threshold (0. ,all_vals = True ,rising = True ,falling = True ) # Get the Hc value
411414 Hc [i ]= mean (hc )
@@ -438,14 +441,7 @@ def hysteresis_correct(data, **kargs):
438441 i = argmax (bh )
439442 data ["BH_Max" ] = max (bh )
440443 data ["BH_Max_H" ] = data .x [i ]
441- mr1 = data .threshold (0.0 , col = xc , xcol = yc , rising = True , falling = False )
442- mr2 = data .threshold (0.0 , col = xc , xcol = yc , rising = False , falling = True )
443-
444- data ["Remenance" ] = abs ((mr2 - mr1 ) / 2 )
445-
446- h_sat_data = data .search (data .setas ["y" ], lambda x , r : low_m <= x <= high_m )[:, xc ]
447- if len (h_sat_data )> 0 :
448- data ["H_sat" ] = (min (h_sat_data ), max (h_sat_data ))
449444
450445 data ["Area" ] = data .integrate ()
451446 return cls (data )
447+ return cls (data )
0 commit comments