I have the follwing issue: I read a line using realines, the line is the following:
Reference Coordinates: Xref = 0.00000E+000, Yref = -1.20982E-002
i want this line to be converted into a numpy array, so that:
array=[nan nan nan nan 0.0 nan nan -1.20982E-002]
than i want to be able to access this array:
number1=array[0][4]
print(number1)
0.00000E+000
number2=array[0][6]
print(number2)
-1.20982E-002
Problem is when im using e.g. np.fromstring (i tried i think all similar numpy routines) I cannot access the array like this. Either I get:
Enter file name: ERIS-NIX_106_-FOLDED-Grid_Distortion-cam2-wl3.txt
["['Reference" 'Coordinates:' 'Xref' '=' '0.00000E+000,' 'Yref' '='
"3.00947E-003\\r\\n']"]
[
Traceback (most recent call last):
File "/home/sebo/Documents/Linear Transform For Eris C1/ERIS-NIX_106_-FOLDED-Grid_Distortion(1)/Open_shift.py", line 51, in <module>
main()
File "/home/sebo/Documents/Linear Transform For Eris C1/ERIS-NIX_106_-FOLDED-Grid_Distortion(1)/Open_shift.py", line 9, in main
reader_affine(file_name,d)
File "/home/sebo/Documents/Linear Transform For Eris C1/ERIS- NIX_106_-FOLDED-Grid_Distortion(1)/Open_shift.py", line 35, in reader_affine
print(line[0][i][i])
IndexError: string index out of range
OR:
Enter file name: ERIS-NIX_106_-FOLDED-Grid_Distortion-cam2-wl3.txt
Traceback (most recent call last):
File "/home/sebo/Documents/Linear Transform For Eris C1/ERIS- NIX_106_-FOLDED-Grid_Distortion(1)/Open_shift.py", line 50, in <module>
main()
File "/home/sebo/Documents/Linear Transform For Eris C1/ERIS- NIX_106_-FOLDED-Grid_Distortion(1)/Open_shift.py", line 9, in main
reader_affine(file_name,d)
File "/home/sebo/Documents/Linear Transform For Eris C1/ERIS-NIX_106_-FOLDED-Grid_Distortion(1)/Open_shift.py", line 29, in reader_affine
line=np.fromstring(critical_line,dtype=float)
ValueError: string size must be a multiple of element size
OR I can seperatily access my array but than I get something like this:
Enter file name: ERIS-NIX_106_-FOLDED-Grid_Distortion-cam2-wl3.txt
[
C
X
=
0
Y
=
3
For a loop that goes like this:
while i in range(0,line.size):
print(line[0][i])
i=i+1