-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroll_survey.py
2561 lines (2058 loc) · 154 KB
/
roll_survey.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
This module provides the main classes used in Roll
"""
import math
import os
import sys
from collections import defaultdict
from enum import Enum
from time import perf_counter
import numpy as np
import pyqtgraph as pg
from qgis.core import QgsCoordinateReferenceSystem
from qgis.PyQt.QtCore import QMarginsF, QRectF, QThread, pyqtSignal
from qgis.PyQt.QtGui import QBrush, QColor, QPainter, QTransform, QVector3D
from qgis.PyQt.QtWidgets import QMessageBox
from qgis.PyQt.QtXml import QDomDocument, QDomElement
from . import config # used to pass initial settings
from .functions import containsPoint3D
from .functions_numba import clipLineF, numbaFixRelationRecord, numbaSetPointRecord, numbaSetRelationRecord, numbaSliceStats, pointsInRect
from .roll_angles import RollAngles
from .roll_bingrid import RollBinGrid
from .roll_binning import BinningType, RollBinning
from .roll_block import RollBlock
from .roll_offset import RollOffset
from .roll_output import RollOutput
from .roll_pattern import RollPattern
from .roll_pattern_seed import RollPatternSeed
from .roll_plane import RollPlane
from .roll_seed import RollSeed
from .roll_sphere import RollSphere
from .roll_template import RollTemplate
from .roll_translate import RollTranslate
from .roll_unique import RollUnique
from .sps_io_and_qc import pntType1, relType2
# See: https://realpython.com/python-multiple-constructors/#instantiating-classes-in-python for multiple constructors
# See: https://stackoverflow.com/questions/39513191/python-operator-overloading-with-multiple-operands for operator overlaoding
# See: https://realpython.com/operator-function-overloading/#overloading-built-in-operators
# See: https://stackoverflow.com/questions/56762491/python-equivalent-to-c-line for showing line numbers
# See: https://www.programcreek.com/python/example/86794/PyQt5.QtCore.QPointF for a 2D point example, QPointF
# See: https://www.programcreek.com/python/example/83788/PyQt5.QtCore.QRectF for QRectF examples
# See: https://doc.qt.io/qtforpython-5/PySide2/QtCore/QPointF.html
# See: https://doc.qt.io/qtforpython-5/PySide2/QtCore/QRectF.html
# See: https://geekflare.com/multiply-matrices-in-python/ for matrix multiplication methods
# See: https://doc.qt.io/qt-6/examples-threadandconcurrent.html for using a worker thread
# in the end we need to plot these classes on a QtScene object managed through PyQtGraph.
# the base class in Qt for graphical objects is **QGraphicsItem** from which other classes can be derived.
# See for example: https://doc.qt.io/qtforpython-5/overviews/qtwidgets-graphicsview-dragdroprobot-example.html#drag-and-drop-robot-example
# In PyQtGraph we have an abstract class **GraphicsItem(object)**.
# See: D:\Source\Python\pyqtgraph\pyqtgraph\graphicsItems\GraphicsItem.py
# Derived from it we have a class that also inherits from Qt's QGraphicsObject:
# class **GraphicsObject(GraphicsItem, QtWidgets.QGraphicsObject)**
# GraphicsObject provides a base class for all graphics items that require signals, slots and properties
# The class extends a QGraphicsItem with QObject's signal/slot and property mechanisms.
# So in PyQtGraph, **GraphicsObject()** is the starting point for all other inherited graphical objects
# some example sub-classes are :
# class BarGraphItem(GraphicsObject)
# class ButtonItem(GraphicsObject)
# class CurvePoint(GraphicsObject)
# class ErrorBarItem(GraphicsObject)
# class GraphItem(GraphicsObject)
# class ImageItem(GraphicsObject)
# class InfiniteLine(GraphicsObject)
# class IsocurveItem(GraphicsObject)
# class ItemGroup(GraphicsObject)
# class LinearRegionItem(GraphicsObject)
# class NonUniformImage(GraphicsObject)
# class PColorMeshItem(GraphicsObject)
# class PlotCurveItem(GraphicsObject)
# class PlotDataItem(GraphicsObject)
# class ROI(GraphicsObject)
# class ScatterPlotItem(GraphicsObject)
# class TextItem(GraphicsObject)
# class UIGraphicsItem(GraphicsObject)
# class CandlestickItem(GraphicsObject) -> in the examples folder
# So where Roll end up painting something, the relevant class(es) need to be derived from PyQtGraph.GraphicsObject as well !!!
# As all classes here are a leaf in the tree derived from RollSurvey, it is this class that needs to be derived from GraphicsObject.
# That implies that the following two functions need to be implemented in RollSurvey:
# >>def paint(self, p, *args)<<
# the paint operation should paint all survey aspects (patterns, points, lines, blocks) dependent on the actual LOD
# >>def boundingRect(self)<<
# boundingRect _must_ indicate the entire area that will be drawn on or else we will get artifacts and possibly crashing.
# to use different symbol size / color iun a graph; use scatterplot :
# See: https://www.geeksforgeeks.org/pyqtgraph-different-colored-spots-on-scatter-plot-graph/
# See: https://www.geeksforgeeks.org/pyqtgraph-getting-rotation-of-spots-in-scatter-plot-graph/
# To give an xml-object a name, create a seperate <name> element as first xml entry (preferred over name attribute)
# the advantage of using element.text is that characters like ' and " don't cause issues in terminating a ""-string
# if len(self.name) > 0:
# name_elem = ET.SubElement(seed_elem, 'name')
# name_elem.text = self.name
class SurveyType(Enum):
Orthogonal = 0
Parallel = 1
Slanted = 2
Brick = 3
Zigzag = 4
Streamer = 5
# Note: we need to keep SurveyType and SurveyList in sync; maybe combine in a dictionary ?!
SurveyList = [
'Orthogonal - standard manner of acquiring land data',
'Parallel - standard manner of acquiring OBN data',
'Slanted - legacy variation on orthogonal, aiming to reduce LMOS',
'Brick - legacy variation on orthogonal, aiming to reduce LMOS',
'zigzag - legacy manner acquiring narrrow azimuth vibroseis data',
'streamer - towed streamer marine survey',
]
class PaintMode(Enum):
justBlocks = 1 # just src, rec & cmp block outlines
justTemplates = 2 # just template rect boundaries
justLines = 3 # just lines
justPoints = 4 # just points
allDetails = 5 # down to patterns
# See: https://docs.python.org/3/howto/enum.html
# See: https://realpython.com/python-enum/#creating-integer-flags-intflag-and-flag
# class Show(IntFlag):
# NONE = 0
# LOD0 = 1
# LOD1 = 2
# LOD2 = 4
# LOD3 = 8
# LOD = LOD0 | LOD1 | LOD2 | LOD3
# LIM0 = 16
# LIM1 = 32
# LIM2 = 64
# LIM3 = 128
# LIM = LIM0 | LIM1 | LIM2 | LIM3
# SUR = 256
# BLK = 512
# TPL = 1024
# LIN = 2048
# PNT = 4096
# PAT = 8192
# ROL = 16384
# ALL = SUR | BLK | TPL | LIN | PNT | PAT | ROL
# TOP = SUR | BLK
class RollSurvey(pg.GraphicsObject):
progress = pyqtSignal(int) # signal to keep track of worker thread progress
message = pyqtSignal(str) # signal to update statusbar progresss text
# See: https://github.com/pyqtgraph/pyqtgraph/blob/develop/examples/CustomGraphItem.py
# This example gives insight in the mouse drag event
# assign default name value
def __init__(self, name: str = 'Untitled') -> None:
pg.GraphicsObject.__init__(self)
self.mouseGrabbed = False # needed to speed up drawing, whilst dragging
self.nShotPoint = 0 # managed in worker thread
self.nShotPoints = -1 # set at -1 to initialize calculations
self.nTemplate = 0 # managed in worker thread
self.nTemplates = -1 # set at -1 to initialize calculations
self.nRecRecord = -1 # set at -1 to initialize calculations
self.nRelRecord = -1 # set at -1 to initialize calculations
self.nOldRecLine = -999999 # to set up the first rec-point in a rel-record
self.nNewRecLine = -1 # to control moving along with rel-records
self.recMin = 0 # to set up the highest rec number on a line
self.recMax = 0 # to set up the highest rec number on a line
self.threadProgress = 0 # progress percentage
self.errorText = None # text explaining which error occurred
self.binTransform = None # binning transform
self.cmpTransform = None # plotting transform local <--> global CRS
self.glbTransform = None # transform to display binning results
self.stkTransform = None # transform to *show* line & stake numbers from Orig(0.0, 0.0) = (1000, 1000)
self.st2Transform = None # transform to *calc* line & stake numbers from Orig(0.0, 0.0) = (1000, 1000)
# self.installEventFilter(self) # captures events through an event filter
# self.setAcceptDrops(True) # needed to capture these events (Nrs 186, 186). See: https://groups.google.com/g/pyqtgraph/c/OKY-Y_rSlL4
# # See: https://doc.qt.io/qt-6/qgraphicsitem.html
# self.setFlags(QGraphicsItem.ItemIsMovable)
# note: the consequence of using QGraphicsItem.ItemIsMovable
# is that the item becomes DETACHED from the X-axis and Y-axis !!! DO NOT USE !
# self.setFlags(QGraphicsItem.ItemIsSelectable)
# note: the consequence of using QGraphicsItem.ItemIsSelectable
# is that the moving the chart is significantly delayed !!! DO NOT USE !
# survey spatial extent
self.srcBoundingRect = QRectF() # source extent
self.recBoundingRect = QRectF() # receiver extent
self.cmpBoundingRect = QRectF() # cmp extent
self.boundingBox = QRectF() # src|rec extent
# survey configuration
self.crs = QgsCoordinateReferenceSystem() # create invalid crs object
self.type = SurveyType.Orthogonal # survey type as defined in class SurveyType()
self.name: str = name
# note: type() is a builtin Python function, so it is recommended NOT to use it as a variable name
# as in that case you'll overwrite a built-in function, which can have undesired side effects
# so using "self.type = xxx" is fine, but "type = xxx" is NOT fine
# survey painting mode
self.paintMode = PaintMode.allDetails # paints down to patterns
self.lodScale = 1.0 # force Level of Detail (LOD) to a higher value (for small Wizard plots)
# survey limits
self.binning = RollBinning()
self.offset = RollOffset()
self.output = RollOutput()
self.angles = RollAngles()
self.unique = RollUnique()
# survey grid
self.grid = RollBinGrid()
# reflector types
self.globalPlane = RollPlane()
self.localPlane = None
self.globalSphere = RollSphere()
self.localSphere = None
# survey block list
self.blockList: list[RollBlock] = []
# pattern list
self.patternList: list[RollPattern] = []
# timings for time critical functions, allowing for 15 steps
# this needs to be cleaned up; put in separate profiler class
self.timerTmin = [float('Inf') for _ in range(15)]
self.timerTmax = [0.0 for _ in range(15)]
self.timerTtot = [0.0 for _ in range(15)]
self.timerFreq = [0 for _ in range(15)]
def calcTransforms(self, createArrays=False):
"""(re)calculate the transforms being used, and optionally initialize fold & offset arrays"""
x = self.grid.orig.x()
y = self.grid.orig.y()
p = self.grid.angle
q = self.grid.scale.x()
r = self.grid.scale.y()
self.glbTransform = QTransform()
self.glbTransform.translate(x, y)
self.glbTransform.rotate(p)
self.glbTransform.scale(q, r)
config.glbTransform = self.glbTransform # for global access to this transform
# set up a QMatrix4x4 using the three transform steps (translate, rotate, scale)
# glbMatrix1 = QMatrix4x4()
# glbMatrix1.translate(QVector3D(x, y, 0))
# glbMatrix1.rotate(p, 0.0, 0.0, 1.0)
# glbMatrix1.scale(q, r)
# set up a QMatrix4x4 using a QTransform
# glbMatrix2 = QMatrix4x4(self.glbTransform)
# both matrices are the same, so using a QMatrix4x4 from QTransform is working fine
# next, a not working attempt to transform the plane itself directly from global to local coordinates:
# M0 = QMatrix4x4(self.glbTransform) # create 4D matrix from transform
# M1, _ = M0.inverted() # invert the matrix
# # M2 = M1.transposed() # transpose the matrix
# n = M1.mapVector(self.globalPlane.normal) # transform the normal
# l = n1.length() # find out that l != 1.0 (not always)
# transform the global reflection plane to local coordinates
# See: https://stackoverflow.com/questions/7685495/transforming-a-3d-plane-using-a-4x4-matrix
# See: https://math.stackexchange.com/questions/2502857/transform-plane-to-another-coordinate-system
# See: https://math.stackexchange.com/questions/3123130/transforming-a-plane
# See: https://www.cs.brandeis.edu/~cs155/Lecture_07_6.pdf
# See: https://cseweb.ucsd.edu/classes/wi18/cse167-a/lec3.pdf
# See: http://www.songho.ca/opengl/gl_normaltransform.html
# admittedly; the transform proved to be tricky when scaling (s != 1.0) is allowed.
# the great escape was to set up the plane using three points in the global space
# by building up the local plane from 3 transformed points, the correct normal was found
# the plane's anchor is simply one of the three points that were used for the transform
toLocalTransform, _ = self.glbTransform.inverted() # get inverse transform
o0 = self.globalPlane.anchor # get the plane's anchor
o1 = toLocalTransform.map(o0.toPointF()) # transform the 2D point
o2 = QVector3D(o1.x(), o1.y(), o0.z()) # 3D point in local coordinates
p0 = o0 + QVector3D(1000.0, 0.0, 0.0) # shift the anchor in x-direction
p1 = toLocalTransform.map(p0.toPointF()) # transform the shifted 2D point
p2 = QVector3D(p1.x(), p1.y(), self.globalPlane.depthAt(p0.toPointF())) # 3D point in local coordinates
q0 = o0 + QVector3D(0.0, 1000.0, 0.0) # shift the anchor in y-direction
q1 = toLocalTransform.map(q0.toPointF()) # transform the shifted 2D point
q2 = QVector3D(q1.x(), q1.y(), self.globalPlane.depthAt(q0.toPointF())) # 3D point in local coordinates
n = QVector3D.normal(o2, p2, q2) # Get the normalized normal vector of a plane defined by p2 - o2 and q2 - o2
self.localPlane = RollPlane.fromAnchorAndNormal(o2, n) # pylint: disable=E1101
# now define the localSphere, based on the globalSphere
assert q == r, 'x- and y-scales need to be identical, preferrably 1.0'
r0 = self.globalSphere.radius
r1 = r0 * q
o0 = self.globalSphere.origin
s1 = toLocalTransform.map(o0.toPointF()) # transform the 2D point to local coordinates
s2 = QVector3D(s1.x(), s1.y(), o0.z() * q) # 3D point in local coordinates, with z axis scaled as well
self.localSphere = RollSphere(s2, r1) # initiate the local sphere
w = self.output.rctOutput.width()
h = self.output.rctOutput.height()
x0 = self.output.rctOutput.left()
y0 = self.output.rctOutput.top()
dx = self.grid.binSize.x()
dy = self.grid.binSize.y()
ox = self.grid.binShift.x()
oy = self.grid.binShift.y()
s0 = self.grid.stakeOrig.x()
l0 = self.grid.stakeOrig.y()
ds = self.grid.stakeSize.x()
dl = self.grid.stakeSize.y()
nx = math.ceil(w / dx)
ny = math.ceil(h / dy)
sx = w / nx
sy = h / ny
if createArrays:
self.output.binOutput = np.zeros(shape=(nx, ny), dtype=np.uint32) # start with empty array of the right size and type
self.output.minOffset = np.zeros(shape=(nx, ny), dtype=np.float32) # start with empty array of the right size and type
self.output.maxOffset = np.zeros(shape=(nx, ny), dtype=np.float32) # start with empty array of the right size and type
# self.output.rmsOffset = np.zeros(shape=(nx, ny), dtype=np.float32) # start with empty array of the right size and type
self.output.minOffset.fill(np.Inf) # start min offset with +inf (use np.full instead)
self.output.maxOffset.fill(np.NINF) # start max offset with -inf (use np.full instead)
# self.output.rmsOffset.fill(np.NINF) # start max offset with -inf (use np.full instead)
self.binTransform = QTransform()
self.binTransform.translate(x0, y0)
self.binTransform.scale(dx, dy)
self.binTransform, _ = self.binTransform.inverted()
self.cmpTransform = QTransform()
self.cmpTransform.translate(x0, y0)
self.cmpTransform.scale(sx, sy)
self.stkTransform = QTransform()
self.stkTransform.translate(-ox, -oy) # first shift origin by small offset (usually 1/2 bin size)
self.stkTransform.scale(ds, dl) # then scale it according to the stake / line intervals
self.stkTransform.translate(-s0, -l0) # then shift origin to the (stake, line) origin
self.stkTransform, _ = self.stkTransform.inverted() # invert the transform before applying
self.st2Transform = QTransform() # no minor shift (for rounding purpose) applied in this case
self.st2Transform.scale(ds, dl) # scale it according to the stake / line intervals
self.st2Transform.translate(-s0, -l0) # then shift origin to (stake, line) origin
self.st2Transform, _ = self.st2Transform.inverted() # invert the transform before applying
def noShotPoints(self):
if self.nShotPoints == -1:
return self.calcNoShotPoints()
else:
return self.nShotPoints
def calcNoShotPoints(self) -> int:
self.nShotPoints = 0
for block in self.blockList:
nBlockShots = 0
for template in block.templateList:
nTemplateShots = 0
for seed in template.seedList:
nSeedShots = 0
if seed.bSource: # Source seed
nSeedShots = 1 # at least one SP
for growStep in seed.grid.growList: # iterate through all grow steps
nSeedShots *= growStep.steps # multiply seed's shots at each level
nTemplateShots += nSeedShots # add to template's SPs
for roll in template.rollList:
nTemplateShots *= roll.steps # template is rolled a number of times
nBlockShots += nTemplateShots
self.nShotPoints += nBlockShots
return self.nShotPoints
def calcNoTemplates(self) -> int:
self.nTemplates = 0
for block in self.blockList:
for template in block.templateList:
nTemplates = 1
for roll in template.rollList:
nTemplates *= roll.steps # template is rolled a number of times
self.nTemplates += nTemplates
return self.nTemplates
def setupGeometryFromTemplates(self) -> bool:
try:
# The array with the list of receiver locations is the most difficult to determine.
# It can be calculated using one of several approaches :
# a) define a large (line, stake) grid and populate this for each line stake number that we come across
# b) just append 'new' receivers to the numpy array and later remove duplicates, of which there will be many
# the difficulty of a) is that you need to be sure of grid increments and start/end points
# the easy part is that at the end the non-zero records can be gathered (filtered out)
# the difficulty of b) is that the recGeom array will overflow, unless you remove duplicates at timely intervals
# the easy part is that you don't have to setup a large grid with offset counters, which can be error prone
# overall, approach b) seems more 'failsafe' and easier to implement.
# c) lastly; use a nested dictionary to check rec positions before adding them to the numpy array
# if a receiver is found at recDict[line][point], there is no need to add it to the numpy array
# gc.collect() # get the garbage collector going
self.calcNoTemplates() # need to know nr templates, to track progress
self.nTemplate = 0 # zero based counter
self.output.recDict = defaultdict(dict) # nested dictionary to access rec positions
self.nRecRecord = 0 # zero based array index
self.nShotPoint = 0 # zero based array index
if self.nShotPoints == -1: # calcNoShotPoints has been skipped ?!?
self.calcNoShotPoints()
# the numpy array with the list of source locations simply follows from self.nShotPoints
self.output.srcGeom = np.zeros(shape=(self.nShotPoints), dtype=pntType1)
# the numpy array with the list of relation records follows from the nr of shot points x number of rec lines (assume 20)
self.output.relGeom = np.zeros(shape=(self.nShotPoints * 20), dtype=relType2)
self.output.relTemp = np.zeros(shape=(100), dtype=relType2) # holds 100 rec lines/template will be increased if needed
# for starters; assume there are 40,000 receivers in a survey, will be extended in steps of 10,000
self.output.recGeom = np.zeros(shape=(40000), dtype=pntType1)
success = self.geometryFromTemplates() # here the work is being done
except BaseException as e:
# self.errorText = str(e)
# See: https://stackoverflow.com/questions/1278705/when-i-catch-an-exception-how-do-i-get-the-type-file-and-line-number
fileName = os.path.split(sys.exc_info()[2].tb_frame.f_code.co_filename)[1]
funcName = sys.exc_info()[2].tb_frame.f_code.co_name
lineNo = str(sys.exc_info()[2].tb_lineno)
self.errorText = f'file: {fileName}, function: {funcName}(), line: {lineNo}, error: {str(e)}'
del (fileName, funcName, lineNo)
success = False
return success
def geometryFromTemplates(self) -> bool:
try:
# get all blocks
for nBlock, block in enumerate(self.blockList):
for template in block.templateList: # get all templates
# how deep is the list ?
length = len(template.rollList)
assert length == 3, 'there must always be 3 roll steps / grow steps'
# todo: search everywhere for "< 3" and insert assertions for length of list
if length == 0:
off0 = QVector3D() # always start at (0, 0, 0)
self.geomTemplate3(nBlock, block, template, off0)
elif length == 1:
# get the template boundaries
for i in range(template.rollList[0].steps):
off0 = QVector3D() # always start at (0, 0, 0)
off0 += template.rollList[0].increment * i
self.geomTemplate3(nBlock, block, template, off0)
elif length == 2:
for i in range(template.rollList[0].steps):
off0 = QVector3D() # always start at (0, 0, 0)
off0 += template.rollList[0].increment * i
for j in range(template.rollList[1].steps):
off1 = off0 + template.rollList[1].increment * j
self.geomTemplate3(nBlock, block, template, off1)
elif length == 3:
for i in range(template.rollList[0].steps):
off0 = QVector3D() # always start at (0, 0, 0)
off0 += template.rollList[0].increment * i
for j in range(template.rollList[1].steps):
off1 = off0 + template.rollList[1].increment * j
for k in range(template.rollList[2].steps):
off2 = off1 + template.rollList[2].increment * k
self.geomTemplate3(nBlock, block, template, off2)
else:
# do something recursively; not implemented yet
raise NotImplementedError('More than three roll steps currently not allowed.')
except StopIteration:
self.errorText = 'geometry creation cancelled by user'
return False
except BaseException as e:
# self.errorText = str(e)
# See: https://stackoverflow.com/questions/1278705/when-i-catch-an-exception-how-do-i-get-the-type-file-and-line-number
fileName = os.path.split(sys.exc_info()[2].tb_frame.f_code.co_filename)[1]
funcName = sys.exc_info()[2].tb_frame.f_code.co_name
lineNo = str(sys.exc_info()[2].tb_lineno)
self.errorText = f'file: {fileName}, function: {funcName}(), line: {lineNo}, error: {str(e)}'
del (fileName, funcName, lineNo)
return False
self.progress.emit(100) # make sure we stop at 100
# first remove all remaining receiver duplicates
self.output.recGeom = np.unique(self.output.recGeom)
# todo; because we keep track of 'self.nRelRecord'
# there's no need to shrink the array based on the 'Uniq' == 1 condition.
# need to change the code; resize the relGeom array based on self.nRelRecord
# trim rel & rec arrays removing any zeros, using the 'Uniq' == 1 condition.
self.output.relGeom = self.output.relGeom[self.output.relGeom['Uniq'] == 1]
self.output.recGeom = self.output.recGeom[self.output.recGeom['Uniq'] == 1]
# set all values in one go at the end
self.output.srcGeom['Uniq'] = 1
self.output.srcGeom['InXps'] = 1
self.output.srcGeom['Code'] = 'E1'
self.output.recGeom['Uniq'] = 1
self.output.recGeom['InXps'] = 1
self.output.recGeom['Code'] = 'G1'
self.output.relGeom['InSps'] = 1
self.output.relGeom['InRps'] = 1
# sort the three geometry arrays
self.output.srcGeom.sort(order=['Index', 'Point', 'Line'])
self.output.recGeom.sort(order=['Index', 'Line', 'Point'])
self.output.relGeom.sort(order=['SrcInd', 'SrcLin', 'SrcPnt', 'RecInd', 'RecLin', 'RecMin', 'RecMax'])
return True
def elapsedTime(self, startTime, index: int) -> None:
currentTime = perf_counter()
deltaTime = currentTime - startTime
self.timerTmin[index] = min(deltaTime, self.timerTmin[index])
self.timerTmax[index] = max(deltaTime, self.timerTmax[index])
self.timerTtot[index] = self.timerTtot[index] + deltaTime
self.timerFreq[index] = self.timerFreq[index] + 1
return perf_counter() # call again; ignore time spent in this funtion
def geomTemplate(self, nBlock, block, template, templateOffset):
"""iterate over all seeds in a template; make sure we start wih *source* seeds
iterate using the three levels in the growList (slow approach)"""
for srcSeed in template.seedList:
while len(srcSeed.grid.growList) < 3:
# First, make sure there are 3 grow steps for every srcSeed
srcSeed.grid.growList.insert(0, RollTranslate())
if not srcSeed.bSource: # work with source seeds here
continue
for i in range(srcSeed.grid.growList[0].steps):
# start with a new PointF object
srcOff0 = QVector3D(templateOffset)
srcOff0 += srcSeed.grid.growList[0].increment * i
for j in range(srcSeed.grid.growList[1].steps):
srcOff1 = srcOff0 + srcSeed.grid.growList[1].increment * j
for k in range(srcSeed.grid.growList[2].steps):
# we now have the correct offset
srcOff2 = srcOff1 + srcSeed.grid.growList[2].increment * k
# we now have the correct source location
srcLoc = srcOff2 + srcSeed.origin
if QThread.currentThread().isInterruptionRequested(): # maybe stop at each shot...
raise StopIteration
# do this now, some shots may fall out of the areal limits later
self.nShotPoint += 1
# a new shotpoint always starts with new relation records
self.nOldRecLine = -999999
# apply integer divide
threadProgress = (100 * self.nShotPoint) // self.nShotPoints
if threadProgress > self.threadProgress:
self.threadProgress = threadProgress
# print("progress % = ", threadProgress)
self.progress.emit(threadProgress + 1)
# is src within block limits (or is the border empty) ?
if containsPoint3D(block.borders.srcBorder, srcLoc):
# useful source point; update the source geometry list here
# need to step back by one to arrive at start of array
nSrc = self.nShotPoint - 1
# line & stake nrs for source point
srcStake = self.st2Transform.map(srcLoc.toPointF())
srcGlob = self.glbTransform.map(srcLoc.toPointF()) # we need global positions
self.output.srcGeom[nSrc]['Line'] = int(srcStake.y())
self.output.srcGeom[nSrc]['Point'] = int(srcStake.x())
self.output.srcGeom[nSrc]['Index'] = nBlock % 10 + 1
# self.output.srcGeom[nSrc]['Code' ] = 'E1' # can do this in one go at the end
# self.output.srcGeom[nSrc]['Depth'] = 0.0 # not needed; zero when initialized
self.output.srcGeom[nSrc]['East'] = srcGlob.x()
self.output.srcGeom[nSrc]['North'] = srcGlob.y()
self.output.srcGeom[nSrc]['LocX'] = srcLoc.x() # x-component of 3D-location
self.output.srcGeom[nSrc]['LocY'] = srcLoc.y() # y-component of 3D-location
self.output.srcGeom[nSrc]['Elev'] = srcLoc.z() # z-component of 3D-location
# now iterate over all seeds to find the receivers
for recSeed in template.seedList: # iterate over all seeds in a template
while len(recSeed.grid.growList) < 3:
# First, make sure there are 3 grow steps for every recSeed
recSeed.grid.growList.insert(0, RollTranslate())
if recSeed.bSource: # work with receiver seeds here
continue
# patches increase here
for l in range(recSeed.grid.growList[0].steps):
# start with a new QVector3D object
recOff0 = QVector3D(templateOffset)
recOff0 += recSeed.grid.growList[0].increment * l
# lines increase here
for m in range(recSeed.grid.growList[1].steps):
recOff1 = recOff0 + recSeed.grid.growList[1].increment * m
# points increase here
for n in range(recSeed.grid.growList[2].steps):
recOff2 = recOff1 + recSeed.grid.growList[2].increment * n
recLoc = QVector3D(recOff2)
# we now have the correct receiver location
recLoc += recSeed.origin
# print("recLoc: ", recLoc.x(), recLoc.y(), recLoc.z() )
# is it within block limits (or is the border empty) ?
if containsPoint3D(block.borders.recBorder, recLoc):
# now we have a valid src-point and rec-point
# time to work with the relation records
# line & stake nrs for receiver point
recStake = self.st2Transform.map(recLoc.toPointF())
# we need global positions for all points
recGlob = self.glbTransform.map(recLoc.toPointF())
recLine = int(recStake.y())
recPoint = int(recStake.x())
self.nNewRecLine = recLine
# check if we're on a 'new' receiver line and need a new rel-record
if self.nNewRecLine != self.nOldRecLine:
self.nOldRecLine = self.nNewRecLine
# first complete the previous record
if self.nRelRecord >= 0: # we need at least one earlier record
self.output.relGeom[self.nRelRecord]['RecMin'] = self.recMin
self.output.relGeom[self.nRelRecord]['RecMax'] = self.recMax
self.nRelRecord += 1 # now start with a new relation record
self.recMin = recPoint # reset minimum rec number
self.recMax = recPoint # reset maximum rec number
self.output.relGeom[self.nRelRecord]['SrcLin'] = int(srcStake.y())
self.output.relGeom[self.nRelRecord]['SrcPnt'] = int(srcStake.x())
self.output.relGeom[self.nRelRecord]['SrcInd'] = nBlock % 10 + 1
self.output.relGeom[self.nRelRecord]['Record'] = self.nShotPoint
self.output.relGeom[self.nRelRecord]['RecLin'] = int(recStake.y())
self.output.relGeom[self.nRelRecord]['RecMin'] = self.recMin
self.output.relGeom[self.nRelRecord]['RecMax'] = self.recMax
self.output.relGeom[self.nRelRecord]['RecInd'] = nBlock % 10 + 1
self.output.relGeom[self.nRelRecord]['Uniq'] = 1
else:
self.recMin = min(recPoint, self.recMin)
self.recMax = max(recPoint, self.recMax)
# self.output.relGeom[self.nRelRecord]['RecMin'] = self.recMin
# self.output.relGeom[self.nRelRecord]['RecMax'] = self.recMax
# apply self.output.relGeom.resize(N) when more memory is needed
arraySize = self.output.relGeom.shape[0]
if self.nRelRecord + 100 > arraySize: # room for less than 100 left ?
self.output.relGeom.resize(arraySize + 1000, refcheck=False) # append 1000 more records
# the problem with receiver records is that they overlap by some 90% from shot to shot.
# rather than adding all receivers first, and removing all receiver duplicates later,
# we use a nested dictionary to find out if a rec station already exists
# sofar, (blocK) index has been neglected, but this could be added as a third nesting level
try: # has it been used before ?
use = self.output.recDict[recLine][recPoint]
self.output.recDict[recLine][recPoint] = use + 1 # increment by one
except KeyError:
self.output.recDict[recLine][recPoint] = 1 # set to one (first time use)
self.nRecRecord += 1 # we have a new receiver record
self.output.recGeom[self.nRecRecord]['Line'] = int(recStake.y())
self.output.recGeom[self.nRecRecord]['Point'] = int(recStake.x())
self.output.recGeom[self.nRecRecord]['Index'] = nBlock % 10 + 1
# self.output.recGeom[self.nRecRecord]['Code' ] = 'G1' # can do this in one go at the end
# self.output.recGeom[self.nRecRecord]['Depth'] = 0.0 # not needed; zero when initialized
self.output.recGeom[self.nRecRecord]['East'] = recGlob.x()
self.output.recGeom[self.nRecRecord]['North'] = recGlob.y()
self.output.recGeom[self.nRecRecord]['LocX'] = recLoc.x() # x-component of 3D-location
self.output.recGeom[self.nRecRecord]['LocY'] = recLoc.y() # y-component of 3D-location
self.output.recGeom[self.nRecRecord]['Elev'] = recLoc.z() # z-component of 3D-location
# we want to remove empty records at the end
self.output.recGeom[self.nRecRecord]['Uniq'] = 1
# apply self.output.recGeom.resize(N) when more memory is needed
arraySize = self.output.recGeom.shape[0]
if self.nRecRecord + 100 > arraySize: # room for less than 100 left ?
# first remove all duplicates
self.output.recGeom = np.unique(self.output.recGeom)
# get array size (again)
arraySize = self.output.recGeom.shape[0]
# adjust nRecRecord to the next available spot
self.nRecRecord = arraySize
# append 1000 more receiver records
self.output.recGeom.resize(arraySize + 1000, refcheck=False)
# finally complete the very last relation record
if self.nRelRecord >= 0: # we need at least one record
self.output.relGeom[self.nRelRecord]['RecMin'] = self.recMin
self.output.relGeom[self.nRelRecord]['RecMax'] = self.recMax
def geomTemplate2(self, nBlock, block, template, templateOffset):
"""Use numpy arrays instead of iterating over the growList.
This provides a much faster approach then using the growlist.
The function is however still rather slow.
Use time.perf_counter() to analyse bottlenecks
"""
# convert the template offset to a numpy array
npTemplateOffset = np.array([templateOffset.x(), templateOffset.y(), templateOffset.z()], dtype=np.float32)
# iterate over all seeds in a template; make sure we start wih *source* seeds
for srcSeed in template.seedList:
time = perf_counter() ###
if not srcSeed.bSource: # work with source seeds here
continue
# we are in a source seed right now; use the numpy array functions to apply selection criteria
srcArray = srcSeed.pointArray + npTemplateOffset
if not block.borders.srcBorder.isNull(): # deal with block's source border if it isn't null()
I = pointsInRect(srcArray, block.borders.srcBorder)
if I.shape[0] == 0:
continue
time = self.elapsedTime(time, 0) ###
srcArray = srcArray[I, :] # filter the source array
time = self.elapsedTime(time, 1) ###
for src in srcArray: # iterate over all sources
self.nShotPoint += 1
self.nOldRecLine = -999999 # a new shotpoint always starts with new relation records
# begin thread progress code
if QThread.currentThread().isInterruptionRequested(): # maybe stop at each shot...
raise StopIteration
threadProgress = (100 * self.nShotPoint) // self.nShotPoints # apply integer divide
if threadProgress > self.threadProgress:
self.threadProgress = threadProgress
self.progress.emit(threadProgress + 1)
# end thread progress code
# useful source point; update the source geometry list here
nSrc = self.nShotPoint - 1 # need to step back by one to arrive at start of array
time = self.elapsedTime(time, 2) ###
# determine line & stake nrs for source point
srcX = src[0]
srcY = src[1]
# srcZ = src[2]
srcStkX, srcStkY = self.st2Transform.map(srcX, srcY) # get line and point indices
srcLocX, srcLocY = self.glbTransform.map(srcX, srcY) # we need global positions
numbaSetPointRecord(self.output.srcGeom, nSrc, srcStkY, srcStkX, nBlock, srcLocX, srcLocY, src)
# self.output.srcGeom[nSrc]['Line'] = int(srcStkY)
# self.output.srcGeom[nSrc]['Point'] = int(srcStkX)
# self.output.srcGeom[nSrc]['Index'] = nBlock % 10 + 1 # the single digit point index is used to indicate block nr
# self.output.srcGeom[nSrc]['Code' ] = 'E1' # can do this in one go at the end
# self.output.srcGeom[nSrc]['Depth'] = 0.0 # not needed; zero when initialized
# self.output.srcGeom[nSrc]['East'] = srcLocX
# self.output.srcGeom[nSrc]['North'] = srcLocY
# self.output.srcGeom[nSrc]['LocX'] = srcX # x-component of 3D-location
# self.output.srcGeom[nSrc]['LocY'] = srcY # y-component of 3D-location
# self.output.srcGeom[nSrc]['Elev'] = srcZ # z-value not affected by transform
time = self.elapsedTime(time, 3) ###
# now iterate over all seeds to find the receivers
for recSeed in template.seedList: # iterate over all rec seeds in a template
if recSeed.bSource: # work with receiver seeds here
continue
# we are in a receiver seed right now; use the numpy array functions to apply selection criteria
recPoints = recSeed.pointArray + npTemplateOffset
time = self.elapsedTime(time, 4) ###
if not block.borders.recBorder.isNull(): # deal with block's receiver border if it isn't null()
I = pointsInRect(recPoints, block.borders.recBorder)
if I.shape[0] == 0:
continue
else:
time = self.elapsedTime(time, 5) ###
recPoints = recPoints[I, :]
time = self.elapsedTime(time, 6) ###
for rec in recPoints: # iterate over all receivers
time = perf_counter() # reset at start of receiver loop
# determine line & stake nrs for receiver point
recX = rec[0]
recY = rec[1]
# recZ = rec[2]
time = self.elapsedTime(time, 7) ###
recStkX, recStkY = self.st2Transform.map(recX, recY) # get line and point indices
recLocX, recLocY = self.glbTransform.map(recX, recY) # we need global positions
time = self.elapsedTime(time, 8) ###
# we have a new receiver record
self.nRecRecord += 1
numbaSetPointRecord(self.output.recGeom, self.nRecRecord, recStkY, recStkX, nBlock, recLocX, recLocY, rec)
# self.output.recGeom[self.nRecRecord]['Line'] = int(recStkY)
# self.output.recGeom[self.nRecRecord]['Point'] = int(recStkX)
# self.output.recGeom[self.nRecRecord]['Index'] = nBlock % 10 + 1 # the single digit point index is used to indicate block nr
# self.output.recGeom[self.nRecRecord]['Code' ] = 'G1' # can do this in one go at the end
# self.output.recGeom[self.nRecRecord]['Depth'] = 0.0 # not needed; zero when initialized
# self.output.recGeom[self.nRecRecord]['East'] = recLocX
# self.output.recGeom[self.nRecRecord]['North'] = recLocY
# self.output.recGeom[self.nRecRecord]['LocX'] = recX # x-component of 3D-location
# self.output.recGeom[self.nRecRecord]['LocY'] = recY # y-component of 3D-location
# self.output.recGeom[self.nRecRecord]['Elev'] = recZ # z-value not affected by transform
# self.output.recGeom[self.nRecRecord]['Uniq'] = 1 # We want to use Uniq == 1 later, to remove empty records
time = self.elapsedTime(time, 9) ###
# apply self.output.recGeom.resize(N) when more memory is needed, after cleaning duplicates
arraySize = self.output.recGeom.shape[0]
if self.nRecRecord + 100 > arraySize: # room for less than 100 left ?
time = perf_counter()
self.output.recGeom = np.unique(self.output.recGeom) # first remove all duplicates
arraySize = self.output.recGeom.shape[0] # get array size (again)
self.nRecRecord = arraySize # adjust nRecRecord to the next available spot
self.output.recGeom.resize(arraySize + 10000, refcheck=False) # append 10000 more records
time = self.elapsedTime(time, 10) ###
time = perf_counter()
# time to work with the relation records, now we have both a valid src-point and rec-point;
self.nNewRecLine = int(recStkY)
if self.nNewRecLine != self.nOldRecLine: # we're on a 'new' receiver line and need a new rel-record
self.nOldRecLine = self.nNewRecLine # save current line number
self.nRelRecord += 1 # increment relation record number
# create new relation record; fill it in completely
numbaSetRelationRecord(self.output.relGeom, self.nRelRecord, srcStkX, srcStkY, nBlock, self.nShotPoint, recStkY, recStkX, recStkX)
# self.output.relGeom[self.nRelRecord]['SrcLin'] = int(srcStkY)
# self.output.relGeom[self.nRelRecord]['SrcPnt'] = int(srcStkX)
# self.output.relGeom[self.nRelRecord]['SrcInd'] = nBlock % 10 + 1
# self.output.relGeom[self.nRelRecord]['Record'] = self.nShotPoint
# self.output.relGeom[self.nRelRecord]['RecLin'] = int(recStkY)
# self.output.relGeom[self.nRelRecord]['RecMin'] = int(recStkX)
# self.output.relGeom[self.nRelRecord]['RecMax'] = int(recStkX)
# self.output.relGeom[self.nRelRecord]['RecInd'] = nBlock % 10 + 1
# self.output.relGeom[self.nRelRecord]['Uniq'] = 1 # needed for compacting array later (remove empty records)
else:
# existing relation record; just update min/max rec stake numbers
numbaFixRelationRecord(self.output.relGeom, self.nRelRecord, recStkX)
# recMin = min(int(recStkX), self.output.relGeom[self.nRelRecord]['RecMin'])
# recMax = max(int(recStkX), self.output.relGeom[self.nRelRecord]['RecMax'])
# self.output.relGeom[self.nRelRecord]['RecMin'] = recMin
# self.output.relGeom[self.nRelRecord]['RecMax'] = recMax
time = self.elapsedTime(time, 11) ###
# apply self.output.relGeom.resize(N) when more memory is needed
arraySize = self.output.relGeom.shape[0]
if self.nRelRecord + 100 > arraySize: # room for less than 100 left ?
time = perf_counter()
self.output.relGeom.resize(arraySize + 10000, refcheck=False) # append 10000 more records
time = self.elapsedTime(time, 12) ###
def geomTemplate3(self, nBlock, block, template, templateOffset):
"""Use numpy arrays instead of iterating over the growList.
This provides a much faster approach then using the growlist.
The function is however still rather slow.
Use time.perf_counter() to analyse bottlenecks
Note: a template is a collection of shots that all record in the same set of receivers.
Upon completion, the teplate is rolled, and the process starts over again
Therefore:
a) the shots from a template can directly be appended to the src list
b) the same can be done for the receivers, as far as they are not already included in the rec list
c) Per shot, several relation records need to be created.
Apart from the source info, these relation records are identical for all shots in the template
"""
# convert the template offset to a numpy array
npTemplateOffset = np.array([templateOffset.x(), templateOffset.y(), templateOffset.z()], dtype=np.float32)
# begin thread progress code
if QThread.currentThread().isInterruptionRequested(): # maybe stop at each shot...
raise StopIteration
self.nTemplate += 1 # work on a new template
threadProgress = (100 * self.nTemplate) // self.nTemplates # apply integer divide
if threadProgress > self.threadProgress:
self.threadProgress = threadProgress
self.progress.emit(threadProgress + 1)
# end thread progress code
nShotPoint = self.nShotPoint # create a copy for relation records creation later on
# iterate over all seeds in a template; make sure we deal wih *source* seeds
for srcSeed in template.seedList:
if not srcSeed.bSource: # work with source seeds here
continue
# we are in a source seed right now; use the numpy array functions to apply selection criteria
srcArray = srcSeed.pointArray + npTemplateOffset
if not block.borders.srcBorder.isNull(): # deal with block's source border if it isn't null()
I = pointsInRect(srcArray, block.borders.srcBorder)
if I.shape[0] == 0:
continue
srcArray = srcArray[I, :] # filter the source array
for src in srcArray: # iterate over all sources
# useful source point; pointsInRect passed it through
# determine line & stake nrs for source point
srcX = src[0]
srcY = src[1]
srcStkX, srcStkY = self.st2Transform.map(srcX, srcY) # get line and point indices
srcLocX, srcLocY = self.glbTransform.map(srcX, srcY) # we need global positions
numbaSetPointRecord(self.output.srcGeom, self.nShotPoint, srcStkY, srcStkX, nBlock, srcLocX, srcLocY, src)
self.nShotPoint += 1 # increment for the next shot
nRelRecord = -1 # start with invalid value (will be 0 for 1st record)
nOldRecLine = -999999 # start with 'funny' value
# now iterate over all seeds to find the receivers
for recSeed in template.seedList: # iterate over all rec seeds in a template
if recSeed.bSource: # work with receiver seeds here
continue
# we are in a receiver seed right now; use the numpy array functions to apply selection criteria
recPoints = recSeed.pointArray + npTemplateOffset
if not block.borders.recBorder.isNull(): # deal with block's receiver border if it isn't null()
I = pointsInRect(recPoints, block.borders.recBorder)
if I.shape[0] == 0:
continue
else:
recPoints = recPoints[I, :]
for rec in recPoints: # iterate over all receivers
# determine line & stake nrs for receiver point
recX = rec[0]
recY = rec[1]
recStkX, recStkY = self.st2Transform.map(recX, recY) # get line and point indices
recLocX, recLocY = self.glbTransform.map(recX, recY) # we need global positions
recPoint = int(recStkX)
recLine = int(recStkY)
# the problem with receiver records is that they overlap by some 90% from shot to shot.
# rather than adding all receivers first, followed by removing all duplicates later,
# we use a nested dictionary to find out if a rec station already exists in our 'list'
# sofar,block nr (=index) has been neglected, but this could be added as a third nesting level
try: # has it been used before ?
_ = self.output.recDict[recLine][recPoint] # test with dummy variable
except KeyError: