diff options
author | Thomas White <taw@physics.org> | 2011-03-31 14:21:34 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:23 +0100 |
commit | 40c22e008a966d55e4a803373306f821f2fc788e (patch) | |
tree | 71eafaa33920678cdfbbbe44560dd0315a88ac24 /src | |
parent | 3bd3007d172cb71684a328aeb064a1bed8f0ff1f (diff) |
Allow default values in geometry files, and set integration radius seperately
Diffstat (limited to 'src')
-rw-r--r-- | src/detector.c | 51 | ||||
-rw-r--r-- | src/detector.h | 3 | ||||
-rw-r--r-- | src/peaks.c | 13 |
3 files changed, 44 insertions, 23 deletions
diff --git a/src/detector.c b/src/detector.c index b3eb8faa..c542a5a1 100644 --- a/src/detector.c +++ b/src/detector.c @@ -306,21 +306,12 @@ static struct panel *new_panel(struct detector *det, const char *name) det->panels = realloc(det->panels, det->n_panels*sizeof(struct panel)); new = &det->panels[det->n_panels-1]; - new->min_fs = -1; - new->min_ss = -1; - new->max_fs = -1; - new->max_ss = -1; - new->cnx = NAN; - new->cny = NAN; - new->clen = -1.0; - new->res = -1.0; - new->badrow = '-'; - new->no_index = 0; - new->peak_sep = 50.0; - new->fsx = 1.0; - new->fsy = 0.0; - new->ssx = 0.0; - new->ssy = 1.0; + memcpy(new, &det->defaults, sizeof(struct panel)); + + /* Create a new copy of the camera length location if needed */ + if ( new->clen_from != NULL ) { + new->clen_from = strdup(new->clen_from); + } strcpy(new->name, name); return new; @@ -408,6 +399,8 @@ static int parse_field_for_panel(struct panel *panel, const char *key, panel->res = atof(val); } else if ( strcmp(key, "peak_sep") == 0 ) { panel->peak_sep = atof(val); + } else if ( strcmp(key, "integr_radius") == 0 ) { + panel->integr_radius = atof(val); } else if ( strcmp(key, "badrow_direction") == 0 ) { panel->badrow = val[0]; /* First character only */ if ( (panel->badrow != 'x') && (panel->badrow != 'y') @@ -487,7 +480,11 @@ static void parse_toplevel(struct detector *det, const char *key, det->mask_good = v; } - } else { + } else if ( strcmp(key, "peak_sep") == 0 ) { + det->defaults.peak_sep = atof(val); + } else if ( strcmp(key, "integr_radius") == 0 ) { + det->defaults.integr_radius = atof(val); + } else if ( parse_field_for_panel(&det->defaults, key, val) ) { ERROR("Unrecognised top level field '%s'\n", key); } } @@ -505,11 +502,12 @@ struct detector *get_detector_geometry(const char *filename) fh = fopen(filename, "r"); if ( fh == NULL ) return NULL; - det = malloc(sizeof(struct detector)); + det = calloc(1, sizeof(struct detector)); if ( det == NULL ) { fclose(fh); return NULL; } + det->n_panels = 0; det->panels = NULL; det->n_bad = 0; @@ -518,6 +516,25 @@ struct detector *get_detector_geometry(const char *filename) det->mask_bad = 0; det->mask = NULL; + /* The default defaults... */ + det->defaults.min_fs = -1; + det->defaults.min_ss = -1; + det->defaults.max_fs = -1; + det->defaults.max_ss = -1; + det->defaults.cnx = NAN; + det->defaults.cny = NAN; + det->defaults.clen = -1.0; + det->defaults.res = -1.0; + det->defaults.badrow = '-'; + det->defaults.no_index = 0; + det->defaults.peak_sep = 50.0; + det->defaults.integr_radius = 10.0; + det->defaults.fsx = 1.0; + det->defaults.fsy = 0.0; + det->defaults.ssx = 0.0; + det->defaults.ssy = 1.0; + strncpy(det->defaults.name, "", 1023); + do { int n1, n2; diff --git a/src/detector.h b/src/detector.h index 42651ebd..0ceff341 100644 --- a/src/detector.h +++ b/src/detector.h @@ -39,6 +39,7 @@ struct panel char badrow; /* 'x' or 'y' */ int no_index; /* Don't index peaks in this panel if non-zero */ double peak_sep; /* Characteristic peak separation */ + double integr_radius; /* Peak integration radius */ double fsx; double fsy; @@ -76,6 +77,8 @@ struct detector char *mask; unsigned int mask_bad; unsigned int mask_good; + + struct panel defaults; }; diff --git a/src/peaks.c b/src/peaks.c index 65002538..38825d93 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -160,8 +160,8 @@ int integrate_peak(struct image *image, int cfs, int css, if ( p == NULL ) return 1; if ( p->no_index ) return 1; - lim = p->peak_sep/4.0; - out_lim = 1.0 + lim; + lim = p->integr_radius; + out_lim = 2.0 + lim; lim_sq = pow(lim, 2.0); out_lim_sq = pow(out_lim, 2.0); @@ -338,15 +338,16 @@ static void search_peaks_in_panel(struct image *image, float threshold, } /* Abort if drifted too far from the foot point */ - if ( distance(mask_fs, mask_ss, fs, ss) - > p->peak_sep ) { + if ( distance(mask_fs, mask_ss, fs, ss) > + p->peak_sep/2.0 ) + { break; } } while ( did_something ); /* Too far from foot point? */ - if ( distance(mask_fs, mask_ss, fs, ss) > p->peak_sep ) { + if ( distance(mask_fs, mask_ss, fs, ss) > p->peak_sep/2.0 ) { nrej_dis++; continue; } @@ -377,7 +378,7 @@ static void search_peaks_in_panel(struct image *image, float threshold, /* Check for a nearby feature */ image_feature_closest(image->features, f_fs, f_ss, &d, &idx); - if ( d < p->peak_sep ) { + if ( d < p->peak_sep/2.0 ) { nrej_pro++; continue; } |