1 // Clipper-map test
2 /* (C) 2002 Kevin Cowtan */
3
4 #include <clipper/clipper.h>
5 #include <clipper/clipper-ccp4.h>
6 //#include <clipper/clipper-ccp4.h>
7
8 #include <iostream>
9
10
11 using namespace clipper;
12 using namespace clipper::data32;
13
14
15
main(int argc,char ** argv)16 int main(int argc, char** argv)
17 {
18 Cell cell = Cell( Cell_descr( 10,10,10,90,90,90 ) );
19 Grid grid = Grid( 20, 20, 20 );
20 Grid_range gmap = Grid_range( cell, grid, 5.0 );
21 std::cout << cell.format() << "\t" << gmap.format() << "\n";
22 cell = Cell( Cell_descr( 10,10,10,90,120,90 ) );
23 gmap = Grid_range ( cell, grid, 5.0 );
24 std::cout << cell.format() << "\t" << gmap.format() << "\n";
25 grid = Grid( 20, 30, 40 );
26 gmap = Grid_range ( cell, grid, 5.0 );
27 std::cout << cell.format() << "\t" << gmap.format() << "\n";
28 gmap = Grid_range ( cell, grid, 2.5 );
29 std::cout << cell.format() << "\t" << gmap.format() << "\n";
30
31 Xmap<float> xmap;
32 CCP4MAPfile file;
33
34 file.open_read( argv[1] );
35 file.import_xmap( xmap );
36 file.close_read();
37
38 Coord_grid c;
39 for ( c.w() = 0; c.w() < 2; c.w()++ ) {
40 std::cout << c.w() << "\n";
41 for ( c.v() = 0; c.v() < 24; c.v()++ ) {
42 for ( c.u() = 0; c.u() < 24; c.u()++ ) {
43 std::cout.width(5);
44 std::cout << rint(1000*xmap.get_data(c)) << " ";
45 }
46 std::cout << "\n";
47 }
48 }
49
50 file.open_write( "out.xmap" );
51 file.export_xmap( xmap );
52 file.close_write();
53
54 NXmap<float> nxmap;
55 file.open_read( argv[1] );
56 file.import_nxmap( nxmap );
57 file.close_read();
58
59 for ( c.v() = 0; c.v() < 2; c.v()++ ) {
60 std::cout << c.v() << "\n";
61 for ( c.w() = 0; c.w() < 24; c.w()++ ) {
62 for ( c.u() = 0; c.u() < 24; c.u()++ ) {
63 std::cout.width(5);
64 std::cout << rint(1000*nxmap.get_data(c)) << " ";
65 }
66 std::cout << "\n";
67 }
68 }
69
70 file.open_write( "out.nxmap" );
71 file.export_nxmap( nxmap );
72 file.close_write();
73
74 RTop_orth rtop( RTop_orth::identity() );
75 Grid_range g( Coord_grid(10,10,10), Coord_grid(20,20,20) );
76 nxmap.init( xmap.cell(), xmap.grid_sampling(), g );
77 NX_operator nxop( xmap, nxmap, rtop );
78
79 nxop.debug();
80
81 NXmap_base::Map_reference_index ix;
82 for ( ix = nxmap.first(); !ix.last(); ix.next() )
83 nxmap[ix] = nxop.xmap_data<Interp_linear,float>( xmap, ix.coord() );
84
85 for ( c = g.min(); !c.last( g ); c.next( g ) )
86 if ( c.index( g ) % 100 == 0 )
87 std::cout << c.format() << " " << xmap.get_data( c ) << " " << nxop.nxmap_data<Interp_linear,float>( nxmap, c ) << "\n";
88
89 }
90