From c6115928bb875b0ed408655ff12b9ca00dae017c Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 7 Jun 2023 14:02:26 +0200 Subject: Move Mille stuff to separate file --- libcrystfel/src/crystfel-mille.c | 168 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 libcrystfel/src/crystfel-mille.c (limited to 'libcrystfel/src/crystfel-mille.c') diff --git a/libcrystfel/src/crystfel-mille.c b/libcrystfel/src/crystfel-mille.c new file mode 100644 index 00000000..c06dff01 --- /dev/null +++ b/libcrystfel/src/crystfel-mille.c @@ -0,0 +1,168 @@ +/* + * crystfel-mille.c + * + * Interface to Millepede geometry refinement + * + * Copyright © 2023 Deutsches Elektronen-Synchrotron DESY, + * a research centre of the Helmholtz Association. + * + * Authors: + * 2023 Thomas White + * + * This file is part of CrystFEL. + * + * CrystFEL is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CrystFEL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CrystFEL. If not, see . + * + */ + +#include + +#include +#include + +#include "image.h" +#include "geometry.h" +#include "cell-utils.h" +#include "predict-refine.h" +#include "profile.h" + +#include + + +static const enum gparam rv[] = +{ + GPARAM_ASX, + GPARAM_ASY, + GPARAM_ASZ, + GPARAM_BSX, + GPARAM_BSY, + GPARAM_BSZ, + GPARAM_CSX, + GPARAM_CSY, + GPARAM_CSZ, +}; + + +int mille_label(int hierarchy_level, int member_index, char param) +{ + int label; + + assert(member_index < 1000); + + label = 100000*hierarchy_level + 100*member_index; + switch ( param ) { + case 'x' : return label+1; + case 'y' : return label+2; + case 'z' : return label+3; + default : abort(); + } +} + + +void write_mille(Mille *mille, int n, UnitCell *cell, + struct reflpeak *rps, struct image *image, + double dx, double dy, + const struct detgeom_panel_group *group, + int hierarchy_level, int member_index) +{ + int i; + float local_gradients[9]; + float global_gradients[6]; + int labels[6]; + + /* Spot x-position terms */ + for ( i=0; idetgeom, dx, dy), + 0.65*rps[i].panel->pixel_pitch); + } + + /* Spot y-position terms */ + for ( i=0; idetgeom, dx, dy), + 0.65*rps[i].panel->pixel_pitch); + } + + /* Next level of hierarchy */ + for ( i=0; in_children; i++ ) { + write_mille(mille, n, cell, rps, image, dx, dy, + group->children[i], hierarchy_level+1, i); + } + +} + + +Mille *crystfel_mille_new(const char *outFileName, + int asBinary, + int writeZero) +{ + return mille_new(outFileName, asBinary, writeZero); +} + + +void crystfel_mille_free(Mille *m) +{ + mille_free(m); +} + + +void crystfel_mille_delete_last_record(Mille *m) +{ + mille_delete_last_record(m); +} + + +void crystfel_mille_write_record(Mille *m) +{ + mille_write_record(m); +} -- cgit v1.2.3