Skip to content

Commit

Permalink
moved sheopn out of try loops
Browse files Browse the repository at this point in the history
  • Loading branch information
ledm committed Mar 25, 2024
1 parent cd404b0 commit 6a67c3d
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions bgcval2/timeseries/timeseriesAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,20 +566,18 @@ def loadData(self):
###############
# load and calculate the real data info
try:
if self.clean:
print(
"timeseriesAnalysis:\t loadData\tUser requested clean run. Wiping old data."
)
assert 0
if self.clean:
print(
"timeseriesAnalysis:\t loadData\tUser requested clean run. Wiping old data."
)
dataD = {}
else:
with shOpen(self.shelvefn_insitu) as sh:
dataD = sh['dataD']
dataD = sh['dataD']
print("timeseriesAnalysis:\t loadData\tOpened shelve:",
self.shelvefn_insitu)
self.dataD = dataD
except:
dataD = {}
print("timeseriesAnalysis:\t loadData\tCould not open in situ shelve:",
self.shelvefn_insitu)


###############
# Test to find out if we need to load the netcdf, or if we can just return the dict as a self.object.
Expand Down Expand Up @@ -672,17 +670,8 @@ def loadData(self):
# Savng shelve
print("timeseriesAnalysis:\t loadData.\tSaving shelve:",
self.shelvefn_insitu)
try:
with shOpen(self.shelvefn_insitu) as sh:
sh['dataD'] = dataD
except:
print(
"timeseriesAnalysis:\t WARNING.\tSaving shelve failed, trying again.:",
self.shelvefn_insitu
)
shutil.move(self.shelvefn_insitu, self.shelvefn_insitu + '.broken')
with shOpen(self.shelvefn_insitu) as sh:
sh['dataD'] = dataD
with shOpen(self.shelvefn_insitu) as sh:
sh['dataD'] = dataD

self.dataD = dataD

Expand Down

0 comments on commit 6a67c3d

Please sign in to comment.