# Export Convert merged reflection data (`crystfel.hkl`) into formats used by downstream software for structure solution and refinement. ## Inputs - `crystfel.hkl` files produced by the Merge step (`_merge_/merge-run/crystfel.hkl`) - Unit cell parameters (inferred automatically from the combined stream header) ## Supported export formats | Format | Extension | Used by | |---|---|---| | **HKLF4** | `.hkl` | SHELX (SHELXL, SHELXT) | | **INS** | `.ins` | SHELX instruction file for structure solution | | **P4P** | `.p4p` | CrystalClear / Rigaku | | **MTZ** | `.mtz` | CCP4 suite (REFMAC, Phaser, etc.) | ## Using the GUI Open the **Export** window from the toolbar or menu. The window has three sections: **Merge Runs**, **Cell**, and **Write files**. ### Merge Runs Lists all `crystfel.hkl` files found under `_merge_*/merge-run*/` in the workspace. - **Refresh** — rescan the workspace for HKL files. - **Open Location** — open the containing folder in the file browser. Select an entry to populate the Cell section automatically. ### Cell Displays the unit cell parsed from the combined stream header. Point group is read from the merge settings JSON written alongside the stream. | Field | Editable | Source | |---|---|---| | Lattice type | after unlock | Stream header | | Centering | after unlock | Stream header | | Point group | read-only | Merge settings JSON | | a, b, c (Å) | after unlock | Stream header | | α, β, γ (°) | after unlock | Stream header | | Space group | always | User entry | | Composition | always | User entry | | d_min (Å) | always | User entry | Click **Enable edits…** to unlock the lattice type, centering, and cell length/angle fields. Point group remains read-only. - **Space group** — required for MTZ export; also used by INS. Use standard notation (e.g. `P 21 21 21`). - **Composition** — chemical formula of the asymmetric unit used by INS (e.g. `C6 H12 N2 O`). - **d_min (Å)** — resolution cutoff applied during HKLF4 and MTZ export. Leave empty for no cutoff. ### Write files | Control | Description | |---|---| | **Export HKLF4** | Write SHELX HKLF4 format. | | **Write INS** | Generate a SHELX instruction file. | | **Write P4P** | Generate a CrystalClear `.p4p` file. | | **Export MTZ** | Convert to CCP4 MTZ format. | | **Anomalous** | Keep Friedel pairs separate (applies to MTZ). | | **Overwrite existing files** | Allow replacing output files that already exist. | All output files are written to the `_merge_/` folder (the parent of the selected `merge-run/` directory). ## Format-specific notes ### HKLF4 Converts `crystfel.hkl` directly to SHELX HKLF4 format. Applies the `d_min` cutoff if set. The output is named `.hkl`. ### INS Generates a SHELX instruction file (`.ins`). Cell parameters, centering, and wavelength are taken from the parsed stream cell. Space group and composition are taken from the Cell section fields. ### P4P Generates a CrystalClear `.p4p` file (`.p4p`) from the unit cell. The non-centrosymmetric flag is inferred automatically from the point group read out of the merge settings. ### MTZ Converts `crystfel.hkl` to CCP4 MTZ format (`.mtz`). Requires: - **Space group** — must be filled in before export; COSEDA will not attempt a default. - **Wavelength** — parsed from the geometry block in the stream. If missing, the export is blocked until wavelength is entered manually via the **Enable edits…** flow. - **Anomalous** checkbox — controls whether Friedel pairs are kept separate. - **d_min** — optional resolution cutoff. Polarisation is fixed to `none` for electron diffraction. ## Outputs All output files are placed in the `_merge_/` folder next to the combined stream: - `.hkl` — HKLF4 reflection file - `.ins` — SHELX instruction file - `.p4p` — CrystalClear parameter file - `.mtz` — MTZ reflection file ## Tips - **Cell.** COSEDA reads the unit cell from the combined stream's header block. If parsing fails, click **Enable edits…** to enter values manually. - **Wavelength.** MTZ export requires a wavelength parsed from the geometry block embedded in the stream. If your stream does not contain one, unlock the cell fields and supply the value directly. - **Multiple exports.** Each format writes a separate output file; you can export to all four from the same HKL selection. - **Overwrite.** By default COSEDA refuses to overwrite existing output files. Tick **Overwrite existing files** before re-exporting with changed parameters.