aiida.restapi.translator.nodes.data.array package

Submodules

Translator for bands data

class aiida.restapi.translator.nodes.data.array.bands.BandsDataTranslator(**kwargs)[source]

Bases: aiida.restapi.translator.nodes.data.DataTranslator

Translator relative to resource ‘bands’ and aiida class BandsData

class BandsData(backend=None, user=None, computer=None, **kwargs)

Bases: aiida.orm.nodes.data.array.kpoints.KpointsData

Class to handle bands data

__abstractmethods__ = frozenset({})
__module__ = 'aiida.orm.nodes.data.array.bands'
_abc_impl = <_abc_data object>
_custom_export_format_replacements = {'dat': 'dat_multicolumn', 'gnu': 'gnuplot', 'pdf': 'mpl_pdf', 'png': 'mpl_png', 'py': 'mpl_singlefile'}
_get_band_segments(cartesian)
_get_bandplot_data(cartesian, prettify_format=None, join_symbol=None, get_segments=False, y_origin=0.0)

Get data to plot a band structure

Parameters
  • 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

Returns

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).

static _get_mpl_body_template(paths)
Parameters

paths – paths of k-points

_logger = <Logger aiida.orm.nodes.data.array.bands.BandsData (REPORT)>
_matplotlib_get_dict(main_file_name='', comments=True, title='', legend=None, legend2=None, y_max_lim=None, y_min_lim=None, y_origin=0.0, prettify_format=None, **kwargs)

Prepare the data to send to the python-matplotlib plotting script.

Parameters
  • 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 = 'data.array.bands.BandsData.'
_prepare_agr(main_file_name='', comments=True, setnumber_offset=0, color_number=1, color_number2=2, legend='', title='', y_max_lim=None, y_min_lim=None, y_origin=0.0, prettify_format=None)

Prepare an xmgrace agr file.

Parameters
  • 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)

  • 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)

  • title – the title

  • 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_min_lim – the minimum on the y axis (if None, put the minimum of the bands); applied after shifting the origin by y_origin

  • 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.

_prepare_agr_batch(main_file_name='', comments=True, prettify_format=None)

Prepare two files, data and batch, to be plot with xmgrace as: xmgrace -batch file.dat

Parameters
  • 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’

  • comments – if True, print comments (if it makes sense for the given format)

  • prettify_format – if None, use the default prettify format. Otherwise specify a string with the prettifier to use.

_prepare_dat_blocks(main_file_name='', comments=True)

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.

Parameters

comments – if True, print comments (if it makes sense for the given format)

_prepare_dat_multicolumn(main_file_name='', comments=True)

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).

Parameters

comments – if True, print comments (if it makes sense for the given format)

_prepare_gnuplot(main_file_name=None, title='', comments=True, prettify_format=None, y_max_lim=None, y_min_lim=None, y_origin=0.0)

Prepare an gnuplot script to plot the bands, with the .dat file returned as an independent file.

Parameters
  • 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’

  • title – if specified, add a title to the plot

  • comments – if True, print comments (if it makes sense for the given format)

  • prettify_format – if None, use the default prettify format. Otherwise specify a string with the prettifier to use.

_prepare_json(main_file_name='', comments=True)

Prepare a json file in a format compatible with the AiiDA band visualizer

Parameters

comments – if True, print comments (if it makes sense for the given format)

_prepare_mpl_pdf(main_file_name='', *args, **kwargs)

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()

_prepare_mpl_png(main_file_name='', *args, **kwargs)

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()

_prepare_mpl_singlefile(*args, **kwargs)

Prepare a python script using matplotlib to plot the bands

For the possible parameters, see documentation of _matplotlib_get_dict()

_prepare_mpl_withjson(main_file_name='', *args, **kwargs)

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()

_query_type_string = 'data.array.bands.'
_set_pbc(value)

validate the pbc, then store them

_validate_bands_occupations(bands, occupations=None, labels=None)

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.

property array_labels

Get the labels associated with the band arrays

get_bands(also_occupations=False, also_labels=False)

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(bands, units=None, occupations=None, labels=None)

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(kpointsdata)

Load the kpoints from a kpoint object. :param kpointsdata: an instance of KpointsData class

show_mpl(**kwargs)

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.

property units

Units in which the data in bands were stored. A string

__label__ = 'bands'
__module__ = 'aiida.restapi.translator.nodes.data.array.bands'
_aiida_class

alias of aiida.orm.nodes.data.array.bands.BandsData

_aiida_type = 'data.array.bands.BandsData'
_result_type = 'bands'
static get_derived_properties(node)[source]

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.