import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.basemap import Basemap import pylab # this code is to analyse the runs from the c1d_PAPA case after modifying the turbulence schemes (TKE,generic,ke,kw,kkl) # for a constant number of vertical levels of 75 ########################### # for the original data: ########################### # Open the netcdf files using the file paths for the files: # init = opennc("initial_conditions/init_PAPASTATION_m06d15.nc",0)# initial conditions orig_T = opennc("original_data/t50n145w_dy.cdf", 0) # original data orig_S = opennc("original_data/s50n145w_dy.cdf", 0) # get/open original data variables here: time_orig = getvar(orig_S, "time", 0) # use one time for all calc, set to 364 days temp_orig = getvar(orig_T, "T_20", 0) #print(temp_orig[0,:])# get temperatures and salinities sal_orig = getvar(orig_S, "S_41", 0) temp_depth_orig = getvar(orig_T, "depth", 0) # get the depths sal_depth_orig = getvar(orig_S, "depth", 0) # plt.plot(temp_orig) # print(sal_depth_orig) # process the original Temp and Sal data:
import time as time # this code is to analyse the runs from the c1d_PAPA case after modifying the turbulence schemes (TKE,generic,ke,kw,kkl) # for a constant number of vertical levels of 75 # type of turbulence scheme: (change this, ke, kw, generic, kkl, TKE0, TKE10, TKE30) scheme = "ke" ########################### # for the original data: ########################### # Open the netcdf files using the file paths for the files: # init = opennc("initial_conditions/init_PAPASTATION_m06d15.nc",0)# initial conditions orig_T = opennc("original_data/t50n145w_dy.cdf", 0) # original data orig_S = opennc("original_data/s50n145w_dy.cdf", 0) # get/open original data variables here: time_orig = getvar(orig_S, "time", 0) # use one time for all calc, set to 364 days temp_orig = getvar(orig_T, "T_20", 0) #print(temp_orig[0,:])# get temperatures and salinities sal_orig = getvar(orig_S, "S_41", 0) temp_depth_orig = getvar(orig_T, "depth", 0) # get the depths sal_depth_orig = getvar(orig_S, "depth", 0) # plt.plot(temp_orig) # print(sal_depth_orig) # process the original Temp and Sal data:
from pRMSE import pRMSE from pvert_grid import pvert_grid from extractdata import extractdata from getvar import getvar from pgraph import pgraph from netCDF4 import Dataset as netcdffile import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.basemap import Basemap import pylab # this code is to analyse the runs from the c1d_PAPA case after modifying the turbulence schemes (TKE,generic,ke,kw,kkl) # for a constant number of vertical levels of 75 # Open the netcdf files using the file paths for the files: init = opennc("initial_conditions/init_PAPASTATION_m06d15.nc", 0) # initial conditions orig_T = opennc("original_data/t50n145w_dy.cdf", 0) # original data orig_S = opennc("original_data/s50n145w_dy.cdf", 0) ke_T = opennc("nc_files_ke_lev75/PAPA_1d_20100615_20110614_grid_T.nc", 0) #output from NEMO, T,W files ke_W = opennc("nc_files_ke_lev75/PAPA_1d_20100615_20110614_grid_W.nc", 0) kw_T = opennc("nc_files_kw_lev75/PAPA_1d_20100615_20110614_grid_T.nc", 0) kw_W = opennc("nc_files_kw_lev75/PAPA_1d_20100615_20110614_grid_W.nc", 0) kkl_T = opennc("nc_files_kkl_lev75/PAPA_1d_20100615_20110614_grid_T.nc", 0) kkl_W = opennc("nc_files_kkl_lev75/PAPA_1d_20100615_20110614_grid_W.nc", 0) generic_T = opennc( "nc_files_generic_lev75/PAPA_1d_20100615_20110614_grid_T.nc", 0) generic_W = opennc( "nc_files_generic_lev75/PAPA_1d_20100615_20110614_grid_W.nc", 0) TKE0_T = opennc("nc_files_TKE0_lev75/PAPA_1d_20100615_20110614_grid_T.nc", 0) TKE0_W = opennc("nc_files_TKE0_lev75/PAPA_1d_20100615_20110614_grid_W.nc", 0)
# this code must fit a curve to the initial condition from opennc import opennc from getvar import getvar from zgrid import zgrid from scipy.interpolate import interp1d from pinitgraph import pinitgraph from netCDF4 import Dataset as netcdffile import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.basemap import Basemap import pylab from scipy.optimize import curve_fit infile4 = 'nc_files/init_PAPASTATION_m06d15.nc' fh_init = opennc(infile4, 1) init_dept = getvar(fh_init, "deptht", 1) # C init_temp = getvar(fh_init, "votemper", 1) init_temp = init_temp[0, :, 1, 1] # C init_sal = getvar(fh_init, "vosaline", 1) init_sal = init_sal[0, :, 1, 1] # C # use the spline interpolation # gert suggested it and it is found online at: # http://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html # works well for salinity and temperature # set out the data xdata = init_dept
# this code must fit a curve to the initial condition from opennc import opennc from getvar import getvar from zgrid import zgrid from scipy.interpolate import interp1d from pinitgraph import pinitgraph from netCDF4 import Dataset as netcdffile import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.basemap import Basemap import pylab from scipy.optimize import curve_fit infile4 = 'nc_files/init_PAPASTATION_m06d15.nc' fh_init = opennc(infile4, 1) init_dept = getvar(fh_init, "deptht", 1) # C init_temp = getvar(fh_init, "votemper", 1) init_temp = init_temp[0, :, 1, 1] # C init_sal = getvar(fh_init, "vosaline", 1) init_sal = init_sal[0, :, 1, 1] # C longi = fh_init.variables["longitude"][:] # use the spline interpolation # gert suggested it and it is found online at: # http://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html # works well for salinity and temperature # set out the data
# from pRMSE import pRMSE from pvert_grid import pvert_grid from extractdata import extractdata from getvar import getvar from pgraph import pgraph from netCDF4 import Dataset as netcdffile import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.basemap import Basemap import pylab # this code is to analyse the runs from the c1d_PAPA case after modifying the turbulence schemes (TKE,generic,ke,kw,kkl) # for a constant number of vertical levels of 75 # Open the netcdf files using the file paths for the files: ke_T = opennc("ncfiles/PAPA_1d_20100615_20110614_grid_T.nc", 0) #output from NEMO, T,W files # ke_W = opennc("ncfiles_ke_lev75/PAPA_1d_20100615_20110614_grid_W.nc",0) ke_T_temp = getvar(ke_T, "votemper", 1) ke_T_sal = getvar(ke_T, "vosaline", 1) ke_T_dep = getvar(ke_T, "deptht", 1) ke_T_time = getvar(ke_T, "time_counter", 1) pgraph(ke_T_time, ke_T_dep, ke_T_temp[0:364, :, 1, 1], "time (days)", "depth", 35, 1, 0, 1, None, [0, 200]) pgraph(ke_T_time, ke_T_dep, ke_T_sal[0:364, :, 1, 1], "time (days)", "depth", 35, 1, 0, 1, None, [0, 200]) plt.show() # a sentimental note, James again proves to have much more luck than I anticipated. A minor error fixed when he poped in the office :-)
from pinitgraph import pinitgraph from netCDF4 import Dataset as netcdffile import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.basemap import Basemap import pylab # read initial conditions from NETcdf file ".nc" infile1 = 'nc_files/chlorophyll_PAPASTATION.nc' infile2 = 'nc_files/forcing_PAPASTATION_1h_y2010.nc' infile3 = 'nc_files/forcing_PAPASTATION_1h_y2011.nc' infile4 = 'nc_files/init_PAPASTATION_m06d15.nc' # open the netcdf file fh_chlor = opennc(infile1, 1) fh_2010 = opennc(infile2, 1) fh_2011 = opennc(infile3, 1) fh_init = opennc(infile4, 1) ##################################################### # get the variables and see which need changing.... # DC means it doesn't need changing and # C means the variable needs changing # # for fh_chlor: (nothing needs changing for this initial condition file) # chlor_chlor= getvar(fh_chlor,"CHLA",1) # DC # chlor_month= getvar(fh_chlor,"MONTH_REG",1) # DC # chlor_xaxis= getvar(fh_chlor,"XAXIS",1) # DC # chlor_yaxis= getvar(fh_chlor,"YAXIS",1) # DC