示例#1
0
    def resolution_merged_isigma(self, limit=None, log=None):
        """Compute a resolution limit where either Mn(I/sigma) = 1.0 (limit if
        set) or the full extent of the data."""

        if limit is None:
            limit = Flags.get_misigma()

        bins, ranges = self.get_resolution_bins()

        misigma_s = get_positive_values(
            [self.calculate_merged_isigma(bin) for bin in bins]
        )
        s_s = [1.0 / (r[0] * r[0]) for r in ranges][: len(misigma_s)]

        if min(misigma_s) > limit:
            return 1.0 / math.sqrt(max(s_s))

        misigma_f = log_fit(s_s, misigma_s, 6)

        if log:
            fout = open(log, "w")
            for j, s in enumerate(s_s):
                d = 1.0 / math.sqrt(s)
                o = misigma_s[j]
                m = misigma_f[j]
                fout.write("%f %f %f %f\n" % (s, d, o, m))
            fout.close()

        try:
            r_misigma = 1.0 / math.sqrt(interpolate_value(s_s, misigma_f, limit))
        except Exception:
            r_misigma = 1.0 / math.sqrt(max(s_s))

        return r_misigma
示例#2
0
    def new_resolution_unmerged_isigma(self, limit=None, log=None):
        """Compute a resolution limit where either I/sigma = 1.0 (limit if
        set) or the full extent of the data."""

        if limit is None:
            limit = Flags.get_isigma()

        bins, ranges = self.get_resolution_bins()

        isigma_s = get_positive_values(
            [self.calculate_unmerged_isigma(bin) for bin in bins]
        )

        s_s = [1.0 / (r[0] * r[0]) for r in ranges][: len(isigma_s)]

        if min(isigma_s) > limit:
            return 1.0 / math.sqrt(max(s_s))

        for _l, s in enumerate(isigma_s):
            if s < limit:
                break

        if _l > 10 and _l < (len(isigma_s) - 10):
            start = _l - 10
            end = _l + 10
        elif _l <= 10:
            start = 0
            end = 20
        elif _l >= (len(isigma_s) - 10):
            start = -20
            end = -1

        _s_s = s_s[start:end]
        _isigma_s = isigma_s[start:end]

        _isigma_f = log_fit(_s_s, _isigma_s, 3)

        if log:
            fout = open(log, "w")
            for j, s in enumerate(_s_s):
                d = 1.0 / math.sqrt(s)
                o = _isigma_s[j]
                m = _isigma_f[j]
                fout.write("%f %f %f %f\n" % (s, d, o, m))
            fout.close()

        try:
            r_isigma = 1.0 / math.sqrt(interpolate_value(_s_s, _isigma_f, limit))
        except Exception:
            r_isigma = 1.0 / math.sqrt(max(_s_s))

        return r_isigma
示例#3
0
文件: Merger.py 项目: ndevenish/xia2
    def resolution_rmerge(self, limit=None, log=None):
        '''Compute a resolution limit where either rmerge = 1.0 (limit if
    set) or the full extent of the data. N.B. this fit is only meaningful
    for positive values.'''

        if limit is None:
            limit = Flags.get_rmerge()

        bins, ranges = self.get_resolution_bins()

        if limit == 0.0:
            return ranges[-1][0]

        rmerge_s = get_positive_values(
            [self.calculate_rmerge(bin) for bin in bins])

        s_s = [1.0 / (r[0] * r[0]) for r in ranges][:len(rmerge_s)]

        if limit == 0.0:
            return 1.0 / math.sqrt(max(s_s))

        if limit > max(rmerge_s):
            return 1.0 / math.sqrt(max(s_s))

        rmerge_f = log_inv_fit(s_s, rmerge_s, 6)

        if log:
            fout = open(log, 'w')
            for j, s in enumerate(s_s):
                d = 1.0 / math.sqrt(s)
                o = rmerge_s[j]
                m = rmerge_f[j]
                fout.write('%f %f %f %f\n' % (s, d, o, m))
            fout.close()

        try:
            r_rmerge = 1.0 / math.sqrt(interpolate_value(s_s, rmerge_f, limit))
        except Exception:
            r_rmerge = 1.0 / math.sqrt(max(s_s))

        return r_rmerge