Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspace | Input | MatrixWorkspace | Mandatory | Workspace that contains plottable data |
JsonFilename | Input | string | Mandatory | Name of the output Json file. Allowed extensions: [‘.json’] |
PlotName | Input | string | Name of the output plot |
This algorithm is to extract plottable 1-D dataset(s) with metadata from a MatrixWorkspace, serialize it into json format, and dump the result to a file.
It currently only support MatrixWorkspace
Note for usage with ORNL live monitor: The output file needs to be named <inst>_<runnumber>_plot_data.json to be cataloged and plotted.
Example:
import os, numpy as np
# prepare input
E = np.arange(-50, 50, 1.0)
I = 1000 * np.exp(-E**2/10**2)
err = I ** .5
dataws = CreateWorkspace(
DataX = E, DataY = I, DataE = err, NSpec = 1,
UnitX = "Energy(meV)")
# output path
out_json = "myplot.json"
# run algorithm
SavePlot1DAsJson(InputWorkspace=dataws, JsonFilename=out_json, PlotName="myplot")
Categories: Algorithms | Utility
Python: SavePlot1DAsJson.py