Skip to content

Commit

Permalink
Convert combined file to NETCDF3_64BIT_DATA with ncks
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Jan 10, 2025
1 parent c1bf043 commit 5b42aa2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions compass/ocean/tests/utility/combine_topo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,10 @@ def _combine(self):
section = config['combine_topo']
renorm_thresh = section.getfloat('renorm_thresh')

out_filename = self.outputs[1]
stem = pathlib.Path(out_filename).stem
netcdf4_filename = f'{stem}.netcdf4.nc'

# Parse config
config = self.config
section = config['combine_topo']
Expand Down Expand Up @@ -652,8 +656,16 @@ def _combine(self):
combined[field] = combined[field].where(valid, fill_val)

# Save combined bathy to NetCDF
_write_netcdf_with_fill_values(combined, self.outputs[1],
format='NETCDF3_64BIT_DATA')
_write_netcdf_with_fill_values(combined, netcdf4_filename)

# writing directly in NETCDF3_64BIT_DATA proved prohibitively slow
# so we will use ncks to convert
args = [
'ncks', '-O', '-5',
netcdf4_filename,
out_filename,
]
check_call(args, logger)

logger.info(' Done.')

Expand Down

0 comments on commit 5b42aa2

Please sign in to comment.