-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathearthquake_map.star
More file actions
634 lines (556 loc) · 28.1 KB
/
Copy pathearthquake_map.star
File metadata and controls
634 lines (556 loc) · 28.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
"""
Applet: Earthquake Map
Summary: Map of global earthquakes
Description: Display a map of earthquakes based on USGS data.
Author: Brian McLaughlin (SpinStabilized)
"""
load("cache.star", "cache")
load("encoding/json.star", "json")
load("http.star", "http")
load("math.star", "math")
load("render.star", "render")
load("schema.star", "schema")
load("time.star", "time")
#-------------------------------------------------------------------------------
# Constants
#-------------------------------------------------------------------------------
# The following DEFAULT_ configurations are strings for compatibility with the
# `config` and `schema` libraries.
DEFAULT_MAG_FILTER = "4"
DEFAULT_MAGNITUDE_SORTING = True
DEFAULT_TIME_FILTER_DURATION = "1"
DEFAULT_TIME_FILTER_UNITS = "days"
DEFAULT_HIDE_WHEN_EMPTY = False
DEFAULT_MAP_CENTER_ID = "Prime Meridian"
DEFAULT_USER_LOCATION = """
{
"lat": "40.6781784",
"lng": "-73.9441579",
"description": "Brooklyn, NY, USA",
"locality": "Brooklyn",
"place_id": "ChIJCSF8lBZEwokRhngABHRcdoI",
"timezone": "America/New_York"
}
"""
DEFAULT_INCLUDE_EARTHQUAKE = True
DEFAULT_INCLUDE_ICEQUAKE = True
DEFAULT_INCLUDE_QUARRY = True
DEFAULT_INCLUDE_EXPLOSION = True
DEFAULT_INCLUDE_OTHER = True
DEFAULT_MAP_BRIGHTNESS = "0.25"
DISPLAY_X_SIZE = 64
DISPLAY_Y_SIZE = 32
HTTP_STATUS_OK = 200
API_CACHE_TTL = 60 # seconds
EARTHQUAKES_LAST_30_DAYS_URL = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson"
#-------------------------------------------------------------------------------
# Utility Functions
#-------------------------------------------------------------------------------
def uint8_to_hex(uint8, add_prefix = False):
"""Take an integer value and return a hex string.
Given an 8 bit unsigned integer, convert the value to a hex string. If the
given value is not an unisgned integer, no guarantee is given of the
returned value. If the integer is larger than 255 (8-bits), only the hex
value of the lower 8-bits will be returned.
Args:
uint8: 8-bit, unsigned, integer
add_prefix: Boolean to indicate if "0x" should be prepended to the result.
Returns:
Hex string representation of the input.
"""
hex_numerals = [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"A",
"B",
"C",
"D",
"E",
"F",
]
hex_string = "0x" if add_prefix else ""
hex_string = hex_string + hex_numerals[(uint8 & 0xf0) >> 4]
hex_string = hex_string + hex_numerals[uint8 & 0xf]
return hex_string
#-------------------------------------------------------------------------------
# USGS API Functions
#-------------------------------------------------------------------------------
def get_usgs_data(magnitude_filter = None, time_filter = None, type_filter = None):
"""Retrieve GeoJSON earthquake data from the USGS.
Retrieve all earthquake data in GeoJSON format from the las 30 days and
will return a list of events.
For more information on the USGS earthquake API GeoJSON enpoints please
visit:
https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
Args:
magnitude_filter (number): The lower-bound magnitude to display.
time_filter (number): Time period in seconds from the current time to
display.
type_filter (dict): Filter on various types of events
Returns:
A list of earthquake events in the following format -
[(lon, lat), magnitude, time]
"""
if magnitude_filter == None:
magnitude_filter = 0
if time_filter == None:
time_filter = duration_calc(30, "days")
time_filter = time.parse_duration("{}s".format(time_filter))
geojson_raw = cache.get("raw_earthquake_data")
if geojson_raw == None:
api_reply = http.get(EARTHQUAKES_LAST_30_DAYS_URL)
if api_reply.status_code == HTTP_STATUS_OK:
geojson_raw = api_reply.body()
else:
geojson_raw = '{"features":[]}'
cache.set("raw_earthquake_data", geojson_raw, ttl_seconds = 60)
events = []
current_time = time.now().in_location("UTC")
geojson_events = json.decode(geojson_raw)["features"]
for event in geojson_events:
if event["properties"]["mag"] != None:
new_event = [
(
float(event["geometry"]["coordinates"][0]),
float(event["geometry"]["coordinates"][1]),
),
float(event["properties"]["mag"]),
time.from_timestamp(int(event["properties"]["time"] // 1000)), # convert from ms to seconds
event["properties"]["type"].lower(),
]
if new_event[1] >= magnitude_filter and \
current_time - new_event[2] <= time_filter and \
(
type_filter == None or
(type_filter["other"] and new_event[3] not in type_filter.keys()) or
(new_event[3] in type_filter.keys() and type_filter[new_event[3]])
):
events.append(new_event)
return events
def duration_calc(time_filter, units = None):
"""Convert a time for filtering to seconds.
Args:
time_filter (number): The time period for filtering.
units (string): Unit for the filter time period. Defaults to minutes.
Returns:
(number) The input time in seconds.
"""
conversion_dict = {
"seconds": 1,
"minutes": 60,
"hours": 60 * 60,
"days": 60 * 60 * 24,
}
if units == None or units not in conversion_dict.keys():
units = "minutes"
return time_filter * conversion_dict[units]
#-------------------------------------------------------------------------------
# Map Utility Functions
#-------------------------------------------------------------------------------
def mag_to_color(magnitude):
"""Converts an earthquake magnitude to a color to display.
Accepts an earthquake magnitude as a numeric value and converts it into a
color based on the color map. Magnitudes above the highest index in the
color map will be clipped as the strongest indicator. Provides color as a
string representation of a 16-bit hex RGB color code (#rrggbb).
Args:
magnitude: An earthquake magnitude
Returns:
A string RGB 16 bit hex color code of the format #rrggbb
"""
color_map = [
"#00b5b8", # Mag 0, Teal
"#bf40bf", # Mag 1, Purple
"#08e8de", # Mag 2, Light Blue
"#0000ff", # Mag 3, Blue
"#00ff00", # Mag 4, Green
"#fff000", # Mag 5, Yellow
"#ffaa1d", # Mag 6, Orange
"#ff0000", # Mag 7+, Red
]
int_mag = len(color_map) - 1 if magnitude >= len(color_map) else int(magnitude)
return color_map[int_mag]
# The following disables a buggy lint check in the bazel starlark linter that
# thinks some floating point division is integer division and is flagging it as
# an error.
# buildifier: disable=integer-division
def map_projection(longitude, latitude, screen_width = 64, screen_height = 32, map_center = None):
"""Project's a map longitude/latitude to screen coordinates.
Args:
longitude: A map coordinate longitude
latitude: A map coordinate latitude
screen_width: size of the screen/image to project to
screen_height: height of the screen/image to project to
map_center: Map center meridian
Returns:
An (x, y) tuple in the screen/image pixel coordinates
"""
radius = screen_width / (2 * math.pi)
longitude_radians = math.radians(longitude + 180)
latitude_radians = math.radians(latitude)
x = int(longitude_radians * radius)
y_from_eq = radius * math.log(math.tan(math.pi / 4 + latitude_radians / 2))
y = int(screen_height / 2 - y_from_eq)
if map_center:
x = pixel_shift(x, map_center)
return x, y
def render_map(map_array, map_center = 0, brightness = 0.25):
"""Shift pixels to account for map central merdian.
Args:
map_array: 2-dimensional array indicating coastlines
map_center: Map center meridian
brightness: Brightness of the map [0...255], default 25% (0.25)
Returns:
A `render.Stack` of pixels that represent the map.
"""
map_stack = []
for y, row in enumerate(map_array):
for x, map_pixel in enumerate(row):
if map_pixel:
x = pixel_shift(x, map_center)
map_stack.append(
pixel(x, y, "#FFFFFF", brightness),
)
return render.Stack(children = map_stack)
def pixel_shift(x, center_longitude = 0):
"""Shift pixels to account for map central merdian.
Args:
x: Tidbyt display x position [0...63]
center_longitude: Map center meridian
Returns:
A new x coordinate shifted with the merdian
"""
new_center_x, _ = map_projection(center_longitude, 0)
current_center_x, _ = map_projection(0, 0)
delta = current_center_x - new_center_x
new_x = x + delta
if new_x > 63:
new_x = new_x - 64
if new_x < 0:
new_x = 64 + new_x
return new_x
#-------------------------------------------------------------------------------
# Render Utility Functions
#-------------------------------------------------------------------------------
def pixel(x, y, color, alpha = 1.0):
"""Pixel by pixel drawing for Tidbyt
Accepts a pixel coordinate as x and y integers on the Tidbyt display as well
as a color definition and provides a `render.Padding` object back to be used
in rendering. The color definition uses the Tidbyt color specifications #rgb,
#rrggbb, #rgba, and #rrggbbaa.
This is based on the work of Tidbyt Discuss user kay where they developed
some amazing spirte based demos for the Tidbyt:
https://discuss.tidbyt.com/t/animating-with-sprites/978
Note: If the color provided is suspected of having an alpha already defined,
the value of the alpha parameter to the function is ignored.
Args:
x: Tidbyt display x position [0...63]
y: Tidbyt display x position [0...31]
color: Hex color value
alpha: Decimal percentage of full brightness [0...1]
Returns:
A `render.Padding` object for the pixel location
"""
if len(color) != 5 and len(color) != 9:
color = color + uint8_to_hex(int(alpha * 255))
return render.Padding(
pad = (x, y, 0, 0),
child = render.Box(width = 1, height = 1, color = color),
)
def blink_pixel(x, y, color_on, color_off = "#000000FF"):
"""Pixel by pixel drawing for Tidbyt, a blinking pixel
Accepts a pixel coordinate as x and y integers on the Tidbyt display as well
as a color definition and provides a `render.Padding` object back to be used
in rendering. The color definition uses the Tidbyt color specifications
#rgb and #rrggbb. If a color has an alpha, the alpha will be ignored.
This is based on the work of Tidbyt Discuss user kay where they developed
some amazing spirte based demos for the Tidbyt:
https://discuss.tidbyt.com/t/animating-with-sprites/978
Note: If the color provided is suspected of having an alpha already defined,
the value of the alpha parameter to the function is ignored.
Args:
x: Tidbyt display x position [0...63]
y: Tidbyt display x position [0...31]
color_on: Hex color value when pixel is "on"
color_off: Hex color value when pixel is "off" (defaults to black)
Returns:
A `render.Animation` object for the pixel location
"""
blink_pixel = [pixel(x, y, color_on), pixel(x, y, color_off)]
return render.Animation(
children = blink_pixel,
)
#-------------------------------------------------------------------------------
# Main
#-------------------------------------------------------------------------------
def main(config):
"""Main function body.
Args:
config: A Tidbyt configuration object
Returns:
A `render.Root` object.
"""
# Define configuration, use defaults if a configuration parameter can't be
# found.
magnitude_filter = int(config.str("mag_filter", DEFAULT_MAG_FILTER))
magnitude_sorting = config.bool("magnitude_sorting", DEFAULT_MAGNITUDE_SORTING)
time_filter_duration = int(config.get("time_filter_duration", DEFAULT_TIME_FILTER_DURATION))
time_filter_units = config.get("time_filter_units", DEFAULT_TIME_FILTER_UNITS)
hide_when_empty = config.bool("hide_when_empty", DEFAULT_HIDE_WHEN_EMPTY)
map_center_id = config.str("map_center_id", DEFAULT_MAP_CENTER_ID)
user_location = config.str("location", DEFAULT_USER_LOCATION)
type_filter = {
"earthquake": config.bool("include_earthquake", DEFAULT_INCLUDE_EARTHQUAKE),
"ice quake": config.bool("include_icequake", DEFAULT_INCLUDE_ICEQUAKE),
"quarry blast": config.bool("include_quarry", DEFAULT_INCLUDE_QUARRY),
"explosion": config.bool("include_explosion", DEFAULT_INCLUDE_EXPLOSION),
"other": config.bool("include_other", DEFAULT_INCLUDE_OTHER),
}
map_brightness = float(config.get("map_brightness", DEFAULT_MAP_BRIGHTNESS))
time_filter = duration_calc(time_filter_duration, time_filter_units)
if map_center_id == "Prime Meridian":
map_center = 0
elif map_center_id == "Date Line":
map_center = -180
elif map_center_id == "Tidbyt Location":
map_center = int(float(json.decode(user_location)["lng"]))
else:
map_center = 0
# Process the earthquakes and generate render data
earthquake_events = get_usgs_data(
magnitude_filter = magnitude_filter,
time_filter = time_filter,
type_filter = type_filter,
)
earthquake_events = sorted(earthquake_events, key = lambda item: item[2])
last_event = earthquake_events[-1] if earthquake_events else None
earthquake_events = earthquake_events[:-1]
if magnitude_sorting:
earthquake_events = sorted(earthquake_events, key = lambda item: item[1])
if earthquake_events or last_event:
render_stack = [render_map(WORLD_MAP_ARRAY, map_center, map_brightness)]
if earthquake_events:
for event in earthquake_events:
x, y = map_projection(event[0][0], event[0][1], map_center = map_center)
render_stack.append(
pixel(x, y, mag_to_color(event[1])),
)
x, y = map_projection(last_event[0][0], last_event[0][1], map_center = map_center)
blink_on = mag_to_color(last_event[1])
render_stack.append(
blink_pixel(x, y, blink_on),
)
return render.Root(
delay = 500,
child = render.Stack(
children = render_stack,
),
)
elif not hide_when_empty:
return render.Root(
child = render_map(WORLD_MAP_ARRAY, map_center),
)
else:
return []
def get_schema():
"""Provide the schema for the Tidbyt app configuration.
Returns:
A `schema.Schema` object.
"""
return schema.Schema(
version = "1",
fields = [
schema.Toggle(
id = "hide_when_empty",
name = "Hide When Empty",
desc = "Enable to hide app when there are no earthquakes to display.",
icon = "eyeSlash",
default = DEFAULT_HIDE_WHEN_EMPTY,
),
schema.Dropdown(
id = "map_brightness",
name = "Map Layer Brightness",
desc = "Set the brightness of the map layer from 0 to 100%.",
icon = "sun",
options = [
schema.Option(display = " 0%", value = "0.00"),
schema.Option(display = " 5%", value = "0.05"),
schema.Option(display = " 10%", value = "0.10"),
schema.Option(display = " 15%", value = "0.15"),
schema.Option(display = " 20%", value = "0.20"),
schema.Option(display = " 25%", value = "0.25"),
schema.Option(display = " 30%", value = "0.30"),
schema.Option(display = " 35%", value = "0.35"),
schema.Option(display = " 40%", value = "0.40"),
schema.Option(display = " 45%", value = "0.45"),
schema.Option(display = " 50%", value = "0.50"),
schema.Option(display = " 55%", value = "0.55"),
schema.Option(display = " 60%", value = "0.60"),
schema.Option(display = " 65%", value = "0.65"),
schema.Option(display = " 70%", value = "0.70"),
schema.Option(display = " 75%", value = "0.75"),
schema.Option(display = " 80%", value = "0.80"),
schema.Option(display = " 85%", value = "0.85"),
schema.Option(display = " 90%", value = "0.90"),
schema.Option(display = " 95%", value = "0.95"),
schema.Option(display = "100%", value = "1.00"),
],
default = DEFAULT_MAP_BRIGHTNESS,
),
schema.Dropdown(
id = "mag_filter",
name = "Magnitude Filter",
desc = "Minimum magnitude to display.",
icon = "houseCrack",
options = [
schema.Option(display = "0 - Teal", value = "0"),
schema.Option(display = "1 - Purple", value = "1"),
schema.Option(display = "2 - Light Blue", value = "2"),
schema.Option(display = "3 - Blue", value = "3"),
schema.Option(display = "4 - Green", value = "4"),
schema.Option(display = "5 - Yellow", value = "5"),
schema.Option(display = "6 - Orange", value = "6"),
schema.Option(display = "7+ - Red", value = "7"),
],
default = DEFAULT_MAG_FILTER,
),
schema.Toggle(
id = "magnitude_sorting",
name = "Sort By Magnitude",
desc = "Prioritize Magnitude Over Most Recent",
icon = "arrowUpWideShort",
default = DEFAULT_MAGNITUDE_SORTING,
),
schema.Text(
id = "time_filter_duration",
name = "Duration Filter",
desc = "Duration in specified units to filter.",
icon = "clock",
default = DEFAULT_TIME_FILTER_DURATION,
),
schema.Dropdown(
id = "time_filter_units",
name = "Duration Filter Units",
desc = "Units of time for the duration filter.",
icon = "clock",
options = [
schema.Option(display = "Day(s)", value = "days"),
schema.Option(display = "Hour(s)", value = "hours"),
schema.Option(display = "Minute(s)", value = "minutes"),
schema.Option(display = "Second(s)", value = "seconds"),
],
default = DEFAULT_TIME_FILTER_UNITS,
),
schema.Toggle(
id = "include_earthquake",
name = "Include Earthquakes",
desc = "Include earthquake events in display.",
icon = "houseCrack",
default = DEFAULT_INCLUDE_EARTHQUAKE,
),
schema.Toggle(
id = "include_icequake",
name = "Include Ice Quakes",
desc = "Include ice quake events in display. (US Only)",
icon = "icicles",
default = DEFAULT_INCLUDE_ICEQUAKE,
),
schema.Toggle(
id = "include_quarry",
name = "Include Quarry Blasts",
desc = "Include quarry blasting events in display. (US Only)",
icon = "hillRockslide",
default = DEFAULT_INCLUDE_QUARRY,
),
schema.Toggle(
id = "include_explosion",
name = "Include Explosions",
desc = "Include explosion events in display. (US Only)",
icon = "explosion",
default = DEFAULT_INCLUDE_EXPLOSION,
),
schema.Toggle(
id = "include_other",
name = "Include Other Events",
desc = "Include other, unspecified, events in display. (US Only)",
icon = "question",
default = DEFAULT_INCLUDE_OTHER,
),
schema.Dropdown(
id = "map_center_id",
name = "Map Center",
desc = "The meridian at the center of the map.",
icon = "compass",
options = [
schema.Option(display = "Prime Merdian", value = "Prime Meridian"),
schema.Option(display = "Date Line", value = "Date Line"),
schema.Option(display = "Tidbyt Location", value = "Tidbyt Location"),
],
default = DEFAULT_MAP_CENTER_ID,
),
schema.Generated(
id = "location_option",
source = "map_center_id",
handler = schema_location,
),
],
)
def schema_location(map_center_id):
if map_center_id == "Tidbyt Location":
return [
schema.Location(
id = "location",
name = "Location",
desc = "Location to select the map central meridian.",
icon = "locationDot",
),
]
else:
return []
#------------------------------------------------------------------------------
# Resources
#------------------------------------------------------------------------------
# Coastline Map generated from GeoJSON data found at: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