Last modified: 12 December 2024

Writing out data to a file


Sherpa contains a number of routines that will write out data to a file. Most functions support writing out both ASCII and FITS binary files.

Writing out columns

The save_arrays is different to the other routines discussed here, in that you give it the columns to write out, rather than writing out a particular type of data, such as PHA or a data set.

The following will will create an ASCII and FITS binary table containing the independent and dependent axes of the default dataset as displayed by plot_data:

sherpa> dplot = get_data_plot()
sherpa> cols = [dplot.x, dplot.y]
sherpa> names = ["x", "y"]
sherpa> save_arrays("src.dat", cols, fields=names)
sherpa> save_arrays("src.fits", cols, fields=names, ascii=False)

Writing out data

The save_data, save_image, and save_table, functions will write out the basic components of a dataset.

Additional columns can be saved with one or more of: save_delchi, save_error, save_filter, save_resid, save_staterror, and save_syserror.

Evaluated models

The save_model and save_source functions will evaluate the model and write out the results, similar to the plot_model and plot_source calls.

PHA data

The save_arf, save_pha, and save_rmf routines will write out ARF, PHA, or RMF data.

The save_grouping and save_quality functions will write out the grouping and quality arrays, such as those created by calls to group_counts or group_snr.

Other commands

The save_all function is used to write out a Python file that will attempt to re-create the current session.