badlands-model / badlands

Basin and Landscape Dynamics model

Home Page:https://badlands.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to write only the last sed.timeXX.hdf5 stratigraphy file.

GeoMattB opened this issue · comments

I'm digging into the model code a little to see if it's relatively simple to make a change so it only writes the sed.time file once at the end of the model run. When running multiple models short display intervals are useful for surface analysis (tin & flow mesh grids) and only the final stratal file is essential, however sed.time files are the largest output and I run out of disk space very quickly if these are written at the same interval as the other products.

I spent a little time trying to work this out and apart from a link between model.py, buildMesh.py and stratiWedge.py I'm not able to get it to stop writing those files.

Could you point me in the right direction, happy to make the changes and merge back if its useful for people.

Plan B: I could add a couple of lines to the model run code so it deletes all the redundant sed.time files at the end of the model run.

Matt

Okay, I did some more digging and this looks like it might work.
It should only take some minor modification to add an option to enable this behaviour in the xml but leave the default as it was before. I've got models to build & need to test this doesn't break anything else so it might take a bit before I get arounf to that part.

#in model.py
#Update next stratal layer time
if self.tNow==self.input.tEnd:
self.write=0 # set parameter to call hdf5 stratal writer
else:
self.write=1
if self.tNow >= self.force.next_layer:
self.force.next_layer += self.input.laytime
sub = self.strata.buildStrata(
self.elevation,
self.cumdiff,
self.force.sealevel,
self.recGrid.boundsPt,
self.write, #was 0
self.outputStep + 1,
)
self.elevation += sub
self.cumdiff += sub

#strataMesh.py line 338+
self.oldload += sub_poro
if write > 0:
self.layerMesh(selev[self.ids] + subs[self.ids])
if write ==0:
self.write_hdf5_stratal(outstep - 1)`

Awesome this is exactly what I was going to suggest! The only thing to change is the value of outStrata in the main loop for the self.strata.buildStrata just put 0:
sub = self.strata.buildStrata(
self.elevation,
self.cumdiff,
self.force.sealevel,
self.recGrid.boundsPt,
0,
self.outputStep,
)
But for the last call in the model.py set it to 1.