forked from dafekt1ve/d3-skewt-and-indices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_before_BRN_fix.html
3554 lines (3200 loc) · 126 KB
/
index_before_BRN_fix.html
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>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="sounding.css">
<title></title>
<body>
<div id="container">
<div id="checks">
<label for="parcel_check"><input id="parcel_check" type="checkbox" checked="checked">Parcel Temperature</input></label>
<label for="parcelmix_check"><input id="parcelmix_check" type="checkbox" checked="checked">Mixed Parcel Temperature</input></label>
<label for="tvc_check"><input id="tvc_check" type="checkbox" checked="checked">Virtual Temperature</input></label>
<label for="twc_check"><input id="twc_check" type="checkbox" checked="checked">Wet Bulb Temperature</input></label>
<br/>
Mixing Layer Depth (in mb):
<input id="ml_depth" type="number" min="1" max="200" value="100" style="width: 50px">
<span> </span>For CAPE Calculations:
<label for="t_CAPE_check"><input name="CAPE_check" id="t_CAPE_check" type="radio" checked value="T">Use T</input></label>
<label for="tv_CAPE_check"><input name="CAPE_check" id="tv_CAPE_check" type="radio" value="Tv">Use Tv</input></label>
</div>
<div id="mainbox">
<div id="checks_wrapper">
<div id="upload_wrapper">
<label id="fileUpload" for="input-file">Upload File:</label>
<input type="file" id="input-file">
</div>
<div id="editData">
<button id="editButton" onClick="tableVis()">Show Data Table</button>
</div>
<div id="reset">
<button id="resetSounding" onClick="resetSounding()">Reset Sounding</button>
</div>
<div id="presets">
<p>Preset Soundings:
<select id="allstar_sounding">
<option disabled>━ Defaults ━</option>
<option value="data_TOP.json" default>Default Sounding</option>
<option value="data_SkewT.json">Flash Sounding</option>
<option disabled>━ Thunderstorms & Tornadoes ━</option>
<option value="./All-Star-Soundings/BMX_2011427_18.html">Tornado Outbreak (BMX)</option>
<option value="./All-Star-Soundings/BMX_2011428_00.html">Tornado Outbreak (BMX)</option>
<option value='./All-Star-Soundings/TOP_200354_12.html'>Tornado Outbreak (TOP)</option>
<option value='./All-Star-Soundings/TOP_200354_18.html'>Tornado Outbreak (TOP)</option>
<option value='./All-Star-Soundings/TOP_200355_00.html'>Tornado Outbreak -- Post Dryline (TOP)</option>
<option value='./All-Star-Soundings/OUN_200358_12.html'>Moore, OK Tornado (OUN)</option>
<option value='./All-Star-Soundings/OUN_200358_18.html'>Moore, OK Tornado (OUN)</option>
<option value='./All-Star-Soundings/OUN_200359_00.html'>Moore, OK Tornado (OUN)</option>
<option value='./All-Star-Soundings/TOP_2004530_00.html'>NE/KS/OK Tornadoes (TOP)</option>
<option value='./All-Star-Soundings/OUN_2004530_00.html'>NE/KS/OK Tornadoes (OUN)</option>
<option value='./All-Star-Soundings/BMX_2011427_18.html'>Severe Weather Outbreak (BMX)</option>
<option value='./All-Star-Soundings/BMX_2011428_00.html'>Severe Weather Outbreak (BMX)</option>
<option value='./All-Star-Soundings/JAN_2011427_18.html'>Severe Weather Outbreak (JAN)</option>
<option value='./All-Star-Soundings/OUN_2011524_12.html'>Severe Weather Outbreak (OUN)</option>
<option value='./All-Star-Soundings/OUN_2011524_18.html'>Severe Weather Outbreak (OUN)</option>
<option value='./All-Star-Soundings/OUN_2013520_12.html'>Moore, OK EF5 Tornado (OUN)</option>
<option value='./All-Star-Soundings/OUN_2013520_18.html'>Moore, OK EF5 Tornado (OUN)</option>
<option value='./All-Star-Soundings/OUN_2013531_12.html'>El Reno, OK EF3 Tornado (OUN)</option>
<option value='./All-Star-Soundings/FGZ_2017820_00.html'>Dry Microburst (FGZ)</option>
<option value='./All-Star-Soundings/OUN_2015615_00.html'>Wet Microburst (OUN)</option>
<option value='./All-Star-Soundings/IAD_2012630_00.html'>Derecho (IAD)</option>
<option disabled>━ Hurricanes ━</option>
<option value='./All-Star-Soundings/EYW_2004813_00.html'>Hurricane Charley (EYW)</option>
<option value='./All-Star-Soundings/EYW_2004813_12.html'>Hurricane Charley (EYW)</option>
<option value='./All-Star-Soundings/TBW_2004813_18.html'>Hurricane Charley (TBW)</option>
<option value='./All-Star-Soundings/TBW_2004814_00.html'>Hurricane Charley (TBW)</option>
<option value='./All-Star-Soundings/CRP_2003716_00.html'>Hurricane Claudette (Near Landfall; CRP)</option>
<option value='./All-Star-Soundings/DRT_2003716_00.html'>Hurricane Claudette (Inland Dry Environment; DRT)</option>
<option value='./All-Star-Soundings/DRT_2003716_06.html'>Hurricane Claudette (Inland Moistening Environment; DRT)</option>
<option value='./All-Star-Soundings/DRT_2003716_12.html'>Hurricane Claudette (Inland over DRT; DRT)</option>
<option value='./All-Star-Soundings/76595_2002923_12.html'>Hurricane Isidore (76595)</option>
<option value='./All-Star-Soundings/MMMD_2002922_12.html'>Hurricane Isidore (MMMD)</option>
<option value='./All-Star-Soundings/LIX_2005827_06.html'>Hurricane Katrina (LIX)</option>
<option value='./All-Star-Soundings/LZK_2005830_00.html'>Remnants of Hurricane Katrina (LZK)</option>
<option value='./All-Star-Soundings/TXKF_20141018_12.html'>Hurricane Gonzalo (direct hit on Bermuda; TXKF)</option>
<option value='./All-Star-Soundings/JAX_2016108_00.json'>Hurricane Matthew (JAX)</option>
<option value='./All-Star-Soundings/CRP_2017826_00.html'>Hurricane Harvey (Near Landfall; CRP)</option>
<option value='./All-Star-Soundings/EYW_2017910_00.html'>Hurricane Irma (12 hrs prior to landfall; EYW))</option>
<option value='./All-Star-Soundings/TBW_2017911_00.html'>Hurricane Irma (12 hrs post landfalll TBW)</option>
<option disabled>━ Heavy Snow ━</option>
<option value="./All-Star-Soundings/ABR_20051129_00.html">Heavy Snow (ABR)</option>
<option value='./All-Star-Soundings/BUF_20011224_12.html'>Heavy Lake Effect Snow (BUF)</option>
<option value='./All-Star-Soundings/BUF_20011225_00.html'>Heavy Lake Effect Snow (BUF)</option>
<option value='./All-Star-Soundings/OUN_20021223_18.html'>Heavy Snow/Thundersnow</option>
<option value='./All-Star-Soundings/FWD_2004213_12.html'>Heavy Snow</option>
<option value='./All-Star-Soundings/FWD_2004214_00.html'>Heavy Snow</option>
<option value='./All-Star-Soundings/FWD_2004214_12.html'>Heavy Snow</option>
<option value='./All-Star-Soundings/FWD_2004215_00.html'>Heavy Snow</option>
<option value='./All-Star-Soundings/ABR_20051129_00.html'>Winter Storm</option>
<option value='./All-Star-Soundings/OKX_2006212_06.html'>Historic Blizzard</option>
<option value='./All-Star-Soundings/CHH_2006212_06.html'>Historic Blizzard</option>
<option value='./All-Star-Soundings/LBF_2006321_00.html'>Great Plains Snowstorm</option>
<option value='./All-Star-Soundings/OAX_2006321_00.html'>Great Plains Snowstorm</option>
<option value='./All-Star-Soundings/BUF_20131212_00.html'>Heavy Lake Effect Snow</option>
<option value='./All-Star-Soundings/CHH_2015127_12.html'>Boston Blizzard</option>
<option value='./All-Star-Soundings/BUF_20141119_00.html'>Heavy Lake Effect Snow</option>
<option value='./All-Star-Soundings/GYX_2015128_00.html'>Blizzard</option>
<option value='./All-Star-Soundings/TFX_2019929_12.html'>4 Feet of Snow</option>
<option disabled>━ Heavy Rain/Flooding ━</option>
<option value='./All-Star-Soundings/FWD_2004728_00.html'>Heavy Rain</option>
<option value='./All-Star-Soundings/FWD_2004728_12.html'>Heavy Rain</option>
<option value='./All-Star-Soundings/FWD_2004729_00.html'>Heavy Rain</option>
<option value='./All-Star-Soundings/FFC_2009920_12.html'>Atlanta Flash Flood</option>
<option value='./All-Star-Soundings/OUN_2010614_00.html'>Oklahoma City Flash Flood</option>
<option value='./All-Star-Soundings/OUN_2010614_12.html'>Oklahoma City Flash Flood</option>
<option value='./All-Star-Soundings/OKX_2014813_12.html'>Historic Flooding on Long Island</option>
<option value='./All-Star-Soundings/DNR_2013912_12.html'>Historic Flooding along Front Range of Colorado</option>
<option value='./All-Star-Soundings/DNR_2013913_12.html'>Historic Flooding along Front Range of Colorado</option>
<option disabled>━ Precipitation Typing ━</option>
<option value='./All-Star-Soundings/FWD_20001213_12.html'>Freezing Rain/Ice Pellets</option>
<option value='./All-Star-Soundings/OUN_20001213_12.html'>Freezing Rain/Ice Pellets</option>
<option value='./All-Star-Soundings/FWD_20001226_00.html'>Rain/Freezing Rain/Ice Pellets</option>
<option value='./All-Star-Soundings/OUN_20001226_00.html'>Rain/Freezing Rain/Ice Pellets</option>
<option value='./All-Star-Soundings/GSO_200821_12.html'>Cold Air Damming</option>
<option disabled>━ Heat Wave ━</option>
<option value='./All-Star-Soundings/OUN_2003721_00.html'>Heat Wave</option>
<option value='./All-Star-Soundings/OUN_201183_00.html'>Heat Wave</option>
<option value='./All-Star-Soundings/FWD_201183_00.html'>Heat Wave</option>
<option value='./All-Star-Soundings/DVN_1995714_00.html'>Heat Wave</option>
<option value='./All-Star-Soundings/ILX_1995714_00.html'>Heat Wave</option>
<option value='./All-Star-Soundings/NKX_201877_00.html'>Heat Wave</option>
<option disabled>━ Cold Wave ━</option>
<option value='./All-Star-Soundings/PABR_2002110_00.html'>Large Inversion/Low Tropopause</option>
<option value='./All-Star-Soundings/OAX_201417_12.html'>Arctic Cold Blast (Record-setting Surface High)</option>
<option value='./All-Star-Soundings/UIL_201427_12.html'>Seattle Record Cold</option>
<option value='./All-Star-Soundings/MPX_199622_12.html'>Frigid Cold</option>
<option value='./All-Star-Soundings/ABR_201416_00.json'>Brutal Cold</option>
<option disabled>━ Wildfire ━</option>
<option value='./All-Star-Soundings/MFR_2018727_00.html'>Carr Wildfire</option>
</select>
<button id="default" onClick="loadSounding()" value="default">Load Sounding</button>
</p>
</div>
</div>
</div>
<div id="hodobox"></div>
<div id="editTableWrap"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.3/d3.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="jsfunctions.js"></script>
<script type="text/javascript">
//var dblClickState = false;
$(document).ready( function() {
$(window).keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
// $("#speedRect").hide();
$("input:checkbox").on("change", function() {
var checkbox_id = $(this).prop("id");
var className = checkbox_id.split("_",1).toString();
$("." + className + ".member").toggle();
$("." + className + ".focus").css('visibility', $('.' +className + '.focus').css('visibility') == 'hidden' ? 'visible' : 'hidden');
if(className == "twc") {
$(".wbztext, .wbz_rectline").css('visibility', $(".wbztext, .wbz_rectline").css('visibility') == 'hidden' ? 'visible' : 'hidden');
drawSkew();
drawText();
tabulate();
} else if (className == "tvc") {
drawSkew();
drawText();
tabulate();
} else if (className == "parcel") {
$(".lcltext, .lcl, .lfctext, .lfc, .eltext, .el").css('visibility', $(".lcltext, .lcl, .lfctext, .lfc, .eltext, .el").css('visibility') == 'hidden' ? 'visible' : 'hidden');
drawSkew();
drawText();
tabulate();
} else if (className == "parcelmix") {
$(".lclmixtext, .lclmix, .lfcmixtext, .lfcmix, .elmixtext, .elmix").css('visibility', $(".lclmixtext, .lclmix, .lfcmixtext, .lfcmix, .elmixtext, .elmix").css('visibility') == 'hidden' ? 'visible' : 'hidden');
drawSkew();
drawText();
tabulate();
} else {
}
})
$("#ml_depth").on("change", function () {
bl_depth = parseFloat($(this).val());
drawSkew();
drawText();
tabulate();
});
$("input:radio[name='CAPE_check']").on("change", function() {
drawSkew();
drawText();
});
});
var loadedPreset = true;
var loadedFile = false;
var lat, long;
var columns = ['press', 'temp', 'dwpt', 'wdir', 'wspd'];
function tableVis () {
$("#editTableWrap").toggle();
if ($("#editTableWrap").is(":visible")) {
$("#editButton").text("Hide Data Table");
} else {
$("#editButton").text("Show Data Table");
}
tabulate();
}
function tabulate() {
d3.select("#editTableWrap").html("");
var table = d3.select('#editTableWrap').append('table').attr("id","editTable");
var thead = table.append('thead');
var tbody = table.append('tbody');
// append the header row
thead.append('tr')
.selectAll('th')
.data(columns).enter()
.append('th')
.text(function (column) { return column; });
// create a row for each object in the data
var rows = tbody.selectAll('tr')
.data(tlinetest[0][0])
.enter()
.append('tr');
// create a cell in each row for each column
var cells = rows.selectAll('td')
.data(function (row) {
return columns.map(function (column) {
return {column: column, value: row[column]};
});
})
.enter()
.append('td')
.attr("contenteditable", "true")
.attr("class", "edit")
.text(function (d) { return d.value; });
rows.selectAll(":first-child").attr("contenteditable", "false");
$("[contenteditable=true]").on("input", function() {
var row = $(this).parent().children();
var i = $("tr:not(:first)").index($(this).parent());
var j = $(this).parent().children("td").index(this);
update(row, i, j);
});
return table;
}
function update(r, i, j) {
var here = $("#editTable tr:not(:first)").eq(i).children("td").eq(j);
var inputText = r.eq(j).text().trim();
var signs = /^[-+.]?[.]?$/;
var numbers = /^[-+]?[0-9]*\.?[0-9]+$/;
if (j%4 == 1 || j%4 == 2) {
if (inputText.match(signs)) {
return false
}
}
if (inputText == "") {
here.addClass("blank");
return false
} else if (inputText.match(numbers)) {
if (j == 1) {
tlinetest[0][0][i].temp = parseFloat(inputText);
if (tlinetest[0][0][i].temp < tlinetest[0][0][i].dwpt) {
// Send error message to user to correct temp and dwpt
here.addClass("blank");
here.next().addClass("blank");
return false
} else {
here.removeClass("blank");
here.next().removeClass("blank");
}
} else if (j == 2) {
tlinetest[0][0][i].dwpt = parseFloat(inputText);
if (tlinetest[0][0][i].dwpt > tlinetest[0][0][i].temp) {
// Send error message to user to correct temp and dwpt
here.addClass("blank");
here.prev().addClass("blank");
return false
} else {
here.removeClass("blank");
here.prev().removeClass("blank");
}
} else if (j == 3) {
if (inputText.match(/^\d*\.?\d+$/)) {
if (parseFloat(inputText) > 360 || parseFloat(inputText) < 0 ) {
var howLarge = parseFloat(inputText)/360;
if (howLarge < 1 && howLarge > 0) {
var direct = parseFloat(inputText);
} else if (howLarge < 0 && howLarge > -1) {
var direct = parseFloat(inputText) + 360;
} else if (Math.abs(howLarge) >= 1) {
var multiplier = Math.floor(howLarge);
var direct = parseFloat(inputText) - 360*multiplier;
}
here.text(direct);
}
tlinetest[0][0][i].wdir = parseFloat(inputText);
} else {
here.text(tlinetest[0][0][i].wdir);
return false;
}
} else if (j == 4) {
if (inputText.match(/^\d*\.?\d+$/)) {
tlinetest[0][0][i].wspd = parseFloat(inputText);
tlinetest[0][0][i].wspdround = Math.round((parseFloat(inputText)/5))*5;
} else {
here.text(tlinetest[0][0][i].wspd);
return false;
}
}
} else {
if (j == 1) {
here.text(tlinetest[0][0][i].temp);
} else if (j == 2) {
here.text(tlinetest[0][0][i].dwpt);
} else if (j == 3) {
here.text(tlinetest[0][0][i].wdir);
} else if (j == 4) {
here.text(tlinetest[0][0][i].wspd);
}
return false;
}
here.removeClass("blank");
drawSkew();
drawText();
}
$("input[type='file']").on("change", function () {
loadedFile = true;
loadFile();
loadedPreset = false;
});
function loadFile() {
loadedPreset = false;
const reader = new FileReader();
reader.readAsText(document.querySelector('input[type="file"]').files[0]);
reader.onload = () => storeResults(reader.result);
loadedFile = true;
}
function storeResults(result) {
sounding = result;
jsonObj = convertFiletoJSON(sounding);
dataParse();
}
function loadSounding () {
loadedFile = false;
var soundingFile = $('#allstar_sounding').children('option:selected').val();
$(".focusgroup").empty();
title = "";
if (soundingFile.includes(".html")) {
getHTMLSounding(soundingFile);
} else if (soundingFile.includes(".json")) {
dataParse(soundingFile);
}
loadedPreset = true;
}
var sounding = '';
function getHTMLSounding(filename) {
var dataRead = fetch(filename)
.then(response => response.blob())
.then(function(myBlob) {
const reader = new FileReader();
reader.readAsText(myBlob);
reader.onload = () => storeResults(reader.result);
});
}
function resetSounding() {
if (loadedFile) {
loadFile();
return;
}
if (loadedPreset) {
loadSounding();
return;
}
}
//some constants from meted.ucar.edu/awips/validate
var R = 287.04; // J/Kg K--gas constant
var Cp = 1004; // J/Kg K--specific heat at constant pressure
var g = 9.80665;
var c5 = -0.37329638;
var c6 = 41.178204;
var c7 = 0.0015945203;
var c10 = 0.1419709;
var c11 = 20.746475;
var c12 = 6672.5713;
var c13 = .000036336427;
var T0 = 288.15;
var P0 = 1013.25;
var jsonObj;
var sdata = new Array();
var data_arr = [];
var filtered = [];
var title = '';
var labels = [];
var ppcl = 0;//pressure for parcel to be lifted
var tpcl = 0;//temp for parcel to be lifted (C)
var tdpcl = 0; //dewpoint for parcel to be lifted
var plcl = 0; //pres at LCL
var tlcl = 0; //temp at LCL
var plfc = -1; //pressure at LFC
var tlfc = 0; //temp at LFC
var pel = 0; //pressure at EL
var tel = 0; //tempC at EL
var thetae_lcl = 0;//theta-e at LCL
var pccl = 0; //pres at ccl - set in calcCCL()
var tccl = 0; //temp at ccl - set in calcCCL(), used by calcConvTemp()
var p_pcl100 = 0;//_parent.capeMC.ppcl
var t_pcl100 = 0;//_parent.capeMC.tpcl
var td_pcl100 = 0;//_parent.capeMC.tdpcl
var parcel_temp = 0;
var parcel_temp_array = new Array();
var pcl_t_arr = new Array();
var ml_pcl_t_arr = new Array();
var parcel_flag = 0;
var cin_parcelT = 0;
var cin_parcelT_array = new Array();
var cin_parcelT_below_LCL_array = new Array();
var pcl_cin_t_arr = new Array();
var pcl_cin_t_below_LCL_arr = new Array();
var bl_depth = 100;
var t500 = 0; //temp(C) at 500 mb
var ws500 = 0; //windspeed at 500 mb
var wd500 = 0; //wind direction at 500 mb
var t700 = 0; //temp at 700(C) mb
var td700 = 0; //dewpoint at 700(C)
var t850 = 0; //temp(C) at 850 mb
var td850 = 0; //dewpoint at 850(C)
var ws850 = 0; //windspeed at 850 mb
var wd850 = 0; //wind direction at 850 mb
var t1000 = 0; //temp(C) at 1000 mb
var td1000 = 0; //dewpoint at 1000(C)
var ws1000 = 0; //windspeed at 1000 mb
var wd1000 = 0; //wind direction at 1000 mb
var flag_1000 = 0;
var flag_850 = 0;
var flag_700 = 0;
var flag_500 = 0;
var tk = 0; //temp (K)
var tdk = 0; //dewpoint (K)
var p_sfc = 0;
var t_sfc = 0;
var td_sfc = 0;
var m = [30, 40, 20, 35],
width = 700 - m[1] - m[3],
height = 700 - m[0] - m[2];
var d2r = (Math.PI/180);
var tempSkew = 55;
var tan = Math.tan(tempSkew*d2r),
basep = 1050,
topp = 100,
plines = [1000,925,850,700,600,500,400,300,200,100]
pticks = [950,900,800,750,650,600,550,450,400,350,250,150];
barbsize = 25;
// Scales and axes. Note the inverted domain for the y-scale: bigger is up!
var x = d3.scale.linear().range([0, width]).domain([-45,50]),
y = d3.scale.log().range([0, height]).domain([topp, basep])
r = d3.scale.linear().range([0,300]).domain([0,150]),
y2 = d3.scale.linear(),
xAxis = d3.svg.axis().scale(x).tickSize(0,0).ticks(10).orient("bottom"),
yAxis = d3.svg.axis().scale(y).tickSize(0,0).tickValues(plines)
.tickFormat(d3.format(".0d")).orient("left")
yAxis2 = d3.svg.axis().scale(y).tickSize(5,0).tickValues(pticks).orient("right"); // just for ticks
// various path generators
var line = d3.svg.line()
.interpolate("linear")
.x(function(d,i) { return x(d.temp) + (y(basep)-y(d.press))/tan; })
.y(function(d,i) { return y(d.press); });
var line2 = d3.svg.line()
.interpolate("linear")
.x(function(d,i) { return x(d.dwpt) + (y(basep)-y(d.press))/tan; })
.y(function(d,i) { return y(d.press); });
var hodoline = d3.svg.line.radial()
.radius(function(d) { return r(d.wspd); })
.angle(function(d) { return (d.wdir+180)*(Math.PI/180); });
// bisector function for tooltips
var bisectTemp = d3.bisector(function(d) { return d.press; }).left;
// create svg container for sounding
var svg = d3.select("div#mainbox").insert("svg", ":first-child")
.attr("width", width + m[1] + m[3])
.attr("height", height + m[0] + m[2])
.attr("id","box")
.append("g")
.attr("transform", "translate(" + m[3] + "," + m[0] + ")");
var titleText = d3.select("div#mainbox svg").append("svg").attr("class", "title").attr("width", 700).attr("height", 40).append("text").attr("class", "titleText");
// create svg container for hodograph
var svghodo = d3.select("div#hodobox").append("svg")
.attr("width", 360)
.attr("height", 300)
.append("g")
.attr("class","hodosvg")
.attr("transform", "translate(150,150)");
hodofocus = svghodo.append("g")
.attr("class","hodogroup")
.append("line")
.attr("class","focus hodarrow")
.attr("x1", "0")
.attr("y1", "0")
.attr("stroke-width","2")
.attr("marker-end","url(#arrowhead)")
.style("display","none");
d3.select(".hodogroup")
.append("circle")
.attr("r", "6px")
.attr("fill", "cyan")
.attr("stroke", "black")
.attr("opacity",".6")
.style("display", "none")
.attr("class", "focus hod");
var svgtext = d3.select("div#hodobox").append("svg").attr("class", "indices").attr("width", 360).attr("height", 400)
.append("g").attr("transform", "translate(0,50)");
makeBarbTemplates();
drawBackground();
drawTextLabels();
var skewtgroup = svg.append("g").attr("class", "skewt"); // put skewt lines in this group
var barbgroup = svg.append("g").attr("class", "windbarb"); // put barbs in this group
var hodogroup = svghodo.append("g").attr("class", "hodo"); // put hodo stuff in this group
var membergroup = skewtgroup.append("g").attr("class", "membergroup"); // put member lines in this group
var labelgroup = skewtgroup.append("g").attr("class", "labelgroup"); // put labels in this group
var focusgroup = skewtgroup.append("g").attr("class", "focusgroup"); // put focus dots in this group
var hodobarbstest = [];
dataParse('data_TOP.json'); // 2003 Jun 24 00Z
//dataParse('data_FWD_20200110_18Z.json'); // 2020 Jan 10 18Z IEM data
//dataParse('data_LBF.json'); // 2003 Jun 23 00Z
//dataParse('data_TBW.json'); // 2019 Nov 26 00Z
//dataParse('data_ILX.json'); // 2013 Nov 17 15Z
//dataParse('data_DNR.json'); // 2019 Nov 26 00Z
//dataParse('data_SkewT.json');// Interactive Skew-T
function dataParse(fileName) {
hodobarbstest = [], tlinetest = [], interpdots = [], barbstest = [], flattened = [];
var hr=0;
var temp = [], temp2 = [], temp3 = [];
var mem = 0;
if (fileName) {
d3.json(fileName, function(err, json) {
parseDataNew(json);
parsedCSV = alldata[mem][hr].filter(function(d) { return (d.temp > -1000 && d.dwpt > -1000); });
barbs = parsedCSV.filter(function(d) { return (d.wdir >= 0 && d.wspd >= 0 && d.press >= topp); });
hodobarbs = barbs.filter(function(d) { return (d.press >= 100); });
interpdot = interpobjects[hr + 49*mem];
temp.push(hodobarbs);
temp2.push(parsedCSV);
temp3.push(barbs);
interpdots.push(interpdot);
hodobarbstest.push(temp);
tlinetest.push(temp2);
barbstest.push(temp3);
// need this for dots for some reason
mouseoverdata = tlinetest[0][0].slice(0).reverse();
flattened = interpdots.reduce(function(a,b) { return a.concat(b); });
drawSkew();
drawText();
drawToolTips();
tabulate();
});
} else {
alldata=[[sdata]];
parsedCSV = alldata[mem][hr].filter(function(d) { return (d.temp > -1000 && d.dwpt > -1000); });
barbs = parsedCSV.filter(function(d) { return (d.wdir >= 0 && d.wspd >= 0 && d.press >= topp); });
hodobarbs = barbs.filter(function(d) { return (d.press >= 100); });
var hAGL;
var test = [];
interpobjects = [];
test.push(parsedCSV[0]);
for (j=1; j< requestedLevels.length; j++) {
hAGL = requestedLevels[j]*1000+parsedCSV[0].hght;
for (i=1; i<parsedCSV.length; i++) {
if (parsedCSV[i].hght > hAGL) {
var interp = d3.interpolateObject(parsedCSV[i-1],parsedCSV[i]);
var half = interp(1-(hAGL - parsedCSV[i].hght)/(parsedCSV[i-1].hght - parsedCSV[i].hght));
test.push(half);
break;
}
};
};
interpobjects.push(test);
interpdot = interpobjects[hr + 49*mem];
temp.push(hodobarbs);
temp2.push(parsedCSV);
temp3.push(barbs);
interpdots.push(interpdot);
hodobarbstest.push(temp);
tlinetest.push(temp2);
barbstest.push(temp3);
// need this for dots for some reason
mouseoverdata = tlinetest[0][0].slice(0).reverse();
flattened = interpdots.reduce(function(a,b) { return a.concat(b); });
for (i=0; i<tlinetest[0][0].length ; i++) {
if (i==0) {
var height0 = tlinetest[0][0][0].hght;
}
tlinetest[0][0][i].hghtagl = tlinetest[0][0][i].hght - height0;
}
d3.selectAll("g.focusgroup > *").remove();
d3.selectAll("g.membergroup > *").remove();
d3.selectAll("g.labelgroup > *").remove();
d3.selectAll("g.windbarb > *").remove();
d3.selectAll("g.hodo > *").remove();
makeBarbTemplates();
drawSkew();
drawText();
drawToolTips();
tabulate();
}
}
function parseDataNew(json) {
requestedLevels = [0,1,3,6,9]; // levels in km agl
interpobjects = [];
alldata = json['tmpc'].map(function(c,k) {
return c.map(function(d,i) {
var obj = d.map(function(e,j) {
return {
press: +json.pres[k][i][j],
hght: +json.hght[k][i][j],
temp: +json.tmpc[k][i][j],
dwpt: +json.dwpt[k][i][j],
wdir: +json.wdir[k][i][j],
wspd: +json.wspd[k][i][j],
hghtagl: +json.hght[k][i][j] - +json.hght[k][i][0],
wspdround: Math.round((json.wspd[k][i][j])/5) * 5
}
});
// interpolate to given heights for each sounding
var test = requestedLevels.map(function(d) {
if (d == 0) { return obj[0]; }
d = 1000*d+obj[0].hght; // want height AGL
for (i=0; i<=obj.length; i++) {
if (obj[i].hght > d) { var closeindex = i; break; } // since hghts increase monotonically
}
var interp = d3.interpolateObject(obj[i-1],obj[i]); // interp btw two levels
var half = interp(1-(d - obj[i].hght)/(obj[i-1].hght - obj[i].hght));
return half
});
interpobjects.push(test);
return obj;
});
});
return alldata;
}
function makeBarbTemplates() {
var speeds = d3.range(5,205,5);
barbdef = svg.append('defs')
barbdef.append("g")
.attr("id","speedRect")
d3.select("#speedRect")
.append("rect").attr("width", "35").attr("height", "15").attr("transform","translate(0,-2)");
d3.select("#speedRect")
.append("line").attr("x1", "0").attr("x2", "30").attr("y1", "7.5").attr("y2","7.5").attr("transform","translate(35,-2)");
d3.select("#speedRect")
.append("circle").attr("r","4").attr("transform","translate(65,5.5)");
speeds.forEach(function(d) {
var thisbarb = barbdef.append('g').attr('id', 'barb'+d);
var flags = Math.floor(d/50);
var pennants = Math.floor((d - flags*50)/10);
var halfpennants = Math.floor((d - flags*50 - pennants*10)/5);
var px = barbsize;
// Draw wind barb stems
thisbarb.append("line").attr("class", "stem").attr("x1", 0).attr("x2", 0).attr("y1", 0).attr("y2", barbsize);
// Draw wind barb flags and pennants for each stem
for (i=0; i<flags; i++) {
thisbarb.append("polyline")
.attr("points", "0,"+px+" -10,"+(px)+" 0,"+(px-4))
.attr("class", "flag");
px -= 7;
}
// Draw pennants on each barb
for (i=0; i<pennants; i++) {
thisbarb.append("line")
.attr("x1", 0)
.attr("x2", -10)
.attr("y1", px)
.attr("y2", px+4)
px -= 3;
}
// Draw half-pennants on each barb
for (i=0; i<halfpennants; i++) {
thisbarb.append("line")
.attr("x1", 0)
.attr("x2", -5)
.attr("y1", px)
.attr("y2", px+2)
px -= 3;
}
});
var arrows = barbdef.append("marker")
.attr("id","arrowhead")
.attr("markerWidth","5")
.attr("markerHeight","5")
.attr("refX","5")
.attr("refY","2.5")
.attr("orient","auto")
.append("polygon")
.attr("points","0 0, 5 2.5, 0 5")
.attr("fill","#777");
}
function drawSkew() {
$(".member, .hododot, .hodoline, .titleText, .windbarb > *, .label").remove();
for (var i=0; i<tlinetest[0][0].length; i+=1) {
var tw = calcWetbulb(tlinetest[0][0][i].press, tlinetest[0][0][i].temp, tlinetest[0][0][i].dwpt);
tlinetest[0][0][i].twc = tw;
var svp = calcVaporPressure(tlinetest[0][0][i].temp);
tlinetest[0][0][i].es = svp;
var vp = calcVaporPressure(tlinetest[0][0][i].dwpt);
tlinetest[0][0][i].e = vp;
var mixr = calcMixingRatio(tlinetest[0][0][i].e, tlinetest[0][0][i].press);
tlinetest[0][0][i].mr = mixr;
rh=calcRelHumidity(tlinetest[0][0][i].e, tlinetest[0][0][i].es);
tlinetest[0][0][i].relh = rh;
// tv=calcVirtualtemperature(tlinetest[0][0][i].temp,tlinetest[0][0][i].mr);
tv=getTv(tlinetest[0][0][i].temp,tlinetest[0][0][i].dwpt,tlinetest[0][0][i].press);
tlinetest[0][0][i].tv = tv;
if (i < 34) {
console.log(i + " = " + tv);
}
sh=calcSpecHumidity(tlinetest[0][0][i].e, tlinetest[0][0][i].press);
tlinetest[0][0][i].sh = sh;
pT=calcTheta(tlinetest[0][0][i].press, tlinetest[0][0][i].temp);
tlinetest[0][0][i].theta = pT;
epT=calcThetaE(tlinetest[0][0][i].press, tlinetest[0][0][i].temp, tlinetest[0][0][i].dwpt );
tlinetest[0][0][i].thetaE = epT;
z = calcZ(tlinetest[0][0][i].press);
tlinetest[0][0][i].Z = z;
}
var pw_total = calcPrecipWater();
tlinetest[0][0][0].pw = pw_total;
wb0_pres = calcWetbulbZero();
tlinetest[0][0][0].wbz = wb0_pres;
frz_lvl=calcFreezeLevel();
tlinetest[0][0][0].frzl = frz_lvl;
thk = calcThick();
tlinetest[0][0][0].thick = thk;
for (i=0; i<tlinetest[0][0].length-1; i++) {
if (tlinetest[0][0][i].press == 1000) {
t1000 = tlinetest[0][0][i].temp;
td1000 = tlinetest[0][0][i].dwpt;
ws1000 = tlinetest[0][0][i].wspd;
wd1000 = tlinetest[0][0][i].wdir;
flag_1000 = 1;
} else if (tlinetest[0][0][i].press < 1000 && flag_1000 == 0) {
if (i == 0) {
t1000 = tlinetest[0][0][i].temp;
td1000 = tlinetest[0][0][i].dwpt;
ws1000 = tlinetest[0][0][i].wspd;
wd1000 = tlinetest[0][0][i].wdir;
flag_1000 = 1;
} else {
t1000 = interpVal(1000, tlinetest[0][0][i].press, tlinetest[0][0][i-1].press, tlinetest[0][0][i].temp, tlinetest[0][0][i-1].temp);
td1000 = interpVal(1000, tlinetest[0][0][i].press, tlinetest[0][0][i-1].press, tlinetest[0][0][i].dwpt, tlinetest[0][0][i-1].dwpt);
ws1000 = interpVal(1000, tlinetest[0][0][i].press, tlinetest[0][0][i-1].press, tlinetest[0][0][i].wspd, tlinetest[0][0][i-1].wspd);
wd1000 = interpVal(1000, tlinetest[0][0][i].press, tlinetest[0][0][i-1].press, tlinetest[0][0][i].wdir, tlinetest[0][0][i-1].wdir);
flag_1000 = 1;
}
} else if (tlinetest[0][0][i].press == 850) {
t850 = tlinetest[0][0][i].temp;
td850 = tlinetest[0][0][i].dwpt;
ws850 = tlinetest[0][0][i].wspd;
wd850 = tlinetest[0][0][i].wdir;
flag_850 = 1;
} else if (tlinetest[0][0][i].press < 850 && flag_850 == 0) {
t850 = interpVal(850, tlinetest[0][0][i].press, tlinetest[0][0][i-1].press, tlinetest[0][0][i].temp, tlinetest[0][0][i-1].temp);
td850 = interpVal(850, tlinetest[0][0][i].press, tlinetest[0][0][i-1].press, tlinetest[0][0][i].dwpt, tlinetest[0][0][i-1].dwpt);
ws850 = interpVal(850, tlinetest[0][0][i].press, tlinetest[0][0][i-1].press, tlinetest[0][0][i].wspd, tlinetest[0][0][i-1].wspd);
wd850 = interpVal(850, tlinetest[0][0][i].press, tlinetest[0][0][i-1].press, tlinetest[0][0][i].wdir, tlinetest[0][0][i-1].wdir);
flag_850 = 1;
} else if (tlinetest[0][0][i].press == 700) {
t700 = tlinetest[0][0][i].temp;
td700 = tlinetest[0][0][i].dwpt;
flag_700 = 1;
} else if (tlinetest[0][0][i].press < 700 && flag_700 == 0) {
t700 = interpVal(700, tlinetest[0][0][i].press, tlinetest[0][0][i-1].press, tlinetest[0][0][i].temp, tlinetest[0][0][i-1].temp);
td700 = interpVal(700, tlinetest[0][0][i].press, tlinetest[0][0][i-1].press, tlinetest[0][0][i].dwpt, tlinetest[0][0][i-1].dwpt);
flag_700 = 1;
} else if (tlinetest[0][0][i].press == 500) {
t500 = tlinetest[0][0][i].temp;
ws500 = tlinetest[0][0][i].wspd;
wd500 = tlinetest[0][0][i].wdir;
flag_500 = 1;
} else if (tlinetest[0][0][i].press < 500 && flag_500 == 0) {
t500 = interpVal(500, tlinetest[0][0][i].press, tlinetest[0][0][i-1].press, tlinetest[0][0][i].temp, tlinetest[0][0][i-1].temp);
ws500 = interpVal(500, tlinetest[0][0][i].press, tlinetest[0][0][i-1].press, tlinetest[0][0][i].wspd, tlinetest[0][0][i-1].wspd);
wd500 = interpVal(500, tlinetest[0][0][i].press, tlinetest[0][0][i-1].press, tlinetest[0][0][i].wdir, tlinetest[0][0][i-1].wdir);
flag_500 = 1;
} else {
}
}
mixed_parcel = getParcelVals();
p_pcl100 = mixed_parcel[0];
t_pcl100 = mixed_parcel[1];
td_pcl100 = mixed_parcel[2];
tlinetest[0][0][0].mixParcelP = p_pcl100;
tlinetest[0][0][0].mixParcelT = t_pcl100;
tlinetest[0][0][0].mixParcelTd = td_pcl100;
Tvmixed_parcel = getParcelVals("Tv");
p_pcl100_tv = Tvmixed_parcel[0];
t_pcl100_tv = Tvmixed_parcel[1];
td_pcl100_tv = Tvmixed_parcel[2];
tlinetest[0][0][0].mixParcelP_tv = p_pcl100_tv;
tlinetest[0][0][0].mixParcelT_tv = t_pcl100_tv;
tlinetest[0][0][0].mixParcelTd_tv = td_pcl100_tv;
var pCCL = calcCCL();
tlinetest[0][0][0].CCL = pCCL;
var conv_temp = calcConvTemp();
tlinetest[0][0][0].tc = conv_temp;
tt=calcTT();//total totals
tlinetest[0][0][0].TT = tt;
ki=calcKI();//K-index
tlinetest[0][0][0].KI = ki;
sweat=calcSWEAT();
tlinetest[0][0][0].SWEAT = sweat;
lclData = calcLCL(tlinetest[0][0][0].press,tlinetest[0][0][0].temp,tlinetest[0][0][0].dwpt);
plcl = lclData[0];
tlcl = lclData[1];
zlcl = lclData[2];
tlinetest[0][0][0].lclP = plcl;
tlinetest[0][0][0].lclT = tlcl;
tlinetest[0][0][0].lclZ = zlcl;
capeBounds = findLFCandEL("SB");
plfc = capeBounds[0];
tlfc = capeBounds[1];
zlfc = capeBounds[2];
pel = capeBounds[3];
tel = capeBounds[4];
zel = capeBounds[5];
tlinetest[0][0][0].lfcP = plfc;
tlinetest[0][0][0].lfcT = tlfc;
tlinetest[0][0][0].lfcZ = zlfc;
tlinetest[0][0][0].elP = pel;
tlinetest[0][0][0].elT = tel;
tlinetest[0][0][0].elZ = zel;
mixlclData = calcLCL(tlinetest[0][0][0].mixParcelP,tlinetest[0][0][0].mixParcelT,tlinetest[0][0][0].mixParcelTd);
mixplcl = mixlclData[0];
mixtlcl = mixlclData[1];
mixzlcl = mixlclData[2];
tlinetest[0][0][0].lclPmix = mixplcl;
tlinetest[0][0][0].lclTmix = mixtlcl;
tlinetest[0][0][0].lclZmix = mixzlcl;
mixcapeBounds = findLFCandEL("ML");
mixplfc = mixcapeBounds[0];
mixtlfc = mixcapeBounds[1];
mixzlfc = mixcapeBounds[2];
mixpel = mixcapeBounds[3];
mixtel = mixcapeBounds[4];
mixzel = mixcapeBounds[5];
tlinetest[0][0][0].lfcPmix = mixplfc;
tlinetest[0][0][0].lfcTmix = mixtlfc;
tlinetest[0][0][0].lfcZmix = mixzlfc;
tlinetest[0][0][0].elPmix = mixpel;
tlinetest[0][0][0].elTmix = mixtel;
tlinetest[0][0][0].elZmix = mixzel;
TvlclData = calcLCL(tlinetest[0][0][0].press,tlinetest[0][0][0].tv,tlinetest[0][0][0].dwpt);
plcl_tv = TvlclData[0];
tlcl_tv = TvlclData[1];
zlcl_tv = TvlclData[2];
tlinetest[0][0][0].lclP_tv = plcl_tv;
tlinetest[0][0][0].lclT_tv = tlcl_tv;
tlinetest[0][0][0].lclZ_tv = zlcl_tv;
capeBounds_tv = findLFCandEL("SBTv");
plfc_tv = capeBounds_tv[0];
tlfc_tv = capeBounds_tv[1];
zlfc_tv = capeBounds_tv[2];
pel_tv = capeBounds_tv[3];
tel_tv = capeBounds_tv[4];
zel_tv = capeBounds_tv[5];
tlinetest[0][0][0].lfcP_tv = plfc_tv;
tlinetest[0][0][0].lfcT_tv = tlfc_tv;
tlinetest[0][0][0].lfcZ_tv = zlfc_tv;
tlinetest[0][0][0].elP_tv = pel_tv;
tlinetest[0][0][0].elT_tv = tel_tv;
tlinetest[0][0][0].elZ_tv = zel_tv;
TvmixlclData = calcLCL(tlinetest[0][0][0].mixParcelP_tv,tlinetest[0][0][0].mixParcelT_tv,tlinetest[0][0][0].mixParcelTd);
mixplcl_tv = TvmixlclData[0];
mixtlcl_tv = TvmixlclData[1];
mixzlcl_tv = TvmixlclData[2];
tlinetest[0][0][0].lclPmix_tv = mixplcl_tv;
tlinetest[0][0][0].lclTmix_tv = mixtlcl_tv;
tlinetest[0][0][0].lclZmix_tv = mixzlcl_tv;
mixcapeBounds_tv = findLFCandEL("MLTv");
mixplfc_tv = mixcapeBounds_tv[0];
mixtlfc_tv = mixcapeBounds_tv[1];
mixzlfc_tv = mixcapeBounds_tv[2];
mixpel_tv = mixcapeBounds_tv[3];
mixtel_tv = mixcapeBounds_tv[4];
mixzel_tv = mixcapeBounds_tv[5];
tlinetest[0][0][0].lfcPmix_tv = mixplfc_tv;
tlinetest[0][0][0].lfcTmix_tv = mixtlfc_tv;
tlinetest[0][0][0].lfcZmix_tv = mixzlfc_tv;
tlinetest[0][0][0].elPmix_tv = mixpel_tv;
tlinetest[0][0][0].elTmix_tv = mixtel_tv;
tlinetest[0][0][0].elZmix_tv = mixzel_tv;
capeArray = getCAPE("SB", 0);//SBCAPE
cape = capeArray[0];
pcl_t_arr = capeArray[1];
cin = capeArray[2];
brn = capeArray[3][0];
brnu = capeArray[3][1];
shr6km = capeArray[3][2];
tlinetest[0][0][0].cape = cape;
tlinetest[0][0][0].cin = cin;
tlinetest[0][0][0].brn = brn;
tlinetest[0][0][0].brnu = brnu;
tlinetest[0][0][0].shr6km = shr6km;
if (pcl_t_arr[0] === undefined) {
parcel_flag = 0;
} else {
parcel_flag = 1;
for (i=0; i<tlinetest[0][0].length; i++) {
if (pcl_t_arr[i] != null) {
tlinetest[0][0][i].parcelT = pcl_t_arr[i];
}
}
}