Skip to content

Commit

Permalink
enable netcdf outputs in 3d model
Browse files Browse the repository at this point in the history
Currently only 2d fields can be exported
  • Loading branch information
tkarna committed Jul 23, 2021
1 parent 1e4f332 commit c088392
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions thetis/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ class CommonModelOptions(FrozenConfigurable):
trait=Unicode(),
default_value=[],
help="Fields to export in HDF5 format").tag(config=True)
fields_to_export_netcdf = List(
trait=Unicode(),
default_value=[],
help="Fields to export in NetCDF format").tag(config=True)
verbose = Integer(0, help="Verbosity level").tag(config=True)
linear_drag_coefficient = FiredrakeScalarExpression(
None, allow_none=True, help=r"""
Expand Down Expand Up @@ -743,10 +747,6 @@ class ModelOptions2d(CommonModelOptions):
2D solver supports 'dg' or 'cg'.""").tag(config=True)
use_supg_tracer = Bool(
False, help="Use SUPG stabilisation in tracer advection").tag(config=True)
fields_to_export_netcdf = List(
trait=Unicode(),
default_value=[],
help="Fields to export in NetCDF format").tag(config=True)

def __init__(self, *args, **kwargs):
self.tracer = OrderedDict()
Expand Down
9 changes: 9 additions & 0 deletions thetis/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,15 @@ def create_exporters(self):
verbose=self.options.verbose > 0,
preproc_funcs=self._field_preproc_funcs)
self.exporters['hdf5'] = e
nc_dir = os.path.join(self.options.output_directory, 'nc')
e = exporter.ExportManager(nc_dir,
self.options.fields_to_export_netcdf,
self.fields,
field_metadata,
export_type='netcdf',
verbose=self.options.verbose > 0,
preproc_funcs=self._field_preproc_funcs)
self.exporters['netcdf'] = e

self._isfrozen = True

Expand Down

0 comments on commit c088392

Please sign in to comment.