-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtvguide.py
More file actions
1230 lines (1036 loc) · 58.2 KB
/
tvguide.py
File metadata and controls
1230 lines (1036 loc) · 58.2 KB
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
"""
Author - William Diment - CIRES IT
"""
import dash
from dash import dcc
from dash import html
from dash import dash_table
from dash.dependencies import Input, Output, State
from sys import stdout
import datetime
import appSelectionOptions
import os
import csv
import subprocess
import pandas as pd
import numpy
import json
import urllib
import json
import vector_functions
import plotly.express as px
#external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
ciresitMapboxToken = 'pk.eyJ1IjoiY2lyZXNpdCIsImEiOiJjazgzbGpoY3oxY2swM2Z0bDd3djIwdXFlIn0.0Z8kTTE8dgSU27tsWOTCeg'
#app.css.append_css({"external_url": "static/stylesheet.css"})
app = dash.Dash(__name__)
app.title = 'TVGuide Aniso'
app.scripts.config.server_locally = True
server = app.server
app.config['suppress_callback_exceptions'] = True
config = {"modeBarButtonsToAdd":[['drawline']] }
tab_height = '25px'
tab_style = {'height': tab_height, 'padding': '0'}
tablet_style = {'line-height': tab_height, 'padding': '0'}
degree_selector = [{'label': '1', 'value':'1'}, {'label': '2', 'value':'2'}, {'label': '3', 'value':'3'}]
phase_selector = [{'label': 'Whole', 'value':'0'}, {'label': 'Quartz', 'value':'1'}, {'label': 'Feldspar', 'value':'2'}, {'label': 'Biotite', 'value':'3'}, {'label': 'Muscovite', 'value':'4'}, {'label': 'Chlorite', 'value':'5'}, {'label': 'Hornblende', 'value':'6'}, {'label': 'Garnet', 'value':'7'}, {'label': 'Pyrite', 'value':'8'}]
sampleN_selector = [{'label': '1', 'value':'1'}, {'label': '2', 'value':'2'}, {'label': '3', 'value':'3'}, {'label': '7', 'value':'7'}, {'label': '8', 'value':'8'}, {'label': '9', 'value':'9'}, {'label': '11', 'value':'11'}, {'label': '13', 'value':'13'}, {'label': '14', 'value':'14'} , {'label': '15', 'value':'15'} , {'label': '21', 'value':'21'}, {'label': '22', 'value':'22'} , {'label': '27', 'value':'27'}]
tensor_selector = [{'label': i, 'value': i} for i in range(1,97)]
average_selector = [{'label': i, 'value': i} for i in range(2,6)]
dataButtonStyle={'padding':'5x', 'text-align': 'center', 'line-height':'5'}
navbar = html.Nav(
className="top-bar fixed",
children=[
html.Div([
html.A(
href="https://cires.colorado.edu"
)],
style={'background-color': 'white',
'width': '600px',
'position': 'center',
'float': 'right',
'margin-right': '-3px',
'margin-top': '-5px',
'border': '3px solid rgb(175, 221, 246)',
'border-radius': '5px'},
className='row'),
# End Sponser Logos
html.Button(
children="Database",
type='button',
n_clicks=0,
title='Click to show database. Click again to hide database',
id="databaseButton",
style={'height': '45px',
'padding': '9px',
'background-color': 'rgb(175, 221, 246)',
'border-radius': '1px',
'font-family': 'Arial',
'font-size': '10px',
'margin-top': '-5px',
'float': 'left',
'margin-left': '-5px'}),
html.Button(
children="Enter Your Own Tensor",
type='button',
n_clicks=0,
title='Click to enter your own tensor. Click again to hide input area.',
id="addRowButton",
style={'height': '45px',
'padding': '9px',
'background-color': 'rgb(175, 221, 246)',
'border-radius': '1px',
'font-family': 'Arial',
'font-size': '10px',
'margin-top': '-5px',
'float': 'left',
'margin-left': '-5px'}),
],
style={'position': 'fixed','top': '0px', 'left': '0px',
'background-color': 'rgb(0, 98, 174)', 'height': '50px',
'width': '100%', 'zIndex': '9999'
},
)
# End Toggle Buttons
body = html.Div([
html.Hr(),
# Title
html.Div([
html.H3('TV Guide - UNDER CONSTRUCTION'),
html.H4('Interactive elastic tensor visualization tool and database'),
html.Div(id='desc_div', children=[
dcc.Markdown(id='description',
children=[],
style={'text-align': 'center',
'width': '70%',
'margin': '0px auto'}
)],
style={'text-align': 'center',
'margin': '0 auto',
'width' :'100%'}
),
html.Hr()],
style={'font-weight': 'bolder',
'text-align': 'center',
'font-size': '50px',
'font-family': 'Times New Roman',
'margin-bottom': '50',
'margin-top': '100'
}),
# End Title
# Options
html.Div(id='unit_selection',
children=[
dcc.Dropdown(
id='unit_selection_dropdown',
placeholder='Select Units',
options=[{'label':'Pascal', 'value':'1'}, {'label':'Gigapascal', 'value':'2'}],
style={'width':'213px'}
)
]),
html.Div(id='dataOptions',
children=[
html.Button(
id='calculate_velocities_button',
children="Visualize Velocities",
title = "Click here to visualize the velocities",
type='button',
n_clicks=0,
),
html.Button(
id='average_tensors_button',
children="Average Tensors",
title = "Click here to average tensors",
type='button',
n_clicks=0,
),
html.Button(
id='calculate_fold_model_button',
children="Calculate Fold Model",
title = "Click here to calculate the fold model for the tensors",
type='button',
n_clicks=0,
),
html.Button(
id='calculate_decomp_button',
children="Decompose Tensors",
title = "Click here to decompose the tensors",
type='button',
n_clicks=0,
),
html.Div(id='test-div')],
style={'text-align': 'center','position':'relative','float':'left','display':'inline'}
),
html.Br(),
html.Br(),
html.Div(id='tensor_average_options', children=[
html.Div(id='number_of_tensors_to_average_div', children=[
dcc.Dropdown(
id='number_of_tensors_to_average_dropdown',
placeholder = 'Select number of tensors to average',
options=average_selector,
value = 2,
style={'height': '30px', 'width': '165px'}
),
]
),
dcc.Dropdown(
id='select_average_tensor1',
options=tensor_selector,
value=1,
placeholder='Select Tensor 1...',
style={'height': '30px', 'width': '165px'}
),
dcc.Dropdown(
id='select_average_tensor2',
options=tensor_selector,
placeholder='Select Tensor 2...',
value=1,
style={'height': '30px', 'width': '165px'}
),
dcc.Dropdown(
id='select_average_tensor3',
options=tensor_selector,
placeholder='Select Tensor 3...',
value=1,
style={'height': '30px', 'width': '165px', 'display':'none'}
),
dcc.Dropdown(
id='select_average_tensor4',
options=tensor_selector,
placeholder='Select Tensor 4...',
value=1,
style={'height': '30px', 'width': '165px', 'display':'none'}
),
dcc.Dropdown(
id='select_average_tensor5',
options=tensor_selector,
placeholder='Select Tensor 5...',
value=1,
style={'height': '30px', 'width': '165px', 'display':'none'}
),
html.Button(id='submit_average_tensors_button',
n_clicks=0,
title=('Submit the selected tensor options'),
children='Submit Average Tensors Options',
type='button',
style={'height': '37px', 'width': '325px'}
),
], style={'display':'none'}),
html.Div(id='tensor_decomp_options', children=[
html.Br(),
dcc.Dropdown(
id='select_decomp_tensor1',
options=tensor_selector,
placeholder='Select Tensor...',
value = 1,
style={'height': '30px', 'width': '165px'}
),
html.Button(id='submit_decomp_tensors_button',
n_clicks=0,
title=('Submit the selected tensor options'),
children='Submit Decomposition',
type='button',
style={'height': '37px', 'width': '325px'}
)
], style={'display':'none'}),
html.Br(),
html.Div(id='decomp-breakdown-displays',children=[
html.Button(
children="Decomposition Breakdown",
type='button',
n_clicks=0,
id="decomp_breakdown"),
html.Button(
children="Isotropic Tensors",
type='button',
n_clicks=0,
id="decomp_iso"),
html.Button(
children="Hexagonal Tensors",
type='button',
n_clicks=0,
id="decomp_hexag"),
html.Button(
children="Orthorhombic Tensors",
type='button',
n_clicks=0,
id="decomp_ortho"),
], style={'display':'none'}),
html.Div(id='averaged_tensors_div', children=[
html.Div(id='weight_selection_div', children=[
dcc.Input(
id='weight_selection_1',
type='number',
min=1,
value=1,
placeholder='Weight 1',
style={'height': '35px', 'width': '165px', 'display':'inline-block'}
),
dcc.Input(
id='weight_selection_2',
type='number',
value=1,
min=1,
placeholder='Weight 2',
style={'height': '35px', 'width': '165px', 'display':'inline-block'}
),
dcc.Input(
id='weight_selection_3',
type='number',
min=1,
value=1,
placeholder='Weight 3',
style={'height': '35px', 'width': '165px', 'display':'inline-block'}
),
dcc.Input(
id='weight_selection_4',
type='number',
min=1,
placeholder='Weight 4',
value=1,
style={'height': '35px', 'width': '165px', 'display':'inline-block'}
),
dcc.Input(
id='weight_selection_5',
type='number',
min=1,
value=1,
placeholder='Weight 5',
style={'height': '35px', 'width': '165px', 'display':'inline-block'}
)], style={'margin-left':'165px'}),
dcc.Input(
id='v_ave_1',
type='text',
placeholder='V_ave 1',
value='',
style={'width':'75%', 'margin-top':'15px'}
),
dcc.Textarea(id='text_area_averaged_tensor',
value=vector_functions.averagingTensorDescription(),
style={'width':'1009px', 'resize':'none'},
disabled=True,
readOnly=True,
draggable=False),
], style={'display':'none'}),
html.Br(),
html.Div(id='tensor_selection_options',
children=[
dcc.Dropdown(
id='select_tensor',
options=tensor_selector,
placeholder='Select Tensor...',
value = 1,
style={'height': '30px', 'width': '165px'}
),
html.Button(id='submit_button',
n_clicks=0,
title=('Submit the selected tensor options'),
children='Submit Tensor',
type='button',
style={'height': '37px', 'width': '165px'}
),
html.Div(id='calculate_velocities_description',
children=[
dcc.Textarea(id='text_area_calculate_velocities',
value=vector_functions.calculateVelocitiesDescription(),
style={'width':'330px', 'height':'110px', 'resize':'none'},
disabled=True,
readOnly=True,
draggable=False),
],
style={'margin-left':'-330px', 'margin-top':'50px'}
),
],
style={'margin-top':'50px', 'display':'flex'}
),
html.Br(),
html.Div(id='tensors_not_filled', children=['You have not correctly filled in the number of tensors - you need 22. This will result in a run time error - please amend your entry.'],
style={'font-style': 'oblique', 'color':'black', 'text-decoration':'underline', 'display':'none'}
),
html.Div(id='tensor_input_table', children=[
html.Br(),
dcc.Input(
id='custom_tensor_list',
type='text',
placeholder='Enter your tensors here!',
value='',
style={'width':'800px'}
),
html.Button(id='addTensorToDatabase',
n_clicks=0,
title=('Submit your own input tensor'),
children='Submit Input Tensor',
type='button',
),
html.Br(),
dcc.Textarea(id='text_area_input_tensor',
value='Input your own tensors here by copy and pasting into the field above as comma separated elements. Click on Submit Input Tensor when done with the tensor. You can input multiple tensors (one by one), once you are done click on Enter Your Own Tensor at the top to remove these displays',
style={'width':'1009px', 'resize':'none'},
draggable=False,
disabled=True),
], style={'display':'none'}),
html.H4(id='database-table-title', children='Database', style={'display':'none'}),
html.Div(id='database_table', children=vector_functions.print_csv_table()[0], style={'display':'none'}),
html.Div(id='database_dataframe', children=vector_functions.print_csv_table()[1], style={'display':'none'}),
html.Div(id='database_dataframe_user_input', children=vector_functions.print_csv_table()[1], style={'display':'none'}),
html.Div(id='database_dataframe_user_averaging_input', children=vector_functions.print_csv_table()[1], style={'display':'none'}),
html.Div(id='decomp_breakdown_table', children=vector_functions.print_breakdown(), style={'display':'none'}),
html.Div(id='decomp_iso_table', children='hello', style={'display':'none'}),
html.Div(id='decomp_hexag_table', children='hello', style={'display':'none'}),
html.Div(id='decomp_ortho_table', children='hello', style={'display':'none'}),
html.Div(id='decomp_component_export', children=[dcc.Textarea(
id='decomp_component_export_text',
value='',
placeholder='Components'
)], style={'display':'none'}),
###put holder here - 7/27/2023
html.Br(),
html.Div([
html.H4(id='tool-title-display', children='Current Tool: Visualize Velocities'),
dcc.Tabs(id='tabs-div', style={'display':'none'}, children=[
dcc.Tab(label='Vp', value='tab-2'),
dcc.Tab(label='Vs1', value='tab-3'),
dcc.Tab(label='Vs2', value='tab-4'),
dcc.Tab(label='VP/VS1', value='tab-13'),
dcc.Tab(label='Vs1 Polarization & splitting time', value='tab-1', className='tooltiptext'),
dcc.Tab(label='3D Quiver Plot/VS1', value='tab-5'),
dcc.Tab(label='VP Fig 3D Plot', value='tab-6'),
dcc.Tab(label='VS1 3D Plot', value='tab-7'),
dcc.Tab(label='VS2 3D Plot', value='tab-8'),
dcc.Tab(label='VP/VS1 3D Plot', value='tab-9'),
dcc.Tab(label='Back Azimuthal Plot', value='tab-10'),
dcc.Tab(label='Radial Plots', value='tab-11'),
]),
dcc.Tabs(id='fold-model-tabs-div', style={'display':'none'}, children=[
dcc.Tab(label='Vp', value='fold-model-tab-2'),
dcc.Tab(label='Vs1', value='fold-model-tab-3'),
dcc.Tab(label='Vs2', value='fold-model-tab-4'),
dcc.Tab(label='VpVs1', value='fold-model-tab-5'),
dcc.Tab(label='Vs1 Polarization & splitting time', value='fold-model-tab-1'),
dcc.Tab(label='3D Quiver Plot/VS1', value='fold-model-tab-6'),
dcc.Tab(label='VP Fig 3D Plot', value='fold-model-tab-7'),
dcc.Tab(label='VS1 3D Plot', value='fold-model-tab-8'),
dcc.Tab(label='VS2 3D Plot', value='fold-model-tab-9'),
dcc.Tab(label='VP/VS1 3D Plot', value='fold-model-tab-10'),
]),
html.Div(id='json_hidden_table', children=[
dcc.Loading(
id='loading-2',
type='default',
children=html.Div(id='loading-output-2')
)
],
title='', style={'margin-top':'10px'}),
html.Div(id='tab-content-display', children=[
dcc.Loading(
id='loading-1',
type='default',
children=html.Div(id='loading-output-1')
),
dcc.Graph(id='graph-display', figure='')
], style={'margin-top':'50px','overflow':'scroll'}),
html.Div(id='fold-model-display', children=[], style={'margin-top':'50px','overflow':'scroll'})
], style={'text-align': 'center', 'top':'15px', 'max-height':'1000px', 'min-width':'1600px'}),
],
className='ten columns offset-by-one', style={'min-width':'1200px'})
# End Static Elements
@app.callback(
Output(component_id='v_ave_1', component_property='value'),
[Input(component_id='submit_average_tensors_button', component_property='n_clicks'),
Input(component_id='number_of_tensors_to_average_dropdown', component_property='value')],
[State(component_id='select_average_tensor1', component_property='value'),
State(component_id='select_average_tensor2', component_property='value'),
State(component_id='select_average_tensor3', component_property='value'),
State(component_id='select_average_tensor4', component_property='value'),
State(component_id='select_average_tensor5', component_property='value'),
State(component_id='weight_selection_1', component_property='value'),
State(component_id='weight_selection_2', component_property='value'),
State(component_id='weight_selection_3', component_property='value'),
State(component_id='weight_selection_4', component_property='value'),
State(component_id='weight_selection_5', component_property='value'),
State(component_id='database_dataframe_user_averaging_input', component_property='children')],
)
def average_tensors(n_clicks, numberOfTensorsToAverage, tensor1, tensor2, tensor3, tensor4, tensor5, weight1, weight2, weight3, weight4, weight5, averagingDatabaseFrame):
averagingDatabaseFrame = averagingDatabaseFrame
display_tensor_style = {'display':'block'}
if n_clicks == 0:
return 'Select tensors to average!'
if numberOfTensorsToAverage == 2:
weight = [weight1, weight2]
if tensor1 < 96 and tensor2 < 96:
V_ave, R_ave = vector_functions.tv_averaging(tensor1, tensor2, None, None, None, False, None, weight)
if tensor1 >= 96 or tensor2 >= 96:
V_ave, R_ave = vector_functions.tv_averaging(tensor1, tensor2, None, None, None, True, averagingDatabaseFrame, weight)
if numberOfTensorsToAverage == 3:
weight = [weight1, weight2, weight3]
if tensor1 < 96 and tensor2 < 96 and tensor3 < 96:
V_ave, R_ave = vector_functions.tv_averaging(tensor1, tensor2, tensor3, None, None, False, None, weight)
if tensor1 >= 96 or tensor2 >= 96 or tensor3 >= 96:
V_ave, R_ave = vector_functions.tv_averaging(tensor1, tensor2, tensor3, None, None, True, averagingDatabaseFrame, weight)
if numberOfTensorsToAverage == 4:
weight = [weight1, weight2, weight3, weight4]
if tensor1 < 96 and tensor2 < 96 and tensor3 < 96 and tensor4 < 96:
V_ave, R_ave = vector_functions.tv_averaging(tensor1, tensor2, tensor3, tensor4, None, False, None, weight)
if tensor1 >= 96 or tensor2 >= 96 or tensor3 >= 96 or tensor4 >= 96:
V_ave, R_ave = vector_functions.tv_averaging(tensor1, tensor2, tensor3, tensor4, None, True, averagingDatabaseFrame, weight)
if numberOfTensorsToAverage == 5:
weight = [weight1, weight2, weight3, weight4, weight5]
if tensor1 < 96 and tensor2 < 96 and tensor3 < 96 and tensor4 < 96 and tensor5 < 96:
V_ave, R_ave = vector_functions.tv_averaging(tensor1, tensor2, tensor3, tensor4, tensor5, False, None, weight)
if tensor1 >= 96 or tensor2 >= 96 or tensor3 >= 96 or tensor4 >= 96 or tensor5 >= 96:
V_ave, R_ave = vector_functions.tv_averaging(tensor1, tensor2, tensor3, tensor4, tensor5, True, averagingDatabaseFrame, weight)
v_ave_string = "{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}".format(V_ave[0],V_ave[1],V_ave[2],V_ave[3],V_ave[4],V_ave[5],V_ave[6],V_ave[7],V_ave[8],V_ave[9],V_ave[10],V_ave[11],V_ave[12],V_ave[13],V_ave[14],V_ave[15],V_ave[16],V_ave[17],V_ave[18],V_ave[19],V_ave[20],V_ave[21],V_ave[22],V_ave[23],V_ave[24],V_ave[25],V_ave[26],V_ave[27],V_ave[28],V_ave[29],V_ave[30],V_ave[31],V_ave[32],V_ave[33],V_ave[34],V_ave[35])
return v_ave_string
@app.callback(
[Output(component_id='graph-display', component_property='figure'),
Output(component_id='fold-model-display', component_property='children'),
Output(component_id='loading-output-1', component_property='children'),
Output(component_id='select_decomp_tensor1', component_property='value')],
[Input(component_id='fold-model-tabs-div', component_property='value'),
Input(component_id='tabs-div', component_property='value'),
Input(component_id='submit_button', component_property='n_clicks')],[
State(component_id='select_tensor', component_property='value'),
State(component_id='database_dataframe_user_input', component_property='children')
]
)
def render_content(folds_tab, tab, button_nclicks, tensor, userInputDataFrame):
#optional return - specify the return function parameter
#fig1, vpFig, vs1Fig, vs2Fig, vpvs1Fig = vector_functions.calculate_tensor_symmetries(2)
tensor = tensor
changed_id = [p['prop_id'] for p in dash.callback_context.triggered][0]
print('this is changed id in the render_content tool', changed_id, 'this is the tab', tab)
if tab == None and folds_tab == None:
tab = 'tab-2'
if tab == 'tab-1' and changed_id != 'fold-model-tabs-div.value':
if changed_id == 'tabs-div.value' or changed_id == 'select_tensor.value' or changed_id == 'submit_button.n_clicks':
plotType = 'Quiver'
if int(tensor) < 96:
fig1 = vector_functions.calculate_tensor_symmetries(tensor, False, plotType, None, userInputDataFrame)
if int(tensor) >= 96:
print('this is the tensor number', tensor)
fig1 = vector_functions.calculate_tensor_symmetries(tensor, True, plotType, None, userInputDataFrame)
return fig1, '', '', tensor
elif tab == 'tab-2' and changed_id != 'fold-model-tabs-div.value':
print('we are in tab-2 section', changed_id)
if changed_id == 'tabs-div.value' or changed_id == 'select_tensor.value' or changed_id == 'submit_button.n_clicks':
plotType = 'VP'
if int(tensor) < 96:
fig1 = vector_functions.calculate_tensor_symmetries(tensor, False, plotType, None, userInputDataFrame)
if int(tensor) >= 96:
print('this is the tensor number', tensor)
fig1 = vector_functions.calculate_tensor_symmetries(tensor, True, plotType, None, userInputDataFrame)
return fig1, '', '', tensor
elif tab == 'tab-3' and changed_id != 'fold-model-tabs-div.value':
if changed_id == 'tabs-div.value' or changed_id == 'select_tensor.value' or changed_id == 'submit_button.n_clicks':
plotType = 'VS1'
if int(tensor) < 96:
fig1 = vector_functions.calculate_tensor_symmetries(tensor, False, plotType, None)
if int(tensor) >= 96:
print('this is the tensor number', tensor)
fig1 = vector_functions.calculate_tensor_symmetries(tensor, True, plotType, None, userInputDataFrame)
return fig1, '', '', tensor
elif tab == 'tab-4' and changed_id != 'fold-model-tabs-div.value':
if changed_id == 'tabs-div.value' or changed_id == 'select_tensor.value' or changed_id == 'submit_button.n_clicks':
plotType = 'VS2'
if int(tensor) < 96:
fig1 = vector_functions.calculate_tensor_symmetries(tensor, False, plotType, None)
if int(tensor) >= 96:
print('this is the tensor number', tensor)
fig1 = vector_functions.calculate_tensor_symmetries(tensor, True, plotType, None, userInputDataFrame)
return fig1, '', '', tensor
elif tab == 'tab-13' and changed_id != 'fold-model-tabs-div.value':
if changed_id == 'tabs-div.value' or changed_id == 'select_tensor.value' or changed_id == 'submit_button.n_clicks':
plotType = 'VPVS1'
if int(tensor) < 96:
fig1 = vector_functions.calculate_tensor_symmetries(tensor, False, plotType, None)
if int(tensor) >= 96:
print('this is the tensor number', tensor)
fig1 = vector_functions.calculate_tensor_symmetries(tensor, True, plotType, None, userInputDataFrame)
return fig1, '', '', tensor
elif tab == 'tab-5' and changed_id != 'fold-model-tabs-div.value':
if changed_id == 'tabs-div.value' or changed_id == 'select_tensor.value' or changed_id == 'submit_button.n_clicks':
plotType = '3DQuiver'
if int(tensor) < 96:
fig1 = vector_functions.calculate_tensor_symmetries(tensor, False, None, plotType)
if int(tensor) >= 96:
print('this is the tensor number', tensor)
fig1 = vector_functions.calculate_tensor_symmetries(tensor, True, None, plotType, userInputDataFrame)
return fig1, '', '', tensor
if tab == 'tab-6' and changed_id != 'fold-model-tabs-div.value':
if changed_id == 'tabs-div.value' or changed_id == 'select_tensor.value' or changed_id == 'submit_button.n_clicks':
plotType = '3DVP'
print('yep')
if int(tensor) < 96:
vpFig = vector_functions.calculate_tensor_symmetries(tensor, False, None, plotType)
if int(tensor) >= 96:
vpFig = vector_functions.calculate_tensor_symmetries(tensor, True, None, plotType, userInputDataFrame)
return vpFig, '', '', tensor
elif tab == 'tab-7' and changed_id != 'fold-model-tabs-div.value':
if changed_id == 'tabs-div.value' or changed_id == 'select_tensor.value' or changed_id == 'submit_button.n_clicks':
plotType = '3DVS1'
if int(tensor) < 96:
vs1Fig = vector_functions.calculate_tensor_symmetries(tensor, False, None, plotType)
if int(tensor) >= 96:
print(tensor)
vs1Fig = vector_functions.calculate_tensor_symmetries(tensor, True, None, plotType, userInputDataFrame)
return vs1Fig, '', '', tensor
elif tab == 'tab-8' and changed_id != 'fold-model-tabs-div.value':
print(changed_id)
if changed_id == 'tabs-div.value' or changed_id == 'select_tensor.value' or changed_id == 'submit_button.n_clicks':
plotType = '3DVS2'
if int(tensor) < 96:
print('we are in the proper tensor selection', tensor)
vs2Fig = vector_functions.calculate_tensor_symmetries(tensor, False,None, plotType)
if int(tensor) >= 96:
print(tensor)
vs2Fig = vector_functions.calculate_tensor_symmetries(tensor, True, None, plotType, userInputDataFrame)
return vs2Fig, '', '', tensor
elif tab == 'tab-9' and changed_id != 'fold-model-tabs-div.value':
if changed_id == 'tabs-div.value' or changed_id == 'select_tensor.value' or changed_id == 'submit_button.n_clicks':
plotType = '3DVPVS1'
if int(tensor) < 96:
vpvs1Fig = vector_functions.calculate_tensor_symmetries(tensor, False,None, plotType)
if int(tensor) >= 96:
print(tensor)
vpvs1Fig = vector_functions.calculate_tensor_symmetries(tensor, True, None, plotType, userInputDataFrame)
return vpvs1Fig, '', '', tensor
elif tab == 'tab-10' and changed_id != 'fold-model-tabs-div.value':
if changed_id == 'tabs-div.value' or changed_id == 'select_tensor.value' or changed_id == 'submit_button.n_clicks':
plotType = 'BackAzimuthal'
print('in backAz')
if int(tensor) < 96:
BackAzFig = vector_functions.calculate_tensor_symmetries(tensor, False, plotType, None)
if int(tensor) >= 96:
BackAzFig = vector_functions.calculate_tensor_symmetries(tensor, True, plotType, None, userInputDataFrame)
return BackAzFig, '', '', tensor
elif tab == 'tab-11' and changed_id != 'fold-model-tabs-div.value':
if changed_id == 'tabs-div.value' or changed_id == 'select_tensor.value' or changed_id == 'submit_button.n_clicks':
plotType = 'RadialPlots'
if int(tensor) < 96:
RadFig = vector_functions.calculate_tensor_symmetries(tensor, False, plotType, None)
if int(tensor) >= 96:
print(tensor)
RadFig = vector_functions.calculate_tensor_symmetries(tensor, True, plotType, None, userInputDataFrame)
return RadFig, '', '', tensor
if changed_id == 'fold-model-tabs-div.value' and folds_tab == 'fold-model-tab-1':
plotType = 'Quiver'
print('in fold polarization')
if int(tensor) <= 96:
fig1 = vector_functions.tv_fold_model(tensor, False, plotType, None)
if int(tensor) > 96:
print('this is the tensor number', tensor)
fig1 = vector_functions.tv_fold_model(tensor, True, plotType, None, userInputDataFrame)
return '', html.Div(children=[dcc.Graph(figure=fig1)], style={'text-align': 'center', 'top':'15px', 'max-height':'1000px', 'min-width':'1600px'}), '', tensor
if changed_id == 'fold-model-tabs-div.value' and folds_tab == 'fold-model-tab-2':
print('in fold model vp')
plotType = 'VP'
if int(tensor) <= 96:
fig1 = vector_functions.tv_fold_model(tensor, False, plotType, None)
if int(tensor) > 96:
print('this is the tensor number in VP', tensor)
fig1 = vector_functions.tv_fold_model(tensor, True, plotType, None, userInputDataFrame)
return '', html.Div(children=[dcc.Graph(figure=fig1)], style={'text-align': 'center', 'top':'15px', 'min-width':'1600px'}), '', tensor
if changed_id == 'fold-model-tabs-div.value' and folds_tab == 'fold-model-tab-3':
print('in vs1 fold tab')
plotType = 'VS1'
if int(tensor) <= 96:
fig1 = vector_functions.tv_fold_model(tensor, False, plotType, None)
if int(tensor) > 96:
print('this is the tensor number in VS1', tensor)
fig1 = vector_functions.tv_fold_model(tensor, True, plotType, None, userInputDataFrame)
return '', html.Div(children=[dcc.Graph(figure=fig1)], style={'text-align': 'center', 'top':'15px', 'max-height':'1000px', 'min-width':'1600px'}), '', tensor
if changed_id == 'fold-model-tabs-div.value' and folds_tab == 'fold-model-tab-4':
plotType = 'VS2'
print('in vs2 fold tab')
if int(tensor) <= 96:
fig1 = vector_functions.tv_fold_model(tensor, False, plotType, None)
if int(tensor) > 96:
print('this is the tensor number', tensor)
fig1 = vector_functions.tv_fold_model(tensor, True, plotType, None, userInputDataFrame)
return '', html.Div(children=[dcc.Graph(figure=fig1)], style={'text-align': 'center', 'top':'15px', 'max-height':'1000px', 'min-width':'1600px'}), '', tensor
if changed_id == 'fold-model-tabs-div.value' and folds_tab == 'fold-model-tab-5':
plotType = 'VPVS1'
print('in vpvs1 fold tab')
if int(tensor) <= 96:
fig1 = vector_functions.tv_fold_model(tensor, False, plotType, None)
if int(tensor) > 96:
print('this is the tensor number', tensor)
fig1 = vector_functions.tv_fold_model(tensor, True, plotType, None, userInputDataFrame)
return '', html.Div(children=[dcc.Graph(figure=fig1)], style={'text-align': 'center', 'top':'15px', 'max-height':'1000px', 'min-width':'1600px'}), '', tensor
if changed_id == 'fold-model-tabs-div.value' and folds_tab == 'fold-model-tab-6':
plotType = '3DQuiver'
print('in 3d quiv fold tab')
if int(tensor) <= 96:
fig1 = vector_functions.tv_fold_model(tensor, False, None, plotType)
if int(tensor) > 96:
print('this is the tensor number', tensor)
fig1 = vector_functions.tv_fold_model(tensor, True, plotType, None, userInputDataFrame)
return '', html.Div(children=[dcc.Graph(figure=fig1)], style={'text-align': 'center', 'top':'15px', 'max-height':'1000px', 'min-width':'1600px'}), '', tensor
if changed_id == 'fold-model-tabs-div.value' and folds_tab == 'fold-model-tab-7':
print('in 3d vp')
plotType = '3DVP'
if int(tensor) < 96:
fig1 = vector_functions.tv_fold_model(tensor, False, None, plotType)
if int(tensor) >= 96:
print('this is the tensor number', tensor)
fig1 = vector_functions.tv_fold_model(tensor, True, plotType, None, userInputDataFrame)
return '', html.Div(children=[dcc.Graph(figure=fig1)], style={'text-align': 'center', 'top':'15px', 'max-height':'1000px', 'min-width':'1600px'}), '', tensor
if changed_id == 'fold-model-tabs-div.value' and folds_tab == 'fold-model-tab-8':
plotType = '3DVS1'
print('in 3d vs1 fold tab')
if int(tensor) < 96:
fig1 = vector_functions.tv_fold_model(tensor, False, None, plotType)
if int(tensor) >= 96:
print('this is the tensor number', tensor)
fig1 = vector_functions.tv_fold_model(tensor, True, plotType, None, userInputDataFrame)
return '', html.Div(children=[dcc.Graph(figure=fig1)], style={'text-align': 'center', 'top':'15px', 'max-height':'1000px', 'min-width':'1600px'}), '', tensor
if changed_id == 'fold-model-tabs-div.value' and folds_tab == 'fold-model-tab-9':
plotType = '3DVS2'
print('in 3d vs2 fold tab')
if int(tensor) < 96:
fig1 = vector_functions.tv_fold_model(tensor, False, None, plotType)
if int(tensor) >= 96:
print('this is the tensor number', tensor)
ffig1 = vector_functions.tv_fold_model(tensor, True, plotType, None, userInputDataFrame)
return '', html.Div(children=[dcc.Graph(figure=fig1)], style={'text-align': 'center', 'top':'15px', 'max-height':'1000px', 'min-width':'1600px'}), '', tensor
if changed_id == 'fold-model-tabs-div.value' and folds_tab == 'fold-model-tab-10':
plotType = '3DVPVS1'
print('in 3d vpvs1 fold tab')
if int(tensor) < 96:
fig1 = vector_functions.tv_fold_model(tensor, False, None, plotType)
if int(tensor) >= 96:
print('this is the tensor number')
fig1 = vector_functions.tv_fold_model(tensor, True, plotType, None, userInputDataFrame)
return '', html.Div(children=[dcc.Graph(figure=fig1)], style={'text-align': 'center', 'top':'15px', 'max-height':'1000px', 'min-width':'1600px'}), '', tensor
else:
return '', '', '', ''
app.layout = html.Div([navbar,body])
@app.callback(
[Output(component_id='database_table', component_property='style'),
Output(component_id='database-table-title', component_property='children')],
[Input(component_id='databaseButton', component_property='n_clicks')])
def display_database_table(n_clicks):
print('hello')
sampleNumber = 1
databaseTableTitle = ''
databaseTableTitleStyle = {'display':'none'}
changed_id = [p['prop_id'] for p in dash.callback_context.triggered][0]
if n_clicks % 2 == 0:
database = {'display': 'none', 'text-align': 'center'}
else:
database = {'display': 'block', 'text-align': 'center'}
breakdownDatabase = {'display': 'none', 'text-align': 'center'}
return database, databaseTableTitle
@app.callback(
Output(component_id='json_hidden_table', component_property='title'),
Output(component_id='loading-output-2', component_property='children'),
Output(component_id='decomp_breakdown_table', component_property='style'),
Output(component_id='decomp_breakdown_table', component_property='children'),
Output(component_id='decomp_iso_table', component_property='style'),
Output(component_id='decomp_iso_table', component_property='children'),
Output(component_id='decomp_hexag_table', component_property='style'),
Output(component_id='decomp_hexag_table', component_property='children'),
Output(component_id='decomp_ortho_table', component_property='style'),
Output(component_id='decomp_ortho_table', component_property='children'),
Output(component_id='tensor_average_options', component_property='style'),
Output(component_id='tensor_selection_options', component_property='style'),
Output(component_id='averaged_tensors_div', component_property='style'),
Output(component_id='tabs-div', component_property='style'),
Output(component_id='fold-model-tabs-div', component_property='style'),
Output(component_id='tab-content-display', component_property='style'),
Output(component_id='fold-model-display', component_property='style'),
Output(component_id='tensor_decomp_options', component_property='style'),
Output(component_id='decomp-breakdown-displays', component_property='style'),
Output(component_id='tool-title-display', component_property='children'),
Output(component_id='database-table-title', component_property='style'),
Output(component_id='graph-display', component_property='style'),
Output(component_id='decomp_component_export', component_property='style'),
Output(component_id='db_csv_table', component_property='data'),
Output(component_id='tensor_input_table', component_property='style'),
Output(component_id='select_tensor', component_property='options'),
Output(component_id='select_decomp_tensor1', component_property='options'),
Output(component_id='select_average_tensor1', component_property='options'),
Output(component_id='select_average_tensor2', component_property='options'),
Output(component_id='select_average_tensor3', component_property='options'),
Output(component_id='select_average_tensor4', component_property='options'),
Output(component_id='select_average_tensor5', component_property='options'),
Output(component_id='tensors_not_filled', component_property='style'),
Output(component_id='database_table', component_property='children'),
Output(component_id='database_dataframe', component_property='children'),
Output(component_id='database_dataframe_user_input', component_property='children'),
Output(component_id='database_dataframe_user_averaging_input', component_property='children'),
Output(component_id='select_tensor', component_property='value'),
Output(component_id='select_average_tensor3', component_property='style'),
Output(component_id='select_average_tensor4', component_property='style'),
Output(component_id='select_average_tensor5', component_property='style'),
Output(component_id='weight_selection_3', component_property='style'),
Output(component_id='weight_selection_4', component_property='style'),
Output(component_id='weight_selection_5', component_property='style'),
Output(component_id='number_of_tensors_to_average_dropdown', component_property='value'),
[Input(component_id='submit_decomp_tensors_button', component_property='n_clicks'),
Input(component_id='decomp_breakdown', component_property='n_clicks'),
Input(component_id='decomp_iso', component_property='n_clicks'),
Input(component_id='decomp_hexag', component_property='n_clicks'),
Input(component_id='decomp_ortho', component_property='n_clicks'),
Input(component_id='average_tensors_button', component_property='n_clicks'),
Input(component_id='calculate_velocities_button', component_property='n_clicks'),
Input(component_id='calculate_fold_model_button', component_property='n_clicks'),
Input(component_id='calculate_decomp_button', component_property='n_clicks'),
Input(component_id='addRowButton', component_property='n_clicks'),
Input(component_id='addTensorToDatabase', component_property='n_clicks'),
Input(component_id='database_table', component_property='children'),
Input(component_id='database_dataframe', component_property='children'),
Input(component_id='number_of_tensors_to_average_dropdown', component_property='value')
],
[State(component_id='select_decomp_tensor1', component_property='value'),
State(component_id='select_tensor', component_property='options'),
State(component_id='db_csv_table', component_property='data'),
State(component_id='db_csv_table', component_property='columns'),
State(component_id='custom_tensor_list', component_property='value')]
)
def generate_decomposition_switch_tools(n_clicks, decomp_breakdown, decomp_iso, decomp_hex, decomp_ortho, average_button, calculate_velocities, calculate_fold_model, decomp, addDatabaseRowButtonClicks, addRowToDatabaseClicks, csvDatabase, databaseDataframe, numberOfAverageTensorsSelect, tensor1, selectDatabaseTensorOptions, databaseRows, databaseColumns, inputTensorList):
print('hello')
changed_id = [p['prop_id'] for p in dash.callback_context.triggered][0]
print("This is the changed ID - generated in decomp/styling tool", changed_id, type(changed_id))
if(tensor1 <= 96):
Line, isoComponent, hexagonalComponent, orthoComponent = vector_functions.decomposition(tensor1)
if(tensor1 > 96):
Line, isoComponent, hexagonalComponent, orthoComponent = vector_functions.decomposition(tensor1, True, 'None', databaseDataframe)
breakdownFrame = vector_functions.print_breakdown(Line)
isoFrame = vector_functions.print_iso_decomp(isoComponent[0])
hexagFrame = vector_functions.print_hexag_decomp(hexagonalComponent[0])
orthoFrame = vector_functions.print_ortho_decomp(orthoComponent[0])
userInputDataFrame = databaseDataframe
numberOfAverageTensorsSelect = numberOfAverageTensorsSelect
breakdownDatabase = {'display': 'none', 'text-align': 'center'}
isoDatabase = {'display': 'none', 'text-align': 'center'}
hexagDatabase = {'display': 'none', 'text-align': 'center'}
orthoDatabase = {'display': 'none', 'text-align': 'center'}
tensor_selection_options_display = {'display':'flex'}
display_tensor_average_options = {'display':'none'}
display_tensor_average_cells = {'display':'none'}
display_tensor_average_cells = {'display':'none'}
display_decomp_options = {'display':'none'}
display_decomp_database_options = {'display':'none'}
third_average_option = {'display':'none'}
fourth_average_option = {'display':'none'}
fifth_average_option = {'display':'none'}
third_weight_selection_option = {'display':'none'}
fourth_weight_selection_option = {'display':'none'}
fifth_weight_selection_option = {'display':'none'}
graphDisplay = {'display':'flex', 'max-width':'1800px', 'margin':'auto'}
decompComponentDisplay = {'display':'none'}
decompOutput = ''
toolTitleDisplay = 'Current Tool: Visualize Velocities'
tabs_div_style = {'display':''}
fold_model_tabs_div = {'display':'none'}
tab_content_display = {'margin-top':'50px'}
fold_model_display = {'display':'none'}
if changed_id == 'decomp_breakdown.n_clicks':
breakdownDatabase = {'display': 'block', 'text-align': 'center'}
isoDatabase = {'display': 'none', 'text-align': 'center'}
hexagDatabase = {'display': 'none', 'text-align': 'center'}
orthoDatabase = {'display': 'none', 'text-align': 'center'}
display_decomp_options = {'display':'flex'}
display_decomp_database_options = {'display':'flex'}
databaseTableTitle = 'Breakdown Table'
databaseTableTitleStyle = {'display':'none'}
tensor_selection_options_display = {'display':'none'}
graphDisplay = {'display':'none'}
tabs_div_style = {'display':'none'}
fold_model_display = {'display':'none'}
toolTitleDisplay = 'Current Tool: Decomposition'
decompComponentDisplay = {'display':'flex'}
if changed_id == 'decomp_iso.n_clicks':
isoDatabase = {'display': 'block', 'text-align': 'center'}
breakdownDatabase = {'display': 'none', 'text-align': 'center'}
hexagDatabase = {'display': 'none', 'text-align': 'center'}
orthoDatabase = {'display': 'none', 'text-align': 'center'}
display_decomp_options = {'display':'flex'}
display_decomp_database_options = {'display':'flex'}
databaseTableTitle = 'Isotropic Decomposition Table'
databaseTableTitleStyle = {'display':'none'}
tensor_selection_options_display = {'display':'none'}
graphDisplay = {'display':'none'}
tabs_div_style = {'display':'none'}
fold_model_display = {'display':'none'}
toolTitleDisplay = 'Current Tool: Decomposition'
decompComponentDisplay = {'display':'flex'}
if changed_id == 'decomp_hexag.n_clicks':
hexagDatabase = {'display': 'block', 'text-align': 'center'}
breakdownDatabase = {'display': 'none', 'text-align': 'center'}
isoDatabase = {'display': 'none', 'text-align': 'center'}
orthoDatabase = {'display': 'none', 'text-align': 'center'}
display_decomp_options = {'display':'flex'}