diff options
author | Thomas White <taw@physics.org> | 2013-03-07 10:50:13 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2013-04-17 17:33:48 +0200 |
commit | bc628cd85f512d962828e9b8c5df5a6e6d22fac5 (patch) | |
tree | 95d9ac47def582023b54884fab131bbc09a746b9 /src | |
parent | 79993f9373e4a7fdcbff8a7d83af4b7289622cf3 (diff) |
Add the possibility to have different partiality models
Diffstat (limited to 'src')
-rw-r--r-- | src/partialator.c | 25 | ||||
-rw-r--r-- | src/post-refinement.c | 13 | ||||
-rw-r--r-- | src/post-refinement.h | 6 |
3 files changed, 33 insertions, 11 deletions
diff --git a/src/partialator.c b/src/partialator.c index a4af3c18..079e078e 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -88,6 +88,7 @@ struct refine_args { RefList *full; Crystal *crystal; + PartialityModel pmodel; }; @@ -106,7 +107,7 @@ static void refine_image(void *task, int id) struct refine_args *pargs = task; Crystal *cr = pargs->crystal; - pr_refine(cr, pargs->full); + pr_refine(cr, pargs->full, pargs->pmodel); } @@ -314,6 +315,8 @@ int main(int argc, char *argv[]) int noscale = 0; Stream *st; Crystal **crystals; + char *pmodel_str = NULL; + PartialityModel pmodel = PMODEL_SPHERE; /* Long options */ const struct option longopts[] = { @@ -326,6 +329,7 @@ int main(int argc, char *argv[]) {"iterations", 1, NULL, 'n'}, {"no-scale", 0, &noscale, 1}, {"reference", 1, NULL, 'r'}, + {"partiality", 1, NULL, 'm'}, {0, 0, NULL, 0} }; @@ -336,7 +340,7 @@ int main(int argc, char *argv[]) } /* Short options */ - while ((c = getopt_long(argc, argv, "hi:o:g:b:y:n:r:j:", + while ((c = getopt_long(argc, argv, "hi:o:g:b:y:n:r:j:m:", longopts, NULL)) != -1) { @@ -370,6 +374,10 @@ int main(int argc, char *argv[]) n_iter = atoi(optarg); break; + case 'm' : + pmodel_str = strdup(optarg); + break; + case 'b' : beam = get_beam_parameters(optarg); if ( beam == NULL ) { @@ -434,6 +442,17 @@ int main(int argc, char *argv[]) return 1; } + if ( pmodel_str != NULL ) { + if ( strcmp(pmodel_str, "sphere") == 0 ) { + pmodel = PMODEL_SPHERE; + } else if ( strcmp(pmodel_str, "unity") == 0 ) { + pmodel = PMODEL_UNITY; + } else { + ERROR("Unknown partiality model '%s'.\n", pmodel_str); + return 1; + } + } + if ( reference_file != NULL ) { RefList *list; @@ -544,7 +563,7 @@ int main(int argc, char *argv[]) crystal_set_image(cryst, &images[i]); /* Now it's safe to do the following */ - update_partialities(cryst); + update_partialities(cryst, pmodel); as = crystal_get_reflections(cryst); nobs += select_scalable_reflections(as, reference); diff --git a/src/post-refinement.c b/src/post-refinement.c index 1439b148..f6f4caa5 100644 --- a/src/post-refinement.c +++ b/src/post-refinement.c @@ -88,7 +88,7 @@ static double partiality_rgradient(double r, double profile_radius) /* Return the gradient of parameter 'k' given the current status of 'image'. */ -double gradient(Crystal *cr, int k, Reflection *refl) +double gradient(Crystal *cr, int k, Reflection *refl, PartialityModel pmodel) { double ds, azix, aziy; double ttlow, tthigh, tt; @@ -364,7 +364,8 @@ static gsl_vector *solve_svd(gsl_vector *v, gsl_matrix *M) /* Perform one cycle of post refinement on 'image' against 'full' */ -static double pr_iterate(Crystal *cr, const RefList *full) +static double pr_iterate(Crystal *cr, const RefList *full, + PartialityModel pmodel) { gsl_matrix *M; gsl_vector *v; @@ -420,7 +421,7 @@ static double pr_iterate(Crystal *cr, const RefList *full) /* Calculate all gradients for this reflection */ for ( k=0; k<NUM_PARAMS; k++ ) { double gr; - gr = gradient(cr, k, refl); + gr = gradient(cr, k, refl, pmodel); gradients[k] = gr; } @@ -532,7 +533,7 @@ static double guide_dev(Crystal *cr, const RefList *full) } -void pr_refine(Crystal *cr, const RefList *full) +void pr_refine(Crystal *cr, const RefList *full, PartialityModel pmodel) { double max_shift, dev; int i; @@ -557,9 +558,9 @@ void pr_refine(Crystal *cr, const RefList *full) cell_get_reciprocal(crystal_get_cell(cr), &asx, &asy, &asz, &bsx, &bsy, &bsz, &csx, &csy, &csz); - max_shift = pr_iterate(cr, full); + max_shift = pr_iterate(cr, full, pmodel); - update_partialities(cr); + update_partialities(cr, pmodel); if ( verbose ) { dev = guide_dev(cr, full); diff --git a/src/post-refinement.h b/src/post-refinement.h index fe171882..7b822938 100644 --- a/src/post-refinement.h +++ b/src/post-refinement.h @@ -40,6 +40,7 @@ #include "image.h" #include "utils.h" #include "crystal.h" +#include "geometry.h" /* Refineable parameters */ @@ -59,10 +60,11 @@ enum { }; -extern void pr_refine(Crystal *cr, const RefList *full); +extern void pr_refine(Crystal *cr, const RefList *full, PartialityModel pmodel); /* Exported so it can be poked by tests/pr_gradient_check */ -extern double gradient(Crystal *cr, int k, Reflection *refl); +extern double gradient(Crystal *cr, int k, Reflection *refl, + PartialityModel pmodel); #endif /* POST_REFINEMENT_H */ |