diff options
author | Thomas White <taw@physics.org> | 2015-11-27 13:05:33 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2015-11-27 13:18:29 +0100 |
commit | 6fc80febf119f9f3183c918f3137a396cbe06e40 (patch) | |
tree | 9b0aa1c9eb5ad43aba38d8513efe5d4daf6b61c2 /libcrystfel/src/cell-utils.c | |
parent | e81e335daf509166fc234c8835203a80d5b21e0d (diff) |
indexamajig: Write target unit cell into stream
Diffstat (limited to 'libcrystfel/src/cell-utils.c')
-rw-r--r-- | libcrystfel/src/cell-utils.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libcrystfel/src/cell-utils.c b/libcrystfel/src/cell-utils.c index 3b3c5fe3..69d4174a 100644 --- a/libcrystfel/src/cell-utils.c +++ b/libcrystfel/src/cell-utils.c @@ -1230,6 +1230,38 @@ static int get_angle_rad(char **bits, int nbits, double *pl) return 0; } +/** + * write_cell: + * @cell: a %UnitCell + * @fh: a file handle + * + * Writes @cell to @fh, in CrystFEL unit cell file format + * + */ +void write_cell(UnitCell *cell, FILE *fh) +{ + double a, b, c, al, be, ga; + LatticeType lt; + + fprintf(fh, "CrystFEL unit cell file version 1.0\n\n"); + lt = cell_get_lattice_type(cell); + fprintf(fh, "lattice_type = %s\n", str_lattice(lt)); + if ( (lt == L_MONOCLINIC) + || (lt == L_TETRAGONAL) + || (lt == L_HEXAGONAL) ) + { + fprintf(fh, "unique_axis = %c\n", cell_get_unique_axis(cell)); + } + fprintf(fh, "centering = %c\n", cell_get_centering(cell)); + cell_get_parameters(cell, &a, &b, &c, &al, &be, &ga); + fprintf(fh, "a = %.2f A\n", a*1e10); + fprintf(fh, "b = %.2f A\n", b*1e10); + fprintf(fh, "c = %.2f A\n", c*1e10); + fprintf(fh, "al = %.2f deg\n", rad2deg(al)); + fprintf(fh, "be = %.2f deg\n", rad2deg(be)); + fprintf(fh, "ga = %.2f deg\n", rad2deg(ga)); +} + /** * load_cell_from_file: |