Skip to content

Commit b2cef5f

Browse files
committed
fix: Make Paraview sources EAMVisSource member variables
1 parent 6c1fe39 commit b2cef5f

1 file changed

Lines changed: 27 additions & 24 deletions

File tree

src/e3sm_quickview/pipeline.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ def __init__(self):
5252
self.timestamps = []
5353
self.center = 0.0
5454

55+
self.prog_filter = None
56+
self.atmos_extract = None
5557
self.atmos_proj = None
58+
self.cont_extract = None
5659
self.cont_proj = None
60+
self.grid_gen = None
5761
self.grid_proj = None
5862

5963
self.extents = [-180.0, 180.0, -90.0, 90.0]
@@ -80,11 +84,11 @@ def ApplyClipping(self, cliplong, cliplat):
8084
if not self.valid:
8185
return
8286

83-
atmos_extract = FindSource("AtmosExtract")
87+
atmos_extract = self.atmos_extract or FindSource("AtmosExtract")
8488
atmos_extract.LongitudeRange = cliplong
8589
atmos_extract.LatitudeRange = cliplat
8690

87-
cont_extract = FindSource("ContExtract")
91+
cont_extract = self.cont_extract or FindSource("ContExtract")
8892
cont_extract.LongitudeRange = cliplong
8993
cont_extract.LatitudeRange = cliplat
9094

@@ -131,10 +135,10 @@ def UpdatePipeline(self, time=0.0):
131135
if cont_proj:
132136
cont_proj.UpdatePipeline(time)
133137

134-
atmos_extract = FindSource("AtmosExtract")
138+
atmos_extract = self.atmos_extract or FindSource("AtmosExtract")
135139
bounds = atmos_extract.GetDataInformation().GetBounds()
136140

137-
grid_gen = FindSource("GridGen")
141+
grid_gen = self.grid_gen or FindSource("GridGen")
138142
if grid_gen:
139143
grid_gen.LongitudeRange = [bounds[0], bounds[1]]
140144
grid_gen.LatitudeRange = [bounds[2], bounds[3]]
@@ -265,25 +269,25 @@ def Update(self, ctrl_file, test_file, conn_file, variables=[], force_reload=Fal
265269
output.CellData.append(inputs[0].CellData["area"], 'area') # needed for utils.compute.extract_avgs
266270
"""
267271
print("ProgrammableFilter script:\n", script, end='')
268-
prog_filter = ProgrammableFilter(registrationName='ProgrammableFilter', Input=[self.ctrl_data, self.test_data])
269-
prog_filter.Script = script
270-
prog_filter.RequestInformationScript = ''
271-
prog_filter.RequestUpdateExtentScript = ''
272-
prog_filter.PythonPath = ''
272+
self.prog_filter = ProgrammableFilter(registrationName='ProgrammableFilter', Input=[self.ctrl_data, self.test_data])
273+
self.prog_filter.Script = script
274+
self.prog_filter.RequestInformationScript = ''
275+
self.prog_filter.RequestUpdateExtentScript = ''
276+
self.prog_filter.PythonPath = ''
273277

274278

275279
# Step 1: Extract and transform atmospheric data
276-
atmos_extract = EAMTransformAndExtract( # noqa: F821
277-
registrationName="AtmosExtract", Input=prog_filter
280+
self.atmos_extract = EAMTransformAndExtract( # noqa: F821
281+
registrationName="AtmosExtract", Input=self.prog_filter
278282
)
279-
atmos_extract.LongitudeRange = [-180.0, 180.0]
280-
atmos_extract.LatitudeRange = [-90.0, 90.0]
281-
atmos_extract.UpdatePipeline()
282-
self.extents = atmos_extract.GetDataInformation().GetBounds()
283+
self.atmos_extract.LongitudeRange = [-180.0, 180.0]
284+
self.atmos_extract.LatitudeRange = [-90.0, 90.0]
285+
self.atmos_extract.UpdatePipeline()
286+
self.extents = self.atmos_extract.GetDataInformation().GetBounds()
283287

284288
# Step 2: Apply map projection to atmospheric data
285289
self.atmos_proj = EAMProject( # noqa: F821
286-
registrationName="AtmosProj", Input=OutputPort(atmos_extract, 0)
290+
registrationName="AtmosProj", Input=OutputPort(self.atmos_extract, 0)
287291
)
288292
self.atmos_proj.Projection = self.projection
289293
self.atmos_proj.Translate = 0
@@ -307,27 +311,26 @@ def Update(self, ctrl_file, test_file, conn_file, variables=[], force_reload=Fal
307311
self.globe = cont_contour
308312

309313
# Step 4: Extract and transform continent data
310-
cont_extract = EAMTransformAndExtract( # noqa: F821
314+
self.cont_extract = EAMTransformAndExtract( # noqa: F821
311315
registrationName="ContExtract", Input=self.globe
312316
)
313-
cont_extract.LongitudeRange = [-180.0, 180.0]
314-
cont_extract.LatitudeRange = [-90.0, 90.0]
315-
317+
self.cont_extract.LongitudeRange = [-180.0, 180.0]
318+
self.cont_extract.LatitudeRange = [-90.0, 90.0]
316319
# Step 5: Apply map projection to continents
317320
self.cont_proj = EAMProject( # noqa: F821
318-
registrationName="ContProj", Input=OutputPort(cont_extract, 0)
321+
registrationName="ContProj", Input=OutputPort(self.cont_extract, 0)
319322
)
320323
self.cont_proj.Projection = self.projection
321324
self.cont_proj.Translate = 0
322325
self.cont_proj.UpdatePipeline()
323326

324327
# Step 6: Generate lat/lon grid lines
325-
grid_gen = EAMGridLines(registrationName="GridGen") # noqa: F821
326-
grid_gen.UpdatePipeline()
328+
self.grid_gen = EAMGridLines(registrationName="GridGen") # noqa: F821
329+
self.grid_gen.UpdatePipeline()
327330

328331
# Step 7: Apply map projection to grid lines
329332
self.grid_proj = EAMProject( # noqa: F821
330-
registrationName="GridProj", Input=OutputPort(grid_gen, 0)
333+
registrationName="GridProj", Input=OutputPort(self.grid_gen, 0)
331334
)
332335
self.grid_proj.Projection = self.projection
333336
self.grid_proj.Translate = 0

0 commit comments

Comments
 (0)