From 7601a2956156569461498a76105267129e848fb0 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 27 Jun 2019 16:34:45 +0200 Subject: partialator: Use Spectrum API --- libcrystfel/src/geometry.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'libcrystfel/src/geometry.c') diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c index ffb17133..4f9515c5 100644 --- a/libcrystfel/src/geometry.c +++ b/libcrystfel/src/geometry.c @@ -522,7 +522,7 @@ static void set_random_partialities(Crystal *cryst) static double do_integral(double q2, double zl, double R, - double lambda, double sig, char *verbose) + Spectrum *spectrum, char *verbose) { int i; double kmin, kmax, kstart, kfinis; @@ -530,7 +530,6 @@ static double do_integral(double q2, double zl, double R, double total = 0.0; double k0, k1; const int SAMPLES = 50; /* Number of samples for integration */ - const double N = 1.5; /* Pointiness of spectrum */ FILE *fh = NULL; assert(R*R < q2); @@ -545,8 +544,7 @@ static double do_integral(double q2, double zl, double R, if ( k1 < 0.0 ) k1 = +INFINITY; /* Range over which E is significantly different from zero */ - kmin = 1.0 / (lambda + 3.0*sig); - kmax = 1.0 / (lambda - 3.0*sig); + spectrum_get_range(spectrum, &kmin, &kmax); /* Calculate range over which E*P is different from zero */ if ( k0 < k1 ) { @@ -592,9 +590,6 @@ static double do_integral(double q2, double zl, double R, snprintf(fn, 63, "partial%s.graph", verbose); fh = fopen(fn, "w"); fprintf(fh, " n p wavelength E P\n"); - STATUS("Nominal k = %e m^-1\n", 1.0/lambda); - STATUS(" (wavelength %e m)\n", lambda); - STATUS("Bandwidth %e m\n", sig); STATUS("k1/2 = %e m^-1\n", -q2/(2.0*zl)); STATUS(" (wavelength %e m)\n", 1.0/(-q2/(2.0*zl))); STATUS("Reflection k goes from %e to %e m^-1\n", k1, k0); @@ -607,7 +602,7 @@ static double do_integral(double q2, double zl, double R, for ( i=0; ilambda; - sig = image->bw * lambda / 2.0; for ( refl = first_refl(crystal_get_reflections(cryst), &iter); refl != NULL; @@ -710,8 +698,9 @@ static void ginn_spectrum_partialities(Crystal *cryst) //snprintf(tmp, 255, "-%i,%i,%i", h, k, l); char *tmp = NULL; - total = do_integral(q2, zl, R, lambda, sig, tmp); - norm = do_integral(q2, -0.5*q2*lambda, R, lambda, sig, NULL); + total = do_integral(q2, zl, R, image->spectrum, tmp); + norm = do_integral(q2, -0.5*q2*image->lambda, R, + image->spectrum, NULL); set_partiality(refl, total/norm); set_lorentz(refl, 1.0); -- cgit v1.2.3