-
Notifications
You must be signed in to change notification settings - Fork 0
/
Files.py
55 lines (44 loc) · 1.3 KB
/
Files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 26 21:36:07 2023
@author: marek
"""
import matrixFileHandling as mfh
import Topography
import Spectroscopy
import numpy as np
def NewFile(file):
mtrx = mfh.Matrix(file)
datatype = mtrx.datatype
result_ref = None
if datatype == 'Z' or datatype == 'I':
result = Topography.Topography(filetype='mtrx', data=mtrx)
if datatype == 'I(V)-curve':
result = Spectroscopy.Spectroscopy(data=mtrx)
if datatype == 'I(V)-map':
result = Spectroscopy.SpectroscopyMap(data=mtrx)
if mtrx.mtrxRef:
result_ref = Topography.Topography(filetype='mtrx', data=mtrx.mtrxRef)
return result, datatype, result_ref
def NewFileXYZ(filename, shape, unit):
X = []
Y = []
Z = []
with open(filename, "r") as file:
for line in file:
x, y, z = line.split()
X.append(float(x))
Y.append(float(y))
Z.append(float(z))
if shape == [0, 0]:
size = int(len(X) ** 0.5)
shape = [size, size]
X = np.array(X)
X = np.reshape(X, shape)
Y = np.array(Y)
Y = np.reshape(Y, shape)
Z = np.array(Z)
Z = np.reshape(Z, shape)
data = [X, Y, Z, filename]
result = Topography.Topography(filetype='xyz', data=data, unit=unit)
return result