Skip to content
Snippets Groups Projects
Commit 130ff3e9 authored by RODIER Quentin's avatar RODIER Quentin
Browse files

Quentin 08/03/2023: use python3 for 013_Iroise KTEST

parent d1719027
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
##############################################
......@@ -20,29 +20,29 @@ file_RSTRT = netCDF4.Dataset(curdir_path+'IROISE_5KM_201109_02_00.nc')
LON_MNH=file_RSTRT.variables['LON'][1:-1,1:-1]
LAT_MNH=file_RSTRT.variables['LAT'][1:-1,1:-1]
U10_MNH=file_RSTRT.variables['UT'][2,1:-1,1:-1]
V10_MNH=file_RSTRT.variables['VT'][2,1:-1,1:-1]
PRES_MNH=file_RSTRT.variables['PABST'][2,1:-1,1:-1]
U10_MNH=file_RSTRT.variables['UT'][0,2,1:-1,1:-1]
V10_MNH=file_RSTRT.variables['VT'][0,2,1:-1,1:-1]
PRES_MNH=file_RSTRT.variables['PABST'][0,2,1:-1,1:-1]
try:
EVAP_MNH=file_RSTRT.variables['EVAP3D'][1:-1,1:-1]
EVAP_MNH=file_RSTRT.variables['EVAP3D'][0,1:-1,1:-1]
except KeyError:
print 'EVAP3D not found... imposed at 0!'
print('EVAP3D not found... imposed at 0!')
EVAP_MNH=np.zeros((np.shape(LON_MNH)[0],np.shape(LON_MNH)[1]))
try:
RAIN_MNH=file_RSTRT.variables['INPRR3D'][1:-1,1:-1]
RAIN_MNH=file_RSTRT.variables['INPRR3D'][0,1:-1,1:-1]
except KeyError:
print 'INPRR3D not found... imposed at 0!'
print('INPRR3D not found... imposed at 0!')
RAIN_MNH=np.zeros((np.shape(LON_MNH)[0],np.shape(LON_MNH)[1]))
try:
FMU_MNH=file_RSTRT.variables['FMU'][1:-1,1:-1]
FMV_MNH=file_RSTRT.variables['FMV'][1:-1,1:-1]
H_MNH=file_RSTRT.variables['H'][1:-1,1:-1]
RN_MNH=file_RSTRT.variables['RN'][1:-1,1:-1]
FMU_MNH=file_RSTRT.variables['FMU'][0,1:-1,1:-1]
FMV_MNH=file_RSTRT.variables['FMV'][0,1:-1,1:-1]
H_MNH=file_RSTRT.variables['H'][0,1:-1,1:-1]
RN_MNH=file_RSTRT.variables['RN'][0,1:-1,1:-1]
except KeyError:
print 'Turbulent fluxes FMU, FMV, H and LE not found... imposed at 0!'
print('Turbulent fluxes FMU, FMV, H and LE not found... imposed at 0!')
FMU_MNH=np.zeros((np.shape(LON_MNH)[0],np.shape(LON_MNH)[1]))
FMV_MNH=np.zeros((np.shape(LON_MNH)[0],np.shape(LON_MNH)[1]))
H_MNH=np.zeros((np.shape(LON_MNH)[0],np.shape(LON_MNH)[1]))
......@@ -50,8 +50,8 @@ except KeyError:
########################################################################
print '------------------------------------------'
print ' Creating netcdf file : rstrt_MNH.nc'
print('------------------------------------------')
print(' Creating netcdf file : rstrt_MNH.nc')
fout=netCDF4.Dataset(curdir_path+'rstrt_MNH.nc','w',format='NETCDF3_64BIT')
fout.Description='Restart file for OASIS coupling'
......@@ -93,6 +93,6 @@ fout.variables['MNH__V10'][:,:] = V10_MNH[:,:]
# ---------------------------------------
fout.close()
print ' Closing netcdf file : rstrt_MNH.nc'
print '-----------------------------------------'
print(' Closing netcdf file : rstrt_MNH.nc')
print('-----------------------------------------')
#####################################################
......@@ -37,8 +37,8 @@ echo '-- Create_restart_file_for_MNH.ncl/py '
echo '---------------------------------------'
rm -f rstrt_MNH.nc
ncl Create_restart_file_for_MNH.ncl
#python Create_restart_file_for_MNH.py
#ncl Create_restart_file_for_MNH.ncl
python3 Create_restart_file_for_MNH.py
fi
#----------------------------
......@@ -26,8 +26,8 @@ curdir_path=os.path.abspath(os.curdir)+'/'
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#
#-- Limit of the grid (from etopo)
lat_domain=[ 46.681, 50.092]
lon_domain=[-6.6348, -1.3652]
lat_domain=[47.0, 49.5]
lon_domain=[-6.2, -4.0]
print ('londomaine[0]',lon_domain[0])
print ('londomaine[1]',lon_domain[1])
......
......@@ -17,7 +17,7 @@ ln -sf $PREP_PGD_FILES/etopo2.nc topo.nc
rm -f grid_toy_model.nc
rm -f rstrt_TOY.nc
ncl Create_grid_and_restart_files_for_TOY.ncl
#python Create_grid_and_restart_files_for_TOY.py
#ncl Create_grid_and_restart_files_for_TOY.ncl
python3 Create_grid_and_restart_files_for_TOY.py
fi
##!/usr/bin/python
##!/usr/bin/python3
# -*- coding: utf-8 -*-
#
####################################################
......@@ -23,9 +23,9 @@ import glob
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#
print '=============================================='
print('==============================================')
curdir_path=os.path.abspath(os.curdir)+'/'
print curdir_path
print(curdir_path)
#
name_file_VAR1_TOY=glob.glob('*toyexe_01.nc')[0]
name_file_VAR1_MOD=glob.glob('*mesonh_01.nc')[0]
......@@ -40,16 +40,16 @@ name_file_GRIDS='grids.nc'
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
print '=============================================='
print('==============================================')
try :
os.mkdir(curdir_path+VAR1+'_'+VAR2+'/')
except OSError:
print 'Directory already created'
print('Directory already created')
else:
print 'Making directory'
print('Making directory')
print '=============================================='
print '~~~~ Plot these variables :', VAR1, VAR2
print('==============================================')
print('~~~~ Plot these variables :', VAR1, VAR2)
file_VAR1_TOY = netCDF4.Dataset(name_file_VAR1_TOY)
file_VAR1_MOD = netCDF4.Dataset(name_file_VAR1_MOD)
......@@ -64,14 +64,14 @@ LAT_TOY=file_GRIDS.variables['toyt.lat']
LON_TOY=file_GRIDS.variables['toyt.lon']
DIM_LAT_TOY=np.shape(LAT_TOY)[0]
DIM_LON_TOY=np.shape(LON_TOY)[1]
print 'DIM_LAT_TOY, DIM_LON_TOY', DIM_LAT_TOY, DIM_LON_TOY
print('DIM_LAT_TOY, DIM_LON_TOY', DIM_LAT_TOY, DIM_LON_TOY)
#~~~~~ MOD
LAT_MOD=file_GRIDS.variables['ssea.lat']
LON_MOD=file_GRIDS.variables['ssea.lon']
DIM_LAT_MOD=np.shape(LAT_MOD)[0]
DIM_LON_MOD=np.shape(LON_MOD)[1]
print 'DIM_LAT_MOD, DIM_LON_MOD', DIM_LAT_MOD, DIM_LON_MOD
print('DIM_LAT_MOD, DIM_LON_MOD', DIM_LAT_MOD, DIM_LON_MOD)
#~~~~~ VAR1/VAR2
VAR1_TOY=file_VAR1_TOY.variables[name_file_VAR1_TOY[0:8]][:,:,:]
......@@ -90,7 +90,7 @@ TIME_TOY=file_VAR1_TOY.variables['time'][:]
#~~~~~ CONVERT VARIABLES
if VAR2=='CHA':
print 'Multiply Charnock coefficient by 1000'
print('Multiply Charnock coefficient by 1000')
VAR2_TOY[:,:,:]=VAR2_TOY[:,:,:]*1000.0
VAR2_MOD[:,:,:]=VAR2_MOD[:,:,:]*1000.0
OPVAR2='*1000.0'
......@@ -99,10 +99,10 @@ if VAR2=='CHA':
#=====================================================
#-----------------------------------------------------
print '~~~~ Temporal loop'
print('~~~~ Temporal loop')
#-----------------------------------------------------
for ind_time in xrange(np.size(TIME_TOY)-1):
print ' ~~~~ Current time :', TIME_TOY[ind_time]
for ind_time in range(np.size(TIME_TOY)-1):
print(' ~~~~ Current time :', TIME_TOY[ind_time])
fig = plt.figure()
fig.suptitle('Cumulated time : '+str(TIME_TOY[ind_time])+'s', fontsize=18)
......@@ -156,4 +156,4 @@ for ind_time in xrange(np.size(TIME_TOY)-1):
plt.savefig(curdir_path+VAR1+"_"+VAR2+"/"+VAR1+"_"+VAR2+"_MOD_TOY_T"+str(ind_time)+".png")
plt.show()
plt.close()
print '=============================================='
print('==============================================')
#!/bin/bash
ncl plot_coupling_model_toy.ncl
#python plot_coupling_model_toy.py
#ncl plot_coupling_model_toy.ncl
python3 plot_coupling_model_toy.py
${POSTRUN} display */*0.png
${POSTRUN} display */*1.png
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment