Translator for bands data
aiida.restapi.translator.nodes.data.array.bands.
BandsDataTranslator
Bases: aiida.restapi.translator.nodes.data.DataTranslator
aiida.restapi.translator.nodes.data.DataTranslator
Translator relative to resource ‘bands’ and aiida class BandsData
BandsData
Bases: aiida.orm.nodes.data.array.kpoints.KpointsData
aiida.orm.nodes.data.array.kpoints.KpointsData
Class to handle bands data
__abstractmethods__
__module__
_abc_impl
_get_band_segments
Return the band segments.
_get_bandplot_data
Get data to plot a band structure
cartesian – if True, distances (for the x-axis) are computed in cartesian coordinates, otherwise they are computed in reciprocal coordinates. cartesian=True will fail if no cell has been set.
prettify_format – by default, strings are not prettified. If you want to prettify them, pass a valid prettify_format string (see valid options in the docstring of :py:func:prettify_labels).
join_symbols – by default, strings are not joined. If you pass a string, this is used to join strings that are much closer than a given threshold. The most typical string is the pipe symbol: |.
|
get_segments – if True, also computes the band split into segments
y_origin – if present, shift bands so to set the value specified at y=0
y=0
a plot_info dictiorary, whose keys are x (array of distances for the x axis of the plot); y (array of bands), labels (list of tuples in the format (float x value of the label, label string), band_type_idx (array containing an index for each band: if there is only one spin, then it’s an array of zeros, of length equal to the number of bands at each point; if there are two spins, then it’s an array of zeros or ones depending on the type of spin; the length is always equalt to the total number of bands per kpoint).
x
y
labels
band_type_idx
_get_mpl_body_template
paths – paths of k-points
_logger
_matplotlib_get_dict
Prepare the data to send to the python-matplotlib plotting script.
comments – if True, print comments (if it makes sense for the given format)
plot_info – a dictionary
setnumber_offset – an offset to be applied to all set numbers (i.e. s0 is replaced by s[offset], s1 by s[offset+1], etc.)
color_number – the color number for lines, symbols, error bars and filling (should be less than the parameter MAX_NUM_AGR_COLORS defined below)
title – the title
legend – the legend (applied only to the first of the set)
legend2 – the legend for second-type spins (applied only to the first of the set)
y_max_lim – the maximum on the y axis (if None, put the maximum of the bands)
y_min_lim – the minimum on the y axis (if None, put the minimum of the bands)
y_origin – the new origin of the y axis -> all bands are replaced by bands-y_origin
prettify_format – if None, use the default prettify format. Otherwise specify a string with the prettifier to use.
kwargs – additional customization variables; only a subset is accepted, see internal variable ‘valid_additional_keywords
_plugin_type_string
_prepare_agr
Prepare an xmgrace agr file.
color_number2 – the color number for lines, symbols, error bars and filling for the second-type spins (should be less than the parameter MAX_NUM_AGR_COLORS defined below)
legend – the legend (applied only to the first set)
y_max_lim – the maximum on the y axis (if None, put the maximum of the bands); applied after shifting the origin by y_origin
y_origin
y_min_lim – the minimum on the y axis (if None, put the minimum of the bands); applied after shifting the origin by y_origin
_prepare_agr_batch
Prepare two files, data and batch, to be plot with xmgrace as: xmgrace -batch file.dat
main_file_name – if the user asks to write the main content on a file, this contains the filename. This should be used to infer a good filename for the additional files. In this case, we remove the extension, and add ‘_data.dat’
_prepare_dat_blocks
Format suitable for gnuplot using blocks. Columns with x and y (path and band energy). Several blocks, separated by two empty lines, one per energy band.
_prepare_dat_multicolumn
Write an N x M matrix. First column is the distance between kpoints, The other columns are the bands. Header contains number of kpoints and the number of bands (commented).
_prepare_gnuplot
Prepare an gnuplot script to plot the bands, with the .dat file returned as an independent file.
title – if specified, add a title to the plot
_prepare_json
Prepare a json file in a format compatible with the AiiDA band visualizer
_prepare_mpl_pdf
Prepare a python script using matplotlib to plot the bands, with the JSON returned as an independent file.
For the possible parameters, see documentation of _matplotlib_get_dict()
_matplotlib_get_dict()
_prepare_mpl_png
_prepare_mpl_singlefile
Prepare a python script using matplotlib to plot the bands
_prepare_mpl_withjson
_query_type_string
_set_pbc
validate the pbc, then store them
_validate_bands_occupations
Validate the list of bands and of occupations before storage. Kpoints must be set in advance. Bands and occupations must be convertible into arrays of Nkpoints x Nbands floats or Nspins x Nkpoints x Nbands; Nkpoints must correspond to the number of kpoints.
array_labels
Get the labels associated with the band arrays
get_bands
Returns an array (nkpoints x num_bands or nspins x nkpoints x num_bands) of energies. :param also_occupations: if True, returns also the occupations array. Default = False
set_bands
Set an array of band energies of dimension (nkpoints x nbands). Kpoints must be set in advance. Can contain floats or None. :param bands: a list of nkpoints lists of nbands bands, or a 2D array of shape (nkpoints x nbands), with band energies for each kpoint :param units: optional, energy units :param occupations: optional, a 2D list or array of floats of same shape as bands, with the occupation associated to each band
set_kpointsdata
Load the kpoints from a kpoint object. :param kpointsdata: an instance of KpointsData class
show_mpl
Call a show() command for the band structure using matplotlib. This uses internally the ‘mpl_singlefile’ format, with empty main_file_name.
Other kwargs are passed to self._exportcontent.
units
Units in which the data in bands were stored. A string
__label__
_aiida_class
alias of aiida.orm.nodes.data.array.bands.BandsData
aiida.orm.nodes.data.array.bands.BandsData
_aiida_type
_result_type
get_derived_properties
Returns: data in a format required by dr.js to visualize a 2D plot with multiple data series.
Strategy: I take advantage of the export functionality of BandsData objects. The raw export has to be filtered for string escape characters. this is done by decoding the string returned by node._exportcontent.
TODO: modify the function exportstring (or add another function in BandsData) so that it returns a python object rather than a string.