Beispiel #1
0
double Reflection::meanIntensityWithExclusion(std::string *filename, int start, int end)
{
    if (filename == NULL)
        return meanIntensity(start, end);
    
    if (end == 0)
        end = acceptedCount();
    double total_intensity = 0;
    double weight = 0;
    int accepted = acceptedCount();
    
    for (int i = start; i < end; i++)
    {
        MillerPtr miller = this->acceptedMiller(i);
        
        if (accepted > 2 && miller->getFilename() == *filename)
            continue;
            
        total_intensity += miller->intensity();
        weight += 1;
    }
    
    total_intensity /= weight;
    
    return total_intensity;
}
Beispiel #2
0
double Reflection::meanSigma(bool friedel)
{
    int num = (int)millerCount();
    int count = 0;
    
    double total_sigi = 0;
    
    for (int i = 0; i < num; i++)
    {
        MillerPtr aMiller = miller(i);
        
        if (aMiller->accepted())
        {
            total_sigi += aMiller->getSigma();
            count++;
        }
    }
    
    total_sigi /= count;
    
    if (total_sigi == 0)
        return nan(" ");
    
    return total_sigi;
}
Beispiel #3
0
double Reflection::meanIntensity(bool withCutoff, int start, int end)
{
    if (end == 0)
        end = withCutoff ? acceptedCount() : millerCount();
    
    double total_intensity = 0;
    double total_weights = 0;
    
    for (int i = start; i < end; i++)
    {
        MillerPtr miller = withCutoff ? this->acceptedMiller(i) : this->miller(i);

        double weight = miller->getWeight(withCutoff);
        double intensity = miller->intensity(withCutoff);
        
        if (weight <= 0)
            continue;
        
        total_intensity += intensity * weight;
        total_weights += weight;
    }
    
    total_intensity /= total_weights;
    
    return total_intensity;
}
Beispiel #4
0
void Shoebox::complexShoebox(double wavelength, double bandwidth, double radius)
{
    MillerPtr tempMiller = getMiller();
    
    if (!tempMiller)
    {
        return;
    }
    
    MatrixPtr mat;
    mat = tempMiller->getMatrix();
    
    vec hkl = new_vector(tempMiller->getH(), tempMiller->getK(), tempMiller->getL());
    mat->multiplyVector(&hkl);
    
    double hk = sqrt(hkl.h * hkl.h + hkl.k * hkl.k);
    
    double maxHK = hk + radius;
    double minHK = hk - radius;
    
    double minWave = wavelength - bandwidth * bandwidthMultiplier;
    double maxWave = wavelength + bandwidth * bandwidthMultiplier;
    
    double max_mm = (maxHK * detectorDistance / (1 / maxWave + hkl.l));
    double min_mm = (minHK * detectorDistance / (1 / minWave + hkl.l));
    
    double width_mm = (radius * detectorDistance / (1 / wavelength));
    
    double mmDiff = max_mm - min_mm;
    
    double widthLeak = 1 * pixelLeak;

    double pixelHeight = mmDiff / mmPerPixel + pixelLeak;
    double pixelWidth = 2 * width_mm / mmPerPixel + widthLeak;
    
    double angle = cartesian_to_angle(hkl.h, hkl.k);
    angle += M_PI / 2;
    
    Box smallBox;
    Box newShoebox;
    compressBigShoebox(pixelWidth, pixelHeight, angle, smallBox);
    chopBox(smallBox);
    centreShoebox(smallBox);
    putBoxOnPaddedBackground(smallBox, newShoebox);

    shoebox = newShoebox;
    printShoebox();
}
Beispiel #5
0
void Reflection::addMiller(MillerPtr miller)
{
    miller->setResolution(resolution);
    millers.push_back(miller);
    
    if (reflectionIds.size() == 0)
    {
        generateReflectionIds();
    }
}
Beispiel #6
0
double Reflection::meanIntensity(int start, int end)
{
    if (end == 0)
        end = acceptedCount();
    
    double total_intensity = 0;
    double weight = 0;
    
    for (int i = start; i < end; i++)
    {
        MillerPtr miller = this->acceptedMiller(i);
        
        total_intensity += miller->intensity();
        weight += 1;
    }
    
    total_intensity /= weight;
    
    return total_intensity;
}
Beispiel #7
0
double Reflection::meanPartiality(bool withCutoff)
{
    int num = millerCount();
    double total_partiality = 0;
    int count = 0;
    
    for (int i = 0; i < num; i++)
    {
        MillerPtr miller = millers[i];
        
        if ((miller->accepted() && withCutoff) || !withCutoff)
        {
            total_partiality += miller->getPartiality();
            count++;
        }
    }
    
    total_partiality /= count;
    
    return total_partiality;
}
Beispiel #8
0
double Miller::averageRawIntensity(vector<MillerPtr> millers)
{
    double allIntensities = 0;
    int num = 0;
    
    for (int i = 0; i < millers.size(); i++)
    {
        MillerPtr miller = millers[i];
        
        double anIntensity = miller->getRawIntensity();
        
        if (anIntensity != anIntensity)
            continue;
        
        allIntensities += anIntensity;
        num++;
    }
    
    allIntensities /= num;
    
    return allIntensities;
}
Beispiel #9
0
double Reflection::meanSigma()
{
    int num = (int)millers.size();
    int count = 0;
    
    double total_sigi = 0;
    
    for (int i = 0; i < num; i++)
    {
        MillerPtr miller = millers[i];
        
        if (miller->accepted())
        {
            total_sigi += miller->getSigma();
            count++;
        }
    }
    
    total_sigi /= count;
    
    return total_sigi;
}
Beispiel #10
0
double Reflection::meanWeight()
{
    int num = (int)millers.size();
    int count = 0;
    
    double total_weight = 0;
    
    for (int i = 0; i < num; i++)
    {
        MillerPtr miller = millers[i];
        
        if (miller->accepted())
        {
            total_weight += 1 / pow(miller->getSigma(), 2);
            count++;
        }
    }
    
    total_weight /= count;
    
    return total_weight;
}
Beispiel #11
0
double Reflection::meanWeight(bool withCutoff)
{
    int num = (int)millerCount();
    int count = 0;
    
    double total_weight = 0;
    
    for (int i = 0; i < num; i++)
    {
        MillerPtr miller = millers[i];
        
        if ((miller->accepted() && withCutoff) || !withCutoff)
        {
            total_weight += miller->getWeight(withCutoff);
            count++;
        }
    }
    
    total_weight /= count;
    
    return total_weight;
}
Beispiel #12
0
Shoebox::Shoebox(MillerPtr parent)
{
    miller = parent;
    
    if (parent)
    {
        ImagePtr image = parent->getImage();
        mmPerPixel = image->getMmPerPixel();
        detectorDistance = image->getDetectorDistance();
    }
    
    pixelLeak = FileParser::getKey("PIXEL_LEAK", PIXEL_LEAK);
    bandwidthMultiplier = FileParser::getKey("SHOEBOX_BANDWIDTH_MULTIPLIER", SHOEBOX_BANDWIDTH_MULTIPLIER);
}
Beispiel #13
0
/**
 Takes the h,k,l values, flips the Miller and folds back onto the asymmetric unit. If the Miller indices are the same, it is twinned. (Not suitable for non-hemihedral twinning at the moment)
 */
bool Reflection::isTwinned()
{
    if (millerCount() > 0)
    {
        int h, k, l = 0;
        int trueH = miller(0)->getH();
        int trueK = miller(0)->getK();
        int trueL = miller(0)->getL();
        
        miller(0)->flip();
        MillerPtr firstMiller = miller(0);
        ccp4spg_put_in_asu(spaceGroup, firstMiller->getH(),
                           firstMiller->getK(), firstMiller->getL(), &h, &k, &l);
        miller(0)->flip();
        
        return (h == trueH && k == trueK && l == trueL);

    }
    else
    {
        return false;
    }
}
Beispiel #14
0
void Reflection::reflectionDescription()
{
    int acceptedCount = 0;
    
    std::ostringstream logged;
    
    for (int i = 0; i < millerCount(); i++)
    {
        MillerPtr miller = this->miller(i);
        logged << miller->getH() << "\t" << miller->getK() << "\t" << miller->getL() << "\t"
        << miller->getRawIntensity() << "\t" << miller->getPartiality()
        << "\t" << miller->getSigma() << "\t" << miller->getFilename()
        << std::endl;
        if (miller->accepted())
            acceptedCount++;
    }
    logged << std::endl;
    
    Logger::mainLogger->addStream(&logged);
}
Beispiel #15
0
void GraphDrawer::plotPolarisation(vector<MtzPtr> mtzs)
{
    int count = 36;
    int divide = 360 / count;
    
    std::map<int, double> histogram;
    std::map<int, int> counts;
    
    for (int i = 0; i < mtzs.size(); i++)
    {
        for (int j = 0; j < mtzs[i]->reflectionCount(); j++)
        {
            if (!mtzs[i]->reflection(j)->betweenResolutions(1.8, 1.4))
                continue;
            
            for (int k = 0; k < mtzs[i]->reflection(j)->millerCount(); k++)
            {
                MillerPtr miller = mtzs[i]->reflection(j)->miller(k);
                
                if (miller->getRawIntensity() < 0)
                    continue;
                
                vec hkl = new_vector(miller->getH(), miller->getK(), miller->getL());
                mtzs[i]->getMatrix()->multiplyVector(&hkl);
                
                double angle = cartesian_to_angle(hkl.h, hkl.k);
                double degrees = angle * 180 / M_PI;
                
                int category = (int)(degrees / divide) * divide;
                
                if (histogram.count(category) == 0)
                {
                    histogram[category] = 0;
                    counts[category] = 0;
                }
                
                histogram[category] += miller->getRawIntensity();
                counts[category]++;
            }
        }
    }
    
    vector<double> xs, ys;
    GraphMap graphMap;
    graphMap["yMin"] = 0;
    graphMap["yMax"] = 200;
    graphMap["title"] = "Average raw intensity vs angle on detector";
    graphMap["xTitle"] = "Angle on detector";
    graphMap["yTitle"] = "Average raw intensity";
    
    int num = 0;
    
    for (int i = 0; i <= 0; i++)
    {
        for (std::map<int, double>::iterator it = histogram.begin(); it != histogram.end(); it++)
        {
            if (i == 0)
                histogram[it->first] /= counts[it->first];
            
            xs.push_back(it->first + (i * 360));
            ys.push_back(histogram[it->first]);
            num++;
        }
    }
    
    std::cout << "Number of X values: " << num << std::endl;
    
    plot("polarisation", graphMap, xs, ys);
}