Skip to content

Commit

Permalink
an attempt to speed up analysis of new regions
Browse files Browse the repository at this point in the history
  • Loading branch information
ledm committed Mar 25, 2024
1 parent 5e342b2 commit 9d88b1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions bgcval2/timeseries/timeseriesAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ def loadModel(self):
self.modeldetails,
regions=self.regions,
layers=self.layers,
modeldataD=self.modeldataD,
)

for l in self.layers:
Expand Down
17 changes: 16 additions & 1 deletion bgcval2/timeseries/timeseriesTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ def __init__(self,
layers=[
'Surface',
],
modeldataD = {},
metrics = ['mean', ],
meantime = 0,
data=''):
self.fn = fn
if type(nc) == type('filename'):
Expand All @@ -276,6 +279,9 @@ def __init__(self,
self.details = details
self.regions = regions
self.layers = layers
self.metrics = metrics
self.modeldataD = modeldataD
self.meantime = meantime
self.name = self.details['name']
if data == '': data = std_extractData(nc, self.details)
self.Fulldata = data
Expand All @@ -294,7 +300,7 @@ def run(self):
depths = {}
lays = self.layers[:]
lays.reverse()

for l in lays:
try:
layer = int(l)
Expand All @@ -317,6 +323,15 @@ def run(self):
continue

for region in self.regions:
loadthisregion = 0
for m in metrics:
if self.modeldataD.get((r, l, m), False) and self.meantime in modeldataD[(r, l, m)]:
# Data arra already exists and This time point's data already exists
continue
# This region does not exist in the processed data, so add it.
loadthisregion +=1
if loadthisregion == 0:
continue
arr, arr_t, arr_z, arr_lat, arr_lon = self.createDataArray(
region, layer)
if len(arr) == 0:
Expand Down

0 comments on commit 9d88b1f

Please sign in to comment.