I’ve been trying to generate forcing data using 1° monthly ACCESS-OM2 output, whereas the examples I’ve seen use 0.1° daily data. I’ve run into two issues so far:
- I use the monthly data to create access_om2_input, and from this the boundary forcing files (north/south/east/west_unprocessed.nc). When these files are passed to
expt.setup_ocean_state_boundaries
(the updated version ofexpt.rectangular_boundaries
in the example recipes), the function assumes the input is daily data. The boundary forcing files it generates don’t cover the full time period I expected them to, (two years of monthly data is misinterpreted as just 24 days). I don’t know if the forcing data has to be daily, or if monthly would be fine as long as it was dated correctly in the files generated!
I could get around this by adding this code in before the north/south/east/west_unprocessed.nc files are saved.
daily_time = pd.date_range(start=date_range[0], end= date_range[1], freq='D')
def interp_to_daily(ds):
return ds.interp(time=daily_time)
## Cut out East & West boundary conditions and save to netCDF
print('East & West boundary condition...')
east = rmom6.longitude_slicer(access_om2_input,
[longitude_extent[1] - buffer, longitude_extent[1] + buffer],
["xu_ocean", "xt_ocean"])
interp_to_daily(east).to_netcdf(tmp_dir + "/east_unprocessed.nc")
- The ACCESS-OM2 data I used has 50 vertical levels (nz=50), but in
rmom6.experiment
I had setnumber_vertical_layers = 75
.Expt.setup_initial_condition()
handled the vertical regridding correctly, and the resulting initial condition files had nz=75 as expected.Expt.setup_ocean_state_boundaries
produced boundary forcing files that still only had nz=50.
Again I could get around this by adding something like this into the notebook before callingExpt.setup_ocean_state_boundaries
rg_output_dir = tmp_dir+"/regrid/"
os.makedirs(rg_output_dir, exist_ok=True)
zl_interp = expt.vgrid.zl.rename({'zl': 'st_ocean'})
directions = ["north", "south", "east", "west"]
for direction in directions:
input_file = os.path.join(tmp_dir, f"{direction}_unprocessed.nc")
output_file = os.path.join(rg_output_dir, f"{direction}_unprocessed.nc")
print(f"Interpolating {input_file}")
ds = xr.open_dataset(input_file)
ds_interp = ds.interp({'st_ocean': zl_interp})
ds_interp.to_netcdf(output_file)
print(f"Saved to {output_file}")
and using rg_output_dir
as the inputput for exp.setup_ocean_state_boundaries(raw_boundaries_path=Path(rg_output_dir))