-
Notifications
You must be signed in to change notification settings - Fork 10
Preparing boundary conditions for CCS1
Open boundary conditions for CCS1 are generated using the brushcutter Python package. Follow the link for installation instructions.
The preprocessing script is here
For this example, OBC data are generated using output from a global MOM6 simulation. The following outlines the full script using sea surface height as an example
-
Download input data
-
Start a Python session and import required modules
from brushcutter import lib_obc_variable as lov
from brushcutter import lib_obc_segments as los
from brushcutter import lib_ioncdf as ncdf
import netCDF4 as nc
import numpy as np
import subprocess as sp
-
Define the source and target grids
momgrd = 'ocean_hgrid.nc'
srcgrd = 'input_data/ocean_hgrid.nc'
-
Define the source sea surface height data
ssh_data = 'input_data/20140101.ocean_month.nc'
-
Define the boundary using the
los.obc_segment
methodsouth = los.obc_segment('segment_001',momgrd,istart=0,iend=360,jstart=0,jend=0)
The label attached to this segment is
segment_001
, it can be anything you choose.momgrd
is the path to the regional model FMS supergrid file. In this example, the model supergrid size equals 360x960 (a reminder that the supergrid has double the refinement of the tracer grid) and the boundary is defined along the south edge of the domain. -
Define the sea surface height (zeta) field to be interpolated to the boundary
zeta_south = lov.obc_variable(south,'zeta',geometry='line',\
obctype='flather',use_locstream=True)
zeta will be the name given to the interpolated field in the file
-
Load the source grid using the source supergrid file
xsrc=nc.Dataset(srcgrd).variables['x'][1::2,1::2]
ysrc=nc.Dataset(srcgrd).variables['y'][1::2,1::2]
-
Now interpolate sea surface heights from the source model and save each time level in a separate file
for k in np.arange(12):
zeta_south.interpolate_from(ssh_data,'ssh',frame=k,from_global=True,\
x_coords=xsrc,y_coords=ysrc, drown='ncl')
time = zeta_south.timesrc
time.calendar = nc.Dataset(ssh_data).variables['time'].calendar
ncdf.write_obc_file([south],[zeta_south],[],time,output='obc_CCS1_'+str(k).zfill(2)+'.nc')
-
Combine individual netCDF files
cmd = 'ncrcat obc_CCS1_??.nc -O -o obc_CCS1.nc'
sp.call(cmd,shell=True)
-
Add the modulo attribute to the time axis
cmd = "ncatted -h -a modulo,time,c,c,' ' obc_CCS1.nc"
sp.call(cmd,shell=True)
Here is a visualization of the resulting surface heights at the CCS1 domain boundaries.