diff options
author | Thomas White <taw@physics.org> | 2011-06-30 12:09:28 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:28 +0100 |
commit | 912db4a457ca53b58092948be2767eff3dc6f941 (patch) | |
tree | f3aed7b5deae6005b86e9723b414a67155119f2b /src | |
parent | f682484bf4476547b2a0af03315eda1064aca089 (diff) |
Save all camera lengths in stream
Diffstat (limited to 'src')
-rw-r--r-- | src/detector.c | 2 | ||||
-rw-r--r-- | src/detector.h | 2 | ||||
-rw-r--r-- | src/stream.c | 44 |
3 files changed, 34 insertions, 14 deletions
diff --git a/src/detector.c b/src/detector.c index 123864a2..47c9e488 100644 --- a/src/detector.c +++ b/src/detector.c @@ -472,7 +472,7 @@ static struct badregion *new_bad_region(struct detector *det, const char *name) } -static struct panel *find_panel_by_name(struct detector *det, const char *name) +struct panel *find_panel_by_name(struct detector *det, const char *name) { int i; diff --git a/src/detector.h b/src/detector.h index 248534f3..08a69f84 100644 --- a/src/detector.h +++ b/src/detector.h @@ -121,7 +121,7 @@ extern double largest_q(struct image *image); extern double smallest_q(struct image *image); -extern int write_detector_geometry(const char *filename, struct detector *det); +extern struct panel *find_panel_by_name(struct detector *det, const char *name); #endif /* DETECTOR_H */ diff --git a/src/stream.c b/src/stream.c index 87c11bf8..316d3bb3 100644 --- a/src/stream.c +++ b/src/stream.c @@ -251,10 +251,15 @@ void write_chunk(FILE *ofh, struct image *i, int f) fprintf(ofh, "photon_energy_eV = %f\n", J_to_eV(ph_lambda_to_en(i->lambda))); - //FIXME:we're writing camera length from first panel only. - //this should actually write camera length for all panels. if ( i->det != NULL ) { - fprintf(ofh, "camera_length = %f\n", i->det->panels[0].clen); + + int j; + + for ( j=0; j<i->det->n_panels; j++ ) { + fprintf(ofh, "camera_length_%s = %f\n", + i->det->panels[j].name, i->det->panels[j].clen); + } + } if ( (f & STREAM_PEAKS) @@ -340,17 +345,32 @@ int read_chunk(FILE *fh, struct image *image) have_filename = 1; } - if ( strncmp(line, "camera_length = ",16) == 0 ) { - //FIXME: assuming here that we have loaded detector - //geometry into image prior to calling this routine. - //otherise, we don't know how many panels there are! - if ( !( image->det == NULL ) ) { + if ( strncmp(line, "camera_length_", 14) == 0 ) { + if ( image->det == NULL ) { + ERROR("Stream had a camera length, but " + "geometry is not currently loaded.\n"); + } else { + int k; - double clen; - clen = atof( line+16 ); - for ( k=0; k< image->det->n_panels; k++ ) { - image->det->panels[k].clen = clen; + char name[1024]; + struct panel *p; + + for ( k=0; k<strlen(line)-14; k++ ) { + char ch = line[k+14]; + name[k] = ch; + if ( (ch == ' ') || (ch == '=') ) { + name[k] = '\0'; + break; + } + } + + p = find_panel_by_name(image->det, name); + if ( p == NULL ) { + ERROR("No panel '%s'\n", name); + } else { + p->clen = atof(line+14+k+3); } + } } |