-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCinCape.tsx
144 lines (130 loc) · 3.84 KB
/
CinCape.tsx
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
import { css } from "@emotion/react";
import styled from "@emotion/styled";
import chroma from "chroma-js";
import { outputP3ColorFromLab } from "../../helpers/colors";
import Tooltip from "../../shared/Tooltip";
export const headerText = css`
text-transform: uppercase;
font-size: 0.7em;
color: rgba(255, 255, 255, 0.8);
`;
const Container = styled.div`
display: flex;
align-items: center;
justify-content: center;
text-align: center;
margin: 3px 0;
> *:not(:last-of-type) {
margin-right: 5px;
}
h4 {
margin: 0 5px;
display: inline;
${headerText}
}
`;
const Description = styled.div`
p {
&:first-of-type {
margin-top: 0;
}
&:last-of-type {
margin-bottom: 0;
}
}
`;
const cinColorScale = chroma
.scale(["white", "white", "yellow", "red"])
.domain([0, -20, -50, -90]);
const Cin = styled.span<{ cin: number }>`
${({ cin }) => outputP3ColorFromLab(cinColorScale(cin).lab())};
`;
const capeColorScale = chroma
.scale(["white", "yellow", "red"])
.domain([0, 1250, 3000]);
const Cape = styled.span<{ cape: number }>`
${({ cape }) => outputP3ColorFromLab(capeColorScale(cape).lab())};
`;
interface CinCapeProps {
cin?: number;
cape: number;
}
export default function CinCape({ cin, cape }: CinCapeProps) {
if (cin == null && cape == null) return null;
return (
<Container>
{cin != null && (
<Tooltip
contents={() => (
<Description>
<p>
<a
href="https://en.wikipedia.org/wiki/Convective_inhibition"
target="_blank"
rel="noreferrer noopener"
>
CIn (Convective inhibition)
</a>{" "}
in J/Kg. We use the most unstable CIN (MUCIN) using the parcel
with highest theta-e in lowest 300 mb.
</p>
<p>
CIN values between <Cin cin={0}>0</Cin> and{" "}
<Cin cin={-25}>-25</Cin> are classified as weak inhibition.
</p>{" "}
<p>
CIN values between <Cin cin={-25}>-25</Cin> and{" "}
<Cin cin={-50}>-50</Cin>, typically qualify as moderate. When
you see CIN values of <Cin cin={-100}>-100</Cin>, you have a
chance of a very large storm!
</p>
</Description>
)}
interactive
>
<Cin cin={cin}>
<h4>CIN</h4>
{cin}
</Cin>
</Tooltip>
)}
<Tooltip
contents={() => (
<Description>
<p>
<a
href="https://en.wikipedia.org/wiki/Convective_available_potential_energy"
target="_blank"
rel="noreferrer noopener"
>
CAPE (Convective Available Potential Energy)
</a>{" "}
in J/Kg. We use the most <strong>unstable CAPE (MUCAPE)</strong>{" "}
using the parcel with highest theta-e in lowest 300 mb.
</p>
<p>
CAPE is directly related to the maximum potential vertical speed
within an updraft; thus, higher values indicate greater potential
for severe weather.
</p>
<p>
On average, <Cape cape={1000}>1,000</Cape> is usually sufficient
for strong to severe storms.
</p>
<p>
CAPE of <Cape cape={3000}>3,000</Cape> to{" "}
<Cape cape={4000}>4,000</Cape>, or higher, is usually a signal of
a very volatile atmosphere that could produce severe storms.
</p>
</Description>
)}
interactive
>
<Cape cape={cape}>
<h4>CAPE</h4>
{cape}
</Cape>
</Tooltip>
</Container>
);
}