LoopStructural 1.6.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of LoopStructural might be problematic. Click here for more details.
- LoopStructural/__init__.py +52 -0
- LoopStructural/datasets/__init__.py +23 -0
- LoopStructural/datasets/_base.py +301 -0
- LoopStructural/datasets/_example_models.py +10 -0
- LoopStructural/datasets/data/claudius.csv +21049 -0
- LoopStructural/datasets/data/claudiusbb.txt +2 -0
- LoopStructural/datasets/data/duplex.csv +126 -0
- LoopStructural/datasets/data/duplexbb.txt +2 -0
- LoopStructural/datasets/data/fault_trace/fault_trace.cpg +1 -0
- LoopStructural/datasets/data/fault_trace/fault_trace.dbf +0 -0
- LoopStructural/datasets/data/fault_trace/fault_trace.prj +1 -0
- LoopStructural/datasets/data/fault_trace/fault_trace.shp +0 -0
- LoopStructural/datasets/data/fault_trace/fault_trace.shx +0 -0
- LoopStructural/datasets/data/geological_map_data/bbox.csv +2 -0
- LoopStructural/datasets/data/geological_map_data/contacts.csv +657 -0
- LoopStructural/datasets/data/geological_map_data/fault_displacement.csv +7 -0
- LoopStructural/datasets/data/geological_map_data/fault_edges.txt +2 -0
- LoopStructural/datasets/data/geological_map_data/fault_locations.csv +79 -0
- LoopStructural/datasets/data/geological_map_data/fault_orientations.csv +19 -0
- LoopStructural/datasets/data/geological_map_data/stratigraphic_order.csv +13 -0
- LoopStructural/datasets/data/geological_map_data/stratigraphic_orientations.csv +207 -0
- LoopStructural/datasets/data/geological_map_data/stratigraphic_thickness.csv +13 -0
- LoopStructural/datasets/data/intrusion.csv +1017 -0
- LoopStructural/datasets/data/intrusionbb.txt +2 -0
- LoopStructural/datasets/data/onefoldbb.txt +2 -0
- LoopStructural/datasets/data/onefolddata.csv +2226 -0
- LoopStructural/datasets/data/refolded_bb.txt +2 -0
- LoopStructural/datasets/data/refolded_fold.csv +205 -0
- LoopStructural/datasets/data/tabular_intrusion.csv +23 -0
- LoopStructural/datatypes/__init__.py +4 -0
- LoopStructural/datatypes/_bounding_box.py +422 -0
- LoopStructural/datatypes/_point.py +166 -0
- LoopStructural/datatypes/_structured_grid.py +94 -0
- LoopStructural/datatypes/_surface.py +184 -0
- LoopStructural/export/exporters.py +554 -0
- LoopStructural/export/file_formats.py +15 -0
- LoopStructural/export/geoh5.py +100 -0
- LoopStructural/export/gocad.py +126 -0
- LoopStructural/export/omf_wrapper.py +88 -0
- LoopStructural/interpolators/__init__.py +105 -0
- LoopStructural/interpolators/_api.py +143 -0
- LoopStructural/interpolators/_builders.py +149 -0
- LoopStructural/interpolators/_cython/__init__.py +0 -0
- LoopStructural/interpolators/_discrete_fold_interpolator.py +183 -0
- LoopStructural/interpolators/_discrete_interpolator.py +692 -0
- LoopStructural/interpolators/_finite_difference_interpolator.py +470 -0
- LoopStructural/interpolators/_geological_interpolator.py +380 -0
- LoopStructural/interpolators/_interpolator_factory.py +89 -0
- LoopStructural/interpolators/_non_linear_discrete_interpolator.py +0 -0
- LoopStructural/interpolators/_operator.py +38 -0
- LoopStructural/interpolators/_p1interpolator.py +228 -0
- LoopStructural/interpolators/_p2interpolator.py +277 -0
- LoopStructural/interpolators/_surfe_wrapper.py +174 -0
- LoopStructural/interpolators/supports/_2d_base_unstructured.py +340 -0
- LoopStructural/interpolators/supports/_2d_p1_unstructured.py +68 -0
- LoopStructural/interpolators/supports/_2d_p2_unstructured.py +288 -0
- LoopStructural/interpolators/supports/_2d_structured_grid.py +462 -0
- LoopStructural/interpolators/supports/_2d_structured_tetra.py +0 -0
- LoopStructural/interpolators/supports/_3d_base_structured.py +467 -0
- LoopStructural/interpolators/supports/_3d_p2_tetra.py +331 -0
- LoopStructural/interpolators/supports/_3d_structured_grid.py +470 -0
- LoopStructural/interpolators/supports/_3d_structured_tetra.py +746 -0
- LoopStructural/interpolators/supports/_3d_unstructured_tetra.py +637 -0
- LoopStructural/interpolators/supports/__init__.py +55 -0
- LoopStructural/interpolators/supports/_aabb.py +77 -0
- LoopStructural/interpolators/supports/_base_support.py +114 -0
- LoopStructural/interpolators/supports/_face_table.py +70 -0
- LoopStructural/interpolators/supports/_support_factory.py +32 -0
- LoopStructural/modelling/__init__.py +29 -0
- LoopStructural/modelling/core/__init__.py +0 -0
- LoopStructural/modelling/core/geological_model.py +1867 -0
- LoopStructural/modelling/features/__init__.py +32 -0
- LoopStructural/modelling/features/_analytical_feature.py +79 -0
- LoopStructural/modelling/features/_base_geological_feature.py +364 -0
- LoopStructural/modelling/features/_cross_product_geological_feature.py +100 -0
- LoopStructural/modelling/features/_geological_feature.py +288 -0
- LoopStructural/modelling/features/_lambda_geological_feature.py +93 -0
- LoopStructural/modelling/features/_region.py +18 -0
- LoopStructural/modelling/features/_structural_frame.py +186 -0
- LoopStructural/modelling/features/_unconformity_feature.py +83 -0
- LoopStructural/modelling/features/builders/__init__.py +5 -0
- LoopStructural/modelling/features/builders/_base_builder.py +111 -0
- LoopStructural/modelling/features/builders/_fault_builder.py +590 -0
- LoopStructural/modelling/features/builders/_folded_feature_builder.py +129 -0
- LoopStructural/modelling/features/builders/_geological_feature_builder.py +543 -0
- LoopStructural/modelling/features/builders/_structural_frame_builder.py +237 -0
- LoopStructural/modelling/features/fault/__init__.py +3 -0
- LoopStructural/modelling/features/fault/_fault_function.py +444 -0
- LoopStructural/modelling/features/fault/_fault_function_feature.py +82 -0
- LoopStructural/modelling/features/fault/_fault_segment.py +505 -0
- LoopStructural/modelling/features/fold/__init__.py +9 -0
- LoopStructural/modelling/features/fold/_fold.py +167 -0
- LoopStructural/modelling/features/fold/_fold_rotation_angle.py +149 -0
- LoopStructural/modelling/features/fold/_fold_rotation_angle_feature.py +67 -0
- LoopStructural/modelling/features/fold/_foldframe.py +194 -0
- LoopStructural/modelling/features/fold/_svariogram.py +188 -0
- LoopStructural/modelling/input/__init__.py +2 -0
- LoopStructural/modelling/input/fault_network.py +80 -0
- LoopStructural/modelling/input/map2loop_processor.py +165 -0
- LoopStructural/modelling/input/process_data.py +650 -0
- LoopStructural/modelling/input/project_file.py +84 -0
- LoopStructural/modelling/intrusions/__init__.py +25 -0
- LoopStructural/modelling/intrusions/geom_conceptual_models.py +142 -0
- LoopStructural/modelling/intrusions/geometric_scaling_functions.py +123 -0
- LoopStructural/modelling/intrusions/intrusion_builder.py +672 -0
- LoopStructural/modelling/intrusions/intrusion_feature.py +410 -0
- LoopStructural/modelling/intrusions/intrusion_frame_builder.py +971 -0
- LoopStructural/modelling/intrusions/intrusion_support_functions.py +460 -0
- LoopStructural/utils/__init__.py +38 -0
- LoopStructural/utils/_surface.py +143 -0
- LoopStructural/utils/_transformation.py +76 -0
- LoopStructural/utils/config.py +18 -0
- LoopStructural/utils/dtm_creator.py +17 -0
- LoopStructural/utils/exceptions.py +31 -0
- LoopStructural/utils/helper.py +292 -0
- LoopStructural/utils/json_encoder.py +18 -0
- LoopStructural/utils/linalg.py +8 -0
- LoopStructural/utils/logging.py +79 -0
- LoopStructural/utils/maths.py +245 -0
- LoopStructural/utils/regions.py +103 -0
- LoopStructural/utils/typing.py +7 -0
- LoopStructural/utils/utils.py +68 -0
- LoopStructural/version.py +1 -0
- LoopStructural/visualisation/__init__.py +11 -0
- LoopStructural-1.6.1.dist-info/LICENSE +21 -0
- LoopStructural-1.6.1.dist-info/METADATA +81 -0
- LoopStructural-1.6.1.dist-info/RECORD +129 -0
- LoopStructural-1.6.1.dist-info/WHEEL +5 -0
- LoopStructural-1.6.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
,X,Y,Z,gx,gy,gz,feature_name,val
|
|
2
|
+
0,8105.964844,7817.088379,4139.524414,-0.369708,0.656831,0.657183,s1,
|
|
3
|
+
1,8025.396484,7858.603516,4092.031738,-0.369707,0.656831,0.657184,s1,
|
|
4
|
+
2,7724.018066,7712.95166,4044.513184,-0.380564,0.661454,0.646258,s1,
|
|
5
|
+
3,7857.236816,7819.785645,4013.841553,-0.380567,0.661454,0.646256,s1,
|
|
6
|
+
4,7607.807129,7613.088379,4115.101074,-0.387485,0.661927,0.641645,s1,
|
|
7
|
+
5,7910.404785,7820.535645,4040.48584,-0.380565,0.661453,0.646258,s1,
|
|
8
|
+
6,7429.226074,7437.434082,4182.181152,-0.142905,0.677173,0.721813,s1,
|
|
9
|
+
7,7166.156738,7341.453125,4238.604492,-0.04103,0.727471,0.684911,s1,
|
|
10
|
+
8,6953.1875,7268.904785,4231.543945,-0.107449,0.650304,0.752037,s1,
|
|
11
|
+
9,4463.743164,8246.233398,3878.191162,-0.322569,0.711064,0.62477,s1,
|
|
12
|
+
10,4146.796875,8192.422852,3782.050781,-0.312602,0.654896,0.688034,s1,
|
|
13
|
+
11,4338.447266,8278.910156,3811.917969,-0.312605,0.654896,0.688033,s1,
|
|
14
|
+
12,3834.705322,7915.335449,3910.998779,-0.38748,0.649857,0.653869,s1,
|
|
15
|
+
13,3962.468018,8059.345215,3834.846436,-0.378529,0.640361,0.668321,s1,
|
|
16
|
+
14,3882.303955,7984.151855,3884.387695,-0.378529,0.640359,0.668324,s1,
|
|
17
|
+
15,3909.378174,8012.899902,3868.044922,-0.378529,0.640361,0.668321,s1,
|
|
18
|
+
16,4484.125,8298.175781,3890.225342,-0.312605,0.654896,0.688033,s1,
|
|
19
|
+
17,4130.777832,8226.283203,3798.846924,-0.361416,0.681936,0.635879,s1,
|
|
20
|
+
18,3991.658447,8110.191406,3819.530029,-0.378529,0.640361,0.668321,s1,
|
|
21
|
+
19,4450.890137,8314.161133,3867.620117,-0.312603,0.654895,0.688035,s1,
|
|
22
|
+
20,4436.492188,7939.796875,3828.122803,-0.271136,0.637735,0.720957,s1,
|
|
23
|
+
21,7479.196777,6897.290527,3940.542969,-0.368301,0.679938,0.634065,s1,
|
|
24
|
+
22,8206.579102,6932.778809,4287.825684,-0.404984,0.644881,0.648164,s1,
|
|
25
|
+
23,6462.431641,6818.061035,3982.512451,0.338511,0.669502,0.661195,s1,
|
|
26
|
+
24,7264.435059,6808.224121,3926.915527,-0.111467,0.699892,0.705497,s1,
|
|
27
|
+
25,7645.959473,6906.973145,4004.677246,-0.363077,0.676886,0.640312,s1,
|
|
28
|
+
26,7361.058105,6841.313965,3928.993896,-0.280938,0.680807,0.676443,s1,
|
|
29
|
+
27,7144.925781,6802.59375,3923.816406,-0.011329,0.717988,0.695963,s1,
|
|
30
|
+
28,8101.257813,6904.299316,4248.177246,-0.404994,0.644886,0.648153,s1,
|
|
31
|
+
29,6699.904785,6798.770996,3957.359863,0.152611,0.701669,0.695968,s1,
|
|
32
|
+
30,8014.854004,6907.269531,4209.583984,-0.373832,0.634949,0.676084,s1,
|
|
33
|
+
31,7545.029297,6898.556152,3945.394775,-0.363489,0.677244,0.6397,s1,
|
|
34
|
+
32,6996.196777,6770.859375,3920.439697,-0.011325,0.717989,0.695963,s1,
|
|
35
|
+
33,6801.747559,6772.209473,3933.853516,0.046899,0.76923,0.637249,s1,
|
|
36
|
+
34,7774.21875,6883.507813,4096.694336,-0.363077,0.676886,0.640312,s1,
|
|
37
|
+
35,4691.230469,7601.061035,3827.233154,-0.209773,0.687909,0.694821,s1,
|
|
38
|
+
36,6129.179199,6958.416504,4059.388184,0.381329,0.664459,0.642715,s1,
|
|
39
|
+
37,4314.089355,7489.594238,3776.57959,-0.329914,0.684349,0.650249,s1,
|
|
40
|
+
38,4987.900879,7507.699219,4001.363037,0.080154,0.720679,0.68862,s1,
|
|
41
|
+
39,5933.955078,7030.11084,4093.896484,0.395108,0.653739,0.64538,s1,
|
|
42
|
+
40,5650.458984,7160.73877,4138.199707,0.37039,0.698023,0.612842,s1,
|
|
43
|
+
41,4228.069336,7340.476074,3859.308105,-0.38856,0.653815,0.649267,s1,
|
|
44
|
+
42,5324.339355,7325.978027,4095.224121,0.191189,0.654038,0.731902,s1,
|
|
45
|
+
43,8192.760742,5877.359375,4350.828613,-0.39605,0.648368,0.650202,s1,
|
|
46
|
+
44,8408.932617,5952.972656,4396.70459,-0.269766,0.711133,0.649242,s1,
|
|
47
|
+
45,7891.730469,5797.015625,4265.481445,-0.386136,0.647771,0.656728,s1,
|
|
48
|
+
46,7289.492188,5886.661621,3905.458984,-0.216029,0.694914,0.685876,s1,
|
|
49
|
+
47,7511.041504,5764.715332,4084.202393,-0.216026,0.694918,0.685873,s1,
|
|
50
|
+
48,7110.464844,5915.281738,3830.131836,-0.028968,0.677946,0.734541,s1,
|
|
51
|
+
49,7710.951172,5764.033203,4186.418457,-0.386135,0.647772,0.656728,s1,
|
|
52
|
+
50,8751.765625,6043.703125,4448.17041,-0.254501,0.740597,0.621889,s1,
|
|
53
|
+
51,7012.740723,5877.980957,3838.769043,0.0,0.701777,0.712397,s1,
|
|
54
|
+
52,8917.792969,6040.024902,4476.911133,0.224536,0.655441,0.721097,s1,
|
|
55
|
+
53,6775.606934,5869.785156,3907.217041,0.198826,0.641144,0.741217,s1,
|
|
56
|
+
54,4381.253906,6395.566895,3989.859131,-0.342008,0.664439,0.664493,s1,
|
|
57
|
+
55,5103.746582,6705.044434,3777.372559,0.125274,0.57823,0.806199,s1,
|
|
58
|
+
56,4580.906738,6500.463379,3929.050781,-0.245391,0.695293,0.675538,s1,
|
|
59
|
+
57,4781.864746,6674.970215,3842.260254,0.017702,0.664107,0.747428,s1,
|
|
60
|
+
58,5354.658203,6622.359863,3814.892822,0.125274,0.578225,0.806202,s1,
|
|
61
|
+
59,5595.521973,6572.089355,3778.007568,0.050248,0.803485,0.5932,s1,
|
|
62
|
+
60,4216.431152,6261.949219,4015.319824,-0.397064,0.646363,0.651579,s1,
|
|
63
|
+
61,5750.165527,6410.730469,3851.6875,0.36676,0.642277,0.673028,s1,
|
|
64
|
+
62,7756.052734,5052.737305,3995.219727,-0.377153,0.662686,0.646995,s1,
|
|
65
|
+
63,8550.444336,5264.115234,4193.849609,-0.265491,0.629312,0.730398,s1,
|
|
66
|
+
64,7399.317871,5042.470703,3828.21875,-0.131798,0.585749,0.799704,s1,
|
|
67
|
+
65,8225.186523,5194.84082,4147.58252,-0.313703,0.63659,0.704516,s1,
|
|
68
|
+
66,9088.108398,5309.286621,4325.186035,0.085211,0.704865,0.704205,s1,
|
|
69
|
+
67,6978.025879,5014.847656,3885.211426,-0.092597,0.623258,0.776515,s1,
|
|
70
|
+
68,4875.105469,5652.085938,3661.939209,-0.106888,0.620644,0.776773,s1,
|
|
71
|
+
69,7497.256348,2278.713135,4266.964355,-0.169299,0.747741,0.642045,s1,
|
|
72
|
+
70,7053.27002,2204.488037,4259.477539,-0.169299,0.747743,0.642042,s1,
|
|
73
|
+
71,7164.26709,2223.044189,4260.19043,-0.169299,0.747743,0.642042,s1,
|
|
74
|
+
72,6827.721191,2178.767578,4256.982422,0.223277,0.670317,0.707688,s1,
|
|
75
|
+
73,6674.572266,2211.646484,4252.422363,0.223277,0.670317,0.707688,s1,
|
|
76
|
+
74,6354.273438,1740.605469,4251.533203,0.344998,0.691604,0.634556,s1,
|
|
77
|
+
75,6519.572754,1627.216431,4272.450684,0.344997,0.691605,0.634554,s1,
|
|
78
|
+
76,7245.841309,1523.812866,4304.941406,-0.042558,0.633008,0.772974,s1,
|
|
79
|
+
77,6638.419434,1552.93396,4282.617188,0.34058,0.642974,0.685996,s1,
|
|
80
|
+
78,7496.476074,1582.927612,4312.900391,-0.320332,0.681916,0.657555,s1,
|
|
81
|
+
79,6795.693359,1515.524414,4289.676758,0.008082,0.670905,0.741499,s1,
|
|
82
|
+
80,7084.677246,1530.314453,4298.628906,0.008082,0.670905,0.741499,s1,
|
|
83
|
+
81,7367.606934,1554.823853,4308.790039,-0.344337,0.644329,0.682842,s1,
|
|
84
|
+
82,6909.200684,1514.232544,4293.893066,0.008076,0.670906,0.741498,s1,
|
|
85
|
+
83,7957.604004,1836.715332,4326.04541,-0.376444,0.657129,0.653048,s1,
|
|
86
|
+
84,3228.516357,3822.811279,3435.260986,-0.063604,0.699823,0.711479,s1,
|
|
87
|
+
85,2708.726563,3649.499268,3574.881348,0.307884,0.669998,0.675507,s1,
|
|
88
|
+
86,2825.633057,3703.024658,3539.217773,-0.006556,0.568228,0.822845,s1,
|
|
89
|
+
87,2960.474365,3728.014893,3492.960449,-0.006556,0.568228,0.822845,s1,
|
|
90
|
+
88,2765.84668,3663.884033,3559.75415,-0.048184,0.712926,0.699582,s1,
|
|
91
|
+
89,3018.998047,3762.053467,3469.934814,-0.095622,0.71278,0.694839,s1,
|
|
92
|
+
90,3122.883545,3790.993408,3433.586914,-0.063604,0.699823,0.711479,s1,
|
|
93
|
+
91,2406.449463,3009.692627,3577.027832,0.324803,0.65123,0.685859,s1,
|
|
94
|
+
92,3040.73999,3109.857178,3350.46582,0.06847,0.704342,0.70655,s1,
|
|
95
|
+
93,2391.452393,2969.916016,3569.719727,0.336214,0.659167,0.67265,s1,
|
|
96
|
+
94,2255.179443,3037.394531,3622.856445,0.346091,0.665645,0.661163,s1,
|
|
97
|
+
95,2891.789063,3070.572998,3364.08667,0.06847,0.704342,0.70655,s1,
|
|
98
|
+
96,2728.980469,3002.033447,3404.610352,0.051908,0.712981,0.699259,s1,
|
|
99
|
+
97,2536.453857,2977.585693,3509.736328,0.334386,0.655734,0.676904,s1,
|
|
100
|
+
98,2084.552979,2559.013916,3562.509766,0.346041,0.665668,0.661167,s1,
|
|
101
|
+
99,2575.643799,2575.219971,3312.878174,0.060054,0.71043,0.701201,s1,
|
|
102
|
+
100,2325.210693,2540.727295,3453.322754,0.372259,0.666912,0.645485,s1,
|
|
103
|
+
101,2852.368164,2550.683838,3306.851318,0.060054,0.710429,0.701202,s1,
|
|
104
|
+
102,2006.726685,2587.699951,3588.91333,0.376925,0.660295,0.649567,s1,
|
|
105
|
+
103,2228.606934,2543.868896,3517.436035,0.367991,0.673677,0.640892,s1,
|
|
106
|
+
0,4009.370117,7648.972168,3842.925049,-0.568667,0.583156,0.580127,s0,
|
|
107
|
+
1,4218.930176,7929.440918,3783.44873,-0.546277,0.59262,0.591931,s0,
|
|
108
|
+
2,4482.91748,8049.223145,3885.868652,-0.476946,0.621541,0.621458,s0,
|
|
109
|
+
3,4555.029297,7777.873535,3875.355469,-0.421183,0.641272,0.641386,s0,
|
|
110
|
+
4,4568.416016,7662.421875,3861.953369,-0.451884,0.63593,0.625615,s0,
|
|
111
|
+
5,4466.666504,7532.352051,3772.635254,-0.477638,0.621548,0.620919,s0,
|
|
112
|
+
6,4369.646973,6892.992188,3941.921143,-0.549863,0.591401,0.589827,s0,
|
|
113
|
+
7,4165.804688,7493.221191,3836.187988,-0.555789,0.589755,0.585908,s0,
|
|
114
|
+
8,4208.575195,7346.544434,3866.482666,-0.551731,0.591313,0.588169,s0,
|
|
115
|
+
9,4304.562012,7291.652344,3832.318359,-0.54776,0.591878,0.591304,s0,
|
|
116
|
+
10,4933.333496,7794.199707,4074.931396,-0.288181,0.677194,0.677023,s0,
|
|
117
|
+
11,5366.666504,7752.48877,4236.485352,0.008536,0.70971,0.704442,s0,
|
|
118
|
+
12,5580.591797,7660.100098,4274.107422,0.117352,0.701625,0.702816,s0,
|
|
119
|
+
13,5271.026855,7627.935059,4167.316895,-0.00829,0.70502,0.709139,s0,
|
|
120
|
+
14,4889.458496,7695.421387,3989.832764,-0.277032,0.678252,0.680608,s0,
|
|
121
|
+
15,4766.666504,7626.451172,3881.420654,-0.374359,0.651457,0.659894,s0,
|
|
122
|
+
16,5131.560059,7542.693848,4079.854492,-0.165985,0.696671,0.697925,s0,
|
|
123
|
+
17,5558.944824,7428.597168,4206.919434,0.15985,0.696944,0.699083,s0,
|
|
124
|
+
18,5484.875,7189.482422,4102.868164,0.096932,0.703771,0.703783,s0,
|
|
125
|
+
19,5082.417969,7336.589355,3938.072021,-0.188768,0.694541,0.694248,s0,
|
|
126
|
+
20,4741.85791,7320.865723,3794.413818,-0.389295,0.66264,0.639811,s0,
|
|
127
|
+
21,4155.880859,6211.439941,4021.229492,-0.597226,0.568197,0.566103,s0,
|
|
128
|
+
22,4453.20752,6563.895996,3973.348633,-0.53082,0.598931,0.599593,s0,
|
|
129
|
+
23,4829.61377,7028.814453,3769.177734,-0.391826,0.656069,0.645016,s0,
|
|
130
|
+
24,5169.915527,7074.88916,3914.19165,-0.154391,0.71185,0.685152,s0,
|
|
131
|
+
25,5629.67627,6939.234375,4031.990967,0.123412,0.699735,0.703662,s0,
|
|
132
|
+
26,4334.217773,6152.475098,3975.194824,-0.668995,0.525793,0.525344,s0,
|
|
133
|
+
27,4627.0,6549.01709,3916.161621,-0.481792,0.622573,0.616668,s0,
|
|
134
|
+
28,5170.319336,6892.950684,3836.450684,-0.179501,0.714548,0.676166,s0,
|
|
135
|
+
29,5666.666504,6805.611816,3951.428223,0.123837,0.699472,0.703849,s0,
|
|
136
|
+
30,4847.910156,6105.776855,3703.392334,-0.874025,0.343567,0.343573,s0,
|
|
137
|
+
31,5083.197754,6410.333496,3729.243896,-0.412542,0.648072,0.640165,s0,
|
|
138
|
+
32,5469.161621,6543.758301,3771.202881,-0.127653,0.683009,0.719168,s0,
|
|
139
|
+
33,5835.682129,6456.692871,3835.11377,0.117087,0.703436,0.701049,s0,
|
|
140
|
+
34,6154.575684,6342.816895,3890.825684,0.134377,0.700838,0.700549,s0,
|
|
141
|
+
35,6719.379395,6353.53125,3832.924805,-0.064413,0.707124,0.70415,s0,
|
|
142
|
+
36,7333.333496,6463.019531,3965.176758,-0.425788,0.640023,0.63959,s0,
|
|
143
|
+
37,7338.318359,6837.125,3929.377441,-0.411302,0.64827,0.640763,s0,
|
|
144
|
+
38,6651.006348,6675.917969,3872.208496,-0.023494,0.712361,0.70142,s0,
|
|
145
|
+
39,5842.095215,6777.003906,3936.412109,0.178295,0.694813,0.69674,s0,
|
|
146
|
+
40,5387.776855,6981.106934,3971.727295,0.005489,0.710293,0.703884,s0,
|
|
147
|
+
41,6108.849121,6845.797363,3991.269043,0.204016,0.69176,0.692709,s0,
|
|
148
|
+
42,7341.734375,7176.017578,4121.938965,-0.410172,0.646421,0.64335,s0,
|
|
149
|
+
43,6678.996582,6964.544434,4075.84082,0.006919,0.708279,0.705898,s0,
|
|
150
|
+
44,5766.666504,7153.339844,4145.367676,0.175414,0.696814,0.695471,s0,
|
|
151
|
+
45,5240.940918,7509.343262,4119.555176,-0.02633,0.721204,0.692222,s0,
|
|
152
|
+
46,5354.41748,7590.835449,4186.582031,0.011965,0.711582,0.702501,s0,
|
|
153
|
+
47,6340.872559,7322.916504,4241.699707,0.156691,0.697761,0.698983,s0,
|
|
154
|
+
48,6373.439453,7184.816406,4193.568848,0.14377,0.700588,0.698932,s0,
|
|
155
|
+
49,7201.859863,7272.037598,4206.691406,-0.344239,0.67125,0.656447,s0,
|
|
156
|
+
50,7133.333496,7385.302734,4257.14209,-0.298244,0.675882,0.673969,s0,
|
|
157
|
+
51,7613.658203,7834.421387,4143.102539,-0.540313,0.594642,0.595368,s0,
|
|
158
|
+
52,7679.076172,7819.037109,4092.387939,-0.541279,0.594511,0.594621,s0,
|
|
159
|
+
53,8024.774902,8128.404297,4077.896484,-0.583905,0.577273,0.570799,s0,
|
|
160
|
+
54,8141.630371,7783.667969,4165.033203,-0.567008,0.578609,0.586271,s0,
|
|
161
|
+
55,7717.412109,7507.744629,4036.983887,-0.532065,0.598917,0.598503,s0,
|
|
162
|
+
56,7804.150879,7332.231934,3976.100586,-0.54076,0.597128,0.592467,s0,
|
|
163
|
+
57,8133.333496,7441.529785,4199.084961,-0.556094,0.587788,0.587592,s0,
|
|
164
|
+
58,8189.136719,7257.324219,4246.875977,-0.546227,0.588379,0.596193,s0,
|
|
165
|
+
59,7529.524902,6976.98291,3967.356445,-0.487609,0.617649,0.617047,s0,
|
|
166
|
+
60,7041.063965,6741.75,3897.362061,-0.264285,0.687459,0.676427,s0,
|
|
167
|
+
61,8087.59375,6839.742188,4256.692871,-0.556886,0.587267,0.587363,s0,
|
|
168
|
+
62,8372.725586,6661.807129,4361.192871,-0.53516,0.591715,0.602891,s0,
|
|
169
|
+
63,4848.871582,5746.206543,3662.156006,-0.804792,-0.419653,-0.419762,s0,
|
|
170
|
+
64,4982.907715,5522.692871,3666.685791,-0.619292,-0.555684,-0.554701,s0,
|
|
171
|
+
65,6833.333496,2338.594727,4247.726563,-0.321716,-0.679558,-0.659318,s0,
|
|
172
|
+
66,7115.095215,2228.187988,4258.949707,-0.164592,-0.69549,-0.69943,s0,
|
|
173
|
+
67,7417.747559,2182.516846,4271.478516,0.052986,-0.707436,-0.704788,s0,
|
|
174
|
+
68,7839.103027,1866.064819,4315.638184,0.177564,-0.693867,-0.697868,s0,
|
|
175
|
+
69,7331.529297,1840.745728,4290.415039,-0.043938,-0.707338,-0.705509,s0,
|
|
176
|
+
70,6792.574707,1835.49646,4274.036621,-0.364239,-0.668887,-0.648013,s0,
|
|
177
|
+
71,6558.556152,1818.588501,4268.064941,-0.482553,-0.61979,-0.618873,s0,
|
|
178
|
+
72,7076.938965,1525.454468,4298.616211,-0.2157,-0.690448,-0.690475,s0,
|
|
179
|
+
73,6333.333496,1655.266235,4252.485352,-0.582786,-0.576819,-0.572399,s0,
|
|
180
|
+
74,6433.333496,1944.069458,4251.100586,-0.507668,-0.614531,-0.603842,s0,
|
|
181
|
+
75,6582.520996,2156.051025,4253.62793,-0.447471,-0.640783,-0.623833,s0,
|
|
182
|
+
76,6842.494629,1604.805542,4287.23291,-0.322784,-0.671236,-0.667272,s0,
|
|
183
|
+
77,6942.468262,1946.295288,4271.891602,-0.290952,-0.679271,-0.673749,s0,
|
|
184
|
+
78,2077.090576,2585.751709,3570.624268,-0.589764,-0.566201,-0.575842,s0,
|
|
185
|
+
79,2273.041748,2485.767334,3463.506104,-0.582227,-0.576076,-0.573715,s0,
|
|
186
|
+
80,2579.394531,2387.856445,3276.770508,-0.493023,-0.622792,-0.607502,s0,
|
|
187
|
+
81,2604.206299,3397.790283,3619.575439,-0.428365,-0.605297,-0.670909,s0,
|
|
188
|
+
82,2847.18457,3370.218018,3529.411621,-0.294692,-0.683219,-0.668108,s0,
|
|
189
|
+
83,3149.769775,3362.736328,3441.502197,-0.132866,-0.701726,-0.699948,s0,
|
|
190
|
+
84,2675.324463,3772.417969,3547.549072,-0.410514,-0.645256,-0.6443,s0,
|
|
191
|
+
85,2923.749756,3678.994141,3511.404297,-0.30169,-0.674455,-0.673864,s0,
|
|
192
|
+
86,3216.66626,3657.719971,3442.514404,-0.085884,-0.716171,-0.69262,s0,
|
|
193
|
+
87,2924.755859,3871.704834,3483.802734,-0.303105,-0.674477,-0.673208,s0,
|
|
194
|
+
88,2570.097656,4184.378418,3399.674316,-0.466875,-0.622452,-0.628157,s0,
|
|
195
|
+
0,4823.496582,5576.529297,3652.300781,0.999869,0.008587,0.013755,s2,
|
|
196
|
+
1,4509.626953,7308.625,3793.699219,0.999753,-0.022182,0.001305,s2,
|
|
197
|
+
2,6904.334473,6378.640625,3828.726563,0.999275,-0.036587,-0.01055,s2,
|
|
198
|
+
3,8717.802734,5402.157227,4271.78125,0.998713,0.032723,-0.038755,s2,
|
|
199
|
+
4,6485.54248,1681.78894,4266.632813,0.999788,0.019579,0.006339,s2,
|
|
200
|
+
5,7817.476074,2067.795166,4299.859375,0.999597,-0.027851,0.005413,s2,
|
|
201
|
+
6,2996.549805,3739.016357,3479.988281,0.999855,0.005633,0.016068,s2,
|
|
202
|
+
7,2894.746094,3217.271973,3423.878906,0.999659,0.025509,0.005496,s2,
|
|
203
|
+
8,2114.25,2670.076172,3580.832031,0.998758,0.045024,-0.021359,s2,
|
|
204
|
+
0,5000.0,100.0,100.0,,,,s1,0.0
|
|
205
|
+
0,4723.504395,4748.135254,3588.621094,,,,s2,0.0
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
feature_name,X,Y,Z,coord,val,gx,gy,gz,intrusion_contact_type,intrusion_anisotropy,intrusion_side
|
|
2
|
+
stratigraphy,0.00,0.00,2.00,,0,,,,,,
|
|
3
|
+
stratigraphy,0.00,5.00,2.00,,0,,,,,,
|
|
4
|
+
stratigraphy,5.00,0.00,2.00,,0,,,,,,
|
|
5
|
+
stratigraphy,5.00,5.00,2.00,,0,,,,,,
|
|
6
|
+
stratigraphy,2.50,2.50,2.00,,,0,0,1,,,
|
|
7
|
+
tabular_intrusion,3.04,2.12,2.18,,,,,,roof,stratigraphy,
|
|
8
|
+
tabular_intrusion,4.02,3.85,2.14,,,,,,roof,stratigraphy,TRUE
|
|
9
|
+
tabular_intrusion,2.02,3.16,2.02,,,,,,roof,stratigraphy,
|
|
10
|
+
tabular_intrusion,2.12,2.16,2.02,,,,,,roof,stratigraphy,
|
|
11
|
+
tabular_intrusion,1.14,3.50,2.04,,,,,,roof,,TRUE
|
|
12
|
+
tabular_intrusion,4.08,3.02,1.18,,,,,,floor,,TRUE
|
|
13
|
+
tabular_intrusion,1.14,1.06,1.16,,,,,,floor,,TRUE
|
|
14
|
+
tabular_intrusion,4.20,2.18,1.12,,,,,,floor,,TRUE
|
|
15
|
+
tabular_intrusion,1.02,3.02,1.12,,,,,,floor,,TRUE
|
|
16
|
+
tabular_intrusion_frame,2.00,2.00,2.00,0,,0,0,-1,,,
|
|
17
|
+
tabular_intrusion_frame,3.00,1.00,2.00,0,,0,0,-1,,,
|
|
18
|
+
tabular_intrusion_frame,1.00,3.00,2.00,0,,0,0,-1,,,
|
|
19
|
+
tabular_intrusion_frame,3.00,2.00,1.00,1,0,,,,,,
|
|
20
|
+
tabular_intrusion_frame,3.00,2.00,1.00,1,,0,1,0,,,
|
|
21
|
+
tabular_intrusion_frame,2.50,1.00,1.00,2,0,,,,,,
|
|
22
|
+
tabular_intrusion_frame,2.50,2.00,1.00,2,0,,,,,,
|
|
23
|
+
tabular_intrusion_frame,2.50,2.00,1.00,2,,1,0,0,,,
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from typing import Optional, Union, Dict
|
|
3
|
+
from LoopStructural.utils.exceptions import LoopValueError
|
|
4
|
+
from LoopStructural.utils import rng
|
|
5
|
+
from LoopStructural.datatypes._structured_grid import StructuredGrid
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
from LoopStructural.utils.logging import getLogger
|
|
9
|
+
|
|
10
|
+
logger = getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class BoundingBox:
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
origin: Optional[np.ndarray] = None,
|
|
17
|
+
maximum: Optional[np.ndarray] = None,
|
|
18
|
+
global_origin: Optional[np.ndarray] = None,
|
|
19
|
+
nsteps: Optional[np.ndarray] = None,
|
|
20
|
+
step_vector: Optional[np.ndarray] = None,
|
|
21
|
+
dimensions: Optional[int] = 3,
|
|
22
|
+
):
|
|
23
|
+
"""A bounding box for a model, defined by the
|
|
24
|
+
origin, maximum and number of steps in each direction
|
|
25
|
+
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
28
|
+
dimensions : int, optional
|
|
29
|
+
_description_, by default 3
|
|
30
|
+
origin : Optional[np.ndarray], optional
|
|
31
|
+
_description_, by default None
|
|
32
|
+
maximum : Optional[np.ndarray], optional
|
|
33
|
+
_description_, by default None
|
|
34
|
+
nsteps : Optional[np.ndarray], optional
|
|
35
|
+
_description_, by default None
|
|
36
|
+
"""
|
|
37
|
+
# reproject relative to the global origin, if origin is not provided.
|
|
38
|
+
# we want the local coordinates to start at 0
|
|
39
|
+
# otherwise uses provided origin. This is useful for having multiple bounding boxes rela
|
|
40
|
+
if global_origin is not None and origin is None:
|
|
41
|
+
origin = np.zeros(global_origin.shape)
|
|
42
|
+
if maximum is None and nsteps is not None and step_vector is not None:
|
|
43
|
+
maximum = origin + nsteps * step_vector
|
|
44
|
+
if origin is not None and global_origin is None:
|
|
45
|
+
global_origin = origin
|
|
46
|
+
self._origin = np.array(origin)
|
|
47
|
+
self._maximum = np.array(maximum)
|
|
48
|
+
self.dimensions = dimensions
|
|
49
|
+
if self.origin.shape:
|
|
50
|
+
if self.origin.shape[0] != self.dimensions:
|
|
51
|
+
logger.warning(
|
|
52
|
+
f"Origin has {self.origin.shape[0]} dimensions but bounding box has {self.dimensions}"
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
else:
|
|
56
|
+
self.dimensions = dimensions
|
|
57
|
+
self._global_origin = global_origin
|
|
58
|
+
self.nsteps = np.array([50, 50, 25])
|
|
59
|
+
if nsteps is not None:
|
|
60
|
+
self.nsteps = np.array(nsteps)
|
|
61
|
+
self.name_map = {
|
|
62
|
+
"xmin": (0, 0),
|
|
63
|
+
"ymin": (0, 1),
|
|
64
|
+
"zmin": (0, 2),
|
|
65
|
+
"xmax": (1, 0),
|
|
66
|
+
"ymax": (1, 1),
|
|
67
|
+
"zmax": (1, 2),
|
|
68
|
+
"lower": (0, 2),
|
|
69
|
+
"upper": (1, 2),
|
|
70
|
+
"minx": (0, 0),
|
|
71
|
+
"miny": (0, 1),
|
|
72
|
+
"minz": (0, 2),
|
|
73
|
+
"maxx": (1, 0),
|
|
74
|
+
"maxy": (1, 1),
|
|
75
|
+
"maxz": (1, 2),
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def global_origin(self):
|
|
80
|
+
return self._global_origin
|
|
81
|
+
|
|
82
|
+
@global_origin.setter
|
|
83
|
+
def global_origin(self, global_origin):
|
|
84
|
+
if self.dimensions != len(global_origin):
|
|
85
|
+
logger.warning(
|
|
86
|
+
f"Global origin has {len(global_origin)} dimensions but bounding box has {self.dimensions}"
|
|
87
|
+
)
|
|
88
|
+
self._global_origin = global_origin
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def global_maximum(self):
|
|
92
|
+
return self.maximum - self.origin + self._global_origin
|
|
93
|
+
|
|
94
|
+
@property
|
|
95
|
+
def valid(self):
|
|
96
|
+
return self._origin is not None and self._maximum is not None
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def origin(self) -> np.ndarray:
|
|
100
|
+
if self._origin is None:
|
|
101
|
+
raise LoopValueError("Origin is not set")
|
|
102
|
+
return self._origin
|
|
103
|
+
|
|
104
|
+
@origin.setter
|
|
105
|
+
def origin(self, origin: np.ndarray):
|
|
106
|
+
if self.dimensions != len(origin):
|
|
107
|
+
logger.warning(
|
|
108
|
+
f"Origin has {len(origin)} dimensions but bounding box has {self.dimensions}"
|
|
109
|
+
)
|
|
110
|
+
self._origin = origin
|
|
111
|
+
|
|
112
|
+
@property
|
|
113
|
+
def maximum(self) -> np.ndarray:
|
|
114
|
+
if self._maximum is None:
|
|
115
|
+
raise LoopValueError("Maximum is not set")
|
|
116
|
+
return self._maximum
|
|
117
|
+
|
|
118
|
+
@maximum.setter
|
|
119
|
+
def maximum(self, maximum: np.ndarray):
|
|
120
|
+
self._maximum = maximum
|
|
121
|
+
|
|
122
|
+
@property
|
|
123
|
+
def nelements(self):
|
|
124
|
+
return self.nsteps.prod()
|
|
125
|
+
|
|
126
|
+
@property
|
|
127
|
+
def volume(self):
|
|
128
|
+
return np.prod(self.maximum - self.origin)
|
|
129
|
+
|
|
130
|
+
@property
|
|
131
|
+
def bb(self):
|
|
132
|
+
return np.array([self.origin, self.maximum])
|
|
133
|
+
|
|
134
|
+
@nelements.setter
|
|
135
|
+
def nelements(self, nelements: Union[int, float]):
|
|
136
|
+
"""Update the number of elements in the associated grid
|
|
137
|
+
This is for visualisation, not for the interpolation
|
|
138
|
+
When set it will update the nsteps/step vector for cubic
|
|
139
|
+
elements
|
|
140
|
+
|
|
141
|
+
Parameters
|
|
142
|
+
----------
|
|
143
|
+
nelements : int,float
|
|
144
|
+
The new number of elements
|
|
145
|
+
"""
|
|
146
|
+
box_vol = self.volume
|
|
147
|
+
ele_vol = box_vol / nelements
|
|
148
|
+
# calculate the step vector of a regular cube
|
|
149
|
+
step_vector = np.zeros(self.dimensions)
|
|
150
|
+
step_vector[:] = ele_vol ** (1.0 / 3.0)
|
|
151
|
+
# number of steps is the length of the box / step vector
|
|
152
|
+
nsteps = np.ceil((self.maximum - self.origin) / step_vector).astype(int)
|
|
153
|
+
self.nsteps = nsteps
|
|
154
|
+
|
|
155
|
+
@property
|
|
156
|
+
def corners(self) -> np.ndarray:
|
|
157
|
+
"""Returns the corners of the bounding box in local coordinates
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
Returns
|
|
162
|
+
-------
|
|
163
|
+
np.ndarray
|
|
164
|
+
array of corners in clockwise order
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
return np.array(
|
|
168
|
+
[
|
|
169
|
+
self.origin.tolist(),
|
|
170
|
+
[self.maximum[0], self.origin[1], self.origin[2]],
|
|
171
|
+
[self.maximum[0], self.maximum[1], self.origin[2]],
|
|
172
|
+
[self.origin[0], self.maximum[1], self.origin[2]],
|
|
173
|
+
[self.origin[0], self.origin[1], self.maximum[2]],
|
|
174
|
+
[self.maximum[0], self.origin[1], self.maximum[2]],
|
|
175
|
+
self.maximum.tolist(),
|
|
176
|
+
[self.origin[0], self.maximum[1], self.maximum[2]],
|
|
177
|
+
]
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
@property
|
|
181
|
+
def corners_global(self) -> np.ndarray:
|
|
182
|
+
"""Returns the corners of the bounding box
|
|
183
|
+
in the original space
|
|
184
|
+
|
|
185
|
+
Returns
|
|
186
|
+
-------
|
|
187
|
+
np.ndarray
|
|
188
|
+
corners of the bounding box
|
|
189
|
+
"""
|
|
190
|
+
return np.array(
|
|
191
|
+
[
|
|
192
|
+
self.global_origin.tolist(),
|
|
193
|
+
[self.global_maximum[0], self.global_origin[1], self.global_origin[2]],
|
|
194
|
+
[self.global_maximum[0], self.global_maximum[1], self.global_origin[2]],
|
|
195
|
+
[self.global_origin[0], self.global_maximum[1], self.global_origin[2]],
|
|
196
|
+
[self.global_origin[0], self.global_origin[1], self.global_maximum[2]],
|
|
197
|
+
[self.global_maximum[0], self.global_origin[1], self.global_maximum[2]],
|
|
198
|
+
self.global_maximum.tolist(),
|
|
199
|
+
[self.global_origin[0], self.global_maximum[1], self.global_maximum[2]],
|
|
200
|
+
]
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
@property
|
|
204
|
+
def step_vector(self):
|
|
205
|
+
return (self.maximum - self.origin) / self.nsteps
|
|
206
|
+
|
|
207
|
+
@property
|
|
208
|
+
def length(self):
|
|
209
|
+
return self.maximum - self.origin
|
|
210
|
+
|
|
211
|
+
def fit(self, locations: np.ndarray, local_coordinate: bool = False) -> BoundingBox:
|
|
212
|
+
"""Initialise the bounding box from a set of points.
|
|
213
|
+
|
|
214
|
+
Parameters
|
|
215
|
+
----------
|
|
216
|
+
locations : np.ndarray
|
|
217
|
+
xyz locations of the points to fit the bbox
|
|
218
|
+
local_coordinate : bool, optional
|
|
219
|
+
whether to set the origin to [0,0,0], by default False
|
|
220
|
+
|
|
221
|
+
Returns
|
|
222
|
+
-------
|
|
223
|
+
BoundingBox
|
|
224
|
+
A reference to the bounding box object, note this is not a new bounding box
|
|
225
|
+
it updates the current one in place.
|
|
226
|
+
|
|
227
|
+
Raises
|
|
228
|
+
------
|
|
229
|
+
LoopValueError
|
|
230
|
+
_description_
|
|
231
|
+
"""
|
|
232
|
+
if locations.shape[1] != self.dimensions:
|
|
233
|
+
raise LoopValueError(
|
|
234
|
+
f"locations array is {locations.shape[1]}D but bounding box is {self.dimensions}"
|
|
235
|
+
)
|
|
236
|
+
origin = locations.min(axis=0)
|
|
237
|
+
maximum = locations.max(axis=0)
|
|
238
|
+
if local_coordinate:
|
|
239
|
+
self.global_origin = origin
|
|
240
|
+
self.origin = np.zeros(3)
|
|
241
|
+
self.maximum = maximum - origin
|
|
242
|
+
else:
|
|
243
|
+
self.origin = origin
|
|
244
|
+
self.maximum = maximum
|
|
245
|
+
self.global_origin = np.zeros(3)
|
|
246
|
+
return self
|
|
247
|
+
|
|
248
|
+
def with_buffer(self, buffer: float = 0.2) -> BoundingBox:
|
|
249
|
+
"""Create a new bounding box with a buffer around the existing bounding box
|
|
250
|
+
|
|
251
|
+
Parameters
|
|
252
|
+
----------
|
|
253
|
+
buffer : float, optional
|
|
254
|
+
percentage to expand the dimensions by, by default 0.2
|
|
255
|
+
|
|
256
|
+
Returns
|
|
257
|
+
-------
|
|
258
|
+
BoundingBox
|
|
259
|
+
The new bounding box object.
|
|
260
|
+
|
|
261
|
+
Raises
|
|
262
|
+
------
|
|
263
|
+
LoopValueError
|
|
264
|
+
if the current bounding box is invalid
|
|
265
|
+
"""
|
|
266
|
+
if self.origin is None or self.maximum is None:
|
|
267
|
+
raise LoopValueError("Cannot create bounding box with buffer, no origin or maximum")
|
|
268
|
+
# local coordinates, rescale into the original bounding boxes global coordinates
|
|
269
|
+
origin = self.origin - buffer * (self.maximum - self.origin)
|
|
270
|
+
maximum = self.maximum + buffer * (self.maximum - self.origin)
|
|
271
|
+
return BoundingBox(
|
|
272
|
+
origin=origin, maximum=maximum, global_origin=self.global_origin + origin
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
def get_value(self, name):
|
|
276
|
+
ix, iy = self.name_map.get(name, (-1, -1))
|
|
277
|
+
if ix == -1 and iy == -1:
|
|
278
|
+
raise LoopValueError(f"{name} is not a valid bounding box name")
|
|
279
|
+
if iy == -1:
|
|
280
|
+
return self.origin[ix]
|
|
281
|
+
|
|
282
|
+
return self.bb[ix,]
|
|
283
|
+
|
|
284
|
+
def __getitem__(self, name):
|
|
285
|
+
if isinstance(name, str):
|
|
286
|
+
return self.get_value(name)
|
|
287
|
+
elif isinstance(name, tuple):
|
|
288
|
+
return self.origin
|
|
289
|
+
return self.get_value(name)
|
|
290
|
+
|
|
291
|
+
def is_inside(self, xyz):
|
|
292
|
+
xyz = np.array(xyz)
|
|
293
|
+
if len(xyz.shape) == 1:
|
|
294
|
+
xyz = xyz.reshape((1, -1))
|
|
295
|
+
if xyz.shape[1] != 3:
|
|
296
|
+
raise LoopValueError(
|
|
297
|
+
f"locations array is {xyz.shape[1]}D but bounding box is {self.dimensions}"
|
|
298
|
+
)
|
|
299
|
+
inside = np.ones(xyz.shape[0], dtype=bool)
|
|
300
|
+
inside = np.logical_and(inside, xyz[:, 0] > self.origin[0])
|
|
301
|
+
inside = np.logical_and(inside, xyz[:, 0] < self.maximum[0])
|
|
302
|
+
inside = np.logical_and(inside, xyz[:, 1] > self.origin[1])
|
|
303
|
+
inside = np.logical_and(inside, xyz[:, 1] < self.maximum[1])
|
|
304
|
+
inside = np.logical_and(inside, xyz[:, 2] > self.origin[2])
|
|
305
|
+
inside = np.logical_and(inside, xyz[:, 2] < self.maximum[2])
|
|
306
|
+
return inside
|
|
307
|
+
|
|
308
|
+
def regular_grid(
|
|
309
|
+
self,
|
|
310
|
+
nsteps: Optional[Union[list, np.ndarray]] = None,
|
|
311
|
+
shuffle: bool = False,
|
|
312
|
+
order: str = "C",
|
|
313
|
+
local: bool = True,
|
|
314
|
+
) -> np.ndarray:
|
|
315
|
+
"""Get the grid of points from the bounding box
|
|
316
|
+
|
|
317
|
+
Parameters
|
|
318
|
+
----------
|
|
319
|
+
nsteps : Optional[Union[list, np.ndarray]], optional
|
|
320
|
+
number of steps, by default None uses self.nsteps
|
|
321
|
+
shuffle : bool, optional
|
|
322
|
+
Whether to return points in order or random, by default False
|
|
323
|
+
order : str, optional
|
|
324
|
+
when flattening using numpy "C" or "F", by default "C"
|
|
325
|
+
local : bool, optional
|
|
326
|
+
Whether to return the points in the local coordinate system of global
|
|
327
|
+
, by default True
|
|
328
|
+
|
|
329
|
+
Returns
|
|
330
|
+
-------
|
|
331
|
+
np.ndarray
|
|
332
|
+
numpy array N,3 of the points
|
|
333
|
+
"""
|
|
334
|
+
|
|
335
|
+
if nsteps is None:
|
|
336
|
+
nsteps = self.nsteps
|
|
337
|
+
coordinates = [
|
|
338
|
+
np.linspace(self.origin[i], self.maximum[i], nsteps[i]) for i in range(self.dimensions)
|
|
339
|
+
]
|
|
340
|
+
|
|
341
|
+
if not local:
|
|
342
|
+
coordinates = [
|
|
343
|
+
np.linspace(self.global_origin[i], self.global_maximum[i], nsteps[i])
|
|
344
|
+
for i in range(self.dimensions)
|
|
345
|
+
]
|
|
346
|
+
coordinate_grid = np.meshgrid(*coordinates, indexing="ij")
|
|
347
|
+
locs = np.array([coord.flatten(order=order) for coord in coordinate_grid]).T
|
|
348
|
+
|
|
349
|
+
if shuffle:
|
|
350
|
+
# logger.info("Shuffling points")
|
|
351
|
+
rng.shuffle(locs)
|
|
352
|
+
return locs
|
|
353
|
+
|
|
354
|
+
def cell_centers(self, order: str = "F") -> np.ndarray:
|
|
355
|
+
"""Get the cell centers of a regular grid
|
|
356
|
+
|
|
357
|
+
Parameters
|
|
358
|
+
----------
|
|
359
|
+
order : str, optional
|
|
360
|
+
order of the grid, by default "C"
|
|
361
|
+
|
|
362
|
+
Returns
|
|
363
|
+
-------
|
|
364
|
+
np.ndarray
|
|
365
|
+
array of cell centers
|
|
366
|
+
"""
|
|
367
|
+
locs = self.regular_grid(order=order, nsteps=self.nsteps - 1)
|
|
368
|
+
|
|
369
|
+
return locs + 0.5 * self.step_vector
|
|
370
|
+
|
|
371
|
+
def to_dict(self) -> dict:
|
|
372
|
+
"""Export the defining characteristics of the bounding
|
|
373
|
+
box to a dictionary for json serialisation
|
|
374
|
+
|
|
375
|
+
Returns
|
|
376
|
+
-------
|
|
377
|
+
dict
|
|
378
|
+
dictionary with origin, maximum and nsteps
|
|
379
|
+
"""
|
|
380
|
+
return {
|
|
381
|
+
"origin": self.origin.tolist(),
|
|
382
|
+
"maximum": self.maximum.tolist(),
|
|
383
|
+
"nsteps": self.nsteps.tolist(),
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
def vtk(self):
|
|
387
|
+
"""Export the model as a pyvista RectilinearGrid
|
|
388
|
+
|
|
389
|
+
Returns
|
|
390
|
+
-------
|
|
391
|
+
pv.RectilinearGrid
|
|
392
|
+
a pyvista grid object
|
|
393
|
+
|
|
394
|
+
Raises
|
|
395
|
+
------
|
|
396
|
+
ImportError
|
|
397
|
+
If pyvista is not installed raise import error
|
|
398
|
+
"""
|
|
399
|
+
try:
|
|
400
|
+
import pyvista as pv
|
|
401
|
+
except ImportError:
|
|
402
|
+
raise ImportError("pyvista is required for vtk support")
|
|
403
|
+
x = np.linspace(self.global_origin[0], self.global_maximum[0], self.nsteps[0])
|
|
404
|
+
y = np.linspace(self.global_origin[1], self.global_maximum[1], self.nsteps[1])
|
|
405
|
+
z = np.linspace(self.global_origin[2], self.global_maximum[2], self.nsteps[2])
|
|
406
|
+
return pv.RectilinearGrid(
|
|
407
|
+
x,
|
|
408
|
+
y,
|
|
409
|
+
z,
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
def structured_grid(
|
|
413
|
+
self, cell_data: Dict[str, np.ndarray] = {}, vertex_data={}, name: str = "bounding_box"
|
|
414
|
+
):
|
|
415
|
+
return StructuredGrid(
|
|
416
|
+
origin=self.global_origin,
|
|
417
|
+
step_vector=self.step_vector,
|
|
418
|
+
nsteps=self.nsteps,
|
|
419
|
+
cell_properties=cell_data,
|
|
420
|
+
properties=vertex_data,
|
|
421
|
+
name=name,
|
|
422
|
+
)
|