aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-10-12 12:24:51 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:39 +0100
commit13257c9d5e5c0d06df4ed0bdcdbc2ba6c7acc6cd (patch)
tree7e4307d5fbf6dc49c26ada1a555e21e892ecf743 /src
parentc479780bc2b15e2d095cdb13d69f372933a06597 (diff)
Rationalise handling of phases in RefList
Diffstat (limited to 'src')
-rw-r--r--src/reflist-utils.c17
-rw-r--r--src/reflist.c6
-rw-r--r--src/reflist.h2
3 files changed, 19 insertions, 6 deletions
diff --git a/src/reflist-utils.c b/src/reflist-utils.c
index 4ad5fa1c..b64e9979 100644
--- a/src/reflist-utils.c
+++ b/src/reflist-utils.c
@@ -68,7 +68,7 @@ double *phases_from_list(RefList *list)
refl = next_refl(refl, iter) ) {
signed int h, k, l;
- double phase = get_phase(refl);
+ double phase = get_phase(refl, NULL);
get_indices(refl, &h, &k, &l);
@@ -230,16 +230,19 @@ void write_reflections_to_file(FILE *fh, RefList *list, UnitCell *cell)
refl = next_refl(refl, iter) ) {
signed int h, k, l;
- double intensity, esd_i, s;
+ double intensity, esd_i, s, ph;
int red;
double fs, ss;
char res[16];
+ char phs[16];
+ int have_phase;
get_indices(refl, &h, &k, &l);
get_detector_pos(refl, &fs, &ss);
intensity = get_intensity(refl);
esd_i = get_esd_intensity(refl);
red = get_redundancy(refl);
+ ph = get_phase(refl, &have_phase);
/* Reflections with redundancy = 0 are not written */
if ( red == 0 ) continue;
@@ -251,9 +254,15 @@ void write_reflections_to_file(FILE *fh, RefList *list, UnitCell *cell)
strcpy(res, " -");
}
+ if ( have_phase ) {
+ snprintf(phs, 16, "%8.2f", rad2deg(ph));
+ } else {
+ strncpy(phs, " -", 15);
+ }
+
fprintf(fh,
"%3i %3i %3i %10.2f %s %10.2f %s %7i %6.1f %6.1f\n",
- h, k, l, intensity, " -", esd_i, res, red,
+ h, k, l, intensity, phs, esd_i, res, red,
fs, ss);
}
@@ -350,7 +359,7 @@ RefList *read_reflections_from_file(FILE *fh)
set_redundancy(refl, cts);
ph = strtod(phs, &v);
- if ( v != NULL ) set_ph(refl, ph);
+ if ( v != NULL ) set_ph(refl, deg2rad(ph));
/* The 1/d value is actually ignored. */
diff --git a/src/reflist.c b/src/reflist.c
index fc61a7e4..33a8d60e 100644
--- a/src/reflist.c
+++ b/src/reflist.c
@@ -78,6 +78,7 @@ struct _refldata {
/* Phase */
double phase;
+ int have_phase;
/* Redundancy */
int redundancy;
@@ -451,12 +452,14 @@ double get_esd_intensity(const Reflection *refl)
/**
* get_phase:
* @refl: A %Reflection
+ * @have_phase: Place to store a non-zero value if the phase is set, or NULL.
*
* Returns: the phase for this reflection.
*
**/
-double get_phase(const Reflection *refl)
+double get_phase(const Reflection *refl, int *have_phase)
{
+ if ( have_phase != NULL ) *have_phase = refl->data.have_phase;
return refl->data.phase;
}
@@ -631,6 +634,7 @@ void set_esd_intensity(Reflection *refl, double esd)
void set_ph(Reflection *refl, double phase)
{
refl->data.phase = phase;
+ refl->data.have_phase = 1;
}
diff --git a/src/reflist.h b/src/reflist.h
index 65c8ef0b..6d64498a 100644
--- a/src/reflist.h
+++ b/src/reflist.h
@@ -73,7 +73,7 @@ extern int get_redundancy(const Reflection *refl);
extern double get_temp1(const Reflection *refl);
extern double get_temp2(const Reflection *refl);
extern double get_esd_intensity(const Reflection *refl);
-extern double get_phase(const Reflection *refl);
+extern double get_phase(const Reflection *refl, int *have_phase);
/* Set */
extern void copy_data(Reflection *to, const Reflection *from);