danielle-losos commited on
Commit
46ec1ae
·
verified ·
1 Parent(s): 6f7e4ab

Update pages/05_GOES_NBR.py

Browse files
Files changed (1) hide show
  1. pages/05_GOES_NBR.py +16 -21
pages/05_GOES_NBR.py CHANGED
@@ -3,7 +3,6 @@ import geemap
3
  import solara
4
  import ipywidgets as widgets
5
 
6
- ee.Initialize()
7
 
8
  fireList = ["North Complex", "Dixie", "Cameron Peak", "August Complex"]
9
  selected_fire = solara.reactive([fireList[0]])
@@ -13,12 +12,12 @@ dixie_bb = ee.Geometry.BBox(-121.680467, 39.759303, -120.065477, 40.873387)
13
  cam_peak_bb = ee.Geometry.BBox(-106.014784, 40.377907, -105.116651, 40.822094)
14
  aug_complex_bb = ee.Geometry.BBox(-123.668726, 39.337654, -122.355860, 40.498304)
15
 
16
- '''
17
  class Map(geemap.Map):
18
  def __init__(self, **kwargs):
19
  super().__init__(**kwargs)
20
  self.add_ee_data()
21
-
22
  selector = widgets.Dropdown(options=fireList, value="North Complex", description='Wildfire Case Study:')
23
  mapFire_button = widgets.Button(description="Map the burn scar")
24
  mapFire_button.on_click(on_button_clicked)
@@ -39,11 +38,9 @@ class Map(geemap.Map):
39
  self.find_layer('Cameron Peak GOES NBR').visible = True
40
  elif selector.value == "August Complex":
41
  self.find_layer('August Complex GOES NBR').visible = True
42
-
43
-
44
-
45
- def add_ee_data(self):
46
- def calc_nbr(pre_start, pre_stop, post_start, post_stop, bbox):
47
  PREgoesCMI = ee.ImageCollection('NOAA/GOES/17/MCMIPF').filter(ee.Filter.date(pre_start, pre_stop)).mean()
48
  POSTgoesCMI = ee.ImageCollection('NOAA/GOES/17/MCMIPF').filter(ee.Filter.date(post_start, post_stop)).mean()
49
  preNBR = PREgoesCMI.select(['CMI_C03','CMI_C06']).normalizedDifference(['CMI_C03', 'CMI_C06']).toFloat().rename('NBR')
@@ -51,27 +48,24 @@ class Map(geemap.Map):
51
  dNBR = preNBR.subtract(postNBR).select('NBR')
52
  dNBRclipped = dNBR.clip(bbox)
53
  return dNBRclipped
 
 
54
 
55
  north_complex_bb = ee.Geometry.BBox(-121.616097, 39.426723, -120.668526, 40.030845)
56
  dixie_bb = ee.Geometry.BBox(-121.680467, 39.759303, -120.065477, 40.873387)
57
  cam_peak_bb = ee.Geometry.BBox(-106.014784, 40.377907, -105.116651, 40.822094)
58
  aug_complex_bb = ee.Geometry.BBox(-123.668726, 39.337654, -122.355860, 40.498304)
59
 
60
- north_complex = calc_nbr('2020-08-15', '2020-08-16', '2020-09-15', '2020-09-16', north_complex_bb)
61
- dixie = calc_nbr('2021-07-12', '2021-07-13', '2021-09-15', '2021-09-16', dixie_bb)
62
- cam_peak = calc_nbr('2020-08-12', '2020-08-13', '2020-09-12', '2020-09-13', cam_peak_bb)
63
- aug_complex = calc_nbr('2020-08-15', '2020-08-16', '2020-11-10', '2020-11-11', aug_complex_bb)
64
 
65
  self.addLayer(north_complex, dNBRvisParams, 'North Complex GOES NBR', True)
66
  self.addLayer(dixie, dNBRvisParams, 'Dixie Complex GOES NBR', False)
67
  self.addLayer(cam_peak, dNBRvisParams, 'Cameron Peak GOES NBR', False)
68
  self.addLayer(aug_complex, dNBRvisParams, 'August Complex GOES NBR', False)
69
 
70
-
71
-
72
- #self.layers = self.layers[:3]
73
-
74
- #mapFire_button.on_click(on_button_clicked)
75
  '''
76
  def calc_nbr(pre_start, pre_stop, post_start, post_stop, bbox):
77
  PREgoesCMI = ee.ImageCollection('NOAA/GOES/17/MCMIPF').filter(ee.Filter.date(pre_start, pre_stop)).mean()
@@ -81,6 +75,7 @@ def calc_nbr(pre_start, pre_stop, post_start, post_stop, bbox):
81
  dNBR = preNBR.subtract(postNBR).select('NBR')
82
  dNBRclipped = dNBR.clip(bbox)
83
  return dNBRclipped
 
84
 
85
  @solara.component
86
  def Page():
@@ -110,25 +105,25 @@ def Page():
110
  height="600px",
111
  layers=[
112
  {
113
- "eeObject": calc_nbr('2020-08-15', '2020-08-16', '2020-09-15', '2020-09-16', north_complex_bb),
114
  "visParams": dNBRvisParams,
115
  "name": "North Complex GOES NBR",
116
  "visible": True
117
  },
118
  {
119
- "eeObject": calc_nbr('2021-07-12', '2021-07-13', '2021-09-15', '2021-09-16', dixie_bb),
120
  "visParams": dNBRvisParams,
121
  "name": "Dixie Complex GOES NBR",
122
  "visible": False
123
  },
124
  {
125
- "eeObject": calc_nbr('2020-08-12', '2020-08-13', '2020-09-12', '2020-09-13', cam_peak_bb),
126
  "visParams": dNBRvisParams,
127
  "name": "Cameron Peak GOES NBR",
128
  "visible": True
129
  },
130
  {
131
- "eeObject": calc_nbr('2020-08-15', '2020-08-16', '2020-11-10', '2020-11-11', aug_complex_bb),
132
  "visParams": dNBRvisParams,
133
  "name": "August Complex GOES NBR",
134
  "visible": False
 
3
  import solara
4
  import ipywidgets as widgets
5
 
 
6
 
7
  fireList = ["North Complex", "Dixie", "Cameron Peak", "August Complex"]
8
  selected_fire = solara.reactive([fireList[0]])
 
12
  cam_peak_bb = ee.Geometry.BBox(-106.014784, 40.377907, -105.116651, 40.822094)
13
  aug_complex_bb = ee.Geometry.BBox(-123.668726, 39.337654, -122.355860, 40.498304)
14
 
15
+
16
  class Map(geemap.Map):
17
  def __init__(self, **kwargs):
18
  super().__init__(**kwargs)
19
  self.add_ee_data()
20
+ '''
21
  selector = widgets.Dropdown(options=fireList, value="North Complex", description='Wildfire Case Study:')
22
  mapFire_button = widgets.Button(description="Map the burn scar")
23
  mapFire_button.on_click(on_button_clicked)
 
38
  self.find_layer('Cameron Peak GOES NBR').visible = True
39
  elif selector.value == "August Complex":
40
  self.find_layer('August Complex GOES NBR').visible = True
41
+ '''
42
+ @staticmethod
43
+ def calc_nbr(pre_start, pre_stop, post_start, post_stop, bbox):
 
 
44
  PREgoesCMI = ee.ImageCollection('NOAA/GOES/17/MCMIPF').filter(ee.Filter.date(pre_start, pre_stop)).mean()
45
  POSTgoesCMI = ee.ImageCollection('NOAA/GOES/17/MCMIPF').filter(ee.Filter.date(post_start, post_stop)).mean()
46
  preNBR = PREgoesCMI.select(['CMI_C03','CMI_C06']).normalizedDifference(['CMI_C03', 'CMI_C06']).toFloat().rename('NBR')
 
48
  dNBR = preNBR.subtract(postNBR).select('NBR')
49
  dNBRclipped = dNBR.clip(bbox)
50
  return dNBRclipped
51
+
52
+ def add_ee_data(self):
53
 
54
  north_complex_bb = ee.Geometry.BBox(-121.616097, 39.426723, -120.668526, 40.030845)
55
  dixie_bb = ee.Geometry.BBox(-121.680467, 39.759303, -120.065477, 40.873387)
56
  cam_peak_bb = ee.Geometry.BBox(-106.014784, 40.377907, -105.116651, 40.822094)
57
  aug_complex_bb = ee.Geometry.BBox(-123.668726, 39.337654, -122.355860, 40.498304)
58
 
59
+ north_complex = self.calc_nbr('2020-08-15', '2020-08-16', '2020-09-15', '2020-09-16', north_complex_bb)
60
+ dixie = self.calc_nbr('2021-07-12', '2021-07-13', '2021-09-15', '2021-09-16', dixie_bb)
61
+ cam_peak = self.calc_nbr('2020-08-12', '2020-08-13', '2020-09-12', '2020-09-13', cam_peak_bb)
62
+ aug_complex = self.calc_nbr('2020-08-15', '2020-08-16', '2020-11-10', '2020-11-11', aug_complex_bb)
63
 
64
  self.addLayer(north_complex, dNBRvisParams, 'North Complex GOES NBR', True)
65
  self.addLayer(dixie, dNBRvisParams, 'Dixie Complex GOES NBR', False)
66
  self.addLayer(cam_peak, dNBRvisParams, 'Cameron Peak GOES NBR', False)
67
  self.addLayer(aug_complex, dNBRvisParams, 'August Complex GOES NBR', False)
68
 
 
 
 
 
 
69
  '''
70
  def calc_nbr(pre_start, pre_stop, post_start, post_stop, bbox):
71
  PREgoesCMI = ee.ImageCollection('NOAA/GOES/17/MCMIPF').filter(ee.Filter.date(pre_start, pre_stop)).mean()
 
75
  dNBR = preNBR.subtract(postNBR).select('NBR')
76
  dNBRclipped = dNBR.clip(bbox)
77
  return dNBRclipped
78
+ '''
79
 
80
  @solara.component
81
  def Page():
 
105
  height="600px",
106
  layers=[
107
  {
108
+ "eeObject": Map.calc_nbr('2020-08-15', '2020-08-16', '2020-09-15', '2020-09-16', north_complex_bb),
109
  "visParams": dNBRvisParams,
110
  "name": "North Complex GOES NBR",
111
  "visible": True
112
  },
113
  {
114
+ "eeObject": Map.calc_nbr('2021-07-12', '2021-07-13', '2021-09-15', '2021-09-16', dixie_bb),
115
  "visParams": dNBRvisParams,
116
  "name": "Dixie Complex GOES NBR",
117
  "visible": False
118
  },
119
  {
120
+ "eeObject": Map.calc_nbr('2020-08-12', '2020-08-13', '2020-09-12', '2020-09-13', cam_peak_bb),
121
  "visParams": dNBRvisParams,
122
  "name": "Cameron Peak GOES NBR",
123
  "visible": True
124
  },
125
  {
126
+ "eeObject": Map.calc_nbr('2020-08-15', '2020-08-16', '2020-11-10', '2020-11-11', aug_complex_bb),
127
  "visParams": dNBRvisParams,
128
  "name": "August Complex GOES NBR",
129
  "visible": False