| 1 |
/* |
| 2 |
* The MIT License |
| 3 |
|
| 4 |
Conograph (powder auto-indexing program) |
| 5 |
|
| 6 |
Copyright (c) <2012> <Ryoko Oishi-Tomiyasu, KEK> |
| 7 |
|
| 8 |
Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 |
of this software and associated documentation files (the "Software"), to deal |
| 10 |
in the Software without restriction, including without limitation the rights |
| 11 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 |
copies of the Software, and to permit persons to whom the Software is |
| 13 |
furnished to do so, subject to the following conditions: |
| 14 |
|
| 15 |
The above copyright notice and this permission notice shall be included in |
| 16 |
all copies or substantial portions of the Software. |
| 17 |
|
| 18 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 |
THE SOFTWARE. |
| 25 |
* |
| 26 |
*/ |
| 27 |
#include <fstream> |
| 28 |
#include "p_out_space_group_dtm.hh" |
| 29 |
#include "../ControlParam.hh" |
| 30 |
#include "../PeakPosData.hh" |
| 31 |
#include "../lattice_symmetry/LatticeFigureOfMeritToDisplay.hh" |
| 32 |
|
| 33 |
|
| 34 |
void print_lattice_array(const ControlParam& cdata, |
| 35 |
const PeakPosData& pdata, |
| 36 |
const vector<LatticeFigureOfMeritToDisplay>& arg, const string& fname) |
| 37 |
{ |
| 38 |
ofstream ofs(fname.c_str()); |
| 39 |
|
| 40 |
ofs.setf(ios::right); |
| 41 |
ofs.setf(ios::scientific); |
| 42 |
ofs.precision(6); |
| 43 |
|
| 44 |
Int4 label_start=0; |
| 45 |
|
| 46 |
ofs.width(label_start); |
| 47 |
ofs << "" << "<ZCodeParameters>\n"; |
| 48 |
label_start++; |
| 49 |
|
| 50 |
ofs.width(label_start); |
| 51 |
ofs << "" << "<ConographOutput>\n"; |
| 52 |
label_start++; |
| 53 |
|
| 54 |
ofs.width(label_start); |
| 55 |
ofs << "" << "<TypeOfReflectionConditions>\n"; |
| 56 |
//label_start++; |
| 57 |
|
| 58 |
for (size_t j=0; j<arg.size(); j++) |
| 59 |
{ |
| 60 |
ofs.width(label_start+1); |
| 61 |
ofs << "" << "<Candidates>\n"; |
| 62 |
//label_start++; |
| 63 |
|
| 64 |
ofs.width(label_start+2); |
| 65 |
ofs << "" << "<SpaceGroups> "+arg[j].putStringTypeOfSystematicAbsences(); |
| 66 |
ofs << "" << " </SpaceGroups>\n"; |
| 67 |
//label_start++; |
| 68 |
|
| 69 |
ofs.width(label_start+2); |
| 70 |
ofs << "" << "<ReflectionConditions> "+arg[j].putStringReflectionConditions(); |
| 71 |
ofs << "" << " </ReflectionConditions>\n"; |
| 72 |
//label_start++; |
| 73 |
|
| 74 |
|
| 75 |
ofs.width(label_start+2); ofs << ""; |
| 76 |
ofs << "<FigureOfMeritWolff name=\""+arg[j].putLatticeFigureOfMerit().putFiguresOfMerit().putLabel_FigureOfMeritWolff() << "\"> "; |
| 77 |
ofs << arg[j].putLatticeFigureOfMerit().putFiguresOfMerit().putFigureOfMeritWolff() << " </FigureOfMeritWolff>\n"; |
| 78 |
|
| 79 |
arg[j].printIndexingResult(cdata, pdata, label_start+2, &ofs); |
| 80 |
|
| 81 |
ofs.width(label_start+1); |
| 82 |
ofs << "" << "</Candidates>\n"; |
| 83 |
//label_start++; |
| 84 |
|
| 85 |
//ofs << arg[j].putStringTypeOfSystematicAbsences() + " (" |
| 86 |
// + arg[j].putLatticeFigureOfMerit().putFiguresOfMerit().putLabel_FigureOfMeritWolff() + "=" |
| 87 |
//+ num2str(arg[j].putLatticeFigureOfMerit().putFiguresOfMerit().putFigureOfMeritWolff(), 3) + ")\n"; |
| 88 |
} |
| 89 |
/*ofs << "\n"; |
| 90 |
label_start--; |
| 91 |
ofs.width(label_start); |
| 92 |
ofs << "" << "</TypeOfReflectionConditions>\n";*/ |
| 93 |
|
| 94 |
ofs.width(label_start); |
| 95 |
ofs << "" << "</TypeOfReflectionConditions>\n"; |
| 96 |
|
| 97 |
label_start--; |
| 98 |
ofs.width(label_start); |
| 99 |
ofs << "" << "</ConographOutput>\n"; |
| 100 |
|
| 101 |
label_start--; |
| 102 |
ofs.width(label_start); |
| 103 |
ofs << "" << "</ZCodeParameters>\n"; |
| 104 |
|
| 105 |
ofs.close(); |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
void printPeakPosition( |
| 110 |
const ControlParam& cdata, |
| 111 |
const PeakPosData& pdata, const Double& MIN_FOM, |
| 112 |
const vector<LatticeFigureOfMeritToDisplay>& latfit_tray, |
| 113 |
const string& fname) |
| 114 |
{ |
| 115 |
ofstream ofs(fname.c_str()); |
| 116 |
ostream * const os = &ofs; |
| 117 |
|
| 118 |
*os << "IGOR\n"; |
| 119 |
*os << "WAVES/O "; |
| 120 |
|
| 121 |
pdata.printData(os); |
| 122 |
|
| 123 |
if( latfit_tray.empty() ) return; |
| 124 |
|
| 125 |
const Int4 isize = latfit_tray.size(); |
| 126 |
for (Int4 j=0, j1=1; j<isize; j++, j1++) |
| 127 |
{ |
| 128 |
const LatticeFigureOfMeritToDisplay& latfit = latfit_tray[j]; |
| 129 |
|
| 130 |
*os << "WAVES/O dphase_" << j1 << ", xphase_" << j1 << ", yphase_" << j1 << ", "; |
| 131 |
*os << "h_" << j1 << ", "; |
| 132 |
*os << "k_" << j1 << ", "; |
| 133 |
*os << "l_" << j1; |
| 134 |
*os << endl; |
| 135 |
|
| 136 |
*os << "BEGIN\n"; |
| 137 |
|
| 138 |
const vector<HKL_Q>& cal_hkl_tray = latfit.putCalMillerIndices(); |
| 139 |
Vec_DP cal_pos_tray; |
| 140 |
latfit.putCalculatedPeakPosInRange(cdata, cal_pos_tray); |
| 141 |
|
| 142 |
const Int4 peak_num = cal_hkl_tray.size(); |
| 143 |
|
| 144 |
for (Int4 i=0; i<peak_num; i++) |
| 145 |
{ |
| 146 |
os->width(15); |
| 147 |
*os << 1.0 / sqrt( cal_hkl_tray[i].Q() ); |
| 148 |
|
| 149 |
os->width(15); |
| 150 |
if( cal_pos_tray[i] < 0.0 ) |
| 151 |
{ |
| 152 |
*os << "NAN"; |
| 153 |
} |
| 154 |
else |
| 155 |
{ |
| 156 |
*os << cal_pos_tray[i]; |
| 157 |
} |
| 158 |
os->width(15); |
| 159 |
*os << 0.0; |
| 160 |
|
| 161 |
const VecDat3<Int4>& hkl = cal_hkl_tray[i].HKL(); |
| 162 |
|
| 163 |
os->width(5); |
| 164 |
*os << hkl[0]; |
| 165 |
os->width(5); |
| 166 |
*os << hkl[1]; |
| 167 |
os->width(5); |
| 168 |
*os << hkl[2]; |
| 169 |
|
| 170 |
#ifdef DEBUG |
| 171 |
const DataReflectionConditions& ref_data = latfit.putDataOnReflectionConditions(); |
| 172 |
if( !(ref_data.isNotExtinct(hkl[0], hkl[1], hkl[2])) ) |
| 173 |
{ |
| 174 |
cout << hkl[0] << " " << hkl[1] << " " << hkl[2] << "\n"; |
| 175 |
cout << latfit.putStringTypeOfSystematicAbsences() << "\n"; |
| 176 |
cout << latfit.putStringReflectionConditions() << "\n"; |
| 177 |
assert(false); |
| 178 |
} |
| 179 |
#endif |
| 180 |
*os << endl; |
| 181 |
} |
| 182 |
*os << "END\n\n"; |
| 183 |
} |
| 184 |
|
| 185 |
VecDat3<Double> length_axis, angle_axis; |
| 186 |
const string str_num_ref = num2str( cdata.putNumberOfReflectionsForFigureOfMerit() ); |
| 187 |
|
| 188 |
*os << "X Display " << pdata.putYIntColumnTitle() << " vs " << pdata.putXColumnTitle() << endl; |
| 189 |
*os << "X ModifyGraph mirror(left)=2\n"; |
| 190 |
*os << "X ModifyGraph mirror(bottom)=2\n"; |
| 191 |
*os << "X ModifyGraph rgb(" << pdata.putYIntColumnTitle() << ")=(0,15872,65280)\n"; |
| 192 |
|
| 193 |
*os << "X AppendToGraph height vs peakpos\n"; |
| 194 |
*os << "X ModifyGraph mode(height)=3,marker(height)=17\n"; |
| 195 |
*os << "X ModifyGraph rgb(height)=(0,65280,65280)\n"; |
| 196 |
|
| 197 |
Double offset = 0.0; |
| 198 |
const Double offset_gap = pdata.putMaxPeakHeightOfFirst20() * (-0.05); |
| 199 |
for (Int4 j=0, j1=1; j<isize; j++, j1++, offset+=offset_gap) |
| 200 |
{ |
| 201 |
if( latfit_tray[j].putLatticeFigureOfMerit().putFiguresOfMerit().putFigureOfMeritWolff() < MIN_FOM ) break; |
| 202 |
*os << "X AppendToGraph yphase_" << j1 << " vs xphase_" << j1 << endl; |
| 203 |
*os << "X ModifyGraph offset(yphase_" << j1 << ")={0," << offset << "},mode(yphase_" << j1 << ")=3,marker(yphase_" << j1; |
| 204 |
*os << ")=10,msize(yphase_" << j1 << ")=3,mrkThick(yphase_" << j1 << ")=0.6,rgb(yphase_" << j1 << ")=(3,52428,1)" << endl; |
| 205 |
} |
| 206 |
|
| 207 |
*os << "X Legend/C/N=text0/J/A=MC \""; |
| 208 |
if( latfit_tray[0].putLatticeFigureOfMerit().putFiguresOfMerit().putFigureOfMeritWolff() >= MIN_FOM ) |
| 209 |
{ |
| 210 |
*os << "\\s(yphase_" << 1 << ") " |
| 211 |
+ latfit_tray[0].putShortStringTypeOfSystematicAbsences() + " (" |
| 212 |
+ latfit_tray[0].putLatticeFigureOfMerit().putFiguresOfMerit().putLabel_FigureOfMeritWolff() + "=" |
| 213 |
+ num2str(latfit_tray[0].putLatticeFigureOfMerit().putFiguresOfMerit().putFigureOfMeritWolff(), 3) + ")"; |
| 214 |
} |
| 215 |
for (Int4 j=1, j1=2; j<isize; j++, j1++) |
| 216 |
{ |
| 217 |
if( latfit_tray[j].putLatticeFigureOfMerit().putFiguresOfMerit().putFigureOfMeritWolff() < MIN_FOM ) break; |
| 218 |
*os << "\\r\\s(yphase_" << j1 << ") " |
| 219 |
+ latfit_tray[j].putShortStringTypeOfSystematicAbsences() + " (" |
| 220 |
+ latfit_tray[j].putLatticeFigureOfMerit().putFiguresOfMerit().putLabel_FigureOfMeritWolff() + "=" |
| 221 |
+ num2str(latfit_tray[j].putLatticeFigureOfMerit().putFiguresOfMerit().putFigureOfMeritWolff(), 3) + ")"; |
| 222 |
} |
| 223 |
*os << "\"\nX Legend/C/N=text0/J/A=RT/X=0.00/Y=0.00\n"; |
| 224 |
|
| 225 |
ofs.close(); |
| 226 |
} |