Search in sources :

Example 1 with HKL

use of ffx.crystal.HKL in project ffx by mjschnie.

the class SigmaAMinimize method setWEstimate.

private void setWEstimate() {
    // generate initial w estimate
    ReflectionSpline spline = new ReflectionSpline(reflectionList, refinementData.nbins);
    int[] nmean = new int[refinementData.nbins];
    for (int i = 0; i < refinementData.nbins; i++) {
        nmean[i] = 0;
    }
    double mean = 0.0, tot = 0.0;
    double[][] fc = refinementData.fctot;
    double[][] fo = refinementData.fsigf;
    for (HKL ih : reflectionList.hkllist) {
        int i = ih.index();
        if (ih.allowed() == 0.0 || Double.isNaN(fc[i][0]) || Double.isNaN(fo[i][0])) {
            continue;
        }
        double s2 = Crystal.invressq(crystal, ih);
        double epsc = ih.epsilonc();
        ComplexNumber fct = new ComplexNumber(fc[i][0], fc[i][1]);
        double ecscale = spline.f(s2, refinementData.fcesq);
        double eoscale = spline.f(s2, refinementData.foesq);
        double ec = fct.times(sqrt(ecscale)).abs();
        double eo = fo[i][0] * sqrt(eoscale);
        double wi = pow(eo - ec, 2.0) / epsc;
        nmean[spline.i1()]++;
        tot++;
        x[spline.i1() + refinementData.nbins] += (wi - x[spline.i1() + refinementData.nbins]) / nmean[spline.i1()];
        mean += (wi - mean) / tot;
    }
    logger.info(String.format(" Starting mean w:    %8.3f", mean));
    logger.info(String.format(" Starting w scaling: %8.3f", 1.0 / mean));
    for (int i = 0; i < refinementData.nbins; i++) {
        x[i] -= x[i + refinementData.nbins];
        x[i] *= scaling[i];
        scaling[i + refinementData.nbins] = 1.0 / mean;
        x[i + refinementData.nbins] *= scaling[i + refinementData.nbins];
    }
    sigmaAEnergy.setScaling(scaling);
}
Also used : ReflectionSpline(ffx.crystal.ReflectionSpline) HKL(ffx.crystal.HKL) ComplexNumber(ffx.numerics.ComplexNumber)

Example 2 with HKL

use of ffx.crystal.HKL in project ffx by mjschnie.

the class CrystalStats method getRFree.

/**
 * simply return the current Rfree value
 *
 * @return rfree value as a percent
 */
public double getRFree() {
    double sum = 0.0;
    double sumfo = 0.0;
    for (HKL ih : reflectionlist.hkllist) {
        int i = ih.index();
        // ignored cases
        if (Double.isNaN(fc[i][0]) || Double.isNaN(fo[i][0]) || fo[i][1] <= 0.0) {
            continue;
        }
        // spline setup
        double ss = Crystal.invressq(crystal, ih);
        double fh = spline.f(ss, refinementdata.spline);
        ComplexNumber c = new ComplexNumber(fc[i][0], fc[i][1]);
        if (refinementdata.isFreeR(i)) {
            sum += abs(abs(fo[i][0]) - fh * abs(c.abs()));
            sumfo += abs(fo[i][0]);
        }
    }
    rfree = (sum / sumfo) * 100.0;
    return rfree;
}
Also used : HKL(ffx.crystal.HKL) ComplexNumber(ffx.numerics.ComplexNumber)

Example 3 with HKL

use of ffx.crystal.HKL in project ffx by mjschnie.

the class CrystalStats method getSigmaA.

/**
 * simply return the current sigmaA value
 *
 * @return sigmaA
 */
public double getSigmaA() {
    double sum = 0.0;
    int nhkl = 0;
    ReflectionSpline sigmaaspline = new ReflectionSpline(reflectionlist, refinementdata.sigmaa.length);
    for (HKL ih : reflectionlist.hkllist) {
        int i = ih.index();
        // ignored cases
        if (Double.isNaN(fc[i][0]) || Double.isNaN(fo[i][0]) || fo[i][1] <= 0.0) {
            continue;
        }
        // spline setup
        double ss = Crystal.invressq(crystal, ih);
        double fh = spline.f(ss, refinementdata.spline);
        double sa = sigmaaspline.f(ss, refinementdata.sigmaa);
        nhkl++;
        sum += (sa - sum) / nhkl;
    }
    return sum;
}
Also used : ReflectionSpline(ffx.crystal.ReflectionSpline) HKL(ffx.crystal.HKL)

Example 4 with HKL

use of ffx.crystal.HKL in project ffx by mjschnie.

the class CrystalStats method printHKLStats.

/**
 * print HKL statistics/completeness info
 */
public void printHKLStats() {
    double[][] res = new double[n][2];
    int[][] nhkl = new int[n][3];
    for (int i = 0; i < n; i++) {
        res[i][0] = Double.NEGATIVE_INFINITY;
        res[i][1] = Double.POSITIVE_INFINITY;
    }
    for (HKL ih : reflectionlist.hkllist) {
        int i = ih.index();
        int b = ih.bin();
        // ignored cases
        if (Double.isNaN(fo[i][0]) || fo[i][1] <= 0.0) {
            nhkl[b][2]++;
            continue;
        }
        // determine res limits of each bin
        double rh = Crystal.res(crystal, ih);
        if (rh > res[b][0]) {
            res[b][0] = rh;
        }
        if (rh < res[b][1]) {
            res[b][1] = rh;
        }
        // count the reflection
        if (freer[i] == refinementdata.rfreeflag) {
            nhkl[b][1]++;
        } else {
            nhkl[b][0]++;
        }
    }
    StringBuilder sb = new StringBuilder(String.format("\n %15s | %8s|%9s| %7s | %7s | %s\n", "Res. Range", " HKL (R)", " HKL (cv)", " Bin", " Miss", "Complete (%)"));
    for (int i = 0; i < n; i++) {
        sb.append(String.format(" %7.3f %7.3f | ", res[i][0], res[i][1]));
        sb.append(String.format("%7d | %7d | %7d | %7d | ", nhkl[i][0], nhkl[i][1], nhkl[i][0] + nhkl[i][1], nhkl[i][2]));
        sb.append(String.format("%6.2f\n", (((double) nhkl[i][0] + nhkl[i][1]) / (nhkl[i][0] + nhkl[i][1] + nhkl[i][2])) * 100.0));
    }
    sb.append(String.format(" %7.3f %7.3f | ", res[0][0], res[n - 1][1]));
    int sum1 = 0;
    int sum2 = 0;
    int sum3 = 0;
    for (int i = 0; i < n; i++) {
        sum1 += nhkl[i][0];
        sum2 += nhkl[i][1];
        sum3 += nhkl[i][2];
    }
    sb.append(String.format("%7d | %7d | %7d | %7d | ", sum1, sum2, sum1 + sum2, sum3));
    sb.append(String.format("%6.2f\n", (((double) sum1 + sum2) / (sum1 + sum2 + sum3)) * 100.0));
    sb.append(String.format(" Number of reflections if complete: %10d", refinementdata.n));
    nobshkl = sum1 + sum2;
    highnobshkl = nhkl[n - 1][0] + nhkl[n - 1][1];
    nobsrfree = sum2;
    highnobsrfree = nhkl[n - 1][1];
    completeness = (((double) sum1 + sum2) / (sum1 + sum2 + sum3)) * 100.0;
    highcompleteness = (((double) nhkl[n - 1][0] + nhkl[n - 1][1]) / (nhkl[n - 1][0] + nhkl[n - 1][1] + nhkl[n - 1][2])) * 100.0;
    if (print) {
        logger.info(sb.toString());
    }
}
Also used : HKL(ffx.crystal.HKL)

Example 5 with HKL

use of ffx.crystal.HKL in project ffx by mjschnie.

the class CrystalStats method getSigmaW.

/**
 * simply return the current sigmaW value
 *
 * @return sigmaW
 */
public double getSigmaW() {
    double sum = 0.0;
    int nhkl = 0;
    ReflectionSpline sigmaaspline = new ReflectionSpline(reflectionlist, refinementdata.sigmaa.length);
    for (HKL ih : reflectionlist.hkllist) {
        int i = ih.index();
        // ignored cases
        if (Double.isNaN(fc[i][0]) || Double.isNaN(fo[i][0]) || fo[i][1] <= 0.0) {
            continue;
        }
        // spline setup
        double ss = Crystal.invressq(crystal, ih);
        double fh = spline.f(ss, refinementdata.spline);
        double wa = sigmaaspline.f(ss, refinementdata.sigmaw);
        nhkl++;
        sum += (wa - sum) / nhkl;
    }
    return sum;
}
Also used : ReflectionSpline(ffx.crystal.ReflectionSpline) HKL(ffx.crystal.HKL)

Aggregations

HKL (ffx.crystal.HKL)27 ComplexNumber (ffx.numerics.ComplexNumber)8 IOException (java.io.IOException)6 Test (org.junit.Test)6 ReflectionSpline (ffx.crystal.ReflectionSpline)5 ReflectionList (ffx.crystal.ReflectionList)4 BufferedReader (java.io.BufferedReader)4 File (java.io.File)4 FileReader (java.io.FileReader)4 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)4 Crystal (ffx.crystal.Crystal)3 Resolution (ffx.crystal.Resolution)3 ByteBuffer (java.nio.ByteBuffer)3 ByteOrder (java.nio.ByteOrder)3 ParallelTeam (edu.rit.pj.ParallelTeam)2 SymOp (ffx.crystal.SymOp)2 ForceFieldEnergy (ffx.potential.ForceFieldEnergy)2 MolecularAssembly (ffx.potential.MolecularAssembly)2 Atom (ffx.potential.bonded.Atom)2 DiffractionRefinementData (ffx.xray.DiffractionRefinementData)2