TKE10_W = opennc("nc_files_TKE10_lev75/PAPA_1d_20100615_20110614_grid_W.nc", 0) TKE30_T = opennc("nc_files_TKE30_lev75/PAPA_1d_20100615_20110614_grid_T.nc", 0) TKE30_W = opennc("nc_files_TKE30_lev75/PAPA_1d_20100615_20110614_grid_W.nc", 0) # initial variables # put in the indexes to map the depth values here: (found from observation) mapindexsalinity = [1, 8, 11, 13, 14, 15, 17, 19, 22, 24, 25, 28, 30] #print(len(mapindexsalinity)) mapindextemperature = [ 1, 4, 8, 9, 10, 11, 13, 14, 15, 17, 19, 21, 24, 25, 27, 29, 30, 34 ] #print(len(mapindextemperature)) # initial variables done # 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) depth_temp_orig = getvar(orig_T, "depth", 0) # get the depths depth_sal_orig = getvar(orig_S, "depth", 0) # will need to resize from 4 dims to 2 dims otherwise havoc # it is to exclude the (obvious) 1,1 dimension that s the 3rd and 4th dimension, must include the time steps 364 of them as well as the temp and sal data for each time step. temp_orig = temp_orig[0:len(time_orig), :].reshape( len(time_orig), len(mapindextemperature) ) #also need to use 364 indexes out of 365 because of the data structures sal_orig = sal_orig.reshape(len(time_orig), len(mapindexsalinity)) # original data done # get calculated variables here(for the different closure schemes):
# 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: # This will resize and get rid of NaN values from the data # it is to exclude the (obvious) 1,1 dimension that s the 3rd and 4th dimension, must include the time steps 364 of them as well as the temp and sal data for each time step. [temp_orig, sal_orig] = processTempandSal(temp_orig, sal_orig, len(time_orig)) # print(temp_orig.shape) # testing # print(sal_orig.shape)
# 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: # This will resize and get rid of NaN values from the data # it is to exclude the (obvious) 1,1 dimension that s the 3rd and 4th dimension, must include the time steps 364 of them as well as the temp and sal data for each time step. [temp_orig, sal_orig] = processTempandSal(temp_orig, sal_orig, len(time_orig)) # print(temp_orig.shape) # testing # print(sal_orig.shape)
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 ydata_S = init_sal ydata_T = init_temp
# 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 :-)
# f2011_lat = getvar(fh_2011,"nav_lat",1) # DC # f2011_lon = getvar(fh_2011,"nav_lon",1) # DC # f2011_wndwe = getvar(fh_2011,"wndwe",1) # DC # f2011_wndsn = getvar(fh_2011,"wndsn",1) # DC # f2011_tinst = getvar(fh_2011,"time_instant",1) # DC # f2011_tcount = getvar(fh_2011,"time_counter",1) # DC # f2011_relhumid = getvar(fh_2011,"humi_r",1) # DC # f2011_humid = getvar(fh_2011,"humi",1) # DC # f2011_sw = getvar(fh_2011,"qsr",1) # DC # f2011_lw = getvar(fh_2011,"qlw",1) # DC # f2011_airtem = getvar(fh_2011,"tair",1) # DC # f2011_rain = getvar(fh_2011,"prec",1) # DC # f2011_snow = getvar(fh_2011,"snow",1) # DC # for fh_init: init_lon = getvar(fh_init, "longitude", 1) # DC init_lat = getvar(fh_init, "latitude", 1) # DC init_time = getvar(fh_init, "time_counter", 1) # DC 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 pinitgraph(init_dept, init_temp, "temperature") # print(init_temp[:,:,1,1]) print(init_dept) # print(init_lon) # print(init_lat)