---
title: Interpreting PyWPEM outputs
description: 'Read rp, rwp, convergence_flag and per-phase mass and volume fractions from a refine_xrd result, and why goodness of fit is always null for this tool.'
tags:
  - pywpem
  - outputs
---

Each operation returns structured JSON — simulated or fitted patterns, refined cell parameters, R-factors, phase fractions, or PDF curves. These let you judge how well a structure fits your data, quantify phases, and compare patterns against experimental measurements.

## Interpreting PyWPEM outputs

Each operation returns a structured JSON result with operation-specific fields plus shared metadata.

## simulate_xrd output

| Field | Type | Description |
|-------|------|-------------|
| `peak_count` | integer | Number of peaks in the simulated pattern |
| `two_theta_min` / `two_theta_max` | number | Angular range of the pattern |
| `formula` | string \| null | Structure formula, if extracted from the CIF |
| `space_group` | string \| null | Space group, if extracted from the CIF |
| `wavelength_used` | number[] | Wavelength(s) actually used for the simulation |
| `grain_size_nm` | number \| null | Grain size used for peak broadening, if set |
| `pattern_csv_url` | string \| null | S3 URL to the simulated pattern CSV |
| `peaks_csv_url` | string \| null | S3 URL to the peak list |
| `plot_url` | string \| null | S3 URL to a pattern plot |

## refine_xrd output

| Field | Type | Description |
|-------|------|-------------|
| `rp` | number \| null | Profile R-factor (%), computed from the fit. `null` when it couldn't be computed — check `metrics_available` |
| `rwp` | number \| null | Weighted profile R-factor (%), computed from the fit. `null` when it couldn't be computed — check `metrics_available` |
| `gof` | null | Goodness of fit / chi² is not computed — always `null` |
| `metrics_available` | boolean | `false` when one or more of `rp`/`rwp` couldn't be computed for this fit |
| `metrics_unavailable_reason` | string \| null | Why a metric is missing, set when `metrics_available` is `false` |
| `iterations_completed` | integer | Number of refinement iterations actually run, read from the solver |
| `convergence_flag` | integer | 1 = converged, 2 = epsilon limit, 3 = max iterations, 4 = lock limit — read from the solver |
| `convergence_message` | string | Human-readable convergence status, read from the solver |
| `phases` | array | Per-phase results (one entry per item in the request's `phases`) |
| `phases[].name` | string | Phase identifier |
| `phases[].initial_lattice` / `phases[].refined_lattice` | object | Lattice constants before and after refinement |
| `phases[].mass_fraction` / `phases[].volume_fraction` | number \| null | Phase fractions, for multi-phase refinements |
| `phases[].peak_count` | integer | Peaks attributed to this phase |
| `computation_time` | string | Wall-clock time for the refinement |
| `fitted_profile_url` / `residual_plot_url` | string \| null | S3 URLs to the fitted profile and residual plot |
| `peak_params_url` | string \| null | S3 URL to fitted peak parameters |

A single `refine_xrd` call with two or more entries in `phases` returns multi-phase results — there's no separate multi-phase operation.

### R-factor interpretation

| R_wp | Quality |
|------|---------|
| &lt; 5% | Excellent refinement |
| 5-10% | Good refinement |
| 10-15% | Acceptable (may need improvement) |
| &gt; 15% | Poor fit (check model or data) |

This tool doesn't compute goodness-of-fit / chi² — `gof` is always `null`. Judge refinement quality from `rwp` and `convergence_flag`, and check `residual_plot_url` for systematic deviations.

## fit_background output

| Field | Type | Description |
|-------|------|-------------|
| `variance` | number | Estimated background variance — feed this into `refine_xrd`'s `variance` parameter |
| `background_points_count` | integer | Number of background points used |
| `background_csv_url` / `no_background_csv_url` | string \| null | Background and background-subtracted CSVs |
| `plot_url` | string \| null | Diagnostic plot |
| `mean_background` / `std_background` | number \| null | Background statistics |

## fit_amorphous output

| Field | Type | Description |
|-------|------|-------------|
| `num_components` | integer | Number of Gaussian components fit |
| `components` | array | Per-component `position_2theta`, `sigma`, `amplitude`, `area` |
| `total_amorphous_fraction` | number \| null | Estimated amorphous fraction |
| `amorphous_csv_url` / `components_csv_url` / `plot_url` | string \| null | Result artifacts |

## fit_xps output

| Field | Type | Description |
|-------|------|-------------|
| `rp` / `rwp` | number | Fit R-factors |
| `iterations_completed` | integer | Iterations run |
| `peaks` | array | Per-peak `atom`, `orbital`, `binding_energy`, `area`, `fwhm`, `lorentzian_fraction` |
| `elemental_composition` | object \| null | Composition derived from the fit |
| `fitted_profile_url` / `peak_params_url` / `plot_url` | string \| null | Result artifacts |

## fit_exafs output

| Field | Type | Description |
|-------|------|-------------|
| `coordination_shells` | array | Per-shell `shell_number`, `r_angstrom`, `coordination_number`, `debye_waller` |
| `first_shell_distance` | number \| null | Nearest-neighbor distance |
| `fft_plot_url` / `wavelet_plot_url` | string \| null | Transform plots |

## Downloading artifacts

- **CSV/JSON exports**: Available from the job result panel
- **Plot images**: Pattern plots are auto-generated for visual inspection
- **S3 artifacts**: Linked in result metadata for programmatic access

⚠︎ Exact result field names may vary slightly by operation and are subject to change on the backend — treat this page as a guide and check a live job result for the authoritative shape.

## Read next
