Esempio n. 1
0
	def setUp ( self ):
		"""Initialisation des tests."""
		self.rfile = '../data/restart_10years.nc'
		self.refile = 'test0.nc'
		self.para = {'hphy','hdyn','uphy','udyn','uforc','uparam'}
		self.ds = xr.open_dataset(self.refile)
		SW = SWmodel(nx=80, ny=80)
		SW.inistate_rst(self.rfile)
		SW.set_time(0)
		endtime = 12 * 30 * 12 * 1
		SW.save(time=np.arange(1, endtime, 12 * 7), para=self.para, name='test.nc')
		for i in range(endtime):
			SW.next()
		self.ds2 = xr.open_dataset('test.nc')
Esempio n. 2
0
SW.initstate_cst(0,0,0)
SW.save(time=np.arange(0,endtime,1),name='longrun.nc')
for i in range(endtime):
	SW.next()
SW.remove_save('longrun.nc')

#Run : two steps
SW.initstate_cst(0,0,0)
SW.save(time=np.arange(0,midtime,1),name='firstrun.nc')
for i in range(0,midtime):
	SW.next()
SW.save_rst('restart_'+str(midtime)+'.nc')
SW.remove_save('firstrun.nc')
SW.initstate_cst(0,0,0)
SW.save(time=np.arange(midtime,endtime,1),name='secondrun.nc')
SW.inistate_rst('restart_'+str(midtime)+'.nc')
for i in range(midtime,endtime):
 	SW.next()

#plots
ds_long = xr.open_dataset('longrun.nc')
ds_first = xr.open_dataset('firstrun.nc')
ds_second = xr.open_dataset('secondrun.nc')
x = 0
y = 0

if PLOT:
	fig, axes = plt.subplots(ncols=1)
	ds_long.hphy.isel(x=x,y=y).plot(ax=axes)
	ds_first.hphy.isel(x=x,y=y).plot(ax=axes)
	ds_second.hphy.isel(x=x,y=y).plot(ax=axes)
Esempio n. 3
0
File: run_z0.py Progetto: brajard/sw
    rfile = '../../data/restart_10years.nc'
    outfile_chg = '../../data/test-z0-change.nc'
    outfile_nochg = '../../data/test-z0-nochange.nc'

    #Run 2 versions of the model
    # - one with the old z limit condition
    # - one with the changed z limit condition
    files2run = {outfile_chg, outfile_nochg}
    #files2run = {} #comment to rerun
    for outfile in files2run:
        para = {'hphy', 'vphy', 'uphy'}
        if 'nochange' in outfile:
            SW = SWmodel(nx=80, ny=80)
        else:
            SW = SWz0(nx=80, ny=80)
        SW.inistate_rst(rfile)
        SW.set_time(0)

        endtime = 12 * 30 * 12 * 10
        SW.save(time=np.arange(0, endtime, 12 * 7), para=para, name=outfile)
        for i in tqdm(range(endtime + 1)):
            SW.next()
    ds_chg = xr.open_dataset(outfile_chg)
    ds_nochg = xr.open_dataset(outfile_nochg)
    out = ds_nochg.assign(dh=ds_chg.hphy - ds_nochg.hphy)
    out = out.assign(du=ds_chg.uphy - ds_nochg.uphy)
    out = out.assign(dv=ds_chg.vphy - ds_nochg.vphy)
    f2plot = {'dh', 'du', 'dv'}

    for par in f2plot:
        fig, ax = plt.subplots(nrows=2)