<jupyter_start><jupyter_text>Interpolate onto a quarter degree grid<jupyter_code>dx = 0.25

xp1_highres = np.arange(m.grid['Xp1'][0], m.grid['Xp1'][-1]+dx, dx)
x_highres = (xp1_highres[1:] + xp1_highres[:-1])/2

yp1_highres = np.arange(m.grid['Yp1'][0], m.grid['Yp1'][-1]+dx, dx)
y_highres = (yp1_highres[1:] + yp1_highres[:-1])/2


temp = np.ma.array(m.temperature['THETA'][:],mask=1-m.grid['HFacC'][:])
NANmask = temp.filled(np.NAN)
temp_interpolated = mitgcm.functions.interp_field(NANmask,m.grid['X'][:],m.grid['Y'][:],
                        x_highres,y_highres,interp_order=3,fill_nans='yes')

temp = np.ma.array(m.zonal_velocity['UVEL'][:],mask=1-m.grid['HFacW'][:])
NANmask = temp.filled(np.NAN)
u_interpolated = mitgcm.functions.interp_field(NANmask,m.grid['Xp1'][:],m.grid['Y'][:],
                                                  xp1_highres,y_highres,interp_order=3,fill_nans='yes')

temp = np.ma.array(m.meridional_velocity['VVEL'][:],mask=1-m.grid['HFacS'][:])
NANmask = temp.filled(np.NAN)
v_interpolated = mitgcm.functions.interp_field(NANmask,m.grid['X'][:],m.grid['Yp1'][:],
                                                  x_highres,yp1_highres,interp_order=3,fill_nans='yes')

temp = np.ma.array(m.free_surface['ETAN'][:],mask=1-m.grid['HFacC'][0,:,:])
NANmask = temp.filled(np.NAN)
eta_interpolated = mitgcm.functions.interp_field(NANmask.reshape((1,NANmask.shape[0],NANmask.shape[1])),
                                                 m.grid['X'][:],m.grid['Y'][:],
                                                  x_highres,y_highres,interp_order=3,fill_nans='yes')<jupyter_output><empty_output><jupyter_text>Export interpolated fields to start the model at a new resolutionThe fields need to be exported as binary files that the model can read when it starts. They also need to be exported  without the extra entries in u and v.<jupyter_code>try:
    os.mkdir('interpolated_fields')
except:
    pass

mitgcm.functions.export_binary('interpolated_fields/temp.interpolated.bin',temp_interpolated)
mitgcm.functions.export_binary('interpolated_fields/u.interpolated.bin',u_interpolated[:,:,:-1])
mitgcm.functions.export_binary('interpolated_fields/v.interpolated.bin',v_interpolated[:,:-1,:])
mitgcm.functions.export_binary('interpolated_fields/eta.interpolated.bin',eta_interpolated)

im = plt.pcolormesh(xp1_highres,y_highres,u_interpolated[level,:,:],
                    cmap='seismic', vmin= -1, vmax = 1)
plt.colorbar(im)
plt.contour(m.grid['X'][:],m.grid['Y'][:],m.bernoulli['BP'][level,:,:],30,colors='k')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1830931047915855, 'fraction_numerical': 0.017919750681729647, 'mean_word_length': 4.35, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '450462', 'license': 'MIT', 'n_tokens_mistral': 1015, 'n_tokens_neox': 1002, 'n_words': 106, 'path': 'examples/interpolation example.ipynb', 'repo_name': 'edoddridge/MITgcm_funcs', 'size': '2567'}