diff options
author | Thomas White <taw@physics.org> | 2019-06-27 16:34:45 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2019-07-17 09:22:23 +0200 |
commit | 7601a2956156569461498a76105267129e848fb0 (patch) | |
tree | 74abe507007eda637731c1d728f9392d8b471a40 /src | |
parent | cccf87c808f430274a0691a0c9557d6f14bf74a9 (diff) |
partialator: Use Spectrum API
Diffstat (limited to 'src')
-rw-r--r-- | src/partialator.c | 29 | ||||
-rw-r--r-- | src/post-refinement.c | 22 |
2 files changed, 39 insertions, 12 deletions
diff --git a/src/partialator.c b/src/partialator.c index 92fcfbe4..de7eeb4b 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -570,8 +570,11 @@ static void skip_to_end(FILE *fh) } -static int set_initial_params(Crystal *cr, FILE *fh) +static int set_initial_params(Crystal *cr, FILE *fh, double force_bandwidth, + double force_radius, double force_lambda) { + struct image *image = crystal_get_image(cr); + if ( fh != NULL ) { int err; @@ -596,6 +599,17 @@ static int set_initial_params(Crystal *cr, FILE *fh) } + if ( force_bandwidth > 0.0 ) { + image->bw = force_bandwidth; + } + if ( force_radius > 0.0 ) { + crystal_set_profile_radius(cr, force_radius); + } + if ( force_lambda > 0.0 ) { + image->lambda = force_lambda; + } + image->spectrum = spectrum_generate_gaussian(image->lambda, image->bw); + return 0; } @@ -1420,7 +1434,9 @@ int main(int argc, char *argv[]) crystal_set_user_flag(cr, PRFLAG_OK); reflist_free(cr_refl); - if ( set_initial_params(cr, sparams_fh) ) { + if ( set_initial_params(cr, sparams_fh, force_bandwidth, + force_radius, force_lambda) ) + { ERROR("Failed to set initial parameters\n"); return 1; } @@ -1451,15 +1467,6 @@ int main(int argc, char *argv[]) STATUS("Initial partiality calculation...\n"); for ( i=0; i<n_crystals; i++ ) { Crystal *cr = crystals[i]; - if ( force_bandwidth > 0.0 ) { - crystal_get_image(cr)->bw = force_bandwidth; - } - if ( force_radius > 0.0 ) { - crystal_set_profile_radius(cr, force_radius); - } - if ( force_lambda > 0.0 ) { - crystal_get_image(cr)->lambda = force_lambda; - } update_predictions(cr); calculate_partialities(cr, pmodel); } diff --git a/src/post-refinement.c b/src/post-refinement.c index 59d44425..6db1a48a 100644 --- a/src/post-refinement.c +++ b/src/post-refinement.c @@ -153,14 +153,22 @@ static void apply_parameters(const Crystal *cr_orig, Crystal *cr_tgt, struct rf_alteration alter) { double R, lambda; + struct gaussian g; + struct image *image; + image = crystal_get_image(cr_tgt); R = crystal_get_profile_radius(cr_orig); lambda = crystal_get_image_const(cr_orig)->lambda; rotate_cell_xy(crystal_get_cell_const(cr_orig), crystal_get_cell(cr_tgt), alter.rot_x, alter.rot_y); crystal_set_profile_radius(cr_tgt, R+alter.delta_R); - crystal_get_image(cr_tgt)->lambda = lambda+alter.delta_wave; + image->lambda = lambda+alter.delta_wave; + + g.kcen = 1.0/image->lambda; + g.sigma = image->bw/image->lambda; + g.height = 1; + spectrum_set_gaussians(image->spectrum, &g, 1); } @@ -442,6 +450,7 @@ static void write_angle_grid(Crystal *cr, const RefList *full, struct rf_priv priv; RefList *list; UnitCell *cell; + Spectrum *spectrum; priv.cr = cr; priv.full = full; @@ -449,6 +458,8 @@ static void write_angle_grid(Crystal *cr, const RefList *full, priv.scaleflags = scaleflags; priv.cr_tgt = crystal_copy(cr); priv.image_tgt = *crystal_get_image(cr); + spectrum = spectrum_new(); + priv.image_tgt.spectrum = spectrum; crystal_set_image(priv.cr_tgt, &priv.image_tgt); list = copy_reflist(crystal_get_reflections(cr)); crystal_set_reflections(priv.cr_tgt, list); @@ -490,6 +501,7 @@ static void write_angle_grid(Crystal *cr, const RefList *full, reflist_free(crystal_get_reflections(priv.cr_tgt)); crystal_free(priv.cr_tgt); + spectrum_free(spectrum); } @@ -502,6 +514,7 @@ static void write_radius_grid(Crystal *cr, const RefList *full, struct rf_priv priv; RefList *list; UnitCell *cell; + Spectrum *spectrum; priv.cr = cr; priv.full = full; @@ -509,6 +522,8 @@ static void write_radius_grid(Crystal *cr, const RefList *full, priv.scaleflags = scaleflags; priv.cr_tgt = crystal_copy(cr); priv.image_tgt = *crystal_get_image(cr); + spectrum = spectrum_new(); + priv.image_tgt.spectrum = spectrum; crystal_set_image(priv.cr_tgt, &priv.image_tgt); list = copy_reflist(crystal_get_reflections(cr)); crystal_set_reflections(priv.cr_tgt, list); @@ -550,6 +565,7 @@ static void write_radius_grid(Crystal *cr, const RefList *full, reflist_free(crystal_get_reflections(priv.cr_tgt)); crystal_free(priv.cr_tgt); + spectrum_free(spectrum); } @@ -635,6 +651,7 @@ static void do_pr_refine(Crystal *cr, const RefList *full, RefList *list; FILE *fh = NULL; UnitCell *cell; + Spectrum *spectrum; try_reindex(cr, full, sym, amb, scaleflags); @@ -651,6 +668,8 @@ static void do_pr_refine(Crystal *cr, const RefList *full, priv.scaleflags = scaleflags; priv.cr_tgt = crystal_copy(cr); priv.image_tgt = *crystal_get_image(cr); + spectrum = spectrum_new(); + priv.image_tgt.spectrum = spectrum; crystal_set_image(priv.cr_tgt, &priv.image_tgt); list = copy_reflist(crystal_get_reflections(cr)); crystal_set_reflections(priv.cr_tgt, list); @@ -718,6 +737,7 @@ static void do_pr_refine(Crystal *cr, const RefList *full, reflist_free(crystal_get_reflections(priv.cr_tgt)); crystal_free(priv.cr_tgt); + spectrum_free(spectrum); } |