write_output#
- crispy.image_ridge_find.write_output(coords, fname, **kwargs)[source]#
Write SCMS output coordinates to a file.
This function saves the SCMS ridge-finding results as a text file. If unconverged walkers are included, they are saved to a separate file with an appended suffix.
- Parameters:
coords (ndarray or tuple of ndarray) – Coordinates of the walkers to save. If a tuple is provided, it should contain: - coords[0]: Converged walker coordinates. - coords[1]: Unconverged walker coordinates.
fname (str) – File name or path to save the output. The file extension determines the format (e.g., .txt).
**kwargs (dict, optional) – Additional arguments passed to numpy.savetxt, such as formatting options (fmt) or delimiter (delimiter).
Notes
If coords contains both converged and unconverged walkers (as a tuple), the unconverged coordinates are saved in a separate file with a suffix (e.g., _unconverged) appended to fname.
The default behavior uses numpy.savetxt for saving coordinates, allowing for flexible formatting via **kwargs.
Examples
Save only converged walkers:
>>> import numpy as np >>> from crispy import image_ridge_find as irf >>> coords = np.array([[1, 2, 3], [4, 5, 6]]) >>> irf.write_output(coords, "output.txt")
Save both converged and unconverged walkers:
>>> coords_converged = np.array([[1, 2, 3], [4, 5, 6]]) >>> coords_unconverged = np.array([[7, 8, 9]]) >>> irf.write_output((coords_converged, coords_unconverged), "output.txt", fmt="%.3f")