# loading saved data for temp_option in range(0, temperature_change_options_length): # selecting the temperature change min_temperature = temperature_change_options[temp_option] mean_ec_y_array[temp_option+1] = np.loadtxt("saved_data/mean_EC_yvalue_"+str(min_temperature)+"_degree_warming_cmip6cmip5.csv", delimiter=",") lower_ec_limit_array[temp_option+1] = np.loadtxt("saved_data/EC_lower_limit_"+str(min_temperature)+"_degree_warming_cmip6cmip5.csv", delimiter=",") upper_ec_limit_array[temp_option+1] = np.loadtxt("saved_data/EC_upper_limit_"+str(min_temperature)+"_degree_warming_cmip6cmip5.csv", delimiter=",") #%% Observational soil carbon # regrid cube regrid_cube = iris.load_cube('/home/links/rmv203/obs_datasets/Tair_WFDEI_ann.nc') regrid_cube = time_average(regrid_cube) regrid_cube.coord('latitude').guess_bounds() regrid_cube.coord('longitude').guess_bounds() regrid_modelcube = regrid_cube.copy() # observational land frac landfraction_obs = combine_netCDF_observations('/home/links/rmv203/obs_datasets/luc4c_landmask.nc', 'mask') # observational soil carbon observational_Cs_data = np.load('saved_variables/observational_Cs_data.npy') observational_Cs_mask = np.load('saved_variables/observational_Cs_mask.npy') observational_Cs0 = np.ma.masked_array(observational_Cs_data, mask=observational_Cs_mask) # global total of observational soil carbon observational_Cs0_cube = numpy_to_cube(observational_Cs0, regrid_modelcube, 2) observational_Cs0_cube = global_total(observational_Cs0_cube, landfrac=landfraction_obs, latlon_cons=None) observational_Cs0_data = observational_Cs0_cube.data
# Heterotrophic Respiration (RH) rh_historical_cube = combine_netCDF_cmip5('/home/rmv203/cmip5_data/rh_Lmon_'+model+'_historical*', 'heterotrophic_respiration_carbon_flux', model) rh_historical_cube = open_netCDF(rh_historical_cube) # Soil Carbon (cSoil) cSoil_historical_cube = combine_netCDF_cmip5('/home/rmv203/cmip5_data/cSoil_Lmon_'+model+'_historical*', 'soil_carbon_content', model) cSoil_historical_cube = open_netCDF(cSoil_historical_cube) # Near Surface Air Temperature (tas) tas_historical_cube = combine_netCDF_cmip5('/home/rmv203/cmip5_data/tas_Amon_'+model+'_historical*', 'air_temperature', model) tas_historical_cube = open_netCDF(tas_historical_cube) # Select historical time period rh_historical_cube = select_time(rh_historical_cube, lower_historical, upper_historical) cSoil_historical_cube = select_time(cSoil_historical_cube, lower_historical, upper_historical) tas_historical_cube = select_time(tas_historical_cube, lower_historical, upper_historical) # Time average rh_historical_cube = time_average(rh_historical_cube) cSoil_historical_cube = time_average(cSoil_historical_cube) tas_historical_cube = time_average(tas_historical_cube) # Converting from cubes to numpy_arrays rh_historical_data = rh_historical_cube.data cSoil_historical_data = cSoil_historical_cube.data tas_historical_data = tas_historical_cube.data # save to use later historical_tas_save_data = tas_historical_data - 273.15 cSoil_historical_save_cube = cSoil_historical_cube.copy() historical_rh_save_data = rh_historical_data*86400.*365. # Calculating Soil Turnover Time (tau_s) tau_s_data_historical = cSoil_historical_data / (rh_historical_data*86400.*365.)
cSoil_historical_cube = combine_netCDF_time_overlap( '/home/rmv203/cmip6_data/cSoil_Emon_' + model + '_historical*', model) cSoil_historical_cube = open_netCDF(cSoil_historical_cube) # Near Surface Air Temperature (tas) tas_historical_cube = combine_netCDF_time_overlap( '/home/rmv203/cmip6_data/tas_Amon_' + model + '_historical*', model) tas_historical_cube = open_netCDF(tas_historical_cube) # Select historical time period rh_historical_cube = select_time(rh_historical_cube, lower_historical, upper_historical) cSoil_historical_cube = select_time(cSoil_historical_cube, lower_historical, upper_historical) tas_historical_cube = select_time(tas_historical_cube, lower_historical, upper_historical) # Time average rh_historical_time_av_cube = time_average(rh_historical_cube) cSoil_historical_time_av_cube = time_average(cSoil_historical_cube) tas_historical_time_av_cube = time_average(tas_historical_cube) # Converting from cubes to numpy_arrays rh_historical_time_av_data = rh_historical_time_av_cube.data cSoil_historical_time_av_data = cSoil_historical_time_av_cube.data tas_historical_time_av_data = tas_historical_time_av_cube.data # Calculating Soil Turnover Time tau_s_data_historical = cSoil_historical_time_av_data / ( rh_historical_time_av_data * 86400. * 365.) tau_s_masked_data_historical = ma.masked_where( np.logical_or(tau_s_data_historical < 1, tau_s_data_historical > 1e4), tau_s_data_historical) #%%
# observational_rh_data = np.load('saved_variables/observational_rh_data.npy') observational_rh_mask = np.load('saved_variables/observational_rh_mask.npy') observational_rh = np.ma.masked_array(observational_rh_data, mask=observational_rh_mask) # loading observational land fraction landfraction_obs = combine_netCDF_observations( '/home/links/rmv203/obs_datasets/luc4c_landmask.nc', 'mask') #%% # Loading regrid cube regrid_cube = iris.load_cube( '/home/links/rmv203/obs_datasets/Tair_WFDEI_ann.nc') regrid_cube = time_average(regrid_cube) regrid_cube.coord('latitude').guess_bounds() regrid_cube.coord('longitude').guess_bounds() regrid_modelcube = regrid_cube.copy() # correct lat and lon dimensions n_lat = regrid_cube.coord('latitude').points n_lon = regrid_cube.coord('longitude').points #%% # inputs lower_historical = 1995 upper_historical = 2005 region_global = [0, 360, -90, 90]
'xtick.color': 'k', 'ytick.color': 'k', 'axes.labelsize': 34, 'xtick.labelsize': 34, 'ytick.labelsize': 34, 'font.size': 34, 'text.usetex': False, "svg.fonttype": 'none' } plt.rcParams.update(params) #%% regrid cube regrid_cube = iris.load_cube( '/home/links/rmv203/obs_datasets/Tair_WFDEI_ann.nc') regrid_cube = time_average(regrid_cube) regrid_cube.coord('latitude').guess_bounds() regrid_cube.coord('longitude').guess_bounds() regrid_modelcube = regrid_cube # correct lat and lon dimensions n_lat = regrid_cube.coord('latitude').points n_lon = regrid_cube.coord('longitude').points #%% Observational datasets # Soil carbon # ncscd ncscd_file = Dataset( '/home/links/rmv203/obs_datasets/NCSCDV22_soilc_0.5x0.5.nc') ncscd_data = ncscd_file.variables['soilc'][:] # hwsd
print(rcp, model) #%% modelled historical # Soil Carbon (cSoil) cSoil_historical_cube_new = combine_netCDF_cmip5('/home/rmv203/cmip5_data/cSoil_Lmon_'+model+'_historical*', 'soil_carbon_content', model) cSoil_historical_cube_new = open_netCDF(cSoil_historical_cube_new) # Near Surface Air Temperature (tas) tas_historical_cube = combine_netCDF_cmip5('/home/rmv203/cmip5_data/tas_Amon_'+model+'_historical*', 'air_temperature', model) tas_historical_cube = open_netCDF(tas_historical_cube) # Select historical time period cSoil_historical_cube_new = select_time(cSoil_historical_cube_new, lower_historical, upper_historical) tas_historical_cube = select_time(tas_historical_cube, lower_historical, upper_historical) # Time average cSoil_historical_time_av_cube_new = time_average(cSoil_historical_cube_new) tas_historical_cube = time_average(tas_historical_cube) tas_historical_data = tas_historical_cube.data # Converting from cubes to numpy_arrays cSoil_historical_time_av_data_new = cSoil_historical_time_av_cube_new.data #%% Modelled Future # Soil Carbon (cSoil) cSoil_cube = combine_netCDF_cmip5('/home/rmv203/cmip5_data/cSoil_Lmon_'+model+'_'+rcp+'_*', 'soil_carbon_content', model) cSoil_cube = open_netCDF(cSoil_cube) # Near Surface Air Temperature (tas) tas_cube = combine_netCDF_cmip5('/home/rmv203/cmip5_data/tas_Amon_'+model+'_'+rcp+'_*', 'air_temperature', model) tas_cube = open_netCDF(tas_cube)