mantle-convection-constrained / terratools

Tools to read, analyse and visualise models written by the TERRA mantle convection code
https://terratools.readthedocs.io/en/latest/
MIT License
6 stars 5 forks source link

Pickling terra models doesn't work without an external pressure function defined. #158

Open jwookey opened 3 weeks ago

jwookey commented 3 weeks ago

The function provided in terra_model.py for writing a terra model into a Python pickle (write_pickle) files fails when no external pressure function is defined, because of the lambda function in the definition of the PREM function.

E.g.:

m = tm.read_netcdf(glob.glob(f'./NC_037/nc*') m.write_pickle(f'NC_037.pkl')

results in:

AttributeError: Can't pickle local object 'TerraModel.init..'

jamespanton93 commented 3 weeks ago

We don't have a way to pass a pressure function in when we read a model with read_netcdf, not sure if this is something that we need?