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(); }
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; }
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); }