diff options
author | Thomas White <taw@physics.org> | 2011-04-07 19:19:49 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:23 +0100 |
commit | 5d5e7d1f985b935d070edeb06897ccf95a1c2bf6 (patch) | |
tree | 85886bed629164e2ba21d7307dc60428e3ce33d1 /src/detector.c | |
parent | 2cad5d99bfb93d49d94b2794b9c79d866c28d572 (diff) |
Tidy up
Diffstat (limited to 'src/detector.c')
-rw-r--r-- | src/detector.c | 83 |
1 files changed, 52 insertions, 31 deletions
diff --git a/src/detector.c b/src/detector.c index f705430d..da57c658 100644 --- a/src/detector.c +++ b/src/detector.c @@ -941,55 +941,76 @@ void get_pixel_extents(struct detector *det, } -int print_detector_geometry(FILE * file, struct image * image) { - - struct panel * p; +int write_detector_geometry(const char *filename, struct detector *det) +{ + struct panel *p; int pi; + FILE *fh; - if ( image == NULL ) return 1; - if ( file == NULL ) return 2; - if ( image->det->n_panels < 1 ) return 3; - - for (pi=0; pi<image->det->n_panels; pi++) { + if ( filename == NULL ) return 2; + if ( det->n_panels < 1 ) return 3; - p = &(image->det->panels[pi]); + fh = fopen(filename, "w"); + if ( fh == NULL ) return 1; - if ( p == NULL ) return 4; + for ( pi=0; pi<det->n_panels; pi++) { - fprintf(file,"%s/min_fs = %d\n",p->name,p->min_fs); - fprintf(file,"%s/min_ss = %d\n",p->name,p->min_ss); - fprintf(file,"%s/max_fs = %d\n",p->name,p->max_fs); - fprintf(file,"%s/max_ss = %d\n",p->name,p->max_ss); - fprintf(file,"%s/badrow_direction = %C\n",p->name,p->badrow); - fprintf(file,"%s/res = %g\n",p->name,p->res); - fprintf(file,"%s/peak_sep = %g\n",p->name,p->peak_sep); - fprintf(file,"%s/clen = %s\n",p->name,p->clen_from); - //FIXME: the following is sketchy, but it will work for now. we need - // to generalise the parser in detector.c char coord; char sign; - if (p->fsx != 0){ - if (p->fsx>0){sign='+';}else{sign='-';} + + p = &(det->panels[pi]); + + if ( p == NULL ) return 4; + + fprintf(fh, "%s/min_fs = %d\n", p->name, p->min_fs); + fprintf(fh, "%s/min_ss = %d\n", p->name, p->min_ss); + fprintf(fh, "%s/max_fs = %d\n", p->name, p->max_fs); + fprintf(fh, "%s/max_ss = %d\n", p->name, p->max_ss); + fprintf(fh, "%s/badrow_direction = %C\n", p->name, p->badrow); + fprintf(fh, "%s/res = %g\n", p->name, p->res); + fprintf(fh, "%s/peak_sep = %g\n", p->name, p->peak_sep); + fprintf(fh, "%s/clen = %s\n", p->name, p->clen_from); + + /* FIXME: The following is sketchy, but it will work for now. + * We need to generalise the parser in detector.c */ + if ( p->fsx != 0 ) { + if ( p->fsx > 0 ) { + sign='+'; + } else { + sign='-'; + } coord = 'x'; } else { - if (p->fsy>0){sign='+';}else{sign='-';} + if ( p->fsy > 0 ) { + sign='+'; + } else { + sign='-'; + } coord = 'y'; } - fprintf(file,"%s/fs = %C%C\n",p->name, sign, coord); + fprintf(fh, "%s/fs = %C%C\n", p->name, sign, coord); if (p->ssx != 0){ - if (p->ssx>0){sign='+';}else{sign='-';} + if ( p->ssx > 0 ) { + sign='+'; + } else { + sign='-'; + } coord = 'x'; } else { - if (p->ssy>0){sign='+';}else{sign='-';} + if ( p->ssy > 0 ) { + sign='+'; + } else { + sign='-'; + } coord = 'y'; } - fprintf(file,"%s/ss = %C%C\n",p->name, sign, coord); - fprintf(file,"%s/corner_x = %g\n",p->name,p->cnx); - fprintf(file,"%s/corner_y = %g\n",p->name,p->cny); - fprintf(file,"%s/no_index = %d\n",p->name,p->no_index); + fprintf(fh, "%s/ss = %C%C\n", p->name, sign, coord); + fprintf(fh, "%s/corner_x = %g\n", p->name, p->cnx); + fprintf(fh, "%s/corner_y = %g\n", p->name, p->cny); + fprintf(fh, "%s/no_index = %d\n", p->name, p->no_index); } + fclose(fh); return 0; - } |