Example #1
0
    def subtractline(self, ms=150, fitrange=('98%', '100%')):
        ''' Subtract a line such that the loop end points are at Ms '''
        result = copy.copy(self)
        result.M = []
        for H,M in zip(self.H, self.M):
            # find current end points, subtract to get close
            amp, offs = hys.normalize(H, M, fitrange=('95%', '100%'), fitbranch=False)
            maxH = max(abs(H))
            M = M - (amp-ms)*H/maxH
            # Do it again to get decent result
            amp, offs = hys.normalize(H, M, fitrange=fitrange, fitbranch=False)
            result.M.append(M - (amp-ms)*H/maxH)

        return result
Example #2
0
    def normalize(self, fitrange=('85%', '99%'), usefirst=False):
        '''
        Normalize loop based on data in fit range
        '''
        result = copy.copy(self)
        result.M = []

        fitrange = hys.valid_fitrange(fitrange)

        first = True

        for H,M in zip(self.H, self.M):

            if not first and usefirst:
                result.M.append((M - offset) / amp)
                continue

            amp, offset = hys.normalize(H, M, fitrange, fitbranch=False)

            result.M.append((M - offset) / amp)
            first = False

        result.log += '{}: Normalized, fitrange={}, usefirst={}\n'.format(_now(), fitrange, usefirst)
        return result