atompy.load_1d_from_txt#
- atompy.load_1d_from_txt(fname, output_format='ndarray', transform=True, xmin=None, xmax=None, **loadtxt_kwargs)[source]#
Load a text file.
This is a wrapper function for
numpy.loadtxt()that changes the output according to output_format.- Parameters:
- fname
str Filename
- output_format{
"ndarray",Hist1d}, default"ndarray" Change output format. See Returns.
- transformbool, default
True Transform the loaded NumPy ndarray.
- xmin
float, optional Specify the lower x-limit of the data in fname. Only necessary if the x-values in fname are not equally spaced. Alternatively, specify xmax.
- xmax
float, optional Specify the upper x-limit of the data in fname. Only necessary if the x-values in fname are not equally spaced. Alternatively, specify xmin. If xmin and xmax are specified, xmax is not used.
- **loadtxt_kwargs
Other
numpy.loadtxt()keyword arguments. Useful if, e.g., you want to skip a certain number of lines in the text file.
- fname
- Returns:
- output
ndarrayorHist1d Depends on output_format.
output_format == "ndarray": Return a NumPy ndarray.output[0]refers to the bin-centers of the loaded histogram,output[1]to the corresponding values.output_format == "Hist1d": Return aHist1d.output.edges(output.histogram) is analogous tooutput[0](output[1]) of the"ndarray"output.
- output
Examples
x, y = ap.load_1d_from_txt("filename.txt", output_format="ndarray") plt.plot(x, y) hist = ap.load_1d_from_txt("filename.txt", output_format="Hist1d") plt.plot(hist.centers, hist.histogram)