<jupyter_start><jupyter_text>Forecasting SSH with the qsgw-DI model(Jupyter Notebook prepared by <NAME> & <NAME>, 2018)<jupyter_code>import sys
print (sys.version)
import sys,os,shutil
import numpy
import matplotlib.pylab as plt
import time
import netCDF4 as nc
import qgsw
file='ssh.nc'
fid = nc.Dataset(file)
lon1d=numpy.array(fid.variables["lon"][:]).squeeze()
lat1d=numpy.array(fid.variables["lat"][:]).squeeze()
lon,lat=numpy.meshgrid(lon1d,lat1d)
SSH=numpy.array(fid.variables["SSH"][:,:]).squeeze()
# Set constant Rossby first baroclinic phase speed to constant value
c=SSH*0. + 2.5 # in m/s

tint=86400*5 # Time of propagator integration in seconds. Can be positive or negative
deltat=86400*1 # Time period of outputs
dt=600 # propagator time step<jupyter_output><empty_output><jupyter_text>Applying the QGSW operator<jupyter_code>Hf,trash=qgsw.qgsw(Hi=SSH, c=c, lon=lon, lat=lat, tint=tint, dtout=deltat, dt=dt,rappel=None,snu=0.)<jupyter_output><empty_output><jupyter_text>Saving the result<jupyter_code>for it in range(numpy.shape(Hf)[0]):
    print it
    ncout = nc.Dataset('OUTPUT/ssh_'+str(it)+'.nc', 'w', format='NETCDF3_CLASSIC')
    ncout.createDimension('x', lon1d.shape[0])
    ncout.createDimension('y', lat1d.shape[0])
    ncout.createDimension('time', None)
    nclon = ncout.createVariable('lon', 'f', ('x',))
    nclat = ncout.createVariable('lat', 'f', ('y',))
    nctim = ncout.createVariable('time', 'f', ('time',))
#   nchei = ncout.createVariable('SSH', 'f', ('time','y','x',))
    nchei = ncout.createVariable('SSH', 'f', ('y','x',))
    nclon[:] = lon1d[:]
    nclat[:] = lat1d[:]
#nctim[:]=range(0,tint+deltat,deltat)
    nctim[:]=deltat*it
#nchei[:,:,:] = Hf[:,:,:]
    nchei[:,:] = Hf[it,:,:]
    ncout.close()<jupyter_output>0
1
2
3
4
5<jupyter_text>Plot<jupyter_code>plt.figure(figsize=(10, 10))

plt.subplot(211)
plt.pcolormesh(lon,lat,SSH)
plt.colorbar(extend='both', fraction=0.042, pad=0.04)
plt.title('SSH_{t}');

plt.subplot(212)
plt.pcolormesh(lon,lat,Hf[-1,:,:])
plt.colorbar(extend='both', fraction=0.042, pad=0.04)
plt.title('SSH_qg_{t+tint} (here after 5 days)');<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19570294255021017, 'fraction_numerical': 0.032227930873423634, 'mean_word_length': 6.595744680851064, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '483759', 'license': 'MIT', 'n_tokens_mistral': 962, 'n_tokens_neox': 926, 'n_words': 152, 'path': 'notebooks/SSHforecastingQGSW.ipynb', 'repo_name': 'redouanelg/qgsw-DI', 'size': '2162'}