aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-06-02 13:05:25 +0200
committerThomas White <taw@physics.org>2020-07-29 18:42:57 +0200
commit4c8f86c583b203fa4098b8e116a1d50cb435d883 (patch)
tree05c09e1436c4c72f6adb6e46b51ddee89b8d4f3a
parenta851516f08edab1f54592b4e6df5ff87d3c6dfd5 (diff)
Convert more bits to detgeom
-rw-r--r--libcrystfel/src/integration.c6
-rw-r--r--libcrystfel/src/stream.c88
-rw-r--r--src/process_image.c12
3 files changed, 21 insertions, 85 deletions
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; i<image->n_crystals; i++ ) {
@@ -1687,7 +1687,7 @@ void integrate_all_5(struct image *image, IntegrationMethod meth,
}
- for ( i=0; i<image->det->n_panels; i++ ) {
+ for ( i=0; i<image->detgeom->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; i<image->det->n_panels; i++ ) {
+ for ( i=0; i<image->detgeom->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; i<image_feature_count(image->features); 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; i<image_feature_count(image->features); 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; j<i->n_crystals; j++ ) {
diff --git a/src/process_image.c b/src/process_image.c
index 34483f46..1d8def8b 100644
--- a/src/process_image.c
+++ b/src/process_image.c
@@ -452,16 +452,8 @@ out:
spectrum_free(image->spectrum);
}
- for ( i=0; i<image->det->n_panels; i++ ) {
- free(image->dp[i]);
- free(image->bad[i]);
- free(image->sat[i]);
- }
- free(image->dp);
- free(image->bad);
- free(image->sat);
+ /* Free image (including detgeom) */
+ image_free(image);
- image_feature_list_free(image->features);
- free_detector_geometry(image->det);
set_last_task(last_task, "sandbox");
}