aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-02-26 13:11:22 +0000
committertaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-02-26 13:11:22 +0000
commit76cd15aa8de3f6c78960314ed5e40849be8fd081 (patch)
treecb95a6e31c23a9fbe2421a18b544cdee2fee61dd
parent4feae844d4782f98eb879e31073fa892bca82baf (diff)
Honour voltage from MRC header if present
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@11 bf6ca9ba-c028-0410-8290-897cf20841d1
-rw-r--r--src/mrc.c7
-rw-r--r--src/utils.c12
-rw-r--r--src/utils.h1
3 files changed, 19 insertions, 1 deletions
diff --git a/src/mrc.c b/src/mrc.c
index 26b43cb..a01809c 100644
--- a/src/mrc.c
+++ b/src/mrc.c
@@ -21,6 +21,7 @@
#include "imagedisplay.h"
#include "itrans.h"
#include "reflections.h"
+#include "utils.h"
int mrc_read(ControlContext *ctx) {
@@ -111,7 +112,11 @@ int mrc_read(ControlContext *ctx) {
printf("Image #%3i: tilt=%f omega=%f L=%f\t", i, ext[i].a_tilt, ext[i].tilt_axis, ext[i].magnification);
ctx->camera_length = ext[i].magnification;
- ctx->lambda = 2.51e-12; /* 200kV. Fudged until Max puts the HT voltage in the MRC headers */
+ if ( ext[i].voltage == 0 ) {
+ ctx->lambda = lambda(200000);
+ } else {
+ ctx->lambda = lambda(1000*ext[i].voltage);
+ }
ctx->omega = ext[i].tilt_axis;
ctx->pixel_size = ext[i].pixel_size;
diff --git a/src/utils.c b/src/utils.c
index ce7c7f3..4055676 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -42,3 +42,15 @@ double angle_between(double x1, double y1, double z1, double x2, double y2, doub
return ((acos((x1*x2 + y1*y2 + z1*z2) / (mod1*mod2)))/M_PI) * 180;
}
+
+/* Wavelength of an electron (in m) given accelerating potential (in V) */
+double lambda(double V) {
+
+ double m = 9.110E-31;
+ double h = 6.625E-34;
+ double e = 1.60E-19;
+ double c = 2.998E8;
+
+ return h / sqrt(2*m*e*V*(1+(e*V / 2*m*c*c)));
+
+}
diff --git a/src/utils.h b/src/utils.h
index 10ef3eb..b4a0dca 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -20,5 +20,6 @@ extern unsigned int smallest(signed int a, signed int b);
extern double distance(double x1, double y1, double x2, double y2);
extern double modulus(double x, double y, double z);
extern double angle_between(double x1, double y1, double z1, double x2, double y2, double z2);
+extern double lambda(double voltage);
#endif /* UTILS_H */