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(); }
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" << "\t" << miller->getSigma() << "\t" << miller->getFilename() << std::endl; if (miller->accepted()) acceptedCount++; } logged << std::endl; std::cout << logged.str(); }
/** 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; } }
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); }