-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1824 lines (1623 loc) · 82.1 KB
/
index.html
File metadata and controls
1824 lines (1623 loc) · 82.1 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Treestimator: Tree Population Simulator</title>
<!-- Chart.js for data visualization -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.9.1/chart.min.js"></script>
<!-- Chart.js Annotation Plugin for vertical line on chart -->
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-annotation@1.4.0/dist/chartjs-plugin-annotation.min.js"></script>
<!-- jsPDF for PDF generation -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<!-- jsPDF AutoTable plugin for structured tables in PDF -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.25/jspdf.plugin.autotable.min.js"></script>
<style>
/* General Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Body Styling */
body {
font-family: 'Inter', sans-serif; /* Using Inter font as per instructions */
background: linear-gradient(180deg, #0a6bda 0%, #31bb0f 100%);
min-height: 100vh;
padding: 20px;
display: flex;
justify-content: center;
align-items: flex-start; /* Align to top */
}
/* Landing Page Specific Styles */
.landing-page {
display: flex; /* Initially flex to center content */
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh; /* Take full viewport height */
text-align: center;
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
padding: 40px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
backdrop-filter: blur(10px);
width: 90%; /* Fluid width */
max-width: 800px; /* Max width for larger screens */
margin: 0 auto; /* Center horizontally */
}
.landing-page h1 {
color: #2E7D32;
font-size: 4em;
font-family:Arial, Helvetica, sans-serif;
margin-bottom: 20px;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}
.landing-page p {
color: #666;
font-size: 1.5em;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
margin-bottom: 20px; /* Adjusted margin */
line-height: 1.6;
}
.landing-page .description { /* New style for description */
font-size: 1.1em;
font-family:'Gill Sans MT','Trebuchet MS', sans-serif;
margin-bottom: 30px;
max-width: 600px;
}
.landing-page .developer-info { /* New style for developer info */
font-size: 0.9em;
color: #888;
margin-top: 20px;
margin-bottom: 30px; /* Space before button */
}
.landing-page .btn {
padding: 18px 50px;
font-size: 1.5em;
font-weight: 700;
border-radius: 30px;
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
color: white;
border: none;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}
.landing-page .btn:hover {
transform: translateY(-3px);
box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4);
}
/* Main App Container */
.container {
max-width: 1400px;
width: 100%; /* Ensure fluid width */
margin: 0 auto;
background: rgba(255, 255, 255, 0.95);
border-radius: 20px; /* Rounded corners */
padding: 30px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
backdrop-filter: blur(10px);
display: none; /* Hidden by default */
}
/* Header Styling */
.header {
text-align: center;
margin-bottom: 40px;
padding-bottom: 20px;
border-bottom: 3px solid #4CAF50;
}
.header h1 {
color: #2E7D32;
font-size: 2.5em;
margin-bottom: 10px;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}
.header p {
color: #666;
font-size: 1.2em;
}
/* New style for the project details row */
.project-details-row {
display: flex; /* Make it a flex container */
flex-wrap: wrap; /* Allow items to wrap to the next line */
height: 150x;
justify-content: space-around; /* Distribute items evenly with space around them */
align-items: center; /* Align items vertically in the center */
margin-bottom: 40px; /* Add some space below it */
padding: 25px; /* Keep existing padding */
border-radius: 5px; /* Keep existing border-radius */
border: 1px solid #e0e0e0; /* Keep existing border */
background: linear-gradient(135deg, #f8f9ff 0%, #e8f5e8 100%); /* Keep existing background */
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); /* Keep existing shadow */
}
.project-details-row h3 {
width: 100%; /* Make the heading take full width */
text-align: center; /* Center the heading */
margin-bottom: 20px;
color: #2E7D32;
font-size: 1.3em;
border-bottom: 0.5px solid #4CAF50;
padding-bottom: 10px;
}
.project-details-row .input-row {
flex: 1; /* Allow each input-row to grow and shrink */
min-width: 280px; /* Minimum width for each input row before wrapping */
margin: 10px 15px; /* Adjust margin for spacing between items */
justify-content: space-between; /* Ensure label and input are spaced */
}
/* Controls Section */
.controls {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 30px;
margin-bottom: 40px;
}
.control-group {
background: linear-gradient(135deg, #f8f9ff 0%, #e8f5e8 100%);
padding: 25px;
border-radius: 15px; /* Rounded corners */
border: 2px solid #e0e0e0;
transition: all 0.3s ease;
}
.control-group:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
.control-group h3 {
color: #2E7D32;
margin-bottom: 20px;
font-size: 1.3em;
border-bottom: 2px solid #4CAF50;
padding-bottom: 10px;
}
.input-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.input-row label {
font-weight: 200;
color: #555;
min-width: 120px;
}
.input-row input[type="number"] {
padding: 10px;
border: 2px solid #ddd;
border-radius: 8px; /* Rounded corners */
width: 120px;
font-size: 1em;
transition: border-color 0.3s ease;
}
.input-row input[type="text"] {
padding: 10px;
border: 2px solid #ddd;
border-radius: 8px; /* Rounded corners */
width: 120px;
font-size: 1em;
transition: border-color 0.3s ease;
}
.input-row input[type="checkbox"] {
width: 20px;
height: 20px;
border-radius: 4px; /* Rounded corners */
cursor: pointer;
}
.input-row input:focus {
outline: none;
border-color: #4CAF50;
box-shadow: 0 0 10px rgba(76, 175, 80, 0.2);
}
/* Thinning section specific styles */
.thinning-regime {
background: #f9f9f9;
border: 1px solid #ddd;
border-radius: 8px;
padding: 15px;
margin-bottom: 10px;
}
.thinning-regime h4 {
color: #2E7D32;
margin-bottom: 10px;
font-size: 1em;
}
.remove-thinning-btn {
background: #ff4444;
color: white;
border: none;
border-radius: 4px;
padding: 5px 10px;
cursor: pointer;
font-size: 0.8em;
margin-top: 10px;
}
.remove-thinning-btn:hover {
background: #cc0000;
}
.add-thinning-btn {
background: #4CAF50;
color: white;
border: none;
border-radius: 4px;
padding: 8px 15px;
cursor: pointer;
font-size: 0.9em;
margin-top: 10px;
}
.add-thinning-btn:hover {
background: #45a049;
}
/* Button Styling */
.button-container {
text-align: center;
margin: 30px 0;
}
.btn {
padding: 15px 40px;
font-size: 1.2em;
font-weight: 600;
border: none;
border-radius: 25px; /* Rounded corners */
cursor: pointer;
transition: all 0.3s ease;
margin: 0 10px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); /* Added shadow for all buttons */
}
.btn-primary {
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}
.btn-secondary {
background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
color: white;
}
.btn-secondary:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4);
}
/* Results Section */
.results {
display: none; /* Hidden by default */
margin-top: 40px;
}
/* Summary Cards */
.summary-cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
margin-bottom: 40px;
}
.summary-card {
background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
padding: 25px;
border-radius: 15px; /* Rounded corners */
text-align: center;
border: 2px solid #e0e0e0;
transition: all 0.3s ease;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05); /* Added subtle shadow */
}
.summary-card:hover {
transform: translateY(-3px);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}
.summary-card h4 {
color: #2E7D32;
font-size: 1.1em;
margin-bottom: 10px;
}
.summary-card .value {
font-size: 1.4em;
font-weight: 700;
color: #4CAF50;
margin-bottom: 5px;
}
/* Charts Container */
.charts-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
gap: 30px;
margin-bottom: 40px;
}
.chart-wrapper {
background: white;
padding: 25px;
border-radius: 15px; /* Rounded corners */
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
max-height: 450px; /* Added max-height to contain the chart */
display: flex; /* Use flexbox for centering content */
flex-direction: column;
justify-content: center;
align-items: center;
}
.chart-wrapper h3 {
color: #2E7D32;
margin-bottom: 20px;
text-align: center;
font-size: 1.3em;
}
/* Canvas specific styling */
canvas {
max-width: 100%; /* Ensure canvas doesn't overflow its wrapper */
max-height: 350px; /* Explicit max-height for the canvas */
width: 100% !important; /* Override Chart.js inline styles if necessary */
height: auto !important; /* Maintain aspect ratio within max-height */
}
/* Detailed Table */
.detailed-table {
background: white;
border-radius: 15px; /* Rounded corners */
overflow: hidden; /* For table borders */
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
margin-bottom: 30px;
}
.detailed-table h3 {
background: linear-gradient(135deg, #2E7D32 0%, #4CAF50 100%);
color: white;
padding: 20px;
margin: 0;
font-size: 1.3em;
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 15px;
text-align: center;
border-bottom: 1px solid #e0e0e0;
}
th {
background: #f8f9fa;
font-weight: 600;
color: #2E7D32;
}
tbody tr:hover {
background: #f0f0f0; /* Lighter hover effect */
}
/* Methodology Section */
.methodology {
background: linear-gradient(135deg, #e8f5e8 0%, #f0f8f0 100%);
padding: 30px;
border-radius: 15px; /* Rounded corners */
border-left: 5px solid #4CAF50;
margin-bottom: 30px;
}
.methodology h3 {
color: #2E7D32;
margin-bottom: 20px;
font-size: 1.4em;
}
.methodology p {
line-height: 1.6;
color: #555;
margin-bottom: 15px;
}
.methodology ul {
padding-left: 20px;
color: #555;
}
.methodology li {
margin-bottom: 10px;
line-height: 1.5;
}
/* Responsive Design */
@media (max-width: 1200px) {
.charts-container {
grid-template-columns: 1fr; /* Stack charts on smaller screens */
}
}
@media (max-width: 768px) {
.controls {
grid-template-columns: 1fr; /* Stack control groups */
}
.input-row {
flex-direction: column;
align-items: flex-start;
gap: 10px;
}
.input-row input[type="number"] {
width: 100%;
}
.btn {
padding: 12px 25px;
font-size: 1em;
margin: 5px; /* Adjust margin for smaller buttons */
}
/* Adjustments for smaller screens for project details row */
.project-details-row {
flex-direction: column; /* Stack items vertically on small screens */
align-items: flex-start; /* Align to start when stacked */
}
.project-details-row .input-row {
width: 100%; /* Full width for input rows when stacked */
margin: 10px 0; /* Adjust margin */
}
.landing-page h1 {
font-size: 2.2em;
}
.landing-page p {
font-size: 1.2em;
}
.landing-page .description {
font-size: 1em;
}
.landing-page .developer-info {
font-size: 0.8em;
}
.landing-page .btn {
font-size: 1.2em;
padding: 15px 30px;
}
}
@media (max-width: 480px) {
.header h1 {
font-size: 1.8em;
}
.header p {
font-size: 1em;
}
.summary-card .value {
font-size: 1.8em;
}
}
</style>
</head>
<body>
<!-- Landing Page -->
<div class="landing-page" id="landingPage">
<h1>Treestimator <span style="font-size:0.3em; color:#4c8f43; font-family:'Gill Sans MT'; font-weight:normal; vertical-align: text-top; margin-left:8px;">(Beta)</span> 🌱</h1> <br>
<p>Contextualized Project Level Seedling to <br>Trees Modeling Tool</p><br>
<p class="description">
<em> Treestimator helps you simulate tree populations at different ages, using your estimates for seedling survival and replacement planting strategies, to enable more effective restoration planning. </em>
</p>
<p class="developer-info">
Developed by Lalisa Duguma, PhD <br> Global Evergreening Alliance (GEA)
</p>
<button style="font-size: 0.9rem;"class="btn" onclick="enterApp()">Enter App</button>
<footer style="margin-top:32px; font-size:0.8em; color:#888; text-align:center;">
© 2025 Lalisa Duguma, Global Evergreening Alliance (GEA). All rights reserved.
</footer>
</div>
<!-- Main Application Container -->
<div class="container" id="mainApp">
<div class="header">
<h1>Treestimator: Seedlings to Trees Estimator</h1>
<p>Contextualized Project Level Seedling to Trees Modeling & Analysis Tool</p><br>
</div>
<div class="controls">
<div class="control-group">
<h3>Project Details</h3>
<div class="input-row">
<label for="userName">Project Leader:</label>
<input type="text" id="userName" value="Lalisa D.">
</div>
<div class="input-row">
<label for="projectLocation">Project Location:</label>
<input type="text" id="projectLocation" value="Dabus, Ethiopia">
</div>
<div class="input-row">
<label for="projectSize">Project Size (ha):</label>
<input type="number" id="projectSize" value="2500" min="0">
</div>
<div class="input-row">
<label for="projectYear">Planting Year:</label>
<input type="number" id="projectYear" value="2025" min="2000" max="2050">
</div>
</div>
<div class="control-group">
<h3>Planting Schedule (Seedlings)</h3>
<div class="input-row">
<label>Year 1:</label>
<input type="number" id="year1" value="100000" min="0">
</div>
<div class="input-row">
<label>Year 2:</label>
<input type="number" id="year2" value="350000" min="0">
</div>
<div class="input-row">
<label>Year 3:</label>
<input type="number" id="year3" value="350000" min="0">
</div>
<div class="input-row">
<label>Year 4:</label>
<input type="number" id="year4" value="150000" min="0">
</div>
<div class="input-row">
<label>Year 5:</label>
<input type="number" id="year5" value="50000" min="0">
</div>
</div>
<div class="control-group">
<h3>Survival Rates (%)</h3>
<div class="input-row">
<label>Year 1 (Age 1):</label>
<input type="number" id="survival1" value="70" step="0.1" min="0" max="100">
</div>
<div class="input-row">
<label>Year 2 (Age 2):</label>
<input type="number" id="survival2" value="85" step="0.1" min="0" max="100">
</div>
<div class="input-row">
<label>Year 3 (Age 3):</label>
<input type="number" id="survival3" value="98" step="0.1" min="0" max="100">
</div>
<div class="input-row">
<label>Year 4 (Age 4):</label>
<input type="number" id="survival4" value="98" step="0.1" min="0" max="100">
</div>
<div class="input-row">
<label>Year 5 (Age 5):</label>
<input type="number" id="survival5" value="98" step="0.1" min="0" max="100">
</div>
<div class="input-row">
<label>Year 6+ (Age 6+):</label>
<input type="number" id="survival6" value="99" step="0.1" min="0" max="100">
</div>
</div>
<div class="control-group">
<h3>Beating Up Settings</h3>
<div class="input-row">
<label>Replace Mortality 12 Months after Planting:</label>
<input type="checkbox" id="beatYear1" checked>
</div>
<div class="input-row">
<label>Replace Mortality 24 Months after Planting:</label>
<input type="checkbox" id="beatYear2" checked>
</div>
<div class="input-row">
<label>Simulation Years:</label>
<input type="number" id="simYears" value="30" min="7" max="50">
</div>
<div class="input-row">
<label>Beating Up Stops (Project Year):</label>
<input type="number" id="beatUpStopYear" value="5" min="1" max="50">
</div>
</div>
<div class="control-group">
<h3>Thinning Regimes</h3>
<div class="input-row">
<label>Number of Thinning Regimes:</label>
<input type="number" id="numThinningRegimes" value="0" min="0" max="10" onchange="updateThinningRegimes()">
</div>
<div id="thinningRegimes">
<!-- Thinning regimes will be dynamically added here -->
</div>
</div>
</div>
<div class="button-container">
<button class="btn btn-primary" onclick="runSimulation()"> Run Simulation: Estimate My Trees</button>
</div>
<footer style="margin-top:32px; font-size:0.8em; color:#888; text-align:center;">
© 2025 Lalisa Duguma, Global Evergreening Alliance (GEA). All rights reserved.
</footer>
<hr style="border:0; border-top:2px solid #4CAF50; margin:24px 0 8px 0;">
<div class="button-container">
<span style="font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; font-weight:bold; font-size:2.1em; color:#1976D2; margin-right:16px; vertical-align:middle;">Your Simulation Results</span>
<button class="btn btn-secondary" onclick="exportToPDF()" style="display:none; vertical-align:middle; font-size:0.95em; padding:4px 12px;" id="exportBtn">📄 Generate PDF Summary</button>
</div>
<div class="results" id="results">
<div class="summary-cards" id="summaryCards">
<!-- Summary cards will be populated here -->
</div>
<div class="charts-container">
<div class="chart-wrapper">
<h3>Total Live Trees Over Time</h3>
<canvas id="survivalChart"></canvas>
</div>
<div class="chart-wrapper">
<h3>Survivors from Main Planting by Planting Year</h3>
<canvas id="cumulativeChart"></canvas>
</div>
</div>
<div class="detailed-table">
<h3>Detailed Year-by-Year Analysis</h3>
<div style="overflow-x: auto;">
<table id="detailedTable">
<!-- Table will be populated here -->
</table>
</div>
</div>
<div class="methodology">
<h3>🧮 Methodological Overview</h3>
<p><strong>This simulation employs a cohort-based survival model with the following key principles:</strong></p>
<ul>
<li><strong>Cohort Tracking:</strong> Each year's plantings (main planting and beat-up or mortality replacements) are tracked as separate cohorts throughout their lifecycle.</li>
<li><strong>Cumulative Survival:</strong> Trees must survive each year's mortality rate to continue to the next year.</li>
<li id="beatingUpStrategy"></li>
<li><strong>Beating Up Cutoff:</strong> All beating up activities stop at the user-defined calendar year. This means no new replacement seedlings are planted from the subsequent calendar year onwards, regardless of tree age.</li>
<li id="methodologySurvivalRates"><strong>Age-Based Mortality:</strong> Survival rates are defined by user input: Age 1 (N/A%), Age 2 (N/A%), Age 3 (N/A%), Age 4 (N/A%), Age 5 (N/A%), Age 6+ (N/A%).</li>
<li id="thinningMethodology"><strong>Thinning Operations:</strong> No thinning regimes defined.</li>
<li><strong>Mathematical Model:</strong> Survivors(end of year) = Survivors(start of year) × Survival Rate(age) × (1 - Thinning Rate if applicable)</li>
</ul><br>
<p><strong>Key Assumptions</strong></p>
<ul>
<li>Beating up only replaces deaths from trees that completed Age 1 or Age 2.</li>
<li>Replacement seedlings are planted at the beginning of rainy season in the subsequent calendar year and follow the same survival pattern as main plantings.</li>
<li>No beating up occurs from the calendar year after the user-defined cutoff onwards.</li>
<li>Thinning is applied to all cohorts of the specified age at the end of each calendar year, before natural mortality.</li>
<li>Thinned trees are removed and do not contribute to future survival or beating up calculations.</li>
<li>No natural regeneration or additional mortality factors beyond the defined survival rates are considered.</li>
<li>Survival rates remain constant within each specified age category.</li>
</ul><br>
<p><strong>Disclaimer</strong></p>
<ul>
<p>This app is provided for estimation purposes only. While best effort was made to ensure accuracy, results may vary and should not be considered definitive. Always consult with a qualified professional for critical decisions.</p>
<p>The Developer is not liable for any damages due to the use of this product. </p>
</ul><br>
<p><strong>Developer</strong></p>
<ul>
<p>Lalisa Duguma, PhD</p>
<p>Global Evergreening Alliance (GEA) (2025) </p>
</ul><br>
</div>
</div>
</div>
<script>
// Function to show the main app and hide the landing page
function enterApp() {
document.getElementById('landingPage').style.display = 'none';
document.getElementById('mainApp').style.display = 'block';
// Adjust body styling for the main app
document.body.style.alignItems = 'flex-start';
document.body.style.padding = '20px';
}
// Ensure Chart.js and its annotation plugin are registered
const { Chart } = window;
if (Chart && typeof ChartjsAnnotation !== 'undefined') {
Chart.register(ChartjsAnnotation);
} else {
console.warn("Chart.js or ChartjsAnnotation plugin not found. Charts and annotations might not work.");
}
let simulationData = null; // Stores the results of the last simulation
let charts = {}; // Stores Chart.js instances for easy destruction
/**
* Updates the thinning regimes input section based on the number specified
*/
function updateThinningRegimes() {
const numRegimes = parseInt(document.getElementById('numThinningRegimes').value) || 0;
const container = document.getElementById('thinningRegimes');
// Clear existing regimes
container.innerHTML = '';
// Add input fields for each regime
for (let i = 1; i <= numRegimes; i++) {
const regimeDiv = document.createElement('div');
regimeDiv.className = 'thinning-regime';
regimeDiv.innerHTML = `
<h4>Thinning Regime ${i}</h4>
<div class="input-row">
<label>Thinning Age (years):</label>
<input type="number" id="thinningAge${i}" value="${5 + (i * 5)}" min="1" max="50">
</div>
<div class="input-row">
<label>Trees Removed (%):</label>
<input type="number" id="thinningPercent${i}" value="30" min="0" max="100" step="0.1">
</div>
`;
container.appendChild(regimeDiv);
}
}
/**
* Gets thinning regimes from user input
* @returns {Array} Array of thinning regime objects
*/
function getThinningRegimes() {
const numRegimes = parseInt(document.getElementById('numThinningRegimes').value) || 0;
const regimes = [];
for (let i = 1; i <= numRegimes; i++) {
const age = parseInt(document.getElementById(`thinningAge${i}`).value);
const percent = parseFloat(document.getElementById(`thinningPercent${i}`).value);
if (!isNaN(age) && !isNaN(percent) && age > 0 && percent >= 0 && percent <= 100) {
regimes.push({
age: age,
removalRate: percent / 100
});
}
}
// Sort regimes by age
regimes.sort((a, b) => a.age - b.age);
return regimes;
}
/**
* Runs the tree planting simulation based on user inputs.
* Fetches input values, performs the simulation, and displays the results.
*/
function runSimulation() {
// Get input values from the UI
const plantingSchedule = {
1: parseInt(document.getElementById('year1').value),
2: parseInt(document.getElementById('year2').value),
3: parseInt(document.getElementById('year3').value),
4: parseInt(document.getElementById('year4').value),
5: parseInt(document.getElementById('year5').value)
};
const survivalRates = {
year1: parseFloat(document.getElementById('survival1').value) / 100,
year2: parseFloat(document.getElementById('survival2').value) / 100,
year3: parseFloat(document.getElementById('survival3').value) / 100,
year4: parseFloat(document.getElementById('survival4').value) / 100,
year5: parseFloat(document.getElementById('survival5').value) / 100,
year6plus: parseFloat(document.getElementById('survival6').value) / 100
};
const beatUpSettings = {
year1: document.getElementById('beatYear1').checked,
year2: document.getElementById('beatYear2').checked
};
const beatUpStopYear = parseInt(document.getElementById('beatUpStopYear').value);
const totalYears = parseInt(document.getElementById('simYears').value);
const thinningRegimes = getThinningRegimes();
// Validate inputs
for (let i = 1; i <= 5; i++) {
if (isNaN(plantingSchedule[i]) || plantingSchedule[i] < 0) {
showMessageBox(`Please enter a valid non-negative number for Year ${i} plantings.`);
return;
}
}
if (isNaN(survivalRates.year1) || survivalRates.year1 < 0 || survivalRates.year1 > 1) {
showMessageBox('Please enter a valid survival rate (0-100) for Year 1.'); return;
}
if (isNaN(survivalRates.year2) || survivalRates.year2 < 0 || survivalRates.year2 > 1) {
showMessageBox('Please enter a valid survival rate (0-100) for Year 2.'); return;
}
if (isNaN(survivalRates.year3) || survivalRates.year3 < 0 || survivalRates.year3 > 1) {
showMessageBox('Please enter a valid survival rate (0-100) for Year 3.'); return;
}
if (isNaN(survivalRates.year4) || survivalRates.year4 < 0 || survivalRates.year4 > 1) {
showMessageBox('Please enter a valid survival rate (0-100) for Year 4.'); return;
}
if (isNaN(survivalRates.year5) || survivalRates.year5 < 0 || survivalRates.year5 > 1) {
showMessageBox('Please enter a valid survival rate (0-100) for Year 5.'); return;
}
if (isNaN(survivalRates.year6plus) || survivalRates.year6plus < 0 || survivalRates.year6plus > 1) {
showMessageBox('Please enter a valid survival rate (0-100) for Year 6+.'); return;
}
if (isNaN(totalYears) || totalYears < 7 || totalYears > 50) {
showMessageBox('Please enter a valid number of simulation years (between 7 and 50).');
return;
}
if (isNaN(beatUpStopYear) || beatUpStopYear < 1 || beatUpStopYear > totalYears) {
showMessageBox(`Please enter a valid year for "Beating Up Stops" (between 1 and ${totalYears}).`);
return;
}
// Validate thinning regimes
for (let i = 0; i < thinningRegimes.length; i++) {
const regime = thinningRegimes[i];
if (regime.age > totalYears) {
showMessageBox(`Thinning age ${regime.age} cannot be greater than simulation years (${totalYears}).`);
return;
}
}
// Perform the simulation
simulationData = performSimulation(plantingSchedule, survivalRates, beatUpSettings, totalYears, beatUpStopYear, thinningRegimes);
// Display results in the UI
displayResults(simulationData);
// Show the export button
document.getElementById('exportBtn').style.display = 'inline-block';
}
/**
* Core simulation logic. Tracks cohorts and their survival over time,
* incorporating main plantings, beat-up or mortality replacements, and thinning operations.
* @param {Object} plantingSchedule - Initial planting counts per year (1-5).
* @param {Object} survivalRates - Survival rates for different age groups.
* @param {Object} beatUpSettings - Flags for enabling Year 1 and Year 2 beat-up.
* @param {number} totalYears - Total simulation years.
* @param {number} beatUpCutoffYear - The calendar year when beating up stops.
* @param {Array} thinningRegimes - Array of thinning regime objects.
* @returns {Object} - Comprehensive simulation results.
*/
function performSimulation(plantingSchedule, survivalRates, beatUpSettings, totalYears, beatUpCutoffYear, thinningRegimes) {
// Stores all active cohorts. Each cohort tracks its planting year, original source, and current survivors.
const activeCohorts = [];
// Stores detailed results for each calendar year of the simulation.
const yearlySimulationResults = [];
// Track total trees removed by thinning
let totalTreesThinned = 0;
// Accumulates deaths from the current year that will trigger beat-up plantings in the *next* year.
// Stores objects like { originalPlantYear: number, deaths: number, age: number }
let deathsToReplaceNextYear = [];
for (let currentCalendarYear = 1; currentCalendarYear <= totalYears; currentCalendarYear++) {
let newPlantingsThisYear = 0; // Total new seedlings planted in this calendar year (main planting + beat-up)
let totalDeathsThisYear = 0; // Total deaths across all cohorts in this calendar year
let totalSurvivorsEndOfYear = 0; // Total live trees at the end of this calendar year
let beatUpPlantingsThisYear = 0; // Total beat-up seedlings planted in this calendar year
let totalThinnedThisYear = 0; // Total trees thinned in this calendar year
const cohortDetailsForCurrentYear = []; // Detailed breakdown of each cohort for the table
// 1. Add new main plantings for the current calendar year (only for Years 1-5)
if (currentCalendarYear <= 5 && plantingSchedule[currentCalendarYear] > 0) {
const count = plantingSchedule[currentCalendarYear];
activeCohorts.push({
id: `P${currentCalendarYear}`, // Unique ID for main planting cohort
plantCalendarYear: currentCalendarYear, // The calendar year this specific cohort was planted
originalPlantYear: currentCalendarYear, // The main planting year this cohort is associated with
currentSurvivors: count // Number of trees alive from this cohort
});
newPlantingsThisYear += count;
}
// 2. Add beat-up or mortality replacements from previous year's accumulated deaths
// These replacements are planted at the *start* of the currentCalendarYear.
// Beat-up or mortality replacements occur from Project Year 2 up to beatUpCutoffYear.
if (currentCalendarYear > 1 && currentCalendarYear <= beatUpCutoffYear) {
deathsToReplaceNextYear.forEach(item => {
const count = item.deaths;
if (count > 0) {
activeCohorts.push({
id: `B${item.age}fromP${item.originalPlantYear}-CY${currentCalendarYear-1}`, // Unique ID for beat-up cohort
plantCalendarYear: currentCalendarYear, // The calendar year this beat-up cohort is planted
originalPlantYear: item.originalPlantYear, // The main planting year this beat-up cohort is replacing
currentSurvivors: count
});
newPlantingsThisYear += count;
beatUpPlantingsThisYear += count;
}
});
}
// Reset the deaths to replace for the next iteration
deathsToReplaceNextYear = [];
// 3. Process survival and thinning for all active cohorts (including newly added ones at the start of this year)
const cohortsToProcess = [...activeCohorts];
activeCohorts.length = 0; // Clear the array to repopulate with surviving cohorts
cohortsToProcess.forEach(cohort => {
if (cohort.currentSurvivors <= 0) {
return; // This cohort has already died out, skip
}
// Calculate the age of the trees in this cohort at the end of the current calendar year
const ageOfCohort = currentCalendarYear - cohort.plantCalendarYear + 1;
let startingCountForCohort = cohort.currentSurvivors;
let survivorsAfterThinning = startingCountForCohort;
let thinnedFromCohort = 0;
// Apply thinning first (before natural mortality)
const applicableThinning = thinningRegimes.find(regime => regime.age === ageOfCohort);
if (applicableThinning) {
thinnedFromCohort = Math.floor(startingCountForCohort * applicableThinning.removalRate);
survivorsAfterThinning = startingCountForCohort - thinnedFromCohort;
totalThinnedThisYear += thinnedFromCohort;
totalTreesThinned += thinnedFromCohort;
}
// Determine the appropriate survival rate based on age
let survivalRate;
if (ageOfCohort === 1) {
survivalRate = survivalRates.year1;
} else if (ageOfCohort === 2) {
survivalRate = survivalRates.year2;
} else if (ageOfCohort === 3) {
survivalRate = survivalRates.year3;
} else if (ageOfCohort === 4) {