-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathluts.py
171 lines (149 loc) · 4.65 KB
/
luts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# pylint: disable=C0103,E0401
"""
Common shared text strings, formatting defaults and lookup tables.
"""
# Core page components
title = "SNAP Community Climate Charts"
description = "Explore temperature and precipitation projections for communities across Alaska and Western Canada"
url = "https://snap.uaf.edu/tools/community-charts"
twitter_preview = (
"https://snap.uaf.edu/tools/community-charts/assets/twitter_preview.png"
)
facebook_preview = (
"https://snap.uaf.edu/tools/community-charts/assets/facebook_preview.png"
)
index_string = f"""
<!DOCTYPE html>
<html>
<head>
<script async defer data-website-id="cc69673a-a302-45ab-ad82-e382c46b0f26" src="https://umami.snap.uaf.edu/script.js" data-do-not-track="true" data-domains="snap.uaf.edu"></script>
{{%metas%}}
<title>{{%title%}}</title>
<!-- Twitter Card data -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@SNAPandACCAP">
<meta name="twitter:title" content="{title}">
<meta name="twitter:description" content="{description}">
<meta name="twitter:creator" content="@SNAPandACCAP">
<meta name="twitter:image:src" content="{twitter_preview}">
<!-- Open Graph data -->
<meta property="og:title" content="{title}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="{url}" />
<meta property="og:image" content="{facebook_preview}" />
<meta property="og:description" content="{description}" />
<meta property="og:site_name" content="{title}" />
<link rel="alternate" hreflang="en" href="{url}" />
<link rel="canonical" href="{url}"/>
<!-- Safari 15 tab bar color -->
<meta name="theme-color" content="#8e1e23">
{{%favicon%}}
{{%css%}}
</head>
<body>
{{%app_entry%}}
<footer>
{{%config%}}
{{%scripts%}}
{{%renderer%}}
</footer>
</body>
</html>
"""
Months = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
]
decades = ["2030-2039", "2060-2069", "2090-2099"]
region_lu = {
"Alaska": "AK",
"Alberta": "AB",
"British Columbia": "BC",
"Manitoba": "MB",
"Northwest Territories": "NT",
"Saskatchewan": "SK",
"Yukon": "YT",
}
resolution_lu = {"cru322": "10min", "prism": "2km"}
variable_lu = {"temp": "Temperature", "precip": "Precipitation"}
imperial_conversion_lu = {"temp": 1.8, "precip": 0.0393701}
scenario_lu = {
"rcp45": "Low Emissions (RCP 4.5)",
"rcp60": "Medium Emissions (RCP 6.0)",
"rcp85": "High Emissions (RCP 8.5)",
}
unit_lu = {
"temp": {"imperial": "°F", "metric": "°C"},
"precip": {"imperial": "in", "metric": "mm"},
}
baseline_lu = {"cru322": "CRU TS 3.22", "prism": "PRISM"}
axis_configs = {
"automargin": True,
"showgrid": False,
"showline": False,
"ticks": "",
"title": {"standoff": 20},
"zeroline": False,
"fixedrange": True,
}
xaxis_config = {**axis_configs, **{"tickformat": "%B %-d, %Y"}}
xaxis_config["title"]["text"] = "Month"
figure_layout = {
"barmode": "grouped",
"titlefont": {"family": "Open Sans"},
"annotations": [
{
"x": 0.5,
"y": -0.35,
"xref": "paper",
"yref": "paper",
"showarrow": False,
"text": "These plots are useful for examining possible trends over time, rather than for precisely predicting values.",
},
{
"x": 0.5,
"y": -0.43,
"xref": "paper",
"yref": "paper",
"showarrow": False,
"text": "Credit: Scenarios Network for Alaska + Arctic Planning, University of Alaska Fairbanks.",
},
],
"margin": dict(t=100, b=130),
"xaxis": xaxis_config,
"yaxis": axis_configs,
"dragmode": False,
}
df_lu_full_temp = {
"2030-2039": {"color": "#ffb100"},
"2060-2069": {"color": "#ff5000"},
"2090-2099": {"color": "#8b0000"},
}
df_lu_full_precip = {
"2030-2039": {"color": "#63d2c1"},
"2060-2069": {"color": "#3990a6"},
"2090-2099": {"color": "#104e8b"},
}
dataset_radio_options = [
{"label": " Temperature", "value": "temp"},
{"label": " Precipitation", "value": "precip"},
]
units_radio_options = [
{"label": " Imperial", "value": "imperial"},
{"label": " Metric", "value": "metric"},
]
rcp_radio_options = [
{"label": " Low Emissions (RCP 4.5)", "value": "rcp45"},
{"label": " Medium Emissions (RCP 6.0)", "value": "rcp60"},
{"label": " High Emissions (RCP 8.5)", "value": "rcp85"},
]