int main() { std::cout << "Doghouse " << std::endl; DogHouse fidos(Dog::make("Fido"), "FidoHouse"); DogHouse spots(Dog::make("spot"), "SpotHouse"); std::cout << " Entering copy-constuction" << std::endl; DogHouse bobs(fidos); std::cout << " After copy-cnstruction bobs" << std::endl; std::cout << "fidos::" << fidos << std::endl; std::cout << "spots:" << spots << std::endl; std::cout << "bobs::" << bobs << std::endl; std::cout << " Entering spots = fidos " << std::endl; spots = fidos; std::cout << "fidos::" << fidos << std::endl; std::cout << "spots:" << spots << std::endl; std::cout << "bobs::" << bobs << std::endl; std::cout << " Entering self assignment " << std::endl; bobs = bobs; std::cout << " bobs:" << bobs << std::endl; Dog* dog = Dog::make("timmy"); std::cout << *dog << std::endl; }
void ds::ReflectionData::spread_data() { std::cout << "Spreading the data in Fourier space.. \n"; std::cout << "Current spots: " << spots() << "\n"; MillerToPeakMultiMap spreaded_raw; for(const_iterator ref=this->begin(); ref!=this->end(); ++ref) { MillerIndex index_in = (*ref).first; PeakData spot_in = (*ref).second; //Insert this spot spreaded_raw.insert(MillerToPeakPair(index_in, spot_in)); //Spread this spot to neighbors if not present for(int ih=-2; ih<=2; ih++) { for(int ik=-2; ik<=2; ik++) { for(int il=-2; il<=2; il++) { MillerIndex new_index = MillerIndex(index_in.h()+ih, index_in.k()+ik, index_in.l()+il); if(!exists(new_index.h(), new_index.k(), new_index.l())) { double distance_square = il*il + ik*ik + ih*ih; //1.6 is to make the integral of exponential 1 double weight = exp(-1.6*distance_square); spreaded_raw.insert(MillerToPeakPair(new_index, spot_in*weight)); } } } } } MillerToPeakMap spreaded_map; tdx::utilities::fourier_utilities::average_peaks(spreaded_raw, spreaded_map); _data.clear(); _data.insert(spreaded_map.begin(), spreaded_map.end()); std::cout << "Spots after spread: " << spots() << "\n"; }
void ds::ReflectionData::replace_reflections(const ReflectionData& input, double cone_angle, double replacement_amplitude_cutoff) { std::cout << "Replacing reflection and keeping the new ones in a cone of angle: " << cone_angle <<"\n"; ReflectionData new_data; if(cone_angle < 0.0 || cone_angle > 90) { std::cerr << "Error: Bad value encountered in cone_angle: " << std::to_string(cone_angle) << " (min 0 and max 90)\n"; return; } double cone_angle_rad = double(cone_angle)*M_PI/180; //Iterate over all possible miller indices h, k, l in input data for(const_iterator ref=input.begin(); ref!=input.end(); ++ref) { //Assign the current Miller Index to the array ds::MillerIndex index = (*ref).first; tdx::Complex current_complex = (*ref).second.value(); if(current_complex.amplitude() > replacement_amplitude_cutoff) { new_data.set_spot_at(index.h(), index.k(), index.l(), current_complex, (*ref).second.weight() ); } } //Iterate over all the current reflections for(const_iterator ref=this->begin(); ref!=this->end(); ++ref) { //Assign the current Miller Index to the array ds::MillerIndex index = (*ref).first; tdx::Complex current_complex = (*ref).second.value(); double radius = std::abs(index.l()*tan(cone_angle_rad)); double distance = sqrt(index.h()*index.h() + index.k()*index.k()); if(current_complex.amplitude() > replacement_amplitude_cutoff && !new_data.exists(index.h(), index.k(), index.l()) && distance < radius) { new_data.set_spot_at(index.h(), index.k(), index.l(), current_complex, (*ref).second.weight() ); } } std::cout << "Current spots " << spots() << " were replaced with: " << new_data.spots() << " (Input had " << input.spots() << " spots)\n"; reset(new_data); }