0.0.119
This commit is contained in:
parent
7472379475
commit
5e71b543aa
BIN
PyPI/dist/guan-0.0.118-py3-none-any.whl
vendored
BIN
PyPI/dist/guan-0.0.118-py3-none-any.whl
vendored
Binary file not shown.
BIN
PyPI/dist/guan-0.0.118.tar.gz
vendored
BIN
PyPI/dist/guan-0.0.118.tar.gz
vendored
Binary file not shown.
@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
# replace with your username:
|
# replace with your username:
|
||||||
name = guan
|
name = guan
|
||||||
version = 0.0.118
|
version = 0.0.119
|
||||||
author = guanjihuan
|
author = guanjihuan
|
||||||
author_email = guanjihuan@163.com
|
author_email = guanjihuan@163.com
|
||||||
description = An open source python package
|
description = An open source python package
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Metadata-Version: 2.1
|
Metadata-Version: 2.1
|
||||||
Name: guan
|
Name: guan
|
||||||
Version: 0.0.118
|
Version: 0.0.119
|
||||||
Summary: An open source python package
|
Summary: An open source python package
|
||||||
Home-page: https://py.guanjihuan.com
|
Home-page: https://py.guanjihuan.com
|
||||||
Author: guanjihuan
|
Author: guanjihuan
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# With this package, you can calculate band structures, density of states, quantum transport and topological invariant of tight-binding models by invoking the functions you need. Other frequently used functions are also integrated in this package, such as file reading/writing, figure plotting, data processing.
|
# With this package, you can calculate band structures, density of states, quantum transport and topological invariant of tight-binding models by invoking the functions you need. Other frequently used functions are also integrated in this package, such as file reading/writing, figure plotting, data processing.
|
||||||
|
|
||||||
# The current version is guan-0.0.118, updated on August 10, 2022.
|
# The current version is guan-0.0.119, updated on August 10, 2022.
|
||||||
|
|
||||||
# Installation: pip install --upgrade guan
|
# Installation: pip install --upgrade guan
|
||||||
|
|
||||||
@ -1681,6 +1681,27 @@ def read_one_dimensional_data(filename='a', format='txt'):
|
|||||||
y_array = np.append(y_array, [y_row], axis=0)
|
y_array = np.append(y_array, [y_row], axis=0)
|
||||||
return x_array, y_array
|
return x_array, y_array
|
||||||
|
|
||||||
|
def read_one_dimensional_complex_data(filename='a', format='txt'):
|
||||||
|
f = open(filename+'.'+format, 'r')
|
||||||
|
text = f.read()
|
||||||
|
f.close()
|
||||||
|
row_list = np.array(text.split('\n'))
|
||||||
|
dim_column = np.array(row_list[0].split()).shape[0]
|
||||||
|
x_array = np.array([])
|
||||||
|
y_array = np.array([])
|
||||||
|
for row in row_list:
|
||||||
|
column = np.array(row.split())
|
||||||
|
if column.shape[0] != 0:
|
||||||
|
x_array = np.append(x_array, [complex(column[0])], axis=0)
|
||||||
|
y_row = np.zeros(dim_column-1, dtype=complex)
|
||||||
|
for dim0 in range(dim_column-1):
|
||||||
|
y_row[dim0] = complex(column[dim0+1])
|
||||||
|
if np.array(y_array).shape[0] == 0:
|
||||||
|
y_array = [y_row]
|
||||||
|
else:
|
||||||
|
y_array = np.append(y_array, [y_row], axis=0)
|
||||||
|
return x_array, y_array
|
||||||
|
|
||||||
def read_two_dimensional_data(filename='a', format='txt'):
|
def read_two_dimensional_data(filename='a', format='txt'):
|
||||||
f = open(filename+'.'+format, 'r')
|
f = open(filename+'.'+format, 'r')
|
||||||
text = f.read()
|
text = f.read()
|
||||||
@ -1708,39 +1729,72 @@ def read_two_dimensional_data(filename='a', format='txt'):
|
|||||||
matrix = np.append(matrix, [matrix_row], axis=0)
|
matrix = np.append(matrix, [matrix_row], axis=0)
|
||||||
return x_array, y_array, matrix
|
return x_array, y_array, matrix
|
||||||
|
|
||||||
|
def read_two_dimensional_complex_data(filename='a', format='txt'):
|
||||||
|
f = open(filename+'.'+format, 'r')
|
||||||
|
text = f.read()
|
||||||
|
f.close()
|
||||||
|
row_list = np.array(text.split('\n'))
|
||||||
|
dim_column = np.array(row_list[0].split()).shape[0]
|
||||||
|
x_array = np.array([])
|
||||||
|
y_array = np.array([])
|
||||||
|
matrix = np.array([])
|
||||||
|
for i0 in range(row_list.shape[0]):
|
||||||
|
column = np.array(row_list[i0].split())
|
||||||
|
if i0 == 0:
|
||||||
|
x_str = column[1::]
|
||||||
|
x_array = np.zeros(x_str.shape[0], dtype=complex)
|
||||||
|
for i00 in range(x_str.shape[0]):
|
||||||
|
x_array[i00] = complex(x_str[i00])
|
||||||
|
elif column.shape[0] != 0:
|
||||||
|
y_array = np.append(y_array, [complex(column[0])], axis=0)
|
||||||
|
matrix_row = np.zeros(dim_column-1, dtype=complex)
|
||||||
|
for dim0 in range(dim_column-1):
|
||||||
|
matrix_row[dim0] = complex(column[dim0+1])
|
||||||
|
if np.array(matrix).shape[0] == 0:
|
||||||
|
matrix = [matrix_row]
|
||||||
|
else:
|
||||||
|
matrix = np.append(matrix, [matrix_row], axis=0)
|
||||||
|
return x_array, y_array, matrix
|
||||||
|
|
||||||
def write_one_dimensional_data(x_array, y_array, filename='a', format='txt'):
|
def write_one_dimensional_data(x_array, y_array, filename='a', format='txt'):
|
||||||
|
with open(filename+'.'+format, 'w') as file:
|
||||||
|
guan.write_one_dimensional_data_without_opening_file(x_array, y_array, file)
|
||||||
|
|
||||||
|
def write_one_dimensional_data_without_opening_file(x_array, y_array, file):
|
||||||
x_array = np.array(x_array)
|
x_array = np.array(x_array)
|
||||||
y_array = np.array(y_array)
|
y_array = np.array(y_array)
|
||||||
with open(filename+'.'+format, 'w') as f:
|
i0 = 0
|
||||||
i0 = 0
|
for x0 in x_array:
|
||||||
for x0 in x_array:
|
file.write(str(x0)+' ')
|
||||||
f.write(str(x0)+' ')
|
if len(y_array.shape) == 1:
|
||||||
if len(y_array.shape) == 1:
|
file.write(str(y_array[i0])+'\n')
|
||||||
f.write(str(y_array[i0])+'\n')
|
elif len(y_array.shape) == 2:
|
||||||
elif len(y_array.shape) == 2:
|
for j0 in range(y_array.shape[1]):
|
||||||
for j0 in range(y_array.shape[1]):
|
file.write(str(y_array[i0, j0])+' ')
|
||||||
f.write(str(y_array[i0, j0])+' ')
|
file.write('\n')
|
||||||
f.write('\n')
|
i0 += 1
|
||||||
i0 += 1
|
|
||||||
|
|
||||||
def write_two_dimensional_data(x_array, y_array, matrix, filename='a', format='txt'):
|
def write_two_dimensional_data(x_array, y_array, matrix, filename='a', format='txt'):
|
||||||
|
with open(filename+'.'+format, 'w') as file:
|
||||||
|
guan.write_two_dimensional_data_without_opening_file(x_array, y_array, matrix, file)
|
||||||
|
|
||||||
|
def write_two_dimensional_data_without_opening_file(x_array, y_array, matrix, file):
|
||||||
x_array = np.array(x_array)
|
x_array = np.array(x_array)
|
||||||
y_array = np.array(y_array)
|
y_array = np.array(y_array)
|
||||||
matrix = np.array(matrix)
|
matrix = np.array(matrix)
|
||||||
with open(filename+'.'+format, 'w') as f:
|
file.write('0 ')
|
||||||
f.write('0 ')
|
for x0 in x_array:
|
||||||
|
file.write(str(x0)+' ')
|
||||||
|
file.write('\n')
|
||||||
|
i0 = 0
|
||||||
|
for y0 in y_array:
|
||||||
|
file.write(str(y0))
|
||||||
|
j0 = 0
|
||||||
for x0 in x_array:
|
for x0 in x_array:
|
||||||
f.write(str(x0)+' ')
|
file.write(' '+str(matrix[i0, j0])+' ')
|
||||||
f.write('\n')
|
j0 += 1
|
||||||
i0 = 0
|
file.write('\n')
|
||||||
for y0 in y_array:
|
i0 += 1
|
||||||
f.write(str(y0))
|
|
||||||
j0 = 0
|
|
||||||
for x0 in x_array:
|
|
||||||
f.write(' '+str(matrix[i0, j0])+' ')
|
|
||||||
j0 += 1
|
|
||||||
f.write('\n')
|
|
||||||
i0 += 1
|
|
||||||
|
|
||||||
def print_array(array, show_index=0, index_type=0):
|
def print_array(array, show_index=0, index_type=0):
|
||||||
if show_index==0:
|
if show_index==0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user