11import numpy as np
22
3+ import sisl ._array as _a
34from sisl .utils import strmap
45from sisl .utils .cmd import default_ArgumentParser , default_namespace
56from ..sile import add_sile , sile_fh_open
@@ -21,7 +22,7 @@ def read_data(self, as_dataarray=False):
2122 as_dataarray: boolean, optional
2223 if `True`, the information is returned as an `xarray.DataArray`
2324 Ticks (if read) are stored as an attribute of the DataArray
24- (under `array.tick_vals ` and `array.tick_labels `)
25+ (under `array.ticks ` and `array.ticklabels `)
2526 """
2627 band_lines = False
2728
@@ -43,19 +44,19 @@ def read_data(self, as_dataarray=False):
4344 no , ns , nk = map (int , l .split ())
4445
4546 # Create the data to contain all band points
46- b = np . empty ([nk , ns , no ], np . float64 )
47+ b = _a . emptyd ([nk , ns , no ])
4748
4849 # for band-lines
4950 if band_lines :
50- k = np . empty ([nk ], np . float64 )
51+ k = _a . emptyd ([nk ])
5152 for ik in range (nk ):
5253 l = [float (x ) for x in self .readline ().split ()]
5354 k [ik ] = l [0 ]
5455 del l [0 ]
5556 # Now populate the eigenvalues
5657 while len (l ) < ns * no :
5758 l .extend ([float (x ) for x in self .readline ().split ()])
58- l = np . array ( l , np . float64 )
59+ l = _a . arrayd ( l )
5960 l .shape = (ns , no )
6061 b [ik , :, :] = l [:, :] - Ef
6162 # Now we need to read the labels for the points
@@ -69,7 +70,7 @@ def read_data(self, as_dataarray=False):
6970 vals = (xlabels , labels ), k , b
7071
7172 else :
72- k = np . empty ([nk , 3 ], np . float64 )
73+ k = _a . emptyd ([nk , 3 ])
7374 for ik in range (nk ):
7475 l = [float (x ) for x in self .readline ().split ()]
7576 k [ik , :] = l [0 :3 ]
@@ -79,26 +80,20 @@ def read_data(self, as_dataarray=False):
7980 # Now populate the eigenvalues
8081 while len (l ) < ns * no :
8182 l .extend ([float (x ) for x in self .readline ().split ()])
82- l = np . array ( l , np . float64 )
83+ l = _a . arrayd ( l )
8384 l .shape = (ns , no )
8485 b [ik , :, :] = l [:, :] - Ef
8586 vals = k , b
8687
8788 if as_dataarray :
8889 from xarray import DataArray
8990
90- ticks = {"tick_vals " : xlabels , "tick_labels " : labels } if band_lines else {}
91+ ticks = {"ticks " : xlabels , "ticklabels " : labels } if band_lines else {}
9192
92- return DataArray (
93- name = "Energy" ,
94- data = b ,
95- coords = [
96- ("K" , k ),
97- ("spin" , np .arange (0 ,b .shape [1 ])),
98- ("iBand" , np .arange (0 ,b .shape [2 ]) + 1 )
99- ],
100- attrs = {** ticks }
101- )
93+ return DataArray (b , name = "Energy" , attrs = ticks ,
94+ coords = [("k" , k ),
95+ ("spin" , _a .arangei (0 , b .shape [1 ])),
96+ ("band" , _a .arangei (0 , b .shape [2 ]))])
10297
10398 return vals
10499
0 commit comments