1 /* Stupid little application to combine two sets of map coefficients
2    by taking the low resolution terms from one set and the high
3    resolution terms from another. */
4 
5 #include "mtz_io.h"
6 
7 using namespace clipper;
8 using namespace clipper::data32;
9 
10 
main()11 int main()
12 {
13   CCP4MTZfile file;
14   MTZcrystal xtal;
15   MTZdataset dset;
16 
17   HKL_info mydata;
18   HKL_data<F_phi> fphi1( mydata );
19   HKL_data<F_phi> fphi2( mydata );
20 
21   String line, filename_in, filename_out, colname_lo, colname_hi, colname_out;
22   float resol = 5.0;
23   filename_out = "mtzcut.mtz";
24   colname_out = "cut";
25 
26   // read and parse input lines
27   while ( std::getline( std::cin, line ), !std::cin.eof() ) {
28     std::vector<String> tokens = line.split(" ");
29     if ( tokens[0] == "inputfile" )  filename_in  = tokens[1];
30     if ( tokens[0] == "outputfile" ) filename_out = tokens[1];
31     if ( tokens[0] == "F_phi_lo" )   colname_lo   = tokens[1];
32     if ( tokens[0] == "F_phi_hi" )   colname_hi   = tokens[1];
33     if ( tokens[0] == "F_phi_out" )  colname_out  = tokens[1];
34     if ( tokens[0] == "resolution" ) resol        = tokens[1].f();
35   }
36 
37   file.open_read( filename_in );
38   file.import_hkl_info( mydata, false );
39   file.import_hkl_data( fphi1, dset, xtal, colname_lo );
40   file.import_hkl_data( fphi2, dset, xtal, colname_hi );
41   file.close_read();
42 
43   HKL_data<F_phi> fphi3( mydata );
44   HKL_info::HKL_reference_index ih;
45   for ( ih = mydata.first(); !ih.last(); ih.next() )
46     fphi3[ih] = (ih.invresolsq() < pow(resol,-2)) ? fphi1[ih] : fphi2[ih];
47 
48   file.open_append( filename_in, filename_out );
49   file.export_hkl_data( fphi3, dset, xtal, colname_out );
50   file.close_append();
51 }
52