aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt8
-rw-r--r--CONTRIBUTING.md52
-rw-r--r--config.h.cmake.in1
-rw-r--r--config.h.in1
-rw-r--r--libcrystfel/CMakeLists.txt7
-rw-r--r--libcrystfel/config.h.cmake.in1
-rw-r--r--libcrystfel/config.h.in1
-rw-r--r--libcrystfel/meson.build8
-rw-r--r--libcrystfel/src/image.c47
-rw-r--r--libcrystfel/src/reflist-utils.c478
-rw-r--r--libcrystfel/src/reflist-utils.h10
-rw-r--r--meson.build8
-rw-r--r--src/crystfel_gui.c20
-rw-r--r--src/crystfelimageview.c37
-rw-r--r--src/crystfelimageview.h6
-rw-r--r--src/crystfelindexingopts.c68
-rw-r--r--src/crystfelindexingopts.h17
-rw-r--r--src/get_hkl.c46
-rw-r--r--src/gui_export.c460
-rw-r--r--src/gui_index.c14
-rw-r--r--src/gui_project.c24
-rw-r--r--src/gui_project.h4
22 files changed, 813 insertions, 505 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7f6d8a72..6cfaab14 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -76,7 +76,6 @@ endif()
pkg_search_module(CAIRO cairo)
pkg_search_module(GDKPIXBUF gdk-pixbuf-2.0)
-pkg_search_module(LIBCCP4 libccp4c)
include(CheckCCompilerFlag)
check_c_compiler_flag("-fdiagnostics-color=always" HAVE_DIAG_COLOR)
@@ -120,7 +119,6 @@ set(HAVE_GDKPIXBUF ${GDKPIXBUF_FOUND})
set(HAVE_GDK ${GDK_FOUND})
set(HAVE_MSGPACK ${MSGPACK_FOUND})
set(HAVE_ZMQ ${ZMQ_FOUND})
-set(HAVE_LIBCCP4 ${LIBCCP4_FOUND})
set(PACKAGE_VERSION ${PROJECT_VERSION})
@@ -405,10 +403,8 @@ if (GTK_FOUND)
add_executable(crystfel ${CRYSTFEL_GUI_SOURCES}
${CMAKE_CURRENT_BINARY_DIR}/version.c)
- target_include_directories(crystfel PRIVATE ${COMMON_INCLUDES} ${GTK_INCLUDE_DIRS}
- ${LIBCCP4_INCLUDES})
- target_link_libraries (crystfel ${COMMON_LIBRARIES} util ${GTK_LIBRARIES}
- ${LIBCCP4_LIBRARIES})
+ target_include_directories(crystfel PRIVATE ${COMMON_INCLUDES} ${GTK_INCLUDE_DIRS})
+ target_link_libraries (crystfel ${COMMON_LIBRARIES} util ${GTK_LIBRARIES})
if (HAVE_SLURM)
target_link_libraries(crystfel slurm)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..00fb770c
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,52 @@
+Contributing to CrystFEL
+========================
+
+Citing CrystFEL
+---------------
+
+The easiest way to ensure the future of CrystFEL is to use it and cite it in your publications! If your paper doesn't already appear on the [citations page](https://www.desy.de/~twhite/crystfel/citations.html), or if the information there is incomplete, be sure to get in touch about it.
+
+
+Reporting issues
+----------------
+
+If you notice a problem, don't suffer in silence! There are three ways to report a problem:
+
+* Send an email to me (taw@physics.org).
+* Open an issue on the [DESY GitLab](https://gitlab.desy.de/thomas.white/crystfel), if you have a DESY or [Helmholtz AAI](https://login.helmholtz.de/home/) account.
+* Open an issue on [Github](https://github.com/taw10/crystfel). You will need a (free) Github account for this.
+
+Opening an issue on one of the project pages is the best way if your problem is well defined and reproducible, for example "I clicked on a button and the program crashed".
+
+When the problem is less well defined, for example "I upgraded to the latest version and now my data doesn't come out as well as before", it's better to get in touch directly because I'll probably need to look at your data to find the problem. In the case of a change in final data quality, I'd rather hear about it directly than read about it an a journal article, which is rarely useful for making further improvements (even if the change is positive!).
+
+The CrystFEL project on the [DESY Jira](https://agira.desy.de/projects/CRYS/issues) server is now regarded as deprecated. Please do not open any new issues there.
+
+
+Contributing patches
+--------------------
+
+Patches to fix issues are always welcome. Use one of the following methods, in rough order of preference:
+
+* Create a merge request on the [DESY GitLab](https://gitlab.desy.de/thomas.white/crystfel), if you have a DESY or [Helmholtz AAI](https://login.helmholtz.de/home/) account.
+* Open a pull request on [Github](https://github.com/taw10/crystfel). You will need a (free) Github account for this.
+* Send a patch to me (taw@physics.org).
+
+The CrystFEL repository on the [DESY Bitbucket](https://stash.desy.de/projects/CRYS/repos/crystfel/) server is now regarded as deprecated. Please do not create any new pull requests there.
+
+For larger changes, such as adding a new feature or extending the current functionality to a new type of data, it's best to get in touch before starting more than a proof of concept. It's very important that new features are compatible with all the existing methods, and it can be difficult to achieve full compatability without a deep knowledge of the internals of CrystFEL. Hundreds of scientific results depend on us getting this right. Bigger changes to CrystFEL will take much longer to review and merge, and we won't rush it. Not even if you have a paper deadline coming up. Feel free to fork the project in the meantime.
+
+All contributions must be under the [GNU General Public License, version 3](https://www.gnu.org/licenses/gpl-3.0.html). The copyright holder of your contributed code depends on your situation, and we do not require any re-assignment of copyright when contributing. In Germany, the copyright holder will most likely be your employer. Please update the copyright and authorship details at the top of each file you make changes to. Including your email address in the source code is optional.
+
+Finally, please make sure that your branch or patch is "clean". That means:
+
+* Follow the formatting style of the existing code rigorously.
+* Remove *all* trailing whitespace.
+* Filter out irrelevant changes (*always* use `git add -p`).
+* Rebase and squash commits to (as far as possible) form a series of self-contained changes.
+
+
+Translations
+------------
+
+Are you interested in translating CrystFEL into another language? Changes to CrystFEL to enable easy translation are planned. It would be helpful to know how much demand there is for this, as well as which languages might be added. Please get in touch if you're interested.
diff --git a/config.h.cmake.in b/config.h.cmake.in
index a206adda..ff310c7d 100644
--- a/config.h.cmake.in
+++ b/config.h.cmake.in
@@ -10,4 +10,3 @@
#cmakedefine HAVE_MSGPACK
#cmakedefine HAVE_ZMQ
#cmakedefine HAVE_SLURM
-#cmakedefine HAVE_LIBCCP4
diff --git a/config.h.in b/config.h.in
index ba3f42a3..6344497f 100644
--- a/config.h.in
+++ b/config.h.in
@@ -10,4 +10,3 @@
#mesondefine HAVE_MSGPACK
#mesondefine HAVE_ZMQ
#mesondefine HAVE_SLURM
-#mesondefine HAVE_LIBCCP4
diff --git a/libcrystfel/CMakeLists.txt b/libcrystfel/CMakeLists.txt
index fc5574fd..1da91680 100644
--- a/libcrystfel/CMakeLists.txt
+++ b/libcrystfel/CMakeLists.txt
@@ -9,6 +9,7 @@ find_package(FLEX REQUIRED)
find_package(BISON REQUIRED)
find_package(Doxygen)
pkg_search_module(FFTW fftw3)
+pkg_search_module(LIBCCP4 libccp4c)
configure_file(src/libcrystfel-version.c.cmake.in libcrystfel-version.c)
@@ -17,6 +18,7 @@ set(HAVE_FFTW ${FFTW_FOUND})
set(HAVE_XGANDALF ${XGANDALF_FOUND})
set(HAVE_PINKINDEXER ${PINKINDEXER_FOUND})
set(HAVE_FDIP ${FDIP_FOUND})
+set(HAVE_LIBCCP4 ${LIBCCP4_FOUND})
# Recent enough version of zlib?
set(CMAKE_REQUIRED_LIBRARIES "-lz")
@@ -162,6 +164,11 @@ if (CURSES_FOUND)
target_link_libraries(${PROJECT_NAME} PRIVATE ${CURSES_LIBRARIES})
endif (CURSES_FOUND)
+if (LIBCCP4_FOUND)
+ target_include_directories(${PROJECT_NAME} PRIVATE ${LIBCCP4_INCLUDES})
+ target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBCCP4_LIBRARIES})
+endif (LIBCCP4_FOUND)
+
target_compile_options(${PROJECT_NAME} PRIVATE -Wall)
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${LIBCRYSTFEL_HEADERS}")
diff --git a/libcrystfel/config.h.cmake.in b/libcrystfel/config.h.cmake.in
index 7f0dcd94..63211779 100644
--- a/libcrystfel/config.h.cmake.in
+++ b/libcrystfel/config.h.cmake.in
@@ -8,6 +8,7 @@
#cmakedefine HAVE_CURSES
#cmakedefine HAVE_GZBUFFER
#cmakedefine HAVE_GDKPIXBUF
+#cmakedefine HAVE_LIBCCP4
#cmakedefine HAVE_FORKPTY_PTY_H
#cmakedefine HAVE_FORKPTY_UTIL_H
diff --git a/libcrystfel/config.h.in b/libcrystfel/config.h.in
index 1fdd2e13..c00f559e 100644
--- a/libcrystfel/config.h.in
+++ b/libcrystfel/config.h.in
@@ -6,6 +6,7 @@
#mesondefine HAVE_FDIP
#mesondefine HAVE_CURSES
#mesondefine HAVE_GZBUFFER
+#mesondefine HAVE_LIBCCP4
#mesondefine HAVE_FORKPTY_PTY_H
#mesondefine HAVE_FORKPTY_UTIL_H
diff --git a/libcrystfel/meson.build b/libcrystfel/meson.build
index 7171f321..10c66ace 100644
--- a/libcrystfel/meson.build
+++ b/libcrystfel/meson.build
@@ -32,6 +32,11 @@ if fdipdep.found()
conf_data.set10('HAVE_FDIP', 1)
endif
+ccp4dep = dependency('libccp4c', required: false)
+if ccp4dep.found()
+ conf_data.set10('HAVE_LIBCCP4', 1)
+endif
+
libcrystfel_versionc = vcs_tag(input: 'src/libcrystfel-version.c.in',
output: 'libcrystfel-version.c')
@@ -123,7 +128,8 @@ libcrystfel = library('crystfel', [libcrystfel_sources, libcrystfel_versionc],
include_directories : [libcrystfel_includes, libcrystfel_conf_inc],
dependencies : [mdep, utildep, fftwdep, gsldep, zlibdep,
hdf5dep, pthreaddep, ncursesdep,
- xgandalfdep, pinkindexerdep, fdipdep],
+ xgandalfdep, pinkindexerdep, fdipdep,
+ ccp4dep],
install : true)
libcrystfeldep = declare_dependency(include_directories : libcrystfel_includes,
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index db47f75d..99b0891e 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -420,67 +420,68 @@ int create_detgeom(struct image *image, const DataTemplate *dtempl)
for ( i=0; i<dtempl->n_panels; i++ ) {
+ struct detgeom_panel *p = &detgeom->panels[i];
double shift_x, shift_y;
- detgeom->panels[i].name = safe_strdup(dtempl->panels[i].name);
+ p->name = safe_strdup(dtempl->panels[i].name);
- detgeom->panels[i].pixel_pitch = dtempl->panels[i].pixel_pitch;
+ p->pixel_pitch = dtempl->panels[i].pixel_pitch;
/* NB cnx,cny are in pixels, cnz is in m */
- detgeom->panels[i].cnx = dtempl->panels[i].cnx;
- detgeom->panels[i].cny = dtempl->panels[i].cny;
- detgeom->panels[i].cnz = im_get_length(image,
- dtempl->panels[i].cnz_from,
- 1e-3);
+ p->cnx = dtempl->panels[i].cnx;
+ p->cny = dtempl->panels[i].cny;
+ p->cnz = im_get_length(image,
+ dtempl->panels[i].cnz_from,
+ 1e-3);
/* Apply offset (in m) and then convert cnz from
* m to pixels */
- detgeom->panels[i].cnz += dtempl->panels[i].cnz_offset;
- detgeom->panels[i].cnz /= detgeom->panels[i].pixel_pitch;
+ p->cnz += dtempl->panels[i].cnz_offset;
+ p->cnz /= p->pixel_pitch;
/* Apply overall shift (already in m) */
shift_x = im_get_length(image, dtempl->shift_x_from, 1.0);
shift_y = im_get_length(image, dtempl->shift_y_from, 1.0);
if ( !isnan(shift_x) ) {
- detgeom->panels[i].cnx += shift_x;
+ p->cnx += shift_x / p->pixel_pitch;
}
if ( !isnan(shift_y) ) {
- detgeom->panels[i].cny += shift_y;
+ p->cny += shift_y / p->pixel_pitch;
}
- detgeom->panels[i].max_adu = dtempl->panels[i].max_adu;
+ p->max_adu = dtempl->panels[i].max_adu;
switch ( dtempl->panels[i].adu_scale_unit ) {
case ADU_PER_PHOTON:
- detgeom->panels[i].adu_per_photon = dtempl->panels[i].adu_scale;
+ p->adu_per_photon = dtempl->panels[i].adu_scale;
break;
case ADU_PER_EV:
- detgeom->panels[i].adu_per_photon = dtempl->panels[i].adu_scale
+ p->adu_per_photon = dtempl->panels[i].adu_scale
* ph_lambda_to_eV(image->lambda);
break;
default:
- detgeom->panels[i].adu_per_photon = 1.0;
+ p->adu_per_photon = 1.0;
ERROR("Invalid ADU/ph scale unit (%i)\n",
dtempl->panels[i].adu_scale_unit);
break;
}
- detgeom->panels[i].w = dtempl->panels[i].orig_max_fs
+ p->w = dtempl->panels[i].orig_max_fs
- dtempl->panels[i].orig_min_fs + 1;
- detgeom->panels[i].h = dtempl->panels[i].orig_max_ss
+ p->h = dtempl->panels[i].orig_max_ss
- dtempl->panels[i].orig_min_ss + 1;
- detgeom->panels[i].fsx = dtempl->panels[i].fsx;
- detgeom->panels[i].fsy = dtempl->panels[i].fsy;
- detgeom->panels[i].fsz = dtempl->panels[i].fsz;
- detgeom->panels[i].ssx = dtempl->panels[i].ssx;
- detgeom->panels[i].ssy = dtempl->panels[i].ssy;
- detgeom->panels[i].ssz = dtempl->panels[i].ssz;
+ p->fsx = dtempl->panels[i].fsx;
+ p->fsy = dtempl->panels[i].fsy;
+ p->fsz = dtempl->panels[i].fsz;
+ p->ssx = dtempl->panels[i].ssx;
+ p->ssy = dtempl->panels[i].ssy;
+ p->ssz = dtempl->panels[i].ssz;
}
diff --git a/libcrystfel/src/reflist-utils.c b/libcrystfel/src/reflist-utils.c
index 42c3f06d..90f7b91b 100644
--- a/libcrystfel/src/reflist-utils.c
+++ b/libcrystfel/src/reflist-utils.c
@@ -35,6 +35,12 @@
#include <stdio.h>
#include <assert.h>
+#ifdef HAVE_LIBCCP4
+#include <ccp4/cmtzlib.h>
+#include <ccp4/csymlib.h>
+#include <ccp4/ccp4_parser.h>
+#endif
+
#include "reflist.h"
#include "cell.h"
#include "cell-utils.h"
@@ -707,3 +713,475 @@ void reflist_add_command_and_version(RefList *list, int argc, char *argv[])
reflist_add_notes(list, tmp);
free(tmp);
}
+
+
+struct point_group_conversion
+{
+ char centering;
+ const char *crystfel;
+ int friedel;
+
+ int xds_spgnum;
+
+ const char *ccp4;
+};
+
+
+/* Table for converting CrystFEL's knowledge about centering, point group
+ * and unique axis into something that can be recognised by external programs.
+ * If xds_spgnum=0, ccp4=NULL, or something is missing form this table entirely,
+ * it means that there is no way to represent the situation to that program
+ * without re-indexing the dataset. */
+struct point_group_conversion pg_conversions[] = {
+
+ /* Triclinic */
+ {'P', "1", 0, 1, "P 1"},
+ {'P', "-1", 1, 1, "P 1"},
+
+ /* Monoclinic */
+ {'P', "2_uaa", 0, 0, "P211"},
+ {'P', "m_uaa", 0, 0, "Pm11"},
+ {'P', "2/m_uaa", 1, 0, "P211"},
+ {'P', "2_uab", 0, 3, "P121"},
+ {'P', "m_uab", 0, 0, "P1m1"},
+ {'P', "2/m_uab", 1, 3, "P121"},
+ {'P', "2_uac", 0, 0, "P112"},
+ {'P', "m_uac", 0, 0, "P11m"},
+ {'P', "2/m_uac", 1, 0, "P112"},
+ {'P', "2", 0, 0, "P121"}, /* unique axis c */
+ {'P', "m", 0, 0, "P11m"}, /* unique axis c */
+ {'P', "2/m", 1, 0, "P121"}, /* unique axis c */
+
+ {'A', "2_uab", 0, 0, "A121"},
+ {'A', "m_uab", 0, 0, "A1m1"},
+ {'A', "2/m_uab", 1, 0, "A121"},
+ {'A', "2_uac", 0, 0, "A112"},
+ {'A', "m_uac", 0, 0, "A11m"},
+ {'A', "2/m_uac", 1, 0, "A112"},
+ {'A', "2", 0, 0, "A121"}, /* unique axis c */
+ {'A', "m", 0, 0, "A11m"}, /* unique axis c */
+ {'A', "2/m", 1, 0, "A121"}, /* unique axis c */
+
+ {'B', "2_uaa", 0, 0, "B211"},
+ {'B', "m_uaa", 0, 0, "Bm11"},
+ {'B', "2/m_uaa", 1, 0, "B211"},
+ {'B', "2_uac", 0, 0, "B112"},
+ {'B', "m_uac", 0, 0, "B11m"},
+ {'B', "2/m_uac", 1, 0, "B112"},
+ {'B', "2", 0, 0, "B112"}, /* unique axis c */
+ {'B', "m", 0, 0, "B11m"}, /* unique axis c */
+ {'B', "2/m", 1, 0, "B112"}, /* unique axis c */
+
+ {'C', "2_uaa", 0, 0, "C211"},
+ {'C', "m_uaa", 0, 0, "Cm11"},
+ {'C', "2/m_uaa", 1, 0, "C211"},
+ {'C', "2_uab", 0, 5, "C121"},
+ {'C', "m_uab", 0, 0, "C1m1"},
+ {'C', "2/m_uab", 1, 5, "C121"},
+
+ {'I', "2_uaa", 0, 0, "I211"},
+ {'I', "m_uaa", 0, 0, "Im11"},
+ {'I', "2/m_uaa", 1, 0, "I211"},
+ {'I', "2_uab", 0, 0, "I121"},
+ {'I', "m_uab", 0, 0, "I1m1"},
+ {'I', "2/m_uab", 1, 0, "I121"},
+ {'I', "2_uac", 0, 0, "I112"},
+ {'I', "m_uac", 0, 0, "I11m"},
+ {'I', "2/m_uac", 1, 0, "I112"},
+ {'I', "2", 0, 0, "I121"}, /* unique axis c */
+ {'I', "m", 0, 0, "I11m"}, /* unique axis c */
+ {'I', "2/m", 1, 0, "I121"}, /* unique axis c */
+
+ /* Orthorhombic */
+ {'P', "222", 0, 16, "P222"},
+ {'P', "mmm", 1, 16, "P222"},
+ {'P', "mm2", 0, 25, "Pmm2"},
+ {'A', "222", 0, 0, "A222"},
+ {'A', "mmm", 1, 0, "A222"},
+ {'A', "mm2", 0, 38, "Amm2"},
+ {'B', "222", 0, 0, "B222"},
+ {'B', "mmm", 1, 0, "B222"},
+ {'B', "mm2", 0, 0, "Bmm2"},
+ {'C', "222", 0, 21, "C222"},
+ {'C', "mmm", 1, 21, "C222"},
+ {'C', "mm2", 0, 35, "Cmm2"},
+ {'F', "222", 0, 22, "F222"},
+ {'F', "mmm", 1, 22, "F222"},
+ {'F', "mm2", 0, 42, "Fmm2"},
+ {'I', "222", 0, 23, "I222"},
+ {'I', "mmm", 1, 23, "I222"},
+ {'I', "mm2", 0, 45, "Imm2"},
+
+ /* Tetragonal */
+ {'P', "4", 0, 75, "P4"}, /* unique axis c */
+ {'P', "4/m", 1, 75, "P4"}, /* unique axis c */
+ {'P', "422", 0, 89, "P422"}, /* unique axis c */
+ {'P', "4/mmm", 1, 89, "P422"}, /* unique axis c */
+ {'P', "4mm", 0, 99, "P4mm"}, /* unique axis c */
+ {'P', "-4", 0, 81, "P-4"}, /* unique axis c */
+ {'P', "-42m", 0, 111, "P-42m"}, /* unique axis c */
+ {'P', "-4m2", 0, 115, "P-4m2"}, /* unique axis c */
+ {'P', "4_uac", 0, 75, "P4"},
+ {'P', "4/m_uac", 1, 75, "P4"},
+ {'P', "422_uac", 0, 89, "P422"},
+ {'P', "4/mmm_uac", 1, 89, "P422"},
+ {'P', "4mm_uac", 0, 99, "P4mm"},
+ {'P', "-4_uac", 0, 81, "P-4"},
+ {'P', "-42m_uac", 0, 111, "P-42m"},
+ {'P', "-4m2_uac", 0, 115, "P-4m2"},
+ {'I', "4", 0, 79, "I4"}, /* unique axis c */
+ {'I', "4/m", 1, 79, "I4"}, /* unique axis c */
+ {'I', "422", 0, 97, "I422"}, /* unique axis c */
+ {'I', "4/mmm", 1, 97, "I422"}, /* unique axis c */
+ {'I', "4mm", 0, 107, "I4mm"}, /* unique axis c */
+ {'I', "-4", 0, 82, "I-4"}, /* unique axis c */
+ {'I', "-42m", 0, 121, "I-42m"}, /* unique axis c */
+ {'I', "-4m2", 0, 119, "I-4m2"}, /* unique axis c */
+ {'I', "4_uac", 0, 79, "I4"},
+ {'I', "4/m_uac", 1, 79, "I4"},
+ {'I', "422_uac", 0, 97, "I422"},
+ {'I', "4/mmm_uac", 1, 97, "I422"},
+ {'I', "4mm_uac", 0, 107, "I4mm"},
+ {'I', "-4_uac", 0, 82, "I-4"},
+ {'I', "-42m_uac", 0, 121, "I-42m"},
+ {'I', "-4m2_uac", 0, 119, "I-4m2"},
+
+ /* Trigonal (rhombohedral) */
+ {'R', "3_R", 0, 0, "R3:R"},
+ {'R', "-3_R", 1, 0, "R3:R"},
+ {'R', "32_R", 0, 0, "R32:R"},
+ {'R', "-3m_R", 1, 0, "R32:R"},
+ {'R', "3m_R", 0, 0, "R3m:R"},
+
+ /* Trigonal (rhombohedral on hexagonal axes) */
+ {'H', "3_H", 0, 146, "R3:H"},
+ {'H', "-3_H", 1, 146, "R3:H"},
+ {'H', "32_H", 0, 155, "R3:H"},
+ {'H', "-3m_H", 1, 155, "R3:H"},
+ {'H', "3m_H", 0, 0, "R3m:H"},
+
+ /* Trigonal (hexagonal) */
+ {'P', "3_H", 0, 143, "P3"},
+ {'P', "-3_H", 1, 143, "P3"},
+ {'P', "312_H", 0, 149, "P312"},
+ {'P', "-31m_H", 1, 149, "P312"},
+ {'P', "321_H", 0, 150, "P321"},
+ {'P', "-3m1_H", 1, 150, "P321"},
+ {'P', "3m1_H", 0, 156, "P3m1"},
+ {'P', "31m_H", 0, 157, "P31m"},
+
+ /* Hexagonal */
+ {'P', "6", 0, 168, "P6"},
+ {'P', "6/m", 1, 168, "P6"},
+ {'P', "622", 0, 177, "P622"},
+ {'P', "6/mmm", 1, 177, "P622"},
+ {'P', "6mm", 0, 177, "P6mm"},
+ {'P', "-6m2", 0, 187, "P-6m2"},
+ {'P', "-62m", 0, 189, "P-62m"},
+
+ /* Cubic */
+ {'P', "23", 0, 195, "P23"},
+ {'P', "m-3", 1, 195, "P23"},
+ {'P', "432", 0, 207, "P432"},
+ {'P', "m-3m", 1, 207, "P432"},
+ {'P', "-43m", 0, 215, "P -4 3 m"},
+ {'I', "23", 0, 197, "I23"},
+ {'I', "m-3", 1, 197, "I23"},
+ {'I', "432", 0, 211, "I432"},
+ {'I', "m-3m", 1, 211, "I432"},
+ {'I', "-43m", 0, 217, "I -4 3 m"},
+ {'F', "23", 0, 196, "F23"},
+ {'F', "m-3", 1, 196, "F23"},
+ {'F', "432", 0, 209, "F432"},
+ {'F', "m-3m", 1, 209, "F432"},
+ {'F', "-43m", 0, 216, "F -4 3 m"},
+
+ {'*', NULL, 0, 0, NULL}
+};
+
+
+static int space_group_for_xds(const char *sym_str, char cen)
+{
+ int i = 0;
+ do {
+ if ( (pg_conversions[i].centering == cen)
+ && (strcmp(sym_str, pg_conversions[i].crystfel) == 0) )
+ {
+ return pg_conversions[i].xds_spgnum;
+ }
+ i++;
+ } while (pg_conversions[i].centering != '*');
+
+ ERROR("Couldn't derive XDS representation of symmetry.\n");
+ return 0;
+}
+
+
+#ifdef HAVE_LIBCCP4
+static const char *space_group_for_mtz(const char *sym_str, char cen)
+{
+ int i = 0;
+ do {
+ if ( (pg_conversions[i].centering == cen)
+ && (strcmp(sym_str, pg_conversions[i].crystfel) == 0) )
+ {
+ return pg_conversions[i].ccp4;
+ }
+ i++;
+ } while (pg_conversions[i].centering != '*');
+
+ ERROR("Couldn't derive CCP4 representation of symmetry.\n");
+ return NULL;
+}
+#endif
+
+
+int write_to_xds(RefList *reflist,
+ SymOpList *sym,
+ UnitCell *cell,
+ double min_res,
+ double max_res,
+ const char *filename)
+{
+ FILE *fh;
+ RefListIterator *iter;
+ Reflection *refl;
+ double a, b, c, al, be,ga;
+ int spg;
+
+ cell_get_parameters(cell, &a, &b, &c, &al, &be, &ga);
+
+ spg = space_group_for_xds(symmetry_name(sym),
+ cell_get_centering(cell));
+ if ( spg == 0 ) return 1;
+
+ fh = fopen(filename, "w");
+ if ( fh == NULL ) return 1;
+
+ fprintf(fh, "!FORMAT=XDS_ASCII MERGE=TRUE FRIEDEL'S_LAW=%s\n",
+ is_centrosymmetric(sym) ? "TRUE" : "FALSE");
+ fprintf(fh, "!SPACE_GROUP_NUMBER=%i\n", spg);
+ fprintf(fh, "!UNIT_CELL_CONSTANT= %.2f %.2f %.2f %.2f %.2f %.2f\n",
+ a*1e10, b*1e10, c*1e10, rad2deg(al), rad2deg(be), rad2deg(ga));
+ fprintf(fh, "!NUMBER_OF_ITEMS_IN_EACH_DATA_RECORD=5\n");
+ fprintf(fh, "!ITEM_H=1\n");
+ fprintf(fh, "!ITEM_K=2\n");
+ fprintf(fh, "!ITEM_L=3\n");
+ fprintf(fh, "!ITEM_IOBS=4\n");
+ fprintf(fh, "!ITEM_SIGMA(IOBS)=5\n");
+ fprintf(fh, "!END_OF_HEADER\n");
+
+ for ( refl = first_refl(reflist, &iter);
+ refl != NULL;
+ refl = next_refl(refl, iter) )
+ {
+ signed int h, k, l;
+ double one_over_d;
+
+ get_indices(refl, &h, &k, &l);
+
+ one_over_d = 2.0*resolution(cell, h, k, l);
+ if ( (one_over_d > min_res) && (one_over_d < max_res) ) {
+
+ fprintf(fh, "%6i %6i %6i %9.2f %9.2f\n",
+ h, k, l,
+ get_intensity(refl),
+ get_esd_intensity(refl));
+
+ }
+ }
+
+ fprintf(fh, "!END_OF_DATA\n");
+
+ fclose(fh);
+ return 0;
+}
+
+
+#ifdef HAVE_LIBCCP4
+static CCP4SPG *add_mtz_symmetry_header(MTZ *mtz, const char *spg_name)
+{
+ CCP4SPG *spg;
+ float rsymx[192][4][4];
+ char ltypex[2];
+ int i;
+
+ spg = ccp4spg_load_by_spgname(spg_name);
+ if ( spg == NULL ) {
+ ERROR("Couldn't look up CCP4 space group '%s'\n", spg_name);
+ return NULL;
+ }
+
+ for ( i=0; i<spg->nsymop; i++ ) {
+ rotandtrn_to_mat4(rsymx[i], spg->symop[i]);
+ }
+ ltypex[0] = spg->symbol_old[0];
+ ltypex[1] = '\0';
+
+ ccp4_lwsymm(mtz, spg->nsymop, spg->nsymop_prim,
+ rsymx, ltypex, spg->spg_ccp4_num, spg->symbol_old,
+ spg->point_group);
+
+ return spg;
+}
+#endif
+
+
+int write_to_mtz(RefList *reflist,
+ SymOpList *sym,
+ UnitCell *cell,
+ double min_res,
+ double max_res,
+ const char *filename,
+ const char *dataset_name)
+{
+#ifdef HAVE_LIBCCP4
+ MTZ *mtz;
+ MTZXTAL *cr;
+ MTZSET *ds;
+ MTZCOL *columns[7];
+ double a, b, c, al, be, ga;
+ int r;
+ char tmp[128];
+ float cellp[6];
+ int refl_i;
+ Reflection *refl;
+ RefListIterator *iter;
+ CCP4SPG *spg;
+ const char *spg_name;
+
+ spg_name = space_group_for_mtz(symmetry_name(sym),
+ cell_get_centering(cell));
+ if ( spg_name == NULL ) {
+ reflist_free(reflist);
+ return 1;
+ }
+
+ mtz = MtzMalloc(0, 0);
+
+ snprintf(tmp, 128, "Data exported via CrystFEL version %s",
+ libcrystfel_version_string());
+ ccp4_lwtitl(mtz, tmp, 0);
+
+ mtz->refs_in_memory = 0;
+ mtz->fileout = MtzOpenForWrite(filename);
+
+ spg = add_mtz_symmetry_header(mtz, spg_name);
+ if ( spg == NULL ) {
+ return 1;
+ }
+
+ cell_get_parameters(cell, &a, &b, &c, &al, &be, &ga);
+ cellp[0] = a*1e10;
+ cellp[1] = b*1e10;
+ cellp[2] = c*1e10;
+ cellp[3] = rad2deg(al);
+ cellp[4] = rad2deg(be);
+ cellp[5] = rad2deg(ga);
+
+ /* FIXME: Proposed labelling:
+ * title = as above
+ * project = basename of folder containing crystfel.project
+ * crystal = name of indexing results run
+ * dataset = name of merge results run */
+ cr = MtzAddXtal(mtz, "Crystal_name", "Project_name", cellp);
+ ds = MtzAddDataset(mtz, cr, dataset_name, 0.0);
+ columns[0] = MtzAddColumn(mtz, ds, "H", "H");
+ columns[1] = MtzAddColumn(mtz, ds, "K", "H");
+ columns[2] = MtzAddColumn(mtz, ds, "L", "H");
+ columns[3] = MtzAddColumn(mtz, ds, "I+", "J");
+ columns[4] = MtzAddColumn(mtz, ds, "SIGI+", "Q");
+ columns[5] = MtzAddColumn(mtz, ds, "I-", "J");
+ columns[6] = MtzAddColumn(mtz, ds, "SIGI-", "Q");
+
+ refl_i = 1;
+ for ( refl = first_refl(reflist, &iter);
+ refl != NULL;
+ refl = next_refl(refl, iter) )
+ {
+ signed int h, k, l;
+ double one_over_d;
+ int isym;
+
+ get_indices(refl, &h, &k, &l);
+
+ one_over_d = 2.0*resolution(cell, h, k, l);
+ if ( (one_over_d > min_res) && (one_over_d < max_res) ) {
+
+ float refldata[7];
+ signed int nh, nk, nl;
+ signed int fh, fk, fl;
+ Reflection *friedel;
+ Reflection *refl_plus;
+ Reflection *refl_minus;
+
+ /* Look for Friedel partner */
+ if ( find_equiv_in_list(reflist, -h, -k, -l,
+ sym, &fh, &fk, &fl) )
+ {
+ friedel = find_refl(reflist, fh, fk, fl);
+ } else {
+ friedel = NULL;
+ }
+
+ /* Move to CCP4's idea of the ASU */
+ isym = ccp4spg_put_in_asu(spg, h, k, l, &nh, &nk, &nl);
+
+ /* Ok, do we have an I+ or an I- ? */
+ if ( is_odd(isym) ) {
+ /* I+ */
+ refl_plus = refl;
+ refl_minus = friedel;
+ } else {
+ /* I- */
+ refl_minus = refl;
+ refl_plus = friedel;
+ }
+
+ /* If we are looking at an I-, only write it out now
+ * if the corresponding I+ if not in 'reflist'.
+ * If I+ is present, then this I- will get written when
+ * the Friedel pair is processed. */
+ if ( !is_odd(isym) && (refl_plus != NULL) ) continue;
+
+ refldata[0] = nh;
+ refldata[1] = nk;
+ refldata[2] = nl;
+ if ( refl_plus != NULL ) {
+ refldata[3] = get_intensity(refl_plus);
+ refldata[4] = get_esd_intensity(refl_plus);
+ } else {
+ refldata[3] = NAN;
+ refldata[4] = NAN;
+ }
+ if ( refl_minus != NULL ) {
+ refldata[5] = get_intensity(refl_minus);
+ refldata[6] = get_esd_intensity(refl_minus);
+ } else {
+ refldata[5] = NAN;
+ refldata[6] = NAN;
+ }
+
+ ccp4_lwrefl(mtz, refldata, columns, 7, refl_i++);
+
+ }
+ }
+
+ r = MtzPut(mtz, " ");
+ ccp4spg_free(&spg);
+ MtzFree(mtz);
+ return 1-r; /* Yes, really. MtzPut return values are backwards */
+#else
+ return 1;
+#endif
+}
+
+
+int libcrystfel_can_write_mtz()
+{
+#ifdef HAVE_LIBCCP4
+ return 1;
+#else
+ return 0;
+#endif
+}
diff --git a/libcrystfel/src/reflist-utils.h b/libcrystfel/src/reflist-utils.h
index f5177cee..bd60c642 100644
--- a/libcrystfel/src/reflist-utils.h
+++ b/libcrystfel/src/reflist-utils.h
@@ -79,6 +79,16 @@ extern void free_contribs(RefList *list);
extern void reflist_add_command_and_version(RefList *list,
int argcv, char *argv[]);
+extern int write_to_mtz(RefList *reflist, SymOpList *sym, UnitCell *cell,
+ double min_res, double max_res,
+ const char *filename, const char *dataset_name);
+
+extern int write_to_xds(RefList *reflist, SymOpList *sym, UnitCell *cell,
+ double min_res, double max_res, const char *filename);
+
+
+extern int libcrystfel_can_write_mtz(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/meson.build b/meson.build
index da524d0c..12b601c0 100644
--- a/meson.build
+++ b/meson.build
@@ -94,11 +94,6 @@ if cc.has_function('clock_gettime', prefix : '#include <time.h>')
conf_data.set10('HAVE_CLOCK_GETTIME', 1)
endif
-ccp4dep = dependency('libccp4c', required: false)
-if ccp4dep.found()
- conf_data.set10('HAVE_LIBCCP4', 1)
-endif
-
# ************************ libcrystfel (subdir) ************************
subdir('libcrystfel')
@@ -240,8 +235,7 @@ if gtkdep.found()
executable('crystfel', gui_sources,
- dependencies : [mdep, libcrystfeldep, gtkdep, gsldep, slurmdep,
- ccp4dep],
+ dependencies : [mdep, libcrystfeldep, gtkdep, gsldep, slurmdep],
install : true,
install_rpath: '$ORIGIN/../lib64/:$ORIGIN/../lib')
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c
index 159b8ec2..3a73a790 100644
--- a/src/crystfel_gui.c
+++ b/src/crystfel_gui.c
@@ -263,6 +263,8 @@ void update_imageview(struct crystfelproject *proj)
proj->indexing_params.ir_inn);
crystfel_image_view_set_show_peaks(CRYSTFEL_IMAGE_VIEW(proj->imageview),
proj->show_peaks);
+ crystfel_image_view_set_show_centre(CRYSTFEL_IMAGE_VIEW(proj->imageview),
+ proj->show_centre);
crystfel_image_view_set_image(CRYSTFEL_IMAGE_VIEW(proj->imageview),
proj->cur_image);
@@ -490,6 +492,15 @@ static gint results_combo_changed_sig(GtkComboBox *w,
}
+static gint show_centre_sig(GtkWidget *w, struct crystfelproject *proj)
+{
+ proj->show_centre = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
+ crystfel_image_view_set_show_centre(CRYSTFEL_IMAGE_VIEW(proj->imageview),
+ proj->show_centre);
+ return FALSE;
+}
+
+
static gint show_peaks_sig(GtkWidget *w, struct crystfelproject *proj)
{
proj->show_peaks = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
@@ -530,6 +541,7 @@ static void add_menu_bar(struct crystfelproject *proj, GtkWidget *vbox)
" <menuitem name=\"peaks\" action=\"PeaksAction\" />"
" <menuitem name=\"refls\" action=\"ReflsAction\" />"
" <menuitem name=\"labelrefls\" action=\"LabelReflsAction\" />"
+ " <menuitem name=\"centre\" action=\"CentreAction\" />"
" <separator />"
" <menuitem name=\"resetzoom\" action=\"ResetZoomAction\" />"
"</menu>"
@@ -570,6 +582,8 @@ static void add_menu_bar(struct crystfelproject *proj, GtkWidget *vbox)
G_CALLBACK(show_refls_sig), FALSE },
{ "LabelReflsAction", NULL, "Show reflection indices", NULL, NULL,
G_CALLBACK(label_refls_sig), FALSE },
+ { "CentreAction", NULL, "Beam centre", NULL, NULL,
+ G_CALLBACK(show_centre_sig), FALSE },
};
proj->action_group = gtk_action_group_new("cellwindow");
@@ -911,6 +925,10 @@ int main(int argc, char *argv[])
stream_close(st);
}
+ w = gtk_ui_manager_get_action(proj.ui, "/mainwindow/view/centre");
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(w),
+ proj.show_centre);
+
w = gtk_ui_manager_get_action(proj.ui, "/mainwindow/view/peaks");
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(w),
proj.show_peaks);
@@ -926,6 +944,8 @@ int main(int argc, char *argv[])
update_imageview(&proj);
}
+ w = gtk_ui_manager_get_widget(proj.ui, "/ui/mainwindow/view/centre");
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w), proj.show_centre);
w = gtk_ui_manager_get_widget(proj.ui, "/ui/mainwindow/view/peaks");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w), proj.show_peaks);
w = gtk_ui_manager_get_widget(proj.ui, "/ui/mainwindow/view/refls");
diff --git a/src/crystfelimageview.c b/src/crystfelimageview.c
index d5c0b51f..8302ae44 100644
--- a/src/crystfelimageview.c
+++ b/src/crystfelimageview.c
@@ -133,6 +133,8 @@ static gint scroll_sig(GtkWidget *window, GdkEventScroll *event,
int claim = FALSE;
int zoom_allowed = 1;
+ if ( iv->image == NULL ) return FALSE;
+
if ( event->direction == GDK_SCROLL_UP ) {
zoom_scale = 1.1;
claim = TRUE;
@@ -144,10 +146,11 @@ static gint scroll_sig(GtkWidget *window, GdkEventScroll *event,
if ( event->direction == GDK_SCROLL_LEFT ) return TRUE;
if ( event->direction == GDK_SCROLL_RIGHT ) return TRUE;
- ratio = iv->zoom / iv->image->detgeom->panels[0].pixel_pitch;
+ /* Size of a detector pixel in screen pixels */
+ ratio = iv->zoom * iv->image->detgeom->panels[0].pixel_pitch;
- if ( (ratio < 5e6) && (zoom_scale < 1.0) ) zoom_allowed = 0;
- if ( (ratio > 1e10) && (zoom_scale > 1.0) ) zoom_allowed = 0;
+ if ( (ratio < 0.05) && (zoom_scale < 1.0) ) zoom_allowed = 0;
+ if ( (ratio > 100.0) && (zoom_scale > 1.0) ) zoom_allowed = 0;
if ( claim && zoom_allowed ) {
@@ -372,11 +375,6 @@ static void draw_panel_rectangle(cairo_t *cr, CrystFELImageView *iv,
cairo_restore(cr);
- cairo_arc(cr, 0.0, 0.0, 0.006, 0, 2.0*M_PI);
- cairo_set_source_rgb(cr, 1.0, 0.0, 0.0);
- cairo_set_line_width(cr, 0.00001);
- cairo_stroke(cr);
-
xs = p.pixel_pitch;
ys = p.pixel_pitch;
cairo_user_to_device_distance(cr, &xs, &ys);
@@ -581,6 +579,19 @@ static gint draw_sig(GtkWidget *window, cairo_t *cr, CrystFELImageView *iv)
}
}
+ if ( iv->show_centre ) {
+ cairo_arc(cr, 0.0, 0.0, 0.006, 0, 2.0*M_PI);
+ cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.9);
+ cairo_set_line_width(cr, 0.0001);
+ cairo_stroke(cr);
+ cairo_move_to(cr, -0.001, 0.0);
+ cairo_line_to(cr, 0.001, 0.0);
+ cairo_move_to(cr, 0.0, -0.001);
+ cairo_line_to(cr, 0.0, 0.001);
+ cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.9);
+ cairo_stroke(cr);
+ }
+
if ( iv->show_peaks ) {
draw_peaks(cr, iv, iv->image->features);
}
@@ -738,6 +749,7 @@ GtkWidget *crystfel_image_view_new()
iv->detector_h = 1.0;
iv->zoom = -1.0;
iv->image = NULL;
+ iv->show_centre = 1;
iv->show_peaks = 0;
iv->brightness = 1.0;
iv->pixbufs = NULL;
@@ -1016,6 +1028,15 @@ void crystfel_image_view_set_brightness(CrystFELImageView *iv,
}
+void crystfel_image_view_set_show_centre(CrystFELImageView *iv,
+ int show_centre)
+{
+ iv->show_centre = show_centre;
+ iv->need_rerender = 1;
+ redraw(iv);
+}
+
+
void crystfel_image_view_set_show_peaks(CrystFELImageView *iv,
int show_peaks)
{
diff --git a/src/crystfelimageview.h b/src/crystfelimageview.h
index 31df0fc2..7d3ac1f6 100644
--- a/src/crystfelimageview.h
+++ b/src/crystfelimageview.h
@@ -75,7 +75,7 @@ struct _crystfelimageview
GtkAdjustment *vadj;
double visible_width;
double visible_height;
- double zoom;
+ double zoom; /* screen pixels per m */
double drag_start_x;
double drag_start_y;
double drag_start_sp_x;
@@ -88,6 +88,7 @@ struct _crystfelimageview
GdkPixbuf **pixbufs;
double brightness;
+ int show_centre;
int show_peaks;
int show_refls;
int label_refls;
@@ -114,6 +115,9 @@ extern void crystfel_image_view_reset_zoom(CrystFELImageView *iv);
extern void crystfel_image_view_set_brightness(CrystFELImageView *iv,
double brightness);
+extern void crystfel_image_view_set_show_centre(CrystFELImageView *iv,
+ int show_centre);
+
extern void crystfel_image_view_set_show_peaks(CrystFELImageView *iv,
int show_peaks);
diff --git a/src/crystfelindexingopts.c b/src/crystfelindexingopts.c
index 82e0fa60..de83c731 100644
--- a/src/crystfelindexingopts.c
+++ b/src/crystfelindexingopts.c
@@ -464,8 +464,40 @@ static GtkWidget *integration_parameters(CrystFELIndexingOpts *io)
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->ir_out),
FALSE, FALSE, 4.0);
- /* FIXME: fix-bandwidth, divergence, profile-radius */
+ /* --fix-profile-radius */
+ hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(hbox),
+ FALSE, FALSE, 4.0);
+ io->fix_profile_radius_p = gtk_check_button_new_with_label("Fix the reflection radius to");
+ gtk_box_pack_start(GTK_BOX(hbox),
+ GTK_WIDGET(io->fix_profile_radius_p),
+ FALSE, FALSE, 0.0);
+ io->fix_profile_radius = gtk_entry_new();
+ gtk_entry_set_width_chars(GTK_ENTRY(io->fix_profile_radius), 6);
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->fix_profile_radius),
+ FALSE, FALSE, 4.0);
+ label = gtk_label_new("nm-1");
+ gtk_label_set_markup(GTK_LABEL(label), "nm<sup>-1</sup>");
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label),
+ FALSE, FALSE, 4.0);
+ i_disable_if_not(io->fix_profile_radius_p, io->fix_profile_radius);
+ gtk_widget_set_tooltip_text(io->fix_profile_radius,
+ "--fix-profile-radius");
+ /* --fix-divergence */
+ hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(hbox),
+ FALSE, FALSE, 4.0);
+ label = gtk_label_new("Beam divergence (full angle) for spot prediction:");
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), FALSE, FALSE, 0.0);
+ io->fix_divergence = gtk_entry_new();
+ gtk_entry_set_width_chars(GTK_ENTRY(io->fix_divergence), 6);
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->fix_divergence),
+ FALSE, FALSE, 4.0);
+ label = gtk_label_new("mrad");
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label),
+ FALSE, FALSE, 4.0);
+ gtk_widget_set_tooltip_text(io->fix_profile_radius, "--fix-divergence");
gtk_widget_show_all(box);
return box;
@@ -879,6 +911,20 @@ char **crystfel_indexing_opts_get_metadata_to_copy(CrystFELIndexingOpts *opts,
}
+double crystfel_indexing_opts_get_fixed_profile_radius(CrystFELIndexingOpts *opts,
+ int *active)
+{
+ *active = get_bool(opts->fix_profile_radius_p);
+ return get_float(opts->fix_profile_radius)*1e9;
+}
+
+
+double crystfel_indexing_opts_get_fixed_divergence(CrystFELIndexingOpts *opts)
+{
+ return get_float(opts->fix_divergence)/1e3;
+}
+
+
/********************** Setters *************************/
@@ -1137,3 +1183,23 @@ void crystfel_indexing_opts_set_exclude_reflections(CrystFELIndexingOpts *opts,
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->no_refls_in_stream),
flag);
}
+
+
+void crystfel_indexing_opts_set_fixed_profile_radius(CrystFELIndexingOpts *opts,
+ int active,
+ double val)
+{
+ char tmp[64];
+ set_active(opts->fix_profile_radius_p, active);
+ snprintf(tmp, 63, "%.3f", val/1e9);
+ gtk_entry_set_text(GTK_ENTRY(opts->fix_profile_radius), tmp);
+}
+
+
+void crystfel_indexing_opts_set_fixed_divergence(CrystFELIndexingOpts *opts,
+ double val)
+{
+ char tmp[64];
+ snprintf(tmp, 63, "%.3f", val*1e3);
+ gtk_entry_set_text(GTK_ENTRY(opts->fix_divergence), tmp);
+}
diff --git a/src/crystfelindexingopts.h b/src/crystfelindexingopts.h
index 72ca8c37..fe5f4ccd 100644
--- a/src/crystfelindexingopts.h
+++ b/src/crystfelindexingopts.h
@@ -79,6 +79,9 @@ struct _crystfelindexingopts
GtkWidget *ir_inn;
GtkWidget *ir_mid;
GtkWidget *ir_out;
+ GtkWidget *fix_profile_radius_p;
+ GtkWidget *fix_profile_radius;
+ GtkWidget *fix_divergence;
GtkWidget *exclude_nonhits;
GtkWidget *no_peaks_in_stream;
@@ -120,6 +123,14 @@ extern int crystfel_indexing_opts_get_exclude_peaks(CrystFELIndexingOpts *opts);
extern int crystfel_indexing_opts_get_exclude_reflections(CrystFELIndexingOpts *opts);
extern char **crystfel_indexing_opts_get_metadata_to_copy(CrystFELIndexingOpts *opts,
int *n);
+extern double crystfel_indexing_opts_get_fixed_profile_radius(CrystFELIndexingOpts *opts,
+ int *active);
+extern double crystfel_indexing_opts_get_fixed_divergence(CrystFELIndexingOpts *opts);
+
+
+
+
+
extern void crystfel_indexing_opts_set_show_stream_opts(CrystFELIndexingOpts *opts,
int val);
@@ -162,5 +173,11 @@ extern void crystfel_indexing_opts_set_exclude_peaks(CrystFELIndexingOpts *opts,
int flag);
extern void crystfel_indexing_opts_set_exclude_reflections(CrystFELIndexingOpts *opts,
int flag);
+extern void crystfel_indexing_opts_set_fixed_profile_radius(CrystFELIndexingOpts *opts,
+ int active,
+ double val);
+extern void crystfel_indexing_opts_set_fixed_divergence(CrystFELIndexingOpts *opts,
+ double val);
+
#endif /* CRYSTFELINDEXINGOPTS_H */
diff --git a/src/get_hkl.c b/src/get_hkl.c
index ea632cbb..71de316d 100644
--- a/src/get_hkl.c
+++ b/src/get_hkl.c
@@ -95,6 +95,8 @@ static void show_help(const char *s)
"\n"
"Don't forget to specify the output filename:\n"
" -o, --output=<filename> Output filename (default: stdout).\n"
+" --output-format=mtz Output in MTZ format.\n"
+" --output-format=xds Output in XDS format.\n"
);
}
@@ -469,6 +471,7 @@ int main(int argc, char *argv[])
float lowres = 0.0; /* 1/d value */
double highres = INFINITY; /* 1/d value */
UnitCell *cell = NULL;
+ char *output_format_str = NULL;
/* Long options */
const struct option longopts[] = {
@@ -491,6 +494,7 @@ int main(int argc, char *argv[])
{"highres", 1, NULL, 3},
{"reindex", 1, NULL, 4},
{"lowres", 1, NULL, 6},
+ {"output-format", 1, NULL, 7},
{0, 0, NULL, 0}
};
@@ -561,6 +565,10 @@ int main(int argc, char *argv[])
lowres = 1.0/lowres; /* m -> m^-1 */
break;
+ case 7 :
+ output_format_str = strdup(optarg);
+ break;
+
case 0 :
break;
@@ -789,24 +797,25 @@ int main(int argc, char *argv[])
}
- if ( (highres < INFINITY) || have_cutoff_aniso || (lowres > 0.0) ) {
-
- if ( cellfile == NULL ) {
- ERROR("You must provide a unit cell when using "
- "--cutoff-angstroms, --highres or --lowres.\n");
- return 1;
- }
-
+ if ( cellfile != NULL ) {
cell = load_cell_from_file(cellfile);
if ( cell == NULL ) {
ERROR("Failed to load cell from '%s'\n", cellfile);
return 1;
}
free(cellfile);
-
}
- input = apply_resolution_cutoff(input, lowres, highres, cell);
+ if ( (highres < INFINITY) || (lowres > 0.0) ) {
+ if ( cell == NULL ) {
+ ERROR("You must provide a unit cell when using "
+ "--highres or --lowres\n");
+ return 1;
+ } else {
+ input = apply_resolution_cutoff(input, lowres, highres,
+ cell);
+ }
+ }
if ( have_cutoff_aniso ) {
@@ -818,6 +827,12 @@ int main(int argc, char *argv[])
double csx, csy, csz;
double as, bs, cs;
+ if ( cell == NULL ) {
+ ERROR("You must provide a unit cell when using "
+ "--cutoff-angstroms\n");
+ return 1;
+ }
+
cell_get_reciprocal(cell, &asx, &asy, &asz,
&bsx, &bsy, &bsz,
&csx, &csy, &csz);
@@ -883,7 +898,16 @@ int main(int argc, char *argv[])
}
reflist_add_command_and_version(input, argc, argv); /* Yes, really! */
- write_reflist(output, input);
+
+ if ( output_format_str == NULL ) {
+ write_reflist(output, input);
+ } else if ( cell == NULL ) {
+ ERROR("You must provide a unit cell to use MTZ or XDS output.\n");
+ } else if ( strcasecmp(output_format_str, "mtz") == 0 ) {
+ write_to_mtz(input, mero, cell, 0, INFINITY, output, "dataset");
+ } else if ( strcasecmp(output_format_str, "xds") == 0 ) {
+ write_to_xds(input, mero, cell, 0, INFINITY, output);
+ }
reflist_free(input);
diff --git a/src/gui_export.c b/src/gui_export.c
index c3499827..50bd126c 100644
--- a/src/gui_export.c
+++ b/src/gui_export.c
@@ -36,12 +36,6 @@
#include <gtk/gtk.h>
#include <assert.h>
-#ifdef HAVE_LIBCCP4
-#include <ccp4/cmtzlib.h>
-#include <ccp4/csymlib.h>
-#include <ccp4/ccp4_parser.h>
-#endif
-
#include <utils.h>
#include <reflist-utils.h>
#include <cell-utils.h>
@@ -65,242 +59,14 @@ struct export_window
};
-struct point_group_conversion
-{
- char centering;
- const char *crystfel;
- int friedel;
-
- int xds_spgnum;
-
- const char *ccp4;
-};
-
-
-/* Table for converting CrystFEL's knowledge about centering, point group
- * and unique axis into something that can be recognised by external programs.
- * If xds_spgnum=0, ccp4=NULL, or something is missing form this table entirely,
- * it means that there is no way to represent the situation to that program
- * without re-indexing the dataset. */
-struct point_group_conversion pg_conversions[] = {
-
- /* Triclinic */
- {'P', "1", 0, 1, "P 1"},
- {'P', "-1", 1, 1, "P 1"},
-
- /* Monoclinic */
- {'P', "2_uaa", 0, 0, "P211"},
- {'P', "m_uaa", 0, 0, "Pm11"},
- {'P', "2/m_uaa", 1, 0, "P211"},
- {'P', "2_uab", 0, 3, "P121"},
- {'P', "m_uab", 0, 0, "P1m1"},
- {'P', "2/m_uab", 1, 3, "P121"},
- {'P', "2_uac", 0, 0, "P112"},
- {'P', "m_uac", 0, 0, "P11m"},
- {'P', "2/m_uac", 1, 0, "P112"},
- {'P', "2", 0, 0, "P121"}, /* unique axis c */
- {'P', "m", 0, 0, "P11m"}, /* unique axis c */
- {'P', "2/m", 1, 0, "P121"}, /* unique axis c */
-
- {'A', "2_uab", 0, 0, "A121"},
- {'A', "m_uab", 0, 0, "A1m1"},
- {'A', "2/m_uab", 1, 0, "A121"},
- {'A', "2_uac", 0, 0, "A112"},
- {'A', "m_uac", 0, 0, "A11m"},
- {'A', "2/m_uac", 1, 0, "A112"},
- {'A', "2", 0, 0, "A121"}, /* unique axis c */
- {'A', "m", 0, 0, "A11m"}, /* unique axis c */
- {'A', "2/m", 1, 0, "A121"}, /* unique axis c */
-
- {'B', "2_uaa", 0, 0, "B211"},
- {'B', "m_uaa", 0, 0, "Bm11"},
- {'B', "2/m_uaa", 1, 0, "B211"},
- {'B', "2_uac", 0, 0, "B112"},
- {'B', "m_uac", 0, 0, "B11m"},
- {'B', "2/m_uac", 1, 0, "B112"},
- {'B', "2", 0, 0, "B112"}, /* unique axis c */
- {'B', "m", 0, 0, "B11m"}, /* unique axis c */
- {'B', "2/m", 1, 0, "B112"}, /* unique axis c */
-
- {'C', "2_uaa", 0, 0, "C211"},
- {'C', "m_uaa", 0, 0, "Cm11"},
- {'C', "2/m_uaa", 1, 0, "C211"},
- {'C', "2_uab", 0, 5, "C121"},
- {'C', "m_uab", 0, 0, "C1m1"},
- {'C', "2/m_uab", 1, 5, "C121"},
-
- {'I', "2_uaa", 0, 0, "I211"},
- {'I', "m_uaa", 0, 0, "Im11"},
- {'I', "2/m_uaa", 1, 0, "I211"},
- {'I', "2_uab", 0, 0, "I121"},
- {'I', "m_uab", 0, 0, "I1m1"},
- {'I', "2/m_uab", 1, 0, "I121"},
- {'I', "2_uac", 0, 0, "I112"},
- {'I', "m_uac", 0, 0, "I11m"},
- {'I', "2/m_uac", 1, 0, "I112"},
- {'I', "2", 0, 0, "I121"}, /* unique axis c */
- {'I', "m", 0, 0, "I11m"}, /* unique axis c */
- {'I', "2/m", 1, 0, "I121"}, /* unique axis c */
-
- /* Orthorhombic */
- {'P', "222", 0, 16, "P222"},
- {'P', "mmm", 1, 16, "P222"},
- {'P', "mm2", 0, 25, "Pmm2"},
- {'A', "222", 0, 0, "A222"},
- {'A', "mmm", 1, 0, "A222"},
- {'A', "mm2", 0, 38, "Amm2"},
- {'B', "222", 0, 0, "B222"},
- {'B', "mmm", 1, 0, "B222"},
- {'B', "mm2", 0, 0, "Bmm2"},
- {'C', "222", 0, 21, "C222"},
- {'C', "mmm", 1, 21, "C222"},
- {'C', "mm2", 0, 35, "Cmm2"},
- {'F', "222", 0, 22, "F222"},
- {'F', "mmm", 1, 22, "F222"},
- {'F', "mm2", 0, 42, "Fmm2"},
- {'I', "222", 0, 23, "I222"},
- {'I', "mmm", 1, 23, "I222"},
- {'I', "mm2", 0, 45, "Imm2"},
-
- /* Tetragonal */
- {'P', "4", 0, 75, "P4"}, /* unique axis c */
- {'P', "4/m", 1, 75, "P4"}, /* unique axis c */
- {'P', "422", 0, 89, "P422"}, /* unique axis c */
- {'P', "4/mmm", 1, 89, "P422"}, /* unique axis c */
- {'P', "4mm", 0, 99, "P4mm"}, /* unique axis c */
- {'P', "-4", 0, 81, "P-4"}, /* unique axis c */
- {'P', "-42m", 0, 111, "P-42m"}, /* unique axis c */
- {'P', "-4m2", 0, 115, "P-4m2"}, /* unique axis c */
- {'P', "4_uac", 0, 75, "P4"},
- {'P', "4/m_uac", 1, 75, "P4"},
- {'P', "422_uac", 0, 89, "P422"},
- {'P', "4/mmm_uac", 1, 89, "P422"},
- {'P', "4mm_uac", 0, 99, "P4mm"},
- {'P', "-4_uac", 0, 81, "P-4"},
- {'P', "-42m_uac", 0, 111, "P-42m"},
- {'P', "-4m2_uac", 0, 115, "P-4m2"},
- {'I', "4", 0, 79, "I4"}, /* unique axis c */
- {'I', "4/m", 1, 79, "I4"}, /* unique axis c */
- {'I', "422", 0, 97, "I422"}, /* unique axis c */
- {'I', "4/mmm", 1, 97, "I422"}, /* unique axis c */
- {'I', "4mm", 0, 107, "I4mm"}, /* unique axis c */
- {'I', "-4", 0, 82, "I-4"}, /* unique axis c */
- {'I', "-42m", 0, 121, "I-42m"}, /* unique axis c */
- {'I', "-4m2", 0, 119, "I-4m2"}, /* unique axis c */
- {'I', "4_uac", 0, 79, "I4"},
- {'I', "4/m_uac", 1, 79, "I4"},
- {'I', "422_uac", 0, 97, "I422"},
- {'I', "4/mmm_uac", 1, 97, "I422"},
- {'I', "4mm_uac", 0, 107, "I4mm"},
- {'I', "-4_uac", 0, 82, "I-4"},
- {'I', "-42m_uac", 0, 121, "I-42m"},
- {'I', "-4m2_uac", 0, 119, "I-4m2"},
-
- /* Trigonal (rhombohedral) */
- {'R', "3_R", 0, 0, "R3:R"},
- {'R', "-3_R", 1, 0, "R3:R"},
- {'R', "32_R", 0, 0, "R32:R"},
- {'R', "-3m_R", 1, 0, "R32:R"},
- {'R', "3m_R", 0, 0, "R3m:R"},
-
- /* Trigonal (rhombohedral on hexagonal axes) */
- {'H', "3_H", 0, 146, "R3:H"},
- {'H', "-3_H", 1, 146, "R3:H"},
- {'H', "32_H", 0, 155, "R3:H"},
- {'H', "-3m_H", 1, 155, "R3:H"},
- {'H', "3m_H", 0, 0, "R3m:H"},
-
- /* Trigonal (hexagonal) */
- {'P', "3_H", 0, 143, "P3"},
- {'P', "-3_H", 1, 143, "P3"},
- {'P', "312_H", 0, 149, "P312"},
- {'P', "-31m_H", 1, 149, "P312"},
- {'P', "321_H", 0, 150, "P321"},
- {'P', "-3m1_H", 1, 150, "P321"},
- {'P', "3m1_H", 0, 156, "P3m1"},
- {'P', "31m_H", 0, 157, "P31m"},
-
- /* Hexagonal */
- {'P', "6", 0, 168, "P6"},
- {'P', "6/m", 1, 168, "P6"},
- {'P', "622", 0, 177, "P622"},
- {'P', "6/mmm", 1, 177, "P622"},
- {'P', "6mm", 0, 177, "P6mm"},
- {'P', "-6m2", 0, 187, "P-6m2"},
- {'P', "-62m", 0, 189, "P-62m"},
-
- /* Cubic */
- {'P', "23", 0, 195, "P23"},
- {'P', "m-3", 1, 195, "P23"},
- {'P', "432", 0, 207, "P432"},
- {'P', "m-3m", 1, 207, "P432"},
- {'P', "-43m", 0, 215, "P -4 3 m"},
- {'I', "23", 0, 197, "I23"},
- {'I', "m-3", 1, 197, "I23"},
- {'I', "432", 0, 211, "I432"},
- {'I', "m-3m", 1, 211, "I432"},
- {'I', "-43m", 0, 217, "I -4 3 m"},
- {'F', "23", 0, 196, "F23"},
- {'F', "m-3", 1, 196, "F23"},
- {'F', "432", 0, 209, "F432"},
- {'F', "m-3m", 1, 209, "F432"},
- {'F', "-43m", 0, 216, "F -4 3 m"},
-
- {'*', NULL, 0, 0, NULL}
-};
-
-
-static int space_group_for_xds(const char *sym_str, char cen)
-{
- int i = 0;
- do {
- if ( (pg_conversions[i].centering == cen)
- && (strcmp(sym_str, pg_conversions[i].crystfel) == 0) )
- {
- return pg_conversions[i].xds_spgnum;
- }
- i++;
- } while (pg_conversions[i].centering != '*');
-
- ERROR("Couldn't derive XDS representation of symmetry.\n");
- return 0;
-}
-
-
-#ifdef HAVE_LIBCCP4
-static const char *space_group_for_mtz(const char *sym_str, char cen)
-{
- int i = 0;
- do {
- if ( (pg_conversions[i].centering == cen)
- && (strcmp(sym_str, pg_conversions[i].crystfel) == 0) )
- {
- return pg_conversions[i].ccp4;
- }
- i++;
- } while (pg_conversions[i].centering != '*');
-
- ERROR("Couldn't derive CCP4 representation of symmetry.\n");
- return NULL;
-}
-#endif
-
-
static int export_to_xds(struct gui_merge_result *result,
const char *filename, UnitCell *cell,
double min_res, double max_res)
{
- FILE *fh;
RefList *reflist;
- RefListIterator *iter;
- Reflection *refl;
- double a, b, c, al, be,ga;
char *sym_str;
SymOpList *sym;
- int spg;
-
- fh = fopen(filename, "w");
- if ( fh == NULL ) return 1;
+ int r;
reflist = read_reflections_2(result->hkl, &sym_str);
if ( reflist == NULL ) return 1;
@@ -309,104 +75,24 @@ static int export_to_xds(struct gui_merge_result *result,
sym = get_pointgroup(sym_str);
if ( sym == NULL ) return 1;
- cell_get_parameters(cell, &a, &b, &c, &al, &be, &ga);
-
- spg = space_group_for_xds(sym_str, cell_get_centering(cell));
- if ( spg == 0 ) return 1;
-
- fprintf(fh, "!FORMAT=XDS_ASCII MERGE=TRUE FRIEDEL'S_LAW=%s\n",
- is_centrosymmetric(sym) ? "TRUE" : "FALSE");
- fprintf(fh, "!SPACE_GROUP_NUMBER=%i\n", spg);
- fprintf(fh, "!UNIT_CELL_CONSTANT= %.2f %.2f %.2f %.2f %.2f %.2f\n",
- a*1e10, b*1e10, c*1e10, rad2deg(al), rad2deg(be), rad2deg(ga));
- fprintf(fh, "!NUMBER_OF_ITEMS_IN_EACH_DATA_RECORD=5\n");
- fprintf(fh, "!ITEM_H=1\n");
- fprintf(fh, "!ITEM_K=2\n");
- fprintf(fh, "!ITEM_L=3\n");
- fprintf(fh, "!ITEM_IOBS=4\n");
- fprintf(fh, "!ITEM_SIGMA(IOBS)=5\n");
- fprintf(fh, "!END_OF_HEADER\n");
-
- for ( refl = first_refl(reflist, &iter);
- refl != NULL;
- refl = next_refl(refl, iter) )
- {
- signed int h, k, l;
- double one_over_d;
-
- get_indices(refl, &h, &k, &l);
-
- one_over_d = 2.0*resolution(cell, h, k, l);
- if ( (one_over_d > min_res) && (one_over_d < max_res) ) {
-
- fprintf(fh, "%6i %6i %6i %9.2f %9.2f\n",
- h, k, l,
- get_intensity(refl),
- get_esd_intensity(refl));
-
- }
- }
+ r = write_to_xds(reflist, sym, cell, min_res, max_res, filename);
- fprintf(fh, "!END_OF_DATA\n");
free_symoplist(sym);
free(sym_str);
reflist_free(reflist);
- fclose(fh);
- return 0;
-}
-
-
-#ifdef HAVE_LIBCCP4
-static CCP4SPG *add_mtz_symmetry_header(MTZ *mtz, const char *spg_name)
-{
- CCP4SPG *spg;
- float rsymx[192][4][4];
- char ltypex[2];
- int i;
-
- spg = ccp4spg_load_by_spgname(spg_name);
- if ( spg == NULL ) {
- ERROR("Couldn't look up CCP4 space group '%s'\n", spg_name);
- return NULL;
- }
-
- for ( i=0; i<spg->nsymop; i++ ) {
- rotandtrn_to_mat4(rsymx[i], spg->symop[i]);
- }
- ltypex[0] = spg->symbol_old[0];
- ltypex[1] = '\0';
-
- ccp4_lwsymm(mtz, spg->nsymop, spg->nsymop_prim,
- rsymx, ltypex, spg->spg_ccp4_num, spg->symbol_old,
- spg->point_group);
-
- return spg;
+ return r;
}
-#endif
static int export_to_mtz(struct gui_merge_result *result,
const char *filename, UnitCell *cell,
double min_res, double max_res)
{
-#ifdef HAVE_LIBCCP4
- MTZ *mtz;
- MTZXTAL *cr;
- MTZSET *ds;
- MTZCOL *columns[7];
- double a, b, c, al, be, ga;
- int r;
- char tmp[128];
- float cellp[6];
- int refl_i;
RefList *reflist;
- Reflection *refl;
- RefListIterator *iter;
- char *sym_str = NULL;
- CCP4SPG *spg;
- const char *spg_name;
+ char *sym_str;
SymOpList *sym;
+ int r;
reflist = read_reflections_2(result->hkl, &sym_str);
if ( reflist == NULL ) return 1;
@@ -415,130 +101,14 @@ static int export_to_mtz(struct gui_merge_result *result,
sym = get_pointgroup(sym_str);
if ( sym == NULL ) return 1;
- spg_name = space_group_for_mtz(sym_str, cell_get_centering(cell));
- if ( spg_name == NULL ) {
- reflist_free(reflist);
- return 1;
- }
-
- mtz = MtzMalloc(0, 0);
-
- snprintf(tmp, 128, "Data exported via CrystFEL GUI, version %s",
- crystfel_version_string());
- ccp4_lwtitl(mtz, tmp, 0);
-
- mtz->refs_in_memory = 0;
- mtz->fileout = MtzOpenForWrite(filename);
-
- spg = add_mtz_symmetry_header(mtz, spg_name);
- if ( spg == NULL ) {
- return 1;
- }
-
- cell_get_parameters(cell, &a, &b, &c, &al, &be, &ga);
- cellp[0] = a*1e10;
- cellp[1] = b*1e10;
- cellp[2] = c*1e10;
- cellp[3] = rad2deg(al);
- cellp[4] = rad2deg(be);
- cellp[5] = rad2deg(ga);
-
- /* FIXME: Proposed labelling:
- * title = as above
- * project = basename of folder containing crystfel.project
- * crystal = name of indexing results run
- * dataset = name of merge results run */
- cr = MtzAddXtal(mtz, "Crystal_name", "Project_name", cellp);
- ds = MtzAddDataset(mtz, cr, result->name, 0.0);
- columns[0] = MtzAddColumn(mtz, ds, "H", "H");
- columns[1] = MtzAddColumn(mtz, ds, "K", "H");
- columns[2] = MtzAddColumn(mtz, ds, "L", "H");
- columns[3] = MtzAddColumn(mtz, ds, "I+", "J");
- columns[4] = MtzAddColumn(mtz, ds, "SIGI+", "Q");
- columns[5] = MtzAddColumn(mtz, ds, "I-", "J");
- columns[6] = MtzAddColumn(mtz, ds, "SIGI-", "Q");
-
- refl_i = 1;
- for ( refl = first_refl(reflist, &iter);
- refl != NULL;
- refl = next_refl(refl, iter) )
- {
- signed int h, k, l;
- double one_over_d;
- int isym;
-
- get_indices(refl, &h, &k, &l);
-
- one_over_d = 2.0*resolution(cell, h, k, l);
- if ( (one_over_d > min_res) && (one_over_d < max_res) ) {
-
- float refldata[7];
- signed int nh, nk, nl;
- signed int fh, fk, fl;
- Reflection *friedel;
- Reflection *refl_plus;
- Reflection *refl_minus;
-
- /* Look for Friedel partner */
- if ( find_equiv_in_list(reflist, -h, -k, -l,
- sym, &fh, &fk, &fl) )
- {
- friedel = find_refl(reflist, fh, fk, fl);
- } else {
- friedel = NULL;
- }
-
- /* Move to CCP4's idea of the ASU */
- isym = ccp4spg_put_in_asu(spg, h, k, l, &nh, &nk, &nl);
-
- /* Ok, do we have an I+ or an I- ? */
- if ( is_odd(isym) ) {
- /* I+ */
- refl_plus = refl;
- refl_minus = friedel;
- } else {
- /* I- */
- refl_minus = refl;
- refl_plus = friedel;
- }
-
- /* If we are looking at an I-, only write it out now
- * if the corresponding I+ if not in 'reflist'.
- * If I+ is present, then this I- will get written when
- * the Friedel pair is processed. */
- if ( !is_odd(isym) && (refl_plus != NULL) ) continue;
-
- refldata[0] = nh;
- refldata[1] = nk;
- refldata[2] = nl;
- if ( refl_plus != NULL ) {
- refldata[3] = get_intensity(refl_plus);
- refldata[4] = get_esd_intensity(refl_plus);
- } else {
- refldata[3] = NAN;
- refldata[4] = NAN;
- }
- if ( refl_minus != NULL ) {
- refldata[5] = get_intensity(refl_minus);
- refldata[6] = get_esd_intensity(refl_minus);
- } else {
- refldata[5] = NAN;
- refldata[6] = NAN;
- }
-
- ccp4_lwrefl(mtz, refldata, columns, 7, refl_i++);
-
- }
- }
+ r = write_to_mtz(reflist, sym, cell, min_res, max_res, filename,
+ result->name);
- r = MtzPut(mtz, " ");
- ccp4spg_free(&spg);
- MtzFree(mtz);
+ free_symoplist(sym);
+ free(sym_str);
reflist_free(reflist);
- return 1-r; /* Yes, really. MtzPut return values are backwards */
-#else
- return 1;
-#endif
+
+ return r;
}
@@ -680,10 +250,10 @@ gint export_sig(GtkWidget *widget, struct crystfelproject *proj)
win->format = gtk_combo_box_text_new();
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(win->format),
FALSE, FALSE, 4.0);
-#ifdef HAVE_LIBCCP4
- gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(win->format), "mtz",
- "MTZ");
-#endif
+ if ( libcrystfel_can_write_mtz() ) {
+ gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(win->format), "mtz",
+ "MTZ");
+ }
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(win->format), "xds",
"XDS ASCII");
gtk_combo_box_set_active(GTK_COMBO_BOX(win->format), 0);
diff --git a/src/gui_index.c b/src/gui_index.c
index 145d0f1e..9b72ca10 100644
--- a/src/gui_index.c
+++ b/src/gui_index.c
@@ -122,6 +122,9 @@ static void get_indexing_opts(struct crystfelproject *proj,
&proj->indexing_params.ir_inn,
&proj->indexing_params.ir_mid,
&proj->indexing_params.ir_out);
+ proj->indexing_params.fix_profile_radius = crystfel_indexing_opts_get_fixed_profile_radius(opts,
+ &proj->indexing_params.use_fix_profile_radius);
+ proj->indexing_params.fix_divergence = crystfel_indexing_opts_get_fixed_divergence(opts);
/* Stream output */
proj->indexing_params.exclude_nonhits = crystfel_indexing_opts_get_exclude_blanks(opts);
@@ -298,6 +301,11 @@ static void set_indexing_opts(struct crystfelproject *proj,
proj->indexing_params.ir_inn,
proj->indexing_params.ir_mid,
proj->indexing_params.ir_out);
+ crystfel_indexing_opts_set_fixed_profile_radius(opts,
+ proj->indexing_params.use_fix_profile_radius,
+ proj->indexing_params.fix_profile_radius);
+ crystfel_indexing_opts_set_fixed_divergence(opts,
+ proj->indexing_params.fix_divergence);
/* Stream output */
crystfel_indexing_opts_set_exclude_blanks(opts,
@@ -781,6 +789,12 @@ static char **indexamajig_command_line(const char *geom_filename,
indexing_params->ir_mid,
indexing_params->ir_out);
add_arg(args, n_args++, tols);
+ if ( indexing_params->use_fix_profile_radius ) {
+ add_arg_float(args, n_args++, "fix-profile-radius",
+ indexing_params->fix_profile_radius);
+ }
+ add_arg_float(args, n_args++, "fix-divergence",
+ indexing_params->fix_divergence);
/* Stream output */
if ( indexing_params->exclude_nonhits ) add_arg(args, n_args++, "--no-non-hits-in-stream");
diff --git a/src/gui_project.c b/src/gui_project.c
index 90b2b0fb..fba38b7c 100644
--- a/src/gui_project.c
+++ b/src/gui_project.c
@@ -295,6 +295,15 @@ static void parse_integration_opt(const char *key, const char *val,
if ( strcmp(key, "integration.ir_out") == 0 ) {
proj->indexing_params.ir_out = parse_float(val);
}
+ if ( strcmp(key, "integration.fix_divergence") == 0 ) {
+ proj->indexing_params.fix_divergence = parse_float(val);
+ }
+ if ( strcmp(key, "integration.fix_profile_radius") == 0 ) {
+ proj->indexing_params.use_fix_profile_radius = parse_int(val);
+ }
+ if ( strcmp(key, "integration.fix_profile_radius_val") == 0 ) {
+ proj->indexing_params.fix_profile_radius = parse_float(val);
+ }
}
@@ -477,6 +486,10 @@ static void handle_var(const char *key, const char *val,
proj->merging_backend_selected = find_backend(val, proj);
}
+ if ( strcmp(key, "show_centre") == 0 ) {
+ proj->show_centre = parse_int(val);
+ }
+
if ( strcmp(key, "show_peaks") == 0 ) {
proj->show_peaks = parse_int(val);
}
@@ -928,6 +941,12 @@ int save_project(struct crystfelproject *proj)
proj->indexing_params.ir_mid);
fprintf(fh, "integration.ir_out %f\n",
proj->indexing_params.ir_out);
+ fprintf(fh, "integration.fix_profile_radius %i\n",
+ proj->indexing_params.use_fix_profile_radius);
+ fprintf(fh, "integration.fix_profile_radius_val %e\n",
+ proj->indexing_params.fix_profile_radius);
+ fprintf(fh, "integration.fix_divergence %e\n",
+ proj->indexing_params.fix_divergence);
fprintf(fh, "stream.exclude_blanks %i\n",
proj->indexing_params.exclude_nonhits);
@@ -1012,6 +1031,7 @@ int save_project(struct crystfelproject *proj)
fprintf(fh, "fom.min_meas %i\n", proj->fom_min_meas);
fprintf(fh, "fom.cell_file %s\n", proj->fom_cell_filename);
+ fprintf(fh, "show_centre %i\n", proj->show_centre);
fprintf(fh, "show_peaks %i\n", proj->show_peaks);
fprintf(fh, "show_refls %i\n", proj->show_refls);
fprintf(fh, "label_refls %i\n", proj->label_refls);
@@ -1098,6 +1118,7 @@ void default_project(struct crystfelproject *proj)
#endif
/* Default parameter values */
+ proj->show_centre = 1;
proj->show_peaks = 1;
proj->show_refls = 1;
proj->label_refls = 1;
@@ -1146,6 +1167,9 @@ void default_project(struct crystfelproject *proj)
proj->indexing_params.exclude_refls = 0;
proj->indexing_params.metadata_to_copy = NULL;
proj->indexing_params.n_metadata = 0;
+ proj->indexing_params.fix_profile_radius = 0.01e9;
+ proj->indexing_params.use_fix_profile_radius = 0;
+ proj->indexing_params.fix_divergence = 0.0;
proj->ambi_params.use_res = 1;
proj->ambi_params.res_min = 20; /* Angstroms */
diff --git a/src/gui_project.h b/src/gui_project.h
index 1bb22d74..e4daeb8d 100644
--- a/src/gui_project.h
+++ b/src/gui_project.h
@@ -87,6 +87,9 @@ struct index_params {
float ir_inn;
float ir_mid;
float ir_out;
+ float fix_profile_radius;
+ int use_fix_profile_radius;
+ float fix_divergence;
/* Stream output */
int exclude_nonhits;
@@ -279,6 +282,7 @@ struct crystfelproject {
int max_frames;
char **filenames;
char **events;
+ int show_centre;
int show_peaks;
struct peak_params peak_search_params;