diff --git a/XAS.py b/XAS.py index 092fe4f1b243d3857602d04217505a9dcdcfc0af..a7bab5001aaa1863a3fce90de4eb3078cadff9f0 100644 --- a/XAS.py +++ b/XAS.py @@ -102,7 +102,8 @@ def xas(nrun, bins=None, Iokey='SCS_XGM', Itkey='MCP3apd', nrjkey='nrj', Iooffse Inputs: nrun: xarray of SCS data - bins: array of bin-edges or number of desired bins + bins: an array of bin-edges or an integer number of + desired bins or a float for the desired bin width. Iokey: string for the Io fields, typically 'SCS_XGM' Itkey: string for the It fields, typically 'MCP3apd' NRJkey: string for the nrj fields, typically 'nrj' @@ -140,6 +141,12 @@ def xas(nrun, bins=None, Iokey='SCS_XGM', Itkey='MCP3apd', nrjkey='nrj', Iooffse num_bins = 80 energy_limits = [np.min(nrj), np.max(nrj)] bins = np.linspace(energy_limits[0], energy_limits[1], num_bins+1) + elif type(bins) == int: + energy_limits = [np.min(nrj), np.max(nrj)] + bins = np.linspace(energy_limits[0], energy_limits[1], bins+1) + elif type(bins) == float: + energy_limits = [np.min(nrj), np.max(nrj)] + bins = np.arange(energy_limits[0], energy_limits[1], bins) dummy, nosample = binning(rundata['nrj'], rundata, whichIo, bins) muA = nosample['muA']