Skip to content

Commit

Permalink
Write SCRIP files in NETCDF3_64BIT_DATA format
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Jan 10, 2025
1 parent 7c98497 commit b50bf38
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion compass/ocean/tests/utility/combine_topo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pathlib
from datetime import datetime
from glob import glob

Expand Down Expand Up @@ -336,6 +337,7 @@ def _create_bedmachine_scrip_file(self):
bedmachine_descriptor = ProjectionGridDescriptor.read(
projection, in_filename, 'BedMachineAntarctica500m',
)
bedmachine_descriptor.format = 'NETCDF3_64BIT_DATA'
bedmachine_descriptor.to_scrip(out_filename)

def _create_target_scrip_file(self):
Expand All @@ -350,6 +352,8 @@ def _create_target_scrip_file(self):
logger.info(f'Create SCRIP file for {self.resolution_name} mesh')

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

# Build cubed sphere SCRIP file using tempestremap
if self.target_grid == 'cubed_sphere':
Expand All @@ -364,15 +368,24 @@ def _create_target_scrip_file(self):
# Create SCRIP file
args = [
'ConvertMeshToSCRIP', '--in', f'{self.resolution_name}.g',
'--out', out_filename,
'--out', netcdf4_filename,
]
check_call(args, logger)

# ConvertMeshToSCRIP doesn't support NETCDF3_64BIT_DATA, so use
# ncks
args = [
'ncks', '-5',
netcdf4_filename,
out_filename,
]

# Build lat-lon SCRIP file using pyremap
elif self.target_grid == 'lat_lon':
descriptor = get_lat_lon_descriptor(
dLon=self.resolution, dLat=self.resolution,
)
descriptor.format = 'NETCDF3_64BIT_DATA'
descriptor.to_scrip(out_filename)

logger.info(' Done.')
Expand Down

0 comments on commit b50bf38

Please sign in to comment.