Spectra¶
These are generic objects for storing 1D/2D spectra e.g. density of states or S(Q,w) maps.
Spectrum1D¶
Broadening¶
A 1D spectrum can be broadened using
Spectrum1D.broaden,
which broadens along the x-axis and returns a new Spectrum1D
object. It can broaden with either a Gaussian or Lorentzian and requires
a broadening FWHM in the same type of units as x_data. For example:
from euphonic import ureg, Spectrum1D
dos = Spectrum1D.from_json_file('dos.json')
fwhm = 1.5*ureg('meV')
dos_broaden = dos.broaden(fwhm, shape='lorentz')
Docstring¶
-
class
Spectrum1D(x_data, y_data, x_tick_labels=None)¶ For storing generic 1D spectra e.g. density of states
Variables: - x_data ((n_x_data,) or (n_x_data + 1,) float Quantity) – The x_data points (if size (n_x_data,)) or x_data bin edges (if size (n_x_data + 1,))
- y_data ((n_x_data,) float Quantity) – The plot data in y
- x_tick_labels (list (int, string) tuples or None) – Special tick labels e.g. for high-symmetry points. The int refers to the index in x_data the label should be applied to
-
__init__(x_data, y_data, x_tick_labels=None)¶ Parameters: - x_data ((n_x_data,) or (n_x_data + 1,) float Quantity) – The x_data points (if size (n_x_data,)) or x_data bin edges (if size (n_x_data + 1,))
- y_data ((n_x_data,) float Quantity) – The plot data in y
- x_tick_labels (list (int, string) tuples or None) – Special tick labels e.g. for high-symmetry points. The int refers to the index in x_data the label should be applied to
-
broaden(x_width, shape='gauss')¶ Broaden y_data and return a new broadened Spectrum1D object
Parameters: - x_width (float Quantity) – The broadening FWHM
- shape ({'gauss', 'lorentz'}, optional) – The broadening shape
Returns: broadened_spectrum – A new Spectrum1D object with broadened y_data
Return type:
-
to_dict()¶ Convert to a dictionary. See Spectrum1D.from_dict for details on keys/values
Returns: Return type: dict
-
to_json_file(filename)¶ Write to a JSON file. JSON fields are equivalent to from_dict keys
Parameters: filename (str) – Name of the JSON file to write to
-
classmethod
from_dict(d)¶ Convert a dictionary to a Spectrum1D object
Parameters: d (dict) – A dictionary with the following keys/values:
- ’x_data’: (n_x_data,) or (n_x_data + 1,) float ndarray
- ’x_data_unit’: str
- ’y_data’: (n_x_data,) float ndarray
- ’y_data_unit’: str
There are also the following optional keys:
- ’x_tick_labels’: list of (int, string) tuples
Returns: Return type: Spectrum1D
-
classmethod
from_json_file(filename)¶ Read from a JSON file. See from_dict for required fields
Parameters: filename (str) – The file to read from
Spectrum2D¶
Broadening¶
A 2D spectrum can be broadened using
Spectrum2D.broaden, which
broadens along either or both of the x/y-axes and returns a new
Spectrum2D object. It can broaden with either a Gaussian or Lorentzian
and requires a broadening FWHM in the same type of units as
x_data/y_data for broadening along the x/y-axis respectively.
For example:
from euphonic import ureg, Spectrum2D
sqw = Spectrum2D.from_json_file('sqw.json')
x_fwhm = 0.05*ureg('1/angstrom')
y_fwhm = 1.5*ureg('meV')
sqw_broaden = sqw.broaden(x_width=x_fwhm, y_width=y_fwhm, shape='lorentz')
Docstring¶
-
class
Spectrum2D(x_data, y_data, z_data, x_tick_labels=None)¶ For storing generic 2D spectra e.g. S(Q,w)
Variables: - x_data ((n_x_data,) or (n_x_data + 1,) float Quantity) – The x_data points (if size (n_x_data,)) or x_data bin edges (if size (n_x_data + 1,))
- y_data ((n_y_data,) or (n_y_data + 1,) float Quantity) – The y_data bin points (if size (n_y_data,)) or y_data bin edges (if size (n_y_data + 1,))
- z_data ((n_x_data, n_y_data) float Quantity) – The plot data in z
- x_tick_labels (list (int, string) tuples or None) – Special tick labels e.g. for high-symmetry points. The int refers to the index in x_data the label should be applied to
-
__init__(x_data, y_data, z_data, x_tick_labels=None)¶ Variables: - x_data ((n_x_data,) or (n_x_data + 1,) float Quantity) – The x_data points (if size (n_x_data,)) or x_data bin edges (if size (n_x_data + 1,))
- y_data ((n_y_data,) or (n_y_data + 1,) float Quantity) – The y_data bin points (if size (n_y_data,)) or y_data bin edges (if size (n_y_data + 1,))
- z_data ((n_x_data, n_y_data) float Quantity) – The plot data in z
- x_tick_labels (list (int, string) tuples or None) – Special tick labels e.g. for high-symmetry points. The int refers to the index in x_data the label should be applied to
-
broaden(x_width=None, y_width=None, shape='gauss')¶ Broaden z_data and return a new broadened Spectrum2D object
Parameters: - x_width (float Quantity, optional) – The broadening FWHM in x
- y_width (float Quantity, optional) – The broadening FWHM in y
- shape ({'gauss', 'lorentz'}, optional) – The broadening shape
Returns: broadened_spectrum – A new Spectrum2D object with broadened z_data
Return type:
-
to_dict()¶ Convert to a dictionary. See Spectrum2D.from_dict for details on keys/values
Returns: Return type: dict
-
classmethod
from_dict(d)¶ Convert a dictionary to a Spectrum2D object
Parameters: d (dict) – A dictionary with the following keys/values:
- ’x_data’: (n_x_data,) or (n_x_data + 1,) float ndarray
- ’x_data_unit’: str
- ’y_data’: (n_y_data,) or (n_y_data + 1,) float ndarray
- ’y_data_unit’: str
- ’z_data’: (n_x_data, n_y_data) float Quantity
- ’z_data_unit’: str
There are also the following optional keys:
- ’x_tick_labels’: list of (int, string) tuples
Returns: Return type: Spectrum2D
-
classmethod
from_json_file(filename)¶ Read from a JSON file. See from_dict for required fields
Parameters: filename (str) – The file to read from
-
to_json_file(filename)¶ Write to a JSON file. JSON fields are equivalent to from_dict keys
Parameters: filename (str) – Name of the JSON file to write to