diff options
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: |