aboutsummaryrefslogtreecommitdiff
path: root/src/diffraction.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/diffraction.c')
-rw-r--r--src/diffraction.c81
1 files changed, 19 insertions, 62 deletions
diff --git a/src/diffraction.c b/src/diffraction.c
index fb512e62..efc56231 100644
--- a/src/diffraction.c
+++ b/src/diffraction.c
@@ -71,13 +71,11 @@ static double lattice_factor(struct rvec q, double ax, double ay, double az,
static double interpolate_linear(const double *ref,
- const unsigned int *counts,
float hd, signed int k, signed int l)
{
signed int h;
double val1, val2;
float f;
- unsigned int c1, c2;
h = (signed int)hd;
if ( hd < 0.0 ) h -= 1;
@@ -86,30 +84,15 @@ static double interpolate_linear(const double *ref,
val1 = lookup_intensity(ref, h, k, l);
val2 = lookup_intensity(ref, h+1, k, l);
- c1 = lookup_count(counts, h, k, l);
- c2 = lookup_count(counts, h+1, k, l);
- if ( c1 == 0 ) {
- ERROR("Needed intensity for %i %i %i, but don't have it.\n",
- h, k, l);
- return 1.0e20;
- }
-
- if ( c2 == 0 ) {
- ERROR("Needed intensity for %i %i %i, but don't have it.\n",
- h+1, k, l);
- return 1.0e20;
- }
-
- val1 = val1 / (double)c1;
- val2 = val2 / (double)c2;
+ val1 = val1;
+ val2 = val2;
return (1.0-f)*val1 + f*val2;
}
static double interpolate_bilinear(const double *ref,
- const unsigned int *counts,
float hd, float kd, signed int l)
{
signed int k;
@@ -121,15 +104,14 @@ static double interpolate_bilinear(const double *ref,
f = kd - (float)k;
assert(f >= 0.0);
- val1 = interpolate_linear(ref, counts, hd, k, l);
- val2 = interpolate_linear(ref, counts, hd, k+1, l);
+ val1 = interpolate_linear(ref, hd, k, l);
+ val2 = interpolate_linear(ref, hd, k+1, l);
return (1.0-f)*val1 + f*val2;
}
static double interpolate_intensity(const double *ref,
- const unsigned int *counts,
float hd, float kd, float ld)
{
signed int l;
@@ -141,15 +123,14 @@ static double interpolate_intensity(const double *ref,
f = ld - (float)l;
assert(f >= 0.0);
- val1 = interpolate_bilinear(ref, counts, hd, kd, l);
- val2 = interpolate_bilinear(ref, counts, hd, kd, l+1);
+ val1 = interpolate_bilinear(ref, hd, kd, l);
+ val2 = interpolate_bilinear(ref, hd, kd, l+1);
return (1.0-f)*val1 + f*val2;
}
static double complex interpolate_phased_linear(const double *ref,
- const unsigned int *counts,
const double *phases,
float hd,
signed int k, signed int l)
@@ -157,7 +138,6 @@ static double complex interpolate_phased_linear(const double *ref,
signed int h;
double val1, val2;
float f;
- unsigned int c1, c2;
double ph1, ph2;
double re1, re2, im1, im2;
double re, im;
@@ -169,25 +149,11 @@ static double complex interpolate_phased_linear(const double *ref,
val1 = lookup_intensity(ref, h, k, l);
val2 = lookup_intensity(ref, h+1, k, l);
- c1 = lookup_count(counts, h, k, l);
- c2 = lookup_count(counts, h+1, k, l);
ph1 = lookup_phase(phases, h, k, l);
ph2 = lookup_phase(phases, h+1, k, l);
- if ( c1 == 0 ) {
- ERROR("Needed intensity for %i %i %i, but don't have it.\n",
- h, k, l);
- return 1.0e20;
- }
-
- if ( c2 == 0 ) {
- ERROR("Needed intensity for %i %i %i, but don't have it.\n",
- h+1, k, l);
- return 1.0e20;
- }
-
- val1 = val1 / (double)c1;
- val2 = val2 / (double)c2;
+ val1 = val1;
+ val2 = val2;
/* Calculate real and imaginary parts */
re1 = val1 * cos(ph1);
@@ -203,7 +169,6 @@ static double complex interpolate_phased_linear(const double *ref,
static double complex interpolate_phased_bilinear(const double *ref,
- const unsigned int *counts,
const double *phases,
float hd, float kd,
signed int l)
@@ -217,15 +182,14 @@ static double complex interpolate_phased_bilinear(const double *ref,
f = kd - (float)k;
assert(f >= 0.0);
- val1 = interpolate_phased_linear(ref, counts, phases, hd, k, l);
- val2 = interpolate_phased_linear(ref, counts, phases, hd, k+1, l);
+ val1 = interpolate_phased_linear(ref, phases, hd, k, l);
+ val2 = interpolate_phased_linear(ref, phases, hd, k+1, l);
return (1.0-f)*val1 + f*val2;
}
static double interpolate_phased_intensity(const double *ref,
- const unsigned int *counts,
const double *phases,
float hd, float kd, float ld)
{
@@ -238,16 +202,15 @@ static double interpolate_phased_intensity(const double *ref,
f = ld - (float)l;
assert(f >= 0.0);
- val1 = interpolate_phased_bilinear(ref, counts, phases, hd, kd, l);
- val2 = interpolate_phased_bilinear(ref, counts, phases, hd, kd, l+1);
+ val1 = interpolate_phased_bilinear(ref, phases, hd, kd, l);
+ val2 = interpolate_phased_bilinear(ref, phases, hd, kd, l+1);
return cabs((1.0-f)*val1 + f*val2);
}
/* Look up the structure factor for the nearest Bragg condition */
-static double molecule_factor(const double *intensities,
- const unsigned int *counts, const double *phases,
+static double molecule_factor(const double *intensities,const double *phases,
struct rvec q,
double ax, double ay, double az,
double bx, double by, double bz,
@@ -267,18 +230,13 @@ static double molecule_factor(const double *intensities,
h = (signed int)rint(hd);
k = (signed int)rint(kd);
l = (signed int)rint(ld);
- if ( lookup_count(counts, h, k, l) == 0 ) {
- ERROR("Needed intensity for %i %i %i, but don't have it.\n",
- h, k, l);
- return 1.0e20;
- }
r = lookup_intensity(intensities, h, k, l);
break;
case GRADIENT_INTERPOLATE :
- r = interpolate_intensity(intensities, counts, hd, kd, ld);
+ r = interpolate_intensity(intensities, hd, kd, ld);
break;
case GRADIENT_PHASED :
- r = interpolate_phased_intensity(intensities, counts, phases,
+ r = interpolate_phased_intensity(intensities, phases,
hd, kd, ld);
break;
default:
@@ -291,7 +249,7 @@ static double molecule_factor(const double *intensities,
double water_diffraction(struct rvec q, double en,
- double beam_r, double water_r)
+ double beam_r, double water_r)
{
double complex fH, fO;
double s, modq;
@@ -390,9 +348,8 @@ double get_tt(struct image *image, unsigned int xs, unsigned int ys)
void get_diffraction(struct image *image, int na, int nb, int nc,
- const double *intensities, const unsigned int *counts,
- const double *phases, UnitCell *cell, int do_water,
- GradientMethod m)
+ const double *intensities, const double *phases,
+ UnitCell *cell, int do_water, GradientMethod m)
{
unsigned int xs, ys;
double ax, ay, az;
@@ -447,7 +404,7 @@ void get_diffraction(struct image *image, int na, int nb, int nc,
I_molecule = 1.0e10;
} else {
I_molecule = molecule_factor(intensities,
- counts, phases, q,
+ phases, q,
ax,ay,az,
bx,by,bz,cx,cy,cz,
m);