Skip to content

Commit ba13e16

Browse files
committed
fix: Fix projections for Robinson and Mollweide
1 parent bd939e6 commit ba13e16

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

src/e3sm_quickview/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,20 +539,20 @@ def _on_slicing_change(self, var, ind_var, **_):
539539
)
540540

541541
@change(
542-
"variables_loaded",
542+
# "variables_loaded",
543543
"crop_longitude",
544544
"crop_latitude",
545545
"projection",
546546
)
547547
def _on_downstream_change(
548548
self,
549-
variables_loaded,
549+
# variables_loaded,
550550
crop_longitude,
551551
crop_latitude,
552552
projection,
553553
**_,
554554
):
555-
if not variables_loaded:
555+
if not self.state.variables_loaded:
556556
return
557557

558558
self.source.ApplyClipping(crop_longitude, crop_latitude)

src/e3sm_quickview/pipeline.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ def __init__(self):
5252
self.timestamps = []
5353
self.center = 0.0
5454

55+
self.atmos_proj = None
56+
self.cont_proj = None
57+
self.grid_proj = None
58+
5559
self.extents = [-180.0, 180.0, -90.0, 90.0]
5660
self.moveextents = [-180.0, 180.0, -90.0, 90.0]
5761

@@ -101,9 +105,9 @@ def UpdateProjection(self, proj):
101105
if not self.valid:
102106
return
103107

104-
atmos_proj = FindSource("AtmosProj")
105-
cont_proj = FindSource("ContProj")
106-
grid_proj = FindSource("GridProj")
108+
atmos_proj = self.atmos_proj or FindSource("AtmosProj")
109+
cont_proj = self.cont_proj or FindSource("ContProj")
110+
grid_proj = self.grid_proj or FindSource("GridProj")
107111
if self.projection != proj:
108112
self.projection = proj
109113
atmos_proj.Projection = proj
@@ -118,12 +122,12 @@ def UpdatePipeline(self, time=0.0):
118122
if not self.valid:
119123
return
120124

121-
atmos_proj = FindSource("AtmosProj")
125+
atmos_proj = self.atmos_proj or FindSource("AtmosProj")
122126
if atmos_proj:
123127
atmos_proj.UpdatePipeline(time)
124128
self.moveextents = atmos_proj.GetDataInformation().GetBounds()
125129

126-
cont_proj = FindSource("ContProj")
130+
cont_proj = self.cont_proj or FindSource("ContProj")
127131
if cont_proj:
128132
cont_proj.UpdatePipeline(time)
129133

@@ -134,7 +138,7 @@ def UpdatePipeline(self, time=0.0):
134138
if grid_gen:
135139
grid_gen.LongitudeRange = [bounds[0], bounds[1]]
136140
grid_gen.LatitudeRange = [bounds[2], bounds[3]]
137-
grid_proj = FindSource("GridProj")
141+
grid_proj = self.grid_proj or FindSource("GridProj")
138142
if grid_proj:
139143
grid_proj.UpdatePipeline(time)
140144

@@ -278,13 +282,13 @@ def Update(self, ctrl_file, test_file, conn_file, variables=[], force_reload=Fal
278282
self.extents = atmos_extract.GetDataInformation().GetBounds()
279283

280284
# Step 2: Apply map projection to atmospheric data
281-
atmos_proj = EAMProject( # noqa: F821
285+
self.atmos_proj = EAMProject( # noqa: F821
282286
registrationName="AtmosProj", Input=OutputPort(atmos_extract, 0)
283287
)
284-
atmos_proj.Projection = self.projection
285-
atmos_proj.Translate = 0
286-
atmos_proj.UpdatePipeline()
287-
self.moveextents = atmos_proj.GetDataInformation().GetBounds()
288+
self.atmos_proj.Projection = self.projection
289+
self.atmos_proj.Translate = 0
290+
self.atmos_proj.UpdatePipeline()
291+
self.moveextents = self.atmos_proj.GetDataInformation().GetBounds()
288292

289293
# Step 3: Load and process continent outlines
290294
if self.globe is None:
@@ -310,29 +314,29 @@ def Update(self, ctrl_file, test_file, conn_file, variables=[], force_reload=Fal
310314
cont_extract.LatitudeRange = [-90.0, 90.0]
311315

312316
# Step 5: Apply map projection to continents
313-
cont_proj = EAMProject( # noqa: F821
317+
self.cont_proj = EAMProject( # noqa: F821
314318
registrationName="ContProj", Input=OutputPort(cont_extract, 0)
315319
)
316-
cont_proj.Projection = self.projection
317-
cont_proj.Translate = 0
318-
cont_proj.UpdatePipeline()
320+
self.cont_proj.Projection = self.projection
321+
self.cont_proj.Translate = 0
322+
self.cont_proj.UpdatePipeline()
319323

320324
# Step 6: Generate lat/lon grid lines
321325
grid_gen = EAMGridLines(registrationName="GridGen") # noqa: F821
322326
grid_gen.UpdatePipeline()
323327

324328
# Step 7: Apply map projection to grid lines
325-
grid_proj = EAMProject( # noqa: F821
329+
self.grid_proj = EAMProject( # noqa: F821
326330
registrationName="GridProj", Input=OutputPort(grid_gen, 0)
327331
)
328-
grid_proj.Projection = self.projection
329-
grid_proj.Translate = 0
330-
grid_proj.UpdatePipeline()
332+
self.grid_proj.Projection = self.projection
333+
self.grid_proj.Translate = 0
334+
self.grid_proj.UpdatePipeline()
331335

332336
# Step 8: Cache all projected views for rendering
333-
self.views["atmosphere_data"] = OutputPort(atmos_proj, 0)
334-
self.views["continents"] = OutputPort(cont_proj, 0)
335-
self.views["grid_lines"] = OutputPort(grid_proj, 0)
337+
self.views["atmosphere_data"] = OutputPort(self.atmos_proj, 0)
338+
self.views["continents"] = OutputPort(self.cont_proj, 0)
339+
self.views["grid_lines"] = OutputPort(self.grid_proj, 0)
336340

337341
self.valid = True
338342
self.observer.clear()

0 commit comments

Comments
 (0)