-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrender-weathernext-graph.js
More file actions
149 lines (115 loc) · 4.37 KB
/
Copy pathrender-weathernext-graph.js
File metadata and controls
149 lines (115 loc) · 4.37 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
// Open this script into Google Earth Engine Code Editor:
// https://code.earthengine.google.com/3fa07391e881110552caeab9a8b270dd
var geometry = /* color: #69d653 */ee.Geometry.Point([-62.08844282226651, 34.61320981665174]);
Map.setOptions('HYBRID')
var palettes = require('users/gena/packages:palettes')
var utils = require('users/gena/packages:utils')
var gl = require('users/gena/packages:gl').init()
var t = ee.Date('2023-09-08')
var images = ee.ImageCollection('projects/gcp-public-data-weathernext/assets/59572747_4_0')
.filterDate(t, t.advance(6, 'hours'))
.filter(ee.Filter.gt('forecast_hour', 0))
print(images.size())
images = images.map(function(i) {
return i.set({ 'system:time_start': ee.Date(i.get('system:time_start')).advance(i.get('forecast_hour'), 'hour').millis() })
})
var visParamsTemp = {
min: -40.0,
max: 35.0,
palette: ['blue', 'purple', 'cyan', 'green', 'yellow', 'red'],
}
var visParamsPrecip = {
min: 0.0,
max: 0.05,
palette: palettes.crameri.berlin[50]
}
var visPrecipMask = {
min: 0.00005,
max: 0.001
}
var properties = [
'total_precipitation_6hr',
'2m_temperature',
'10m_u_component_of_wind',
'10m_v_component_of_wind'
]
// query temperature values at a given location
var chartUV = ui.Chart.image.series({
imageCollection: images.select(['10m_u_component_of_wind', '10m_v_component_of_wind']),
region: geometry,
reducer: ee.Reducer.first(),
scale: 1000
}).setOptions({ title: 'wind speed (m/s)'})
var chartP = ui.Chart.image.series({
imageCollection: images.select(['total_precipitation_6hr']),
region: geometry,
reducer: ee.Reducer.first(),
scale: 1000
}).setOptions({ title: 'precipitation (mm)'})
var chartT = ui.Chart.image.series({
imageCollection: images.select(['2m_temperature']).map(function(i) { return i.subtract(273.15).copyProperties(i, ['system:time_start']) }),
region: geometry,
reducer: ee.Reducer.first(),
scale: 1000
}).setOptions({ title: 'temperature (C)'})
var panel = ui.Panel([
chartUV,
chartT,
chartP
])
panel.style().set({ position: 'bottom-right', width: '300px', height: '700px' })
Map.add(panel)
// animate
var animation = require('users/gena/packages:animation')
print('Precipitation rate, min: 0, max: 0.05')
palettes.showPalette('', palettes.crameri.berlin[50])
print('Velocity at 10m, min: 10, max: 50')
palettes.showPalette('', palettes.crameri.vik[50].slice(10))
images = images.map(function(i) {
i = i.resample('bilinear')
var p = i.select('total_precipitation_6hr')
var pRGB = p.visualize(visParamsPrecip)
var weight = 0.6 // wegith of Hillshade vs RGB intensity (0 - flat, 1 - HS)
var exaggeration = 2500 // vertical exaggeration
var azimuth = 315 // Sun azimuth
var zenith = 20 // Sun elevation
var brightness = -0.05 // 0 - default
var contrast = 0.05 // 0 - default
var saturation = 0.8 // 1 - default
var castShadows = false
var uv = i.select(['10m_u_component_of_wind', '10m_v_component_of_wind'], ['x', 'y'])
.multiply(2).float()
var abs = uv.pow(2).reduce(ee.Reducer.sum()).sqrt()
var uvRGB = abs
.mask(abs.unitScale(7, 15))
.visualize({ min: 10, max: 50, palette: palettes.crameri.vik[50].slice(10), opacity: 0.8 }).rename(['r', 'g', 'b']).float()
var uvArrows = gl.renderArrows(gl.fragCoord, uv, Map.getScale(), 8, 15, 0.7)
var bg = ee.Image(1).visualize({ palette: ['black'], opacity: 0.5, forceRgbOutput: true })
// render P
return ee.ImageCollection([
bg,
utils.hillshadeRGB(
p.updateMask(p.unitScale(visPrecipMask.min, visPrecipMask.max)).visualize(visParamsPrecip).blend(uvArrows),
p,
weight, exaggeration * 500, azimuth, zenith, contrast, brightness, saturation, castShadows),
]).mosaic()
.set({ label: i.date().format('YYYY-MM-dd HH:mm').cat(' (').cat(ee.Number(i.get('forecast_hour')).format('%d')).cat(' hours)') })
// // render UV
// return ee.ImageCollection([
// bg,
// utils.hillshadeRGB(
// uvRGB.blend(uvArrows),
// abs,
// weight, exaggeration, azimuth, zenith, contrast, brightness, saturation, castShadows),
// ]).mosaic()
// .set({ label: i.date().format('YYYY-MM-dd HH:mm').cat(' (').cat(ee.Number(i.get('forecast_hour')).format('%d')).cat(' hours)') })
})
print(images.first())
animation.animate(images, {
label: 'label',
maxFrames: 50,
preloadCount: 1,
compact: true,
timeStep: 150
// hidePlay: true
})