-
Notifications
You must be signed in to change notification settings - Fork 3
/
gebpy_app.py
7117 lines (6858 loc) · 405 KB
/
gebpy_app.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
#!/usr/bin/env python
# -*-coding: utf-8 -*-
# ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- -
# Name: gebpy_app.py
# Author: Maximilian A. Beeskow
# Version: 1.0
# Date: 01.02.2024
# License: GPL v3.0
# ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- -
## MODULES
# external
from datetime import datetime
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog
import collections
import numpy as np
import random as rd
import matplotlib.pyplot as plt
from modules.geophysics import Elasticity as elast
import matplotlib as mpl
from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2Tk)
import matplotlib.patches as mpatches
from matplotlib.figure import Figure
# internal
from modules.gui_elements import SimpleElements
from modules.oxides import Oxides
from modules.carbonates import Carbonates, CarbonateRocks
from modules.igneous import Plutonic, Volcanic, UltraMafic, Pyroclastic
from modules.sulfides import Sulfides
from modules.sulfates import Sulfates
from modules.halides import Halides
from modules.phospides import Phospides
from modules.phosphates import Phosphates
from modules.silicates import Phyllosilicates, Tectosilicates, Inosilicates, Nesosilicates, Sorosilicates, \
Cyclosilicates
from modules.organics import Organics
from modules.fluids import Water
from modules.siliciclastics import SiliciclasticRocks, Geophysics
from modules.ore import OreRocks
from modules.metamorphics import GranuliteFacies, GreenschistFacies, AmphiboliteFacies
from modules.exploration import ExplorationInterface
# Sequence Stratigraphy
from modules.series import Muschelkalk, Zechstein, Buntsandstein
from modules.petrophysics import SeismicVelocities
## GUI
class GebPyGUI(tk.Frame):
#
def __init__(self, parent, var_screen_width, var_screen_height):
tk.Frame.__init__(self, parent)
#
var_screen_width = var_screen_width
var_screen_height = var_screen_height
#
### Container
self.gui_elements = {}
self.gui_elements_sub = {}
gui_elements = ["Frame", "Label", "Button", "Radiobutton", "Checkbox", "Entry", "Option Menu", "Canvas",
"Figure", "Axis"]
gui_priority = ["Static", "Temporary", "Rockbuilder Static", "Rockbuilder Temporary", "Element Concentration",
"Compound Concentration"]
gui_subwindows = ["Trace Elements", "Mineralogy", "Mineral Physics", "Mineral Chemistry", "Synthetic LA-ICP-MS"]
#
for subwindow in gui_subwindows:
self.gui_elements_sub[subwindow] = {}
for priority in gui_priority:
self.gui_elements_sub[subwindow][priority] = {}
for gui_element in gui_elements:
if gui_element not in ["Canvas", "Figure", "Axis"]:
self.gui_elements_sub[subwindow][priority][gui_element] = []
else:
self.gui_elements_sub[subwindow][priority][gui_element] = {}
#
for priority in gui_priority:
self.gui_elements[priority] = {}
for gui_element in gui_elements:
if gui_element not in ["Canvas", "Figure", "Axis"]:
self.gui_elements[priority][gui_element] = []
else:
self.gui_elements[priority][gui_element] = {}
#
### Colors
self.colors_gebpy = {
"Background": "#EFEFEF", "Navigation": "#252422", "Accent": "#EB5E28", "Option": "#CCC5B9",
"White": "#FFFFFF", "Black": "#000000", "Accent Blue": "#118AB2"}
#
### Variables
self.gui_variables = {}
for gui_element in gui_elements:
self.gui_variables[gui_element] = {}
#
self.last_rb_analysis_mineral = tk.IntVar()
self.last_rb_analysis_mineral.set(42)
self.last_rb_diagram_mineral = tk.IntVar()
self.last_rb_diagram_mineral.set(42)
#
self.last_rb_analysis_rock = tk.IntVar()
self.last_rb_analysis_rock.set(42)
self.last_rb_diagram_rock = tk.IntVar()
self.last_rb_diagram_rock.set(42)
#
self.last_rb_setting = {"Mineralogy": {}, "Petrology": {}, "Stratigraphy": {}}
# Mineralogy
self.last_rb_setting["Mineralogy"]["General Mode"] = tk.IntVar()
self.last_rb_setting["Mineralogy"]["General Mode"].set(42)
self.last_rb_setting["Mineralogy"]["Mineral Physics"] = tk.IntVar()
self.last_rb_setting["Mineralogy"]["Mineral Physics"].set(42)
self.last_rb_setting["Mineralogy"]["Mineral Chemistry"] = tk.IntVar()
self.last_rb_setting["Mineralogy"]["Mineral Chemistry"].set(42)
self.last_rb_setting["Mineralogy"]["Composition Elements"] = tk.IntVar()
self.last_rb_setting["Mineralogy"]["Composition Elements"].set(42)
# Petrology
self.last_rb_setting["Petrology"]["General Mode"] = tk.IntVar()
self.last_rb_setting["Petrology"]["General Mode"].set(42)
self.last_rb_setting["Petrology"]["Rock Physics"] = tk.IntVar()
self.last_rb_setting["Petrology"]["Rock Physics"].set(42)
self.last_rb_setting["Petrology"]["Rock Chemistry"] = tk.IntVar()
self.last_rb_setting["Petrology"]["Rock Chemistry"].set(42)
self.last_rb_setting["Petrology"]["Composition Minerals"] = tk.IntVar()
self.last_rb_setting["Petrology"]["Composition Minerals"].set(42)
self.last_rb_setting["Petrology"]["Composition Elements"] = tk.IntVar()
self.last_rb_setting["Petrology"]["Composition Elements"].set(42)
# Stratigraphy
#
### General Settings
self.parent = parent
self.parent.title("GebPy")
#
var_geometry = ""
var_window_width = int(round(0.95*int(var_screen_width), -2))
if var_window_width > 1800:
var_window_width = 1800
var_geometry += str(var_window_width)
var_geometry += "x"
var_window_height = int(round(0.85*int(var_screen_height), -2))
if var_window_height > 975:
var_window_height = 975
var_geometry += str(var_window_height)
var_geometry += "+0+0"
self.parent.geometry(var_geometry)
#self.parent.geometry("1800x975+0+0")
self.parent.resizable(False, False)
self.parent["bg"] = self.colors_gebpy["Background"]
#
## Geometry and Layout
# window_width = 1800
# window_heigth = 975
# #
# row_min = 15
# n_rows = int(window_heigth / row_min)
# #
# column_min = 10
# n_columns = int(window_width / column_min)
#
window_width = var_window_width
window_heigth = var_window_height
#
row_min = 15
n_rows = int(window_heigth/row_min)
#
column_min = 10
n_columns = int(window_width/column_min)
#
self.n_rows = n_rows
self.n_columns = n_columns
#
for x in range(n_columns):
tk.Grid.columnconfigure(self.parent, x, weight=1)
for y in range(n_rows):
tk.Grid.rowconfigure(self.parent, y, weight=1)
#
# Rows
for i in range(0, n_rows):
self.parent.grid_rowconfigure(i, minsize=row_min)
# Columns
for i in range(0, n_columns):
self.parent.grid_columnconfigure(i, minsize=column_min)
#
## Navigation Bar
frm_navigation = SimpleElements(
parent=self.parent, row_id=0, column_id=0, n_rows=100, n_columns=32, bg=self.colors_gebpy["Navigation"],
fg=self.colors_gebpy["Navigation"]).create_frame()
frm_accent = SimpleElements(
parent=self.parent, row_id=0, column_id=33, n_rows=100, n_columns=1, bg=self.colors_gebpy["Accent"],
fg=self.colors_gebpy["Accent"]).create_frame()
#
self.gui_elements["Static"]["Frame"].extend([frm_navigation, frm_accent])
#
## Logo
try:
gebpy_logo = tk.PhotoImage(file="documents/readme_images/GebPy_Logo_new.png")
gebpy_logo = gebpy_logo.subsample(5, 5)
img = tk.Label(self.parent, image=gebpy_logo, bg=self.colors_gebpy["Navigation"])
img.image = gebpy_logo
img.grid(row=0, column=0, rowspan=5, columnspan=32, sticky="nesw")
except:
print("Image not found!")
#
### Menu Bar
menubar = tk.Menu(self.parent)
self.parent.config(menu=menubar)
## Project
project_menu = tk.Menu(menubar, tearoff=0)
#
project_menu.add_command(
label="New", command=self.restart_gebpy)
project_menu.add_separator()
project_menu.add_command(
label="Exit", command=self.parent.destroy)
#
menubar.add_cascade(
label="Project",
menu=project_menu)
#
## Mineralogy
mineralogy_menu = tk.Menu(menubar, tearoff=0)
#
sub_mineral_groups = tk.Menu(mineralogy_menu, tearoff=0)
mineral_groups = [
"Oxides", "Sulfides", "Sulfates", "Halides", "Tectosilicates", "Nesosilicates", "Sorosilicates",
"Cyclosilicates", "Inosilicates", "Phyllosilicates", "Carbonates", "Phosphates", "Phospides",
"Miscellaneous"]
mineral_groups.sort()
for mineral_group in mineral_groups:
if mineral_group == "Oxides":
sub_oxides = tk.Menu(sub_mineral_groups, tearoff=0)
self.oxide_minerals = [
"Quartz", "Magnetite", "Hematite", "Al-Spinel", "Ilmenite", "Cassiterite", "Chromite", "Corundum",
"Rutile", "Pyrolusite", "Magnesiochromite", "Zincochromite", "Cr-Spinel", "Cuprospinel",
"Jacobsite", "Magnesioferrite", "Trevorite", "Franklinite", "Ulvospinel", "Fe-Spinel", "Uraninite",
"Litharge", "Massicot", "Minium", "Plattnerite", "Scrutinyite", "Zincite", "Columbite", "Tantalite",
"Coltan", "Crocoite", "Wulfenite", "Goethite", "Wolframite", "Huebnerite", "Ferberite", "Boehmite",
"Gibbsite", "Au(III)-Oxide", "Brucite", "Valentinite", "Senarmontite", "Ferberite-Huebnerite",
"Spinel", "Diaspore", "Cuprite", "Brookite", "Anatase", "Manganite", "Groutite", "Pyrophanite",
"Geikielite", "Claudetite", "Arsenolite", "Bismite", "Sphaerobismite", "Manganochromite",
"Nichromite", "Cochromite"]
self.oxide_minerals.sort()
for mineral in self.oxide_minerals:
sub_oxides.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Oxides",
menu=sub_oxides)
elif mineral_group == "Carbonates":
sub_carbonates = tk.Menu(sub_mineral_groups, tearoff=0)
self.carbonate_minerals = [
"Calcite", "Dolomite", "Magnesite", "Siderite", "Rhodochrosite", "Aragonite", "Cerrusite",
"Ankerite", "Azurite", "Malachite", "Ikaite", "Smithsonite"]
self.carbonate_minerals.sort()
for mineral in self.carbonate_minerals:
sub_carbonates.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Carbonates",
menu=sub_carbonates)
elif mineral_group == "Sulfides":
sub_sulfides = tk.Menu(sub_mineral_groups, tearoff=0)
self.sulfide_minerals = [
"Pyrite", "Chalcopyrite", "Galena", "Acanthite", "Chalcocite", "Bornite", "Sphalerite",
"Pyrrhotite", "Millerite", "Pentlandite", "Covellite", "Cinnabar", "Realgar", "Orpiment",
"Stibnite", "Marcasite", "Molybdenite", "Fahlore", "Gallite", "Roquesite", "Lenaite", "Laforetite",
"Vaesite", "Cattierite", "Cobaltite", "Marmatite"]
self.sulfide_minerals.sort()
for mineral in self.sulfide_minerals:
sub_sulfides.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Sulfides",
menu=sub_sulfides)
elif mineral_group == "Sulfates":
sub_sulfates = tk.Menu(sub_mineral_groups, tearoff=0)
self.sulfate_minerals = [
"Barite", "Celestite", "Anglesite", "Anhydrite", "Hanksite", "Gypsum", "Alunite", "Jarosite",
"Chalcanthite", "Kieserite", "Scheelite", "Hexahydrite", "Kainite"]
self.sulfate_minerals.sort()
for mineral in self.sulfate_minerals:
sub_sulfates.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Sulfates",
menu=sub_sulfates)
elif mineral_group == "Halides":
sub_halides = tk.Menu(sub_mineral_groups, tearoff=0)
self.halide_minerals = ["Halite", "Fluorite", "Sylvite", "Carnallite"]
self.halide_minerals.sort()
for mineral in self.halide_minerals:
sub_halides.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Halides",
menu=sub_halides)
elif mineral_group == "Phosphates":
sub_phosphates = tk.Menu(sub_mineral_groups, tearoff=0)
self.phosphate_minerals = ["Apatite", "Fluoroapatite", "Hydroxyapatite", "Chloroapatite"]
self.phosphate_minerals.sort()
for mineral in self.phosphate_minerals:
sub_phosphates.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Phosphates",
menu=sub_phosphates)
elif mineral_group == "Phospides":
sub_phosphides = tk.Menu(sub_mineral_groups, tearoff=0)
self.phospide_minerals = ["Allabogdanite"]
self.phospide_minerals.sort()
for mineral in self.phospide_minerals:
sub_phosphides.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Phospides",
menu=sub_phosphides)
elif mineral_group == "Tectosilicates":
sub_tectosilicates = tk.Menu(sub_mineral_groups, tearoff=0)
self.tectosilicate_minerals = [
"Alkaline Feldspar", "Plagioclase", "Scapolite", "Danburite", "Nepheline", "Orthoclase"]
self.tectosilicate_minerals.sort()
for mineral in self.tectosilicate_minerals:
sub_tectosilicates.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Tectosilicates",
menu=sub_tectosilicates)
elif mineral_group == "Sorosilicates":
sub_sorosilicates = tk.Menu(sub_mineral_groups, tearoff=0)
self.sorosilicate_minerals = ["Epidote", "Zoisite", "Gehlenite"]
self.sorosilicate_minerals.sort()
for mineral in self.sorosilicate_minerals:
sub_sorosilicates.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Sorosilicates",
menu=sub_sorosilicates)
elif mineral_group == "Inosilicates":
sub_inosilicates = tk.Menu(sub_mineral_groups, tearoff=0)
self.inosilicate_minerals = [
"Enstatite", "Ferrosilite", "Diopside", "Jadeite", "Aegirine", "Spodumene", "Wollastonite",
"Tremolite", "Actinolite", "Glaucophane", "Augite", "Arfvedsonite", "Ca-Amphibole", "Na-Amphibole",
"Mg-Fe-Pyroxene", "Ca-Pyroxene", "Na-Pyroxene", "Donpeacorite", "Orthopyroxene", "Clinopyroxene"]
self.inosilicate_minerals.sort()
for mineral in self.inosilicate_minerals:
sub_inosilicates.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Inosilicates",
menu=sub_inosilicates)
elif mineral_group == "Nesosilicates":
sub_nesosilicates = tk.Menu(sub_mineral_groups, tearoff=0)
self.nesosilicate_minerals = [
"Zircon", "Titanite", "Thorite", "Andalusite", "Kyanite", "Sillimanite", "Topaz", "Staurolite",
"Fayalite", "Forsterite", "Tephroite", "Ca-Olivine", "Liebenbergite", "Olivine", "Pyrope",
"Almandine", "Grossular", "Anhadrite", "Uvarovite", "Al-Garnet", "Ca-Garnet"]
self.nesosilicate_minerals.sort()
for mineral in self.nesosilicate_minerals:
sub_nesosilicates.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Nesosilicates",
menu=sub_nesosilicates)
elif mineral_group == "Phyllosilicates":
sub_phyllosilicates = tk.Menu(sub_mineral_groups, tearoff=0)
self.phyllosilicate_minerals = [
"Illite", "Kaolinite", "Montmorillonite", "Chamosite", "Clinochlore", "Pennantite", "Nimite",
"Chlorite", "Vermiculite", "Annite", "Phlogopite", "Eastonite", "Siderophyllite", "Biotite",
"Muscovite", "Glauconite", "Nontronite", "Saponite", "Talc", "Chrysotile", "Antigorite",
"Pyrophyllite"]
self.phyllosilicate_minerals.sort()
for mineral in self.phyllosilicate_minerals:
sub_phyllosilicates.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Phyllosilicates",
menu=sub_phyllosilicates)
elif mineral_group == "Cyclosilicates":
sub_cyclosilicates = tk.Menu(sub_mineral_groups, tearoff=0)
self.cyclosilicate_minerals = [
"Beryl", "Benitoite", "Cordierite", "Sekaninaite", "Schorl", "Elbaite", "Liddicoatite"]
self.cyclosilicate_minerals.sort()
for mineral in self.cyclosilicate_minerals:
sub_cyclosilicates.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Cyclosilicates",
menu=sub_cyclosilicates)
elif mineral_group == "Miscellaneous":
sub_miscellaneous = tk.Menu(sub_mineral_groups, tearoff=0)
self.miscellaneous_minerals = ["Organic Matter"]
self.miscellaneous_minerals.sort()
for mineral in self.miscellaneous_minerals:
sub_miscellaneous.add_command(
label=mineral, command=lambda name=mineral: self.select_mineral(name))
#
sub_mineral_groups.add_cascade(
label="Miscellaneous",
menu=sub_miscellaneous)
else:
sub_mineral_groups.add_command(
label=mineral_group)
#
sub_special_groups = tk.Menu(mineralogy_menu, tearoff=0)
special_groups = [
"Spinel Group", "Hematite Group", "Rutile Group", "Periclase Group", "Scheelite Group"]
special_groups.sort()
for special_group in special_groups:
sub_special_groups.add_command(
label=special_group, command=lambda var_name=special_group: self.select_special_group(var_name))
#
sub_ore_minerals = tk.Menu(mineralogy_menu, tearoff=0)
ore_minerals = [
"Fe Ores", "Pb Ores", "Zn Ores", "Cu Ores", "Al Ores", "Sn Ores"]
ore_minerals.sort()
for ore_mineral in ore_minerals:
sub_ore_minerals.add_command(
label=ore_mineral)
#
mineralogy_menu.add_cascade(
label="Mineral Groups",
menu=sub_mineral_groups)
mineralogy_menu.add_cascade(
label="Special Groups",
menu=sub_special_groups)
mineralogy_menu.add_cascade(
label="Ore Minerals",
menu=sub_ore_minerals)
menubar.add_cascade(
label="Mineralogy",
menu=mineralogy_menu)
#
## Petrology
petrology_menu = tk.Menu(menubar, tearoff=0)
#
sub_rock_groups = tk.Menu(mineralogy_menu, tearoff=0)
rock_groups = [
"Sedimentary Rocks", "Igneous Rocks", "Metamorphic Rocks", "Evaporite Rocks", "Ore Rocks"]
rock_groups.sort()
for rock_group in rock_groups:
if rock_group == "Sedimentary Rocks":
sub_sedimentary = tk.Menu(petrology_menu, tearoff=0)
sedimentary_rocks = {
"Siliciclastic": ["Sandstone", "Shale", "Mudstone", "Conglomerate", "Greywacke (Huckenholz)",
"Siltstone"],
"Carbonate": ["Limestone", "Dolostone", "Marl"]}
sedimentary_rocks = collections.OrderedDict(sorted(sedimentary_rocks.items()))
i = 1
n = len(sedimentary_rocks)
for rock_group, rock_list in sedimentary_rocks.items():
rock_list.sort()
for rock in rock_list:
sub_sedimentary.add_command(
label=rock, command=lambda var_name=rock: self.select_rock(var_name))
if i < n:
sub_sedimentary.add_separator()
i += 1
#
sub_rock_groups.add_cascade(
label="Sedimentary Rocks",
menu=sub_sedimentary)
elif rock_group == "Igneous Rocks":
sub_igneous = tk.Menu(petrology_menu, tearoff=0)
igneous_rocks = {
"Plutonic": ["Granite (Streckeisen)", "Granodiorite (Streckeisen)", "Tonalite (Streckeisen)",
"Gabbro (Streckeisen)", "Diorite (Streckeisen)", "Monzonite (Streckeisen)",
"Syenite (Streckeisen)", "Granitoid (Streckeisen)", "Quarzolite (Streckeisen)",
"Foid-bearing Syenite (Streckeisen)", "Foid-bearing Monzonite (Streckeisen)",
"Foid-bearing Monzodiorite (Streckeisen)", "Foid-bearing Monzogabbro (Streckeisen)",
"Foid Monzosyenite (Streckeisen)", "Foid Monzodiorite (Streckeisen)",
"Foid Monzogabbro (Streckeisen)", "Foidolite (Streckeisen)", "Norite (Streckeisen)",
"Monzodiorite (Streckeisen)", "Monzogabbro (Streckeisen)"],
"Volcanic": ["Rhyolite (Streckeisen)", "Dacite (Streckeisen)", "Trachyte (Streckeisen)",
"Latite (Streckeisen)", "Andesite (Streckeisen)", "Basalt (Streckeisen)",
"Phonolite (Streckeisen)", "Tephrite (Streckeisen)", "Foidite (Streckeisen)",
"Foid-bearing Trachyte (Streckeisen)", "Foid-bearing Latite (Streckeisen)",
"Foid-bearing Andesite (Streckeisen)", "Foid-bearing Basalt (Streckeisen)",
"Basalt (Yoder & Tilley)"],
"Ultramafic": ["Orthopyroxenite", "Clinopyroxenite", "Dunite", "Harzburgite", "Wehrlite",
"Websterite", "Lherzolite", "Olivine-Websterite", "Olivine-Orthopyroxenite",
"Olivine-Clinopyroxenite", "Peridotite", "Pyroxenite"]}
#
igneous_rocks = collections.OrderedDict(sorted(igneous_rocks.items()))
i = 1
n = len(igneous_rocks)
for rock_group, rock_list in igneous_rocks.items():
rock_list.sort()
for rock in rock_list:
sub_igneous.add_command(
label=rock, command=lambda var_name=rock: self.select_rock(var_name))
if i < n:
sub_igneous.add_separator()
i += 1
#
sub_rock_groups.add_cascade(
label="Igneous Rocks",
menu=sub_igneous)
#
elif rock_group == "Ore Rocks":
sub_ore = tk.Menu(petrology_menu, tearoff=0)
ore_rocks = {
"Fe-ore": ["Itabirite", "Compact Hematite", "Friable Hematite", "Goethite Hematite",
"Al-rich Itabirite", "Compact Quartz Itabirite", "Friable Quartz Itabirite",
"Goethite Itabirite", "Banded Iron Formation"],
"Al-ore": ["Bauxite"]}
#
ore_rocks = collections.OrderedDict(sorted(ore_rocks.items()))
i = 1
n = len(ore_rocks)
for rock_group, rock_list in ore_rocks.items():
rock_list.sort()
for rock in rock_list:
sub_ore.add_command(
label=rock, command=lambda var_name=rock: self.select_rock(var_name))
if i < n:
sub_ore.add_separator()
i += 1
#
sub_rock_groups.add_cascade(
label="Ore Rocks",
menu=sub_ore)
#
elif rock_group == "Metamorphic Rocks":
sub_metamorphic = tk.Menu(petrology_menu, tearoff=0)
metamorphic_rocks = {
"Granulite-Facies": ["Felsic Granulite", "Mafic Granulite"],
"Greenschist-Facies": ["Basaltic Greenschist", "Ultramafic Greenschist", "Pelitic Greenschist"],
"Amphibolite-Facies": ["Ortho-Amphibolite"]}
#
metamorphic_rocks = collections.OrderedDict(sorted(metamorphic_rocks.items()))
i = 1
n = len(metamorphic_rocks)
for rock_group, rock_list in metamorphic_rocks.items():
rock_list.sort()
for rock in rock_list:
sub_metamorphic.add_command(
label=rock, command=lambda var_name=rock: self.select_rock(var_name))
if i < n:
sub_metamorphic.add_separator()
i += 1
#
sub_rock_groups.add_cascade(
label="Metamorphic Rocks",
menu=sub_metamorphic)
else:
sub_rock_groups.add_command(
label=rock_group)
#
petrology_menu.add_cascade(
label="Rock Groups",
menu=sub_rock_groups)
#
petrology_menu.add_separator()
petrology_menu.add_command(
label="Rock Comparison", command=self.rock_comparison)
petrology_menu.add_command(
label="Rock Builder", command=self.rock_builder)
#
menubar.add_cascade(
label="Petrology",
menu=petrology_menu)
#
## STRATIGRAPHY
stratigraphy_menu = tk.Menu(menubar, tearoff=0)
#
sub_permian = tk.Menu(stratigraphy_menu, tearoff=0)
permian_units = ["Zechstein", "Rotliegendes"]
for unit in permian_units:
sub_permian.add_command(label=unit, command=lambda var_unit=unit: self.real_sequences(var_unit))
#
sub_triassic = tk.Menu(stratigraphy_menu, tearoff=0)
triassic_units = ["Keuper", "Muschelkalk"]
for unit in triassic_units:
sub_triassic.add_command(label=unit, command=lambda var_unit=unit: self.real_sequences(var_unit))
#
sub_buntstandstein = tk.Menu(stratigraphy_menu, tearoff=0)
buntsandstein_units = ["Buntsandstein", "Upper Buntsandstein", "Medium Buntsandstein", "Lower Buntsandstein"]
for unit in buntsandstein_units:
sub_buntstandstein.add_command(label=unit, command=lambda var_unit=unit: self.real_sequences(var_unit))
if unit == "Buntsandstein":
sub_buntstandstein.add_separator()
#
# Real Sequences
stratigraphy_menu.add_cascade(
label="Triassic Units",
menu=sub_triassic)
stratigraphy_menu.add_cascade(
label="Permian Units",
menu=sub_permian)
#
sub_triassic.add_cascade(
label="Buntsandstein",
menu=sub_buntstandstein)
#
stratigraphy_menu.add_separator()
stratigraphy_menu.add_command(
label="Create Sequences")
#
menubar.add_cascade(
label="Stratigraphy",
menu=stratigraphy_menu)
## EXPLORATION
exploration_menu = tk.Menu(menubar, tearoff=0)
exploration_menu.add_command(
label="Borehole data", command=lambda mode="Borehole data": self.select_exploration(mode))
menubar.add_cascade(
label="Exploration",
menu=exploration_menu)
## DATABASE
database_menu = tk.Menu(menubar, tearoff=0)
database_menu.add_command(
label="Elements")
database_menu.add_command(
label="Minerals")
#
menubar.add_cascade(
label="Database",
menu=database_menu)
#
## Help
help_menu = tk.Menu(menubar, tearoff=0)
help_menu.add_command(
label="About")
menubar.add_cascade(
label="Help",
menu=help_menu)
#
## Buttons
btn_quit = SimpleElements(
parent=self.parent, row_id=n_rows - 3, column_id=16, n_rows=3, n_columns=15,
bg=self.colors_gebpy["Option"], fg=self.colors_gebpy["Navigation"]).create_button(
text="Quit GebPy", command=self.parent.quit)
btn_restart = SimpleElements(
parent=self.parent, row_id=n_rows - 3, column_id=1, n_rows=3, n_columns=15,
bg=self.colors_gebpy["Option"], fg=self.colors_gebpy["Navigation"]).create_button(
text="Restart GebPy", command=self.restart_gebpy)
#
#self.gui_elements["Static"]["Button"].extend([btn_quit, btn_restart])
####################################################################################################################
## EXPLORATION #####################################################################################################
####################################################################################################################
def select_exploration(self, mode):
ExplorationInterface(parent=self.parent).create_subwindow_borehole_data()
if mode == "Borehole data":
## Labels
lbl_title = SimpleElements(
parent=self.parent, row_id=5, column_id=0, n_rows=2, n_columns=32, bg=self.colors_gebpy["Accent"],
fg=self.colors_gebpy["Navigation"]).create_label(
text="Borehole data", font_option="sans 14 bold", relief=tk.FLAT)
lbl_datapoints = SimpleElements(
parent=self.parent, row_id=7, column_id=0, n_rows=2, n_columns=16, bg=self.colors_gebpy["Navigation"],
fg=self.colors_gebpy["Background"]).create_label(
text="Number of data points", font_option="sans 10 bold", relief=tk.FLAT)
lbl_units = SimpleElements(
parent=self.parent, row_id=9, column_id=0, n_rows=2, n_columns=16, bg=self.colors_gebpy["Navigation"],
fg=self.colors_gebpy["Background"]).create_label(
text="Number of units", font_option="sans 10 bold", relief=tk.FLAT)
#########################
## M i n e r a l o g y ##
#########################
#
def select_mineral(self, name):
## Cleaning
for category in ["Label", "Button", "Entry", "Radiobutton"]:
for gui_element in self.gui_elements["Static"][category]:
gui_element.grid_remove()
#
for key_01 in self.gui_elements_sub["Mineral Chemistry"].keys():
for key_02 in self.gui_elements_sub["Mineral Chemistry"][key_01].keys():
for gui_item in self.gui_elements_sub["Mineral Chemistry"][key_01][key_02]:
gui_item.grid_remove()
#
self.gui_elements_sub["Mineral Chemistry"][key_01][key_02].clear()
#
## Initialization
self.gui_variables["Entry"]["Number Samples"] = tk.IntVar()
self.gui_variables["Entry"]["Number Samples"].set(100)
self.gui_variables["Radiobutton"]["Analysis Mode"] = tk.IntVar()
self.gui_variables["Radiobutton"]["Analysis Mode"].set(0)
self.gui_variables["Radiobutton"]["Trace Elements"] = tk.IntVar()
self.gui_variables["Radiobutton"]["Trace Elements"].set(0)
self.gui_variables["Radiobutton"]["Oxidation State"] = tk.IntVar()
self.gui_variables["Radiobutton"]["Oxidation State"].set(0)
self.gui_variables["Radiobutton"]["Diagram Type Mineral"] = tk.IntVar()
self.gui_variables["Radiobutton"]["Diagram Type Mineral"].set(0)
self.gui_variables["Radiobutton"]["Diagram Type Elements"] = tk.IntVar()
self.gui_variables["Radiobutton"]["Diagram Type Elements"].set(0)
self.gui_variables["Option Menu"]["Trace Elements"] = tk.StringVar()
self.gui_variables["Option Menu"]["Trace Elements"].set("Select Trace Element")
self.gui_variables["Checkbox"]["Trace Elements"] = {}
self.gui_variables["Entry"]["Minimum"] = {}
self.gui_variables["Entry"]["Maximum"] = {}
self.gui_variables["Entry"]["Mean"] = {}
self.gui_variables["Entry"]["Error"] = {}
self.gui_variables["Entry"]["Trace Elements"] = {}
self.gui_variables["Entry"]["Trace Elements"]["Minimum"] = {}
self.gui_variables["Entry"]["Trace Elements"]["Maximum"] = {}
self.trace_elements_all = {"All": []}
categories_short = ["M", "V", "rho", "vP", "vS", "vP/vS", "K", "G", "E", "nu", "GR", "PE", "U"]
for category in categories_short:
self.gui_variables["Entry"]["Minimum"][category] = tk.StringVar()
self.gui_variables["Entry"]["Minimum"][category].set(0.0)
self.gui_variables["Entry"]["Maximum"][category] = tk.StringVar()
self.gui_variables["Entry"]["Maximum"][category].set(0.0)
self.gui_variables["Entry"]["Mean"][category] = tk.StringVar()
self.gui_variables["Entry"]["Mean"][category].set(0.0)
self.gui_variables["Entry"]["Error"][category] = tk.StringVar()
self.gui_variables["Entry"]["Error"][category].set(0.0)
self.btn_traces = None
self.subwindow_traces = False
#
## Labels
lbl_mineralogy = SimpleElements(
parent=self.parent, row_id=5, column_id=0, n_rows=2, n_columns=32, bg=self.colors_gebpy["Accent"],
fg=self.colors_gebpy["Navigation"]).create_label(
text="Mineralogy", font_option="sans 14 bold", relief=tk.FLAT)
lbl_name = SimpleElements(
parent=self.parent, row_id=7, column_id=0, n_rows=2, n_columns=32, bg=self.colors_gebpy["Navigation"],
fg=self.colors_gebpy["Background"]).create_label(
text=name, font_option="sans 12 bold", relief=tk.FLAT)
lbl_samples = SimpleElements(
parent=self.parent, row_id=9, column_id=0, n_rows=2, n_columns=16, bg=self.colors_gebpy["Navigation"],
fg=self.colors_gebpy["Background"]).create_label(
text="Number of Datapoints", font_option="sans 10 bold", relief=tk.FLAT)
lbl_traces = SimpleElements(
parent=self.parent, row_id=11, column_id=0, n_rows=6, n_columns=16, bg=self.colors_gebpy["Navigation"],
fg=self.colors_gebpy["Background"]).create_label(
text="Trace Elements", font_option="sans 10 bold", relief=tk.FLAT)
lbl_addsetup = SimpleElements(
parent=self.parent, row_id=31, column_id=0, n_rows=2, n_columns=32, bg=self.colors_gebpy["Accent"],
fg=self.colors_gebpy["Navigation"]).create_label(
text="Additional Settings", font_option="sans 14 bold", relief=tk.FLAT)
#
self.gui_elements["Static"]["Label"].extend(
[lbl_mineralogy, lbl_name, lbl_samples, lbl_traces, lbl_addsetup])
#
## Entries
entr_samples = SimpleElements(
parent=self.parent, row_id=9, column_id=16, n_rows=2, n_columns=15, bg=self.colors_gebpy["Background"],
fg=self.colors_gebpy["Navigation"]).create_entry(var_entr=self.gui_variables["Entry"]["Number Samples"])
#
self.gui_elements["Static"]["Entry"].extend([entr_samples])
#
## Radiobuttons
rb_trace_without = SimpleElements(
parent=self.parent, row_id=11, column_id=16, n_rows=2, n_columns=15, bg=self.colors_gebpy["Navigation"],
fg=self.colors_gebpy["Background"]).create_radiobutton(
text="Without Trace Elements", var_rb=self.gui_variables["Radiobutton"]["Trace Elements"], value_rb=0,
color_bg=self.colors_gebpy["Navigation"], command=lambda var_name=name: self.change_rb_traces(var_name))
self.gui_elements["Static"]["Radiobutton"].extend([rb_trace_without])
if name in ["Quartz", "Orthoclase"]:
rb_trace_with = SimpleElements(
parent=self.parent, row_id=13, column_id=16, n_rows=2, n_columns=15, bg=self.colors_gebpy["Navigation"],
fg=self.colors_gebpy["Background"]).create_radiobutton(
text="With Trace Elements", var_rb=self.gui_variables["Radiobutton"]["Trace Elements"], value_rb=1,
color_bg=self.colors_gebpy["Navigation"], command=lambda var_name=name: self.change_rb_traces(var_name))
self.gui_elements["Static"]["Radiobutton"].extend([rb_trace_with])
## Buttons
btn_generate_data = SimpleElements(
parent=self.parent, row_id=18, column_id=16, n_rows=2, n_columns=15,
bg=self.colors_gebpy["Option"], fg=self.colors_gebpy["Navigation"]).create_button(
text="Run Simulation", command=lambda var_name=name: self.run_simulation_mineralogy(var_name))
#
self.gui_elements["Static"]["Button"].append(btn_generate_data)
#
####################
## SPECIAL GROUPS ##################################################################################################
####################
#
def select_special_group(self, var_name):
## Mineral Data
#
if var_name == "Spinel Group":
mineral_names = np.sort(["Spinel", "Chihmingite", "Chromite", "Cochromite", "Coulsonite", "Cuprospinel",
"Dellagiustaite", "Franklinite", "Gahnite", "Galaxite", "Hercynite", "Jacobsite",
"Magnesiochromite", "Magnesiocoulsonite", "Magnesioferrite", "Magnetite",
"Manganochromite", "Nichromite", "Thermaerogenite", "Trevorite", "Vuorelainenite",
"Zincochromite"])
mineral_group = {}
#
for mineral in mineral_names:
try:
data_mineral = Oxides(mineral=mineral, data_type=True, traces_list=[]).generate_dataset(number=1)
mineral_group[mineral] = data_mineral
except:
pass
#
elif var_name == "Hematite Group":
mineral_names = np.sort(["Corundum", "Eskolaite", "Hematite", "Karelianite", "Tistarite"])
mineral_group = {}
#
for mineral in mineral_names:
try:
data_mineral = Oxides(mineral=mineral, data_type=True, traces_list=[]).generate_dataset(number=1)
mineral_group[mineral] = data_mineral
except:
pass
#
elif var_name == "Rutile Group":
mineral_names = np.sort(["Argutite", "Cassiterite", "Paratellurite", "Plattnerite", "Pyrolusite", "Rutile",
"Stishovite"])
mineral_group = {}
#
for mineral in mineral_names:
try:
data_mineral = Oxides(mineral=mineral, data_type=True, traces_list=[]).generate_dataset(number=1)
mineral_group[mineral] = data_mineral
except:
pass
#
elif var_name == "Periclase Group":
mineral_names = np.sort(["Bunsenite", "Manganosite", "Periclase", "Wuestite"])
mineral_group = {}
#
for mineral in mineral_names:
try:
data_mineral = Oxides(mineral=mineral, data_type=True, traces_list=[]).generate_dataset(number=1)
mineral_group[mineral] = data_mineral
except:
pass
#
elif var_name == "Scheelite Group":
mineral_names = np.sort(["Powellite", "Scheelite", "Stolzite", "Wulfenite"])
mineral_group = {}
#
for mineral in mineral_names:
try:
data_mineral = Oxides(mineral=mineral, data_type=True, traces_list=[]).generate_dataset(number=1)
mineral_group[mineral] = data_mineral
except:
pass
#
## TABLE
#
start_column = 35
list_categories = ["Mineral",
"M (kg/mol)", "V (\u00C5\u00B3/mol)", "rho (kg/m\u00B3)", "vP (m/s)", "vS (m/s)",
"K (GPa)", "G (GPa)", "E (GPa)", "nu (1)", "GR (API)", "PE (barns/e\u207B)"]
list_categories_short = ["Mineral", "M", "V", "rho", "vP", "vS", "K", "G", "E", "nu", "GR", "PE"]
list_minerals = list(mineral_group.keys())
list_width = list(80*np.ones(len(list_categories)))
list_width = [int(item) for item in list_width]
list_width[0] = 120
#
n_columns = 100
tv_ma_results = SimpleElements(
parent=self.parent, row_id=0, column_id=start_column, n_rows=20, n_columns=n_columns,
fg=self.colors_gebpy["Black"], bg=self.colors_gebpy["White"]).create_treeview(
n_categories=len(list_categories), text_n=list_categories,
width_n=list_width, individual=True)
#
scb_v = ttk.Scrollbar(self.parent, orient="vertical")
scb_h = ttk.Scrollbar(self.parent, orient="horizontal")
tv_ma_results.configure(xscrollcommand=scb_h.set, yscrollcommand=scb_v.set)
scb_v.config(command=tv_ma_results.yview)
scb_h.config(command=tv_ma_results.xview)
scb_v.grid(row=0, column=start_column + n_columns, rowspan=20, columnspan=1, sticky="ns")
scb_h.grid(row=20, column=start_column, rowspan=1, columnspan=n_columns, sticky="ew")
#
for index, mineral in enumerate(list_minerals):
entries = [mineral]
#
for category_parameter in list_categories_short[1:]:
try:
entries.append(round(np.mean(mineral_group[mineral][category_parameter]), 3))
except:
entries.append(mineral_group[mineral][category_parameter])
#
tv_ma_results.insert("", tk.END, values=entries)
#
## DIAGRAMS
#
self.mineral_group_scatter(mineral_data=mineral_group)
#
def mineral_group_scatter(self, mineral_data):
fig_mineral_group = Figure(
figsize=(6, 6), dpi=150, tight_layout=True, facecolor=self.colors_gebpy["Background"])
ax_mineral_group = fig_mineral_group.subplots(nrows=3, ncols=3)
#
categories = [["M", "V", "rho"], ["vP", "vS", "vP/vS"], ["GR", "PE", "nu"]]
labels = [["M (kg/mol)", "V (A$^3$/mol", "rho (g/cm$^3$"], ["vP (m/s)", "vS (m/s)", "vP/vS (1)"],
["GR (API)", "PE (barns/e$^-$)", "nu (1)"]]
#
helper_x = []
helper_y = {}
for i, subcategories in enumerate(categories):
for j, subcategory in enumerate(subcategories):
helper_y[subcategory] = []
for mineral, dataset in mineral_data.items():
helper_x.append(dataset["rho"][-1]/1000)
helper_y[subcategory].append(dataset[subcategory][-1])
#
ax_mineral_group[i][j].scatter(dataset["rho"][-1]/1000, dataset[subcategory][-1])
#
x_min = 0.9*min(helper_x)
x_max = 1.1*max(helper_x)
#
for i, subcategories in enumerate(categories):
for j, subcategory in enumerate(subcategories):
y_min = 0.9*min(helper_y[subcategory])
y_max = 1.1*max(helper_y[subcategory])
#
ax_mineral_group[i][j].set_xlim(left=x_min, right=x_max)
ax_mineral_group[i][j].set_ylim(bottom=y_min, top=y_max)
ax_mineral_group[i][j].set_xticks(np.around(
np.linspace(x_min, x_max, 4, dtype=float, endpoint=True), 2))
ax_mineral_group[i][j].set_yticks(np.around(
np.linspace(y_min, y_max, 4, dtype=float, endpoint=True), 2))
ax_mineral_group[i][j].xaxis.set_tick_params(labelsize=8)
ax_mineral_group[i][j].yaxis.set_tick_params(labelsize=8)
ax_mineral_group[i][j].set_xlabel("Density - kg/m$^3$", fontsize=8)
ax_mineral_group[i][j].set_ylabel(labels[i][j], labelpad=0.5, fontsize=8)
ax_mineral_group[i][j].grid(True)
ax_mineral_group[i][j].set_axisbelow(True)
#
canvas_mineral_group = FigureCanvasTkAgg(fig_mineral_group, master=self.parent)
canvas_mineral_group.get_tk_widget().grid(
row=21, column=35, rowspan=int(self.n_rows - 21), columnspan=int(2*(self.n_rows - 21)), sticky="nesw")
def closest_number(self, n, m):
# Find the quotient
q = int(n/m)
# 1st possible closest number
n1 = m*q
# 2nd possible closest number
if ((n*m) > 0):
n2 = (m*(q + 1))
else:
n2 = (m*(q - 1))
# if true, then n1 is the required closest number
if (abs(n - n1) < abs(n - n2)):
return n1
# else n2 is the required closest number
return n2
def myround(self, x, prec=2, base=.05):
return round(base*round(float(x)/base), prec)
def improve_xlimits(self, x_min, x_max):
if x_min > 1:
if (x_max - x_min) < 0.5:
x_min = self.myround(x=x_min - 0.005, base=0.005)
x_max = self.myround(x=x_max + 0.005, base=0.005)
elif 0.5 <= (x_max - x_min) < 5:
x_min = self.myround(x=x_min - 2, base=5)
x_max = self.myround(x=x_max + 2, base=5)
elif 5 <= (x_max - x_min) < 10:
x_min = self.myround(x=x_min - 2, base=5)
x_max = self.myround(x=x_max + 2, base=5)
elif 10 <= (x_max - x_min) < 15:
x_min = self.myround(x=x_min - 3, base=2.5)
x_max = self.myround(x=x_max + 3, base=2.5)
elif 15 <= (x_max - x_min) < 25:
x_min = self.myround(x=x_min - 3.5, base=5)
x_max = self.myround(x=x_max + 3.5, base=5)
elif 25 <= (x_max - x_min) < 50:
x_min = self.myround(x=x_min - 5, base=5)
x_max = self.myround(x=x_max + 5, base=5)
elif 50 <= (x_max - x_min) < 100:
x_min = self.myround(x=x_min - 25, base=5)
x_max = self.myround(x=x_max + 25, base=5)
else:
x_min = self.myround(x=x_min - 50, base=5)
x_max = self.myround(x=x_max + 50, base=5)
else:
if 5 <= (x_max - x_min) < 10:
x_min = self.myround(x=x_min - 5, base=5)
x_max = self.myround(x=x_max + 5, base=5)
elif 1 <= (x_max - x_min) < 5:
x_min = self.myround(x=x_min - 0.5, base=0.5)
x_max = self.myround(x=x_max + 0.5, base=0.5)
elif 0.05 <= (x_max - x_min) < 0.5:
x_min = self.myround(x=x_min - 0.025, base=0.025)
x_max = self.myround(x=x_max + 0.025, base=0.025)
elif 0.01 <= (x_max - x_min) < 0.05:
x_min = self.myround(x=x_min - 0.005, base=0.005)
x_max = self.myround(x=x_max + 0.005, base=0.005)
else: