sisl.io.siesta.gridncSileSiesta

class sisl.io.siesta.gridncSileSiesta(filename, mode='r', lvl=0, access=1, *args, **kwargs)

Bases: SileCDFSiesta

NetCDF real-space grid file

The grid sile will automatically convert the units from Siesta units (Bohr, Ry) to sisl units (Ang, eV) provided the correct extension is present.

Plotting

plot

Plotting functions for the gridncSileSiesta class.

plot.grid([index, name, ...])

Calls read_grid and creates a GridPlot from its output.

Methods

base_directory([relative_to])

Retrieve the base directory of the file, relative to the path relative_to

close()

dir_file([filename, filename_base])

File of the current Sile

iter([group, dimension, variable, levels, root])

Iterator on all groups, variables and dimensions.

read(*args, **kwargs)

Generic read method which should be overloaded in child-classes

read_grid([index, name])

Reads a grid in the current Siesta.grid.nc file

read_lattice()

Returns a Lattice object from a Siesta.grid.nc file

write(*args, **kwargs)

Generic write method which should be overloaded in child-classes

write_grid(grid[, spin, nspin])

Write a grid to the grid.nc file

write_lattice(lattice)

Write a supercell to the grid.nc file

Attributes

base_file

File of the current Sile

file

File of the current Sile

base_directory(relative_to='.')

Retrieve the base directory of the file, relative to the path relative_to

close()
dir_file(filename=None, filename_base='')

File of the current Sile

iter(group=True, dimension=True, variable=True, levels=-1, root=None)

Iterator on all groups, variables and dimensions.

This iterator iterates through all groups, variables and dimensions in the Dataset

The generator sequence will _always_ be:

  1. Group

  2. Dimensions in group

  3. Variables in group

As the dimensions are generated before the variables it is possible to copy groups, dimensions, and then variables such that one always ensures correct dependencies in the generation of a new SileCDF.

Parameters:
  • group (bool (True)) – whether the iterator yields Group instances

  • dimension (bool (True)) – whether the iterator yields Dimension instances

  • variable (bool (True)) – whether the iterator yields Variable instances

  • levels (int (-1)) – number of levels to traverse, with respect to root variable, i.e. number of sub-groups this iterator will return.

  • root (str (None)) – the base root to start iterating from.

Examples

Script for looping and checking each instance.

>>> for gv in self.iter():
...     if self.isGroup(gv):
...         # is group
...     elif self.isDimension(gv):
...         # is dimension
...     elif self.isVariable(gv):
...         # is variable
plot.grid(index=0, name='gridfunc', *args, data_kwargs={}, axes: Axes = ['z'], represent: Literal['real', 'imag', 'mod', 'phase', 'deg_phase', 'rad_phase'] = 'real', transforms: Sequence[str | Callable] = (), reduce_method: Literal['average', 'sum'] = 'average', boundary_mode: str = 'grid-wrap', nsc: tuple[int, int, int] = (1, 1, 1), interp: tuple[int, int, int] = (1, 1, 1), isos: Sequence[dict] = [], smooth: bool = False, colorscale: Colorscale | None = None, crange: tuple[float, float] | None = None, cmid: float | None = None, show_cell: Literal['box', 'axes', False] = 'box', cell_style: dict = {}, x_range: Sequence[float] | None = None, y_range: Sequence[float] | None = None, z_range: Sequence[float] | None = None, plot_geom: bool = False, geom_kwargs: dict = {}, backend: str = 'plotly') GridPlot

Calls read_grid and creates a GridPlot from its output.

Parameters:
  • index (int or array_like, optional) – the spin-index for retrieving one of the components. If a vector is passed it refers to the fraction per indexed component. I.e. [0.5, 0.5] will return sum of half the first two components. Default to the first component.

  • name (str, optional) – the name for the grid-function (do not supply for standard Siesta output)

  • geometry (Geometry, optional) – add the Geometry to the Grid

  • spin (optional) – same as index argument. spin argument has precedence.

  • axes – The axes to project the grid to.

  • represent – The representation of the grid to plot.

  • transforms – List of transforms to apply to the grid before plotting.

  • reduce_method – The method used to reduce the grid axes that are not displayed.

  • boundary_mode – The method used to deal with the boundary conditions. Only used if the grid is to be orthogonalized. See scipy docs for more info on the possible values.

  • nsc – The number of unit cells to display in each direction.

  • interp – The interpolation factor to use for each axis to make the grid smoother.

  • isos – List of isosurfaces or isocontours to plot. See the showcase notebooks for examples.

  • smooth – Whether to ask the plotting backend to make an attempt at smoothing the grid display.

  • colorscale – Colorscale to use for the grid display in the 2D representation. If None, the default colorscale is used for each backend.

  • crange – Min and max values for the colorscale.

  • cmid – The value at which the colorscale is centered.

  • show_cell – Method used to display the unit cell. If False, the cell is not displayed.

  • cell_style – Style specification for the cell. See the showcase notebooks for examples.

  • x_range – The range of the x axis to take into account. Even if the X axis is not displayed! This is important because the reducing operation will only be applied on this range.

  • y_range – The range of the y axis to take into account. Even if the Y axis is not displayed! This is important because the reducing operation will only be applied on this range.

  • z_range – The range of the z axis to take into account. Even if the Z axis is not displayed! This is important because the reducing operation will only be applied on this range.

  • plot_geom – Whether to plot the associated geometry (if any).

  • geom_kwargs – Keyword arguments to pass to the geometry plot of the associated geometry.

  • backend – The backend to use to generate the figure.

See also

GridPlot

The plot class used to generate the plot.

read_grid

The method called to get the data.

read(*args, **kwargs)

Generic read method which should be overloaded in child-classes

Parameters:

kwargs – keyword arguments will try and search for the attribute read_<> and call it with the remaining **kwargs as arguments.

read_grid(index=0, name='gridfunc', *args, **kwargs) Grid[source]

Reads a grid in the current Siesta.grid.nc file

Enables the reading and processing of the grids created by Siesta

Parameters:
  • index (int or array_like, optional) – the spin-index for retrieving one of the components. If a vector is passed it refers to the fraction per indexed component. I.e. [0.5, 0.5] will return sum of half the first two components. Default to the first component.

  • name (str, optional) – the name for the grid-function (do not supply for standard Siesta output)

  • geometry (Geometry, optional) – add the Geometry to the Grid

  • spin (optional) – same as index argument. spin argument has precedence.

read_lattice() Lattice[source]

Returns a Lattice object from a Siesta.grid.nc file

write(*args, **kwargs)

Generic write method which should be overloaded in child-classes

Parameters:

**kwargs – keyword arguments will try and search for the attribute write_ and call it with the remaining **kwargs as arguments.

write_grid(grid, spin=0, nspin=None, **kwargs)[source]

Write a grid to the grid.nc file

write_lattice(lattice)[source]

Write a supercell to the grid.nc file

property base_file

File of the current Sile

property file

File of the current Sile

plot

Plotting functions for the gridncSileSiesta class.