An FFT example

Most crystallographic calculations are based upon the observed data, i.e structure factors, phase probability estimates, and associated data. This page describes how to read observed structure factors and phases from an MTZ file, and perform a Fourier transformation to obtain an electron density map.

For reflection data to be meaningful, a cell, spacegroup, and resolution limit must first be defined. This can be achieved by defining a Spacegroup object (clipper::Spacegroup), a Cell object (clipper::Cell), and a resolution object (clipper::Resolution), and using them to create a reflection list (clipper::HKL_info). However, in this case the cell, spacegroup and resolution will be imported from the MTZ file, so it is not necessary to set their values. Therefore an uninitialised clipper::HKL_info object is created using the null constructor.

If we want to calculate a map, we need a structure factor and phase. So we'll create a data list of type F_phi . The data list must refer to a reflection list, so we pass our clipper::HKL_info object to the constructor.

Next, we want to open an MTZ file. I'll assume it is called my.mtz . To do this we create an clipper::MTZfile object. This is an i/o object which can be linked to an MTZ file by an open command, and can then fill Clipper data objects using the information from that file.

When we created the reflection list object, we did not provide a cell or spacegroup, or generate a reflection list. So we'll get those from the file now.

mtzin.import_hkl_info( myhkl ); // read sg, cell, reso, hkls

Now we want some actual data. We read a couple of MTZ columns into the data list we created earlier.

mtzin.import_hkl_data( fphidata, "/native/CuKa/[FCAL,PHICAL]" );

Note that we create the data-list as a child of the reflection list myhkl . (Actually, any descendent will do). The import operation will actually move it, by inserting the appropriate CCrystal and CDataset objects, according to the information on the file.

Note also that we give specify the MTZ columns by giving the full path: crystal, dataset, and column names. The column names are grouped in square brackets. (For older MTZ files, which do not have crystal and dataset entries, the dummy names "unnamed_crystal" and "unnamed_dataset" are used.)

Now we close the MTZ file. NOTE: No data is actually read until you close the file!

mtzin.close_read();

Next, we create a map. For this we need to provide a grid. The grid depends on the spacegroup, cell, and resolution, which we get from the reflection list: