20
20
from conftest import config , test_path
21
21
22
22
23
- def test_lpf_file_reader_mono_v1 ():
23
+ def test_lpf_file_reader_mono_v1_DirectSimu ():
24
24
# Lpf file reader creation
25
25
stub = speos .get_stub_insecure_channel (
26
26
port = config .get ("SpeosServerPort" ), stub_type = lpf_file_reader__v1__pb2_grpc .LpfFileReader_MonoStub
27
27
)
28
28
29
29
# Init with file path
30
- path = os .path .join (test_path , "basic_1 .lpf" )
30
+ path = os .path .join (test_path , "basic_DirectSimu .lpf" )
31
31
stub .InitLpfFileName (lpf_file_reader__v1__pb2 .InitLpfFileNameRequest_Mono (lpf_file_path = path ))
32
32
33
- # Check Nb XMPs
34
- assert stub .GetNbOfXMPs (Empty ()).nb_of_xmps == 3
35
-
36
- # Check Nb Traces
37
- nb_of_traces = stub .GetNbOfTraces (Empty ()).nb_of_traces
38
- assert nb_of_traces == 10
33
+ # GetInformation
34
+ res_information = stub .GetInformation (lpf_file_reader__v1__pb2 .GetInformationRequest_Mono ())
35
+ nb_of_traces = res_information .nb_of_traces
36
+ assert nb_of_traces == 24817
37
+ assert res_information .nb_of_xmps == 3
38
+ assert res_information .has_sensor_contributions == False # No contributions stored in Direct simu
39
+ assert len (res_information .sensor_names ) == 3
40
+ assert res_information .sensor_names [0 ] == "Irradiance Sensor (0)"
41
+ assert res_information .sensor_names [2 ] == "Irradiance Sensor (2)"
39
42
40
43
# Read
41
44
raypaths = []
42
45
for rp in stub .Read (lpf_file_reader__v1__pb2 .ReadRequest_Mono ()):
43
46
raypaths .append (rp )
44
47
assert len (raypaths ) == nb_of_traces
45
48
46
- # Check result (first and last entry)
47
- expectedNbOfImpactOnFaces0 = 4
48
- assert len (raypaths [0 ].impacts ) == expectedNbOfImpactOnFaces0
49
- assert raypaths [0 ].impacts [1 ] == lpf_file_reader__v1__pb2 .TripletFloat (
50
- x = 4.4084320068359375 , y = 14.999999046325684 , z = 2.4493408203125
51
- )
52
- assert len (raypaths [0 ].wavelengths ) == expectedNbOfImpactOnFaces0
53
- assert raypaths [0 ].wavelengths [1 ] == 678.1803588867188
54
- assert len (raypaths [0 ].body_context_ids ) == expectedNbOfImpactOnFaces0
49
+ # Check result (first entry)
50
+ expected_nb_of_impact = 5
51
+ assert len (raypaths [0 ].impacts ) == expected_nb_of_impact
52
+ assert raypaths [0 ].impacts [1 ] == lpf_file_reader__v1__pb2 .TripletFloat (x = 3.19368935 , y = 14.999999 , z = - 3.94779062 )
53
+ assert len (raypaths [0 ].wavelengths ) == expected_nb_of_impact
54
+ assert raypaths [0 ].wavelengths [1 ] == 691.44708251953125
55
+ assert len (raypaths [0 ].body_context_ids ) == expected_nb_of_impact
55
56
assert raypaths [0 ].body_context_ids [1 ] == 2001802324
56
- assert len (raypaths [0 ].unique_face_ids ) == expectedNbOfImpactOnFaces0
57
+ assert len (raypaths [0 ].unique_face_ids ) == expected_nb_of_impact
57
58
assert raypaths [0 ].unique_face_ids [1 ] == 1815582994
58
59
assert raypaths [0 ].lastDirection == lpf_file_reader__v1__pb2 .TripletFloat (
59
- x = 0.2041478008031845 , y = - 0.9723469614982605 , z = 0.11342425644397736
60
+ x = 0.0606396869 , y = 0.995341122 , z = - 0.0749590397
60
61
)
61
- assert len (raypaths [0 ].interaction_statuses ) == expectedNbOfImpactOnFaces0
62
+ assert len (raypaths [0 ].interaction_statuses ) == expected_nb_of_impact
62
63
assert raypaths [0 ].interaction_statuses [0 ] == lpf_file_reader__v1__pb2 .RayPath .PhotonStatus .StatusJustEmitted
63
64
assert (
64
65
raypaths [0 ].interaction_statuses [1 ] == lpf_file_reader__v1__pb2 .RayPath .PhotonStatus .StatusSpecularTransmitted
65
66
)
66
- assert raypaths [0 ].interaction_statuses [ 3 ] == lpf_file_reader__v1__pb2 . RayPath . PhotonStatus . StatusSpecularReflected
67
+ assert len ( raypaths [0 ].sensor_contributions ) == 0
67
68
68
- expectedNbOfImpactOnFaces9 = 6
69
- assert len (raypaths [9 ].impacts ) == expectedNbOfImpactOnFaces9
70
- assert raypaths [9 ].impacts [1 ] == lpf_file_reader__v1__pb2 .TripletFloat (
71
- x = - 1.8186546564102173 , y = 15.0 , z = - 6.767658233642578
72
- )
73
- assert len (raypaths [9 ].wavelengths ) == expectedNbOfImpactOnFaces9
74
- assert raypaths [9 ].wavelengths [1 ] == 743.3338623046875
75
- assert len (raypaths [9 ].body_context_ids ) == expectedNbOfImpactOnFaces9
76
- assert raypaths [9 ].body_context_ids [1 ] == 2001802324
77
- assert len (raypaths [9 ].unique_face_ids ) == expectedNbOfImpactOnFaces9
78
- assert raypaths [9 ].unique_face_ids [1 ] == 1815582994
79
- assert raypaths [9 ].lastDirection == lpf_file_reader__v1__pb2 .TripletFloat (
80
- x = 0.14110437035560608 , y = 0.8392737507820129 , z = 0.5250800848007202
69
+ # Close
70
+ stub .CloseLpfFileName (Empty ())
71
+
72
+
73
+ def test_lpf_file_reader_mono_v1_InverseSimu ():
74
+ # Lpf file reader creation
75
+ stub = speos .get_stub_insecure_channel (
76
+ port = config .get ("SpeosServerPort" ), stub_type = lpf_file_reader__v1__pb2_grpc .LpfFileReader_MonoStub
81
77
)
82
- assert len (raypaths [9 ].interaction_statuses ) == expectedNbOfImpactOnFaces9
83
- assert raypaths [9 ].interaction_statuses [0 ] == lpf_file_reader__v1__pb2 .RayPath .PhotonStatus .StatusJustEmitted
84
- assert raypaths [9 ].interaction_statuses [4 ] == lpf_file_reader__v1__pb2 .RayPath .PhotonStatus .StatusSpecularReflected
85
- assert (
86
- raypaths [9 ].interaction_statuses [5 ] == lpf_file_reader__v1__pb2 .RayPath .PhotonStatus .StatusSpecularTransmitted
78
+
79
+ # Init with file path
80
+ path = os .path .join (test_path , "basic_InverseSimu.lpf" )
81
+ stub .InitLpfFileName (lpf_file_reader__v1__pb2 .InitLpfFileNameRequest_Mono (lpf_file_path = path ))
82
+
83
+ # GetInformation
84
+ res_information = stub .GetInformation (lpf_file_reader__v1__pb2 .GetInformationRequest_Mono ())
85
+ nb_of_traces = res_information .nb_of_traces
86
+ assert nb_of_traces == 21044
87
+ assert res_information .nb_of_xmps == 1
88
+ assert res_information .has_sensor_contributions == True # contributions stored in Inverse simu
89
+ assert len (res_information .sensor_names ) == 1
90
+ assert res_information .sensor_names [0 ] == "Camera_Perfect_Lens_System_V2:3"
91
+
92
+ # Read
93
+ raypaths = []
94
+ for rp in stub .Read (lpf_file_reader__v1__pb2 .ReadRequest_Mono ()):
95
+ raypaths .append (rp )
96
+ assert len (raypaths ) == nb_of_traces
97
+
98
+ # Check sensor_contributions in first raypath
99
+ assert len (raypaths [0 ].sensor_contributions ) == 1
100
+ assert raypaths [0 ].sensor_contributions [0 ].sensor_id == 0
101
+ assert raypaths [0 ].sensor_contributions [0 ].coordinates == lpf_file_reader__v1__pb2 .DoubletDouble (
102
+ x = - 0.20848463202592682 , y = 0.1897648665199252
87
103
)
88
104
89
105
# Close
@@ -100,50 +116,35 @@ def test_lpf_file_reader_multi_v1():
100
116
guid = stub .Create (Empty ())
101
117
102
118
# Init with file path
103
- path = os .path .join (test_path , "basic_1 .lpf" )
119
+ path = os .path .join (test_path , "basic_DirectSimu .lpf" )
104
120
stub .InitLpfFileName (lpf_file_reader__v1__pb2 .InitLpfFileNameRequest_Multi (id = guid , lpf_file_path = path ))
105
121
106
- # Check Nb Traces
107
- nb_of_traces = stub .GetNbOfTraces (guid ).nb_of_traces
108
- assert nb_of_traces == 10
122
+ # GetInformation
123
+ res_information = stub .GetInformation (lpf_file_reader__v1__pb2 .GetInformationRequest_Multi (id = guid ))
124
+ nb_of_traces = res_information .nb_of_traces
125
+ assert nb_of_traces == 24817
126
+ assert res_information .nb_of_xmps == 3
109
127
110
128
# Create a second reader
111
129
guid2 = stub .Create (Empty ())
112
-
113
- # Get Nb XMPs for first reader
114
- assert stub .GetNbOfXMPs (guid ).nb_of_xmps == 3
115
-
116
130
# Init second reader
117
- path2 = os .path .join (test_path , "basic_2 .lpf" )
131
+ path2 = os .path .join (test_path , "basic_InverseSimu .lpf" )
118
132
stub .InitLpfFileName (lpf_file_reader__v1__pb2 .InitLpfFileNameRequest_Multi (id = guid2 , lpf_file_path = path2 ))
119
133
120
- # Check Nb Traces and read second
121
- nb_of_traces2 = stub .GetNbOfTraces (guid2 ).nb_of_traces
122
- assert nb_of_traces2 == 5
134
+ # GetInformation and read second
135
+ res_information = stub .GetInformation (lpf_file_reader__v1__pb2 .GetInformationRequest_Multi (id = guid2 ))
136
+ nb_of_traces2 = res_information .nb_of_traces
137
+ assert nb_of_traces2 == 21044
123
138
raypaths2 = []
124
139
for rp in stub .Read (lpf_file_reader__v1__pb2 .ReadRequest_Multi (id = guid2 )):
125
140
raypaths2 .append (rp )
126
141
assert len (raypaths2 ) == nb_of_traces2
127
142
128
- # Check result (fourth entry)
129
- expectedNbOfImpactOnFaces3 = 5
130
- assert len (raypaths2 [3 ].impacts ) == expectedNbOfImpactOnFaces3
131
- assert raypaths2 [3 ].impacts [1 ] == lpf_file_reader__v1__pb2 .TripletFloat (
132
- x = 5.026374340057373 , y = 15.000000953674316 , z = 0.7341787815093994
133
- )
134
- assert len (raypaths2 [3 ].wavelengths ) == expectedNbOfImpactOnFaces3
135
- assert raypaths2 [3 ].wavelengths [1 ] == 652.2732543945312
136
- assert len (raypaths2 [3 ].body_context_ids ) == expectedNbOfImpactOnFaces3
137
- assert raypaths2 [3 ].body_context_ids [1 ] == 2001802324
138
- assert len (raypaths2 [3 ].unique_face_ids ) == expectedNbOfImpactOnFaces3
139
- assert raypaths2 [3 ].unique_face_ids [1 ] == 1815582994
140
- assert raypaths2 [3 ].lastDirection == lpf_file_reader__v1__pb2 .TripletFloat (
141
- x = 0.09542781859636307 , y = 0.9953387975692749 , z = 0.013935667462646961
142
- )
143
- assert len (raypaths2 [3 ].interaction_statuses ) == expectedNbOfImpactOnFaces3
144
- assert raypaths2 [3 ].interaction_statuses [0 ] == lpf_file_reader__v1__pb2 .RayPath .PhotonStatus .StatusJustEmitted
145
- assert (
146
- raypaths2 [3 ].interaction_statuses [1 ] == lpf_file_reader__v1__pb2 .RayPath .PhotonStatus .StatusSpecularTransmitted
143
+ # Check sensor_contributions in first raypath
144
+ assert len (raypaths2 [0 ].sensor_contributions ) == 1
145
+ assert raypaths2 [0 ].sensor_contributions [0 ].sensor_id == 0
146
+ assert raypaths2 [0 ].sensor_contributions [0 ].coordinates == lpf_file_reader__v1__pb2 .DoubletDouble (
147
+ x = - 0.20848463202592682 , y = 0.1897648665199252
147
148
)
148
149
149
150
# Delete the second reader
@@ -155,30 +156,15 @@ def test_lpf_file_reader_multi_v1():
155
156
raypaths .append (rp )
156
157
assert len (raypaths ) == nb_of_traces
157
158
158
- # Check result (first entry)
159
- expectedNbOfImpactOnFaces0 = 4
160
- assert len (raypaths [0 ].impacts ) == expectedNbOfImpactOnFaces0
161
- assert raypaths [0 ].impacts [1 ] == lpf_file_reader__v1__pb2 .TripletFloat (
162
- x = 4.4084320068359375 , y = 14.999999046325684 , z = 2.4493408203125
163
- )
164
- assert len (raypaths [0 ].wavelengths ) == expectedNbOfImpactOnFaces0
165
- assert raypaths [0 ].wavelengths [1 ] == 678.1803588867188
166
- assert len (raypaths [0 ].body_context_ids ) == expectedNbOfImpactOnFaces0
167
- assert raypaths [0 ].body_context_ids [1 ] == 2001802324
168
- assert len (raypaths [0 ].unique_face_ids ) == expectedNbOfImpactOnFaces0
169
- assert raypaths [0 ].unique_face_ids [1 ] == 1815582994
170
- assert raypaths [0 ].lastDirection == lpf_file_reader__v1__pb2 .TripletFloat (
171
- x = 0.2041478008031845 , y = - 0.9723469614982605 , z = 0.11342425644397736
172
- )
173
- assert len (raypaths [0 ].interaction_statuses ) == expectedNbOfImpactOnFaces0
174
- assert raypaths [0 ].interaction_statuses [0 ] == lpf_file_reader__v1__pb2 .RayPath .PhotonStatus .StatusJustEmitted
159
+ # Check some result (first entry)
160
+ expected_nb_of_impact = 5
161
+ assert len (raypaths [0 ].impacts ) == expected_nb_of_impact
162
+ assert raypaths [0 ].impacts [1 ] == lpf_file_reader__v1__pb2 .TripletFloat (x = 3.19368935 , y = 14.999999 , z = - 3.94779062 )
163
+ assert len (raypaths [0 ].interaction_statuses ) == expected_nb_of_impact
175
164
assert (
176
165
raypaths [0 ].interaction_statuses [1 ] == lpf_file_reader__v1__pb2 .RayPath .PhotonStatus .StatusSpecularTransmitted
177
166
)
178
- assert (
179
- raypaths [0 ].interaction_statuses [2 ] == lpf_file_reader__v1__pb2 .RayPath .PhotonStatus .StatusSpecularTransmitted
180
- )
181
- assert raypaths [0 ].interaction_statuses [3 ] == lpf_file_reader__v1__pb2 .RayPath .PhotonStatus .StatusSpecularReflected
167
+ assert len (raypaths [0 ].sensor_contributions ) == 0
182
168
183
169
# Close and Delete the first
184
170
stub .CloseLpfFileName (guid )
0 commit comments