From 4c8f86c583b203fa4098b8e116a1d50cb435d883 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 2 Jun 2020 13:05:25 +0200 Subject: Convert more bits to detgeom --- libcrystfel/src/integration.c | 6 +-- libcrystfel/src/stream.c | 88 ++++++++----------------------------------- 2 files changed, 19 insertions(+), 75 deletions(-) (limited to 'libcrystfel/src') diff --git a/libcrystfel/src/integration.c b/libcrystfel/src/integration.c index 85d7cd94..00f1d997 100644 --- a/libcrystfel/src/integration.c +++ b/libcrystfel/src/integration.c @@ -1660,7 +1660,7 @@ void integrate_all_5(struct image *image, IntegrationMethod meth, pthread_mutex_t *term_lock, int overpredict) { int i; - int *masks[image->det->n_panels]; + int *masks[image->detgeom->n_panels]; /* Predict all reflections */ for ( i=0; in_crystals; i++ ) { @@ -1687,7 +1687,7 @@ void integrate_all_5(struct image *image, IntegrationMethod meth, } - for ( i=0; idet->n_panels; i++ ) { + for ( i=0; idetgeom->n_panels; i++ ) { masks[i] = make_BgMask(image, &image->detgeom->panels[i], i, ir_inn); } @@ -1725,7 +1725,7 @@ void integrate_all_5(struct image *image, IntegrationMethod meth, } - for ( i=0; idet->n_panels; i++ ) { + for ( i=0; idetgeom->n_panels; i++ ) { free(masks[i]); } } diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index 3343750c..be8a2c0d 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -52,6 +52,7 @@ #include "reflist.h" #include "reflist-utils.h" #include "datatemplate.h" +#include "detgeom.h" /** \file stream.h */ @@ -209,61 +210,8 @@ static int read_peaks_2_3(Stream *st, struct image *image) } -static int write_peaks(struct image *image, FILE *ofh) -{ - int i; - - fprintf(ofh, PEAK_LIST_START_MARKER"\n"); - fprintf(ofh, " fs/px ss/px (1/d)/nm^-1 Intensity\n"); - - for ( i=0; ifeatures); i++ ) { - - struct imagefeature *f; - struct rvec r; - double q; - - f = image_get_feature(image->features, i); - if ( f == NULL ) continue; - - r = get_q_for_panel(&image->det->panels[f->pn], - f->fs, f->ss, - NULL, 1.0/image->lambda); - q = modulus(r.u, r.v, r.w); - - if ( image->det != NULL ) { - - struct panel *p; - double write_fs, write_ss; - - p = find_orig_panel(image->det, f->fs, f->ss); - if ( p == NULL ) { - ERROR("Panel not found\n"); - return 1; - } - - /* Convert coordinates to match arrangement of panels in - * HDF5 file */ - write_fs = f->fs + p->orig_min_fs; - write_ss = f->ss + p->orig_min_ss; - - fprintf(ofh, "%7.2f %7.2f %10.2f %10.2f\n", - write_fs, write_ss, q/1.0e9, f->intensity); - - } else { - - fprintf(ofh, "%7.2f %7.2f %10.2f %10.2f\n", - f->fs, f->ss, q/1.0e9, f->intensity); - - } - - } - - fprintf(ofh, PEAK_LIST_END_MARKER"\n"); - return 0; -} - - -static int write_peaks_2_3(struct image *image, FILE *ofh) +static int write_peaks(struct image *image, + const DataTemplate *dtempl, FILE *ofh) { int i; @@ -273,27 +221,27 @@ static int write_peaks_2_3(struct image *image, FILE *ofh) for ( i=0; ifeatures); i++ ) { struct imagefeature *f; - struct rvec r; + double r[3]; double q; - double write_fs, write_ss; - struct panel *p; + float write_fs, write_ss; + struct detgeom_panel *p; f = image_get_feature(image->features, i); if ( f == NULL ) continue; - p = &image->det->panels[f->pn]; - r = get_q_for_panel(p, f->fs, f->ss, - NULL, 1.0/image->lambda); - q = modulus(r.u, r.v, r.w); + p = &image->detgeom->panels[f->pn]; + detgeom_transform_coords(p, f->fs, f->ss, + image->lambda, r); + q = modulus(r[0], r[1], r[2]); - /* Convert coordinates to match arrangement of panels in HDF5 - * file */ - write_fs = f->fs + p->orig_min_fs; - write_ss = f->ss + p->orig_min_ss; + write_fs = f->fs; + write_ss = f->ss; + data_template_panel_to_file_coords(dtempl, f->pn, + &write_fs, &write_ss); fprintf(ofh, "%7.2f %7.2f %10.2f %10.2f %s\n", write_fs, write_ss, q/1.0e9, f->intensity, - p->name); + data_template_panel_name(dtempl, f->pn)); } @@ -741,11 +689,7 @@ int write_chunk(Stream *st, struct image *i, fprintf(st->fh, "peak_resolution = %f nm^-1 or %f A\n", i->peak_resolution/1e9, 1e10/i->peak_resolution); if ( include_peaks ) { - if ( AT_LEAST_VERSION(st, 2, 3) ) { - ret = write_peaks_2_3(i, st->fh); - } else { - ret = write_peaks(i, st->fh); - } + ret = write_peaks(i, dtempl, st->fh); } for ( j=0; jn_crystals; j++ ) { -- cgit v1.2.3