def meanProfile(basedir, acronym, f, startindx, endindx, fileprefix): # How many vertical levels depends on which set we look at if suffix == '_PL2': c = 120 elif suffix == '_PL': c = 18 H = np.zeros((24,2,c)) for i in np.arange(startindx,endindx): print(i) prefix = file_prefix(i) flx = xr.open_dataset(basedir + fileprefix + '_icon_tropic_' + prefix + str(i) + suffix + '.nc') clch = xr.open_dataset(basedir + 'CLCONV_2D_icon_tropic_' + prefix + str(i) + '.nc').clch.isel(time=0,lev=0) # The factor of -1 is because pressure decreases upward temp = -1.*(flx.lwflxall.isel(time=0)-flx.lwflxclr.isel(time=0)).where(clch > f) temp = temp.assign_coords(plev_2=temp.plev_2.values) temp = temp.differentiate('plev_2') # Factor of 86400 to convert K s-1 to K day-1. H[i-startindx,0] = g/cp*86400*temp.mean(dim={'ncells'}) temp = -1.*(flx.swflxall.isel(time=0)-flx.swflxclr.isel(time=0)).where(clch > f) temp = temp.assign_coords(plev_2=temp.plev_2.values) temp = temp.differentiate('plev_2') H[i-startindx,1] = g/cp*86400*temp.mean(dim={'ncells'}) print('Saving mean heating rates from ' + basedir + '...') np.save('../output/H_' + acronym + suffix + '.npy',H) return H
def meanProfile(basedir, acronym, f, startindx, endindx, fileprefix): # How many vertical levels depends on which set we look at if suffix == '_PL2': c = 120 elif suffix == '_PL': c = 18 QG = np.zeros((24,c)) for i in np.arange(startindx,endindx): print(i) prefix = file_prefix(i) flx = xr.open_dataset(basedir + fileprefix + '_icon_tropic_' + prefix + str(i) + suffix + '.nc') clch = xr.open_dataset(basedir + 'CLCONV_2D_icon_tropic_' + prefix + str(i) + '.nc').clch.isel(time=0,lev=0) QG[i-startindx] = flx.qg.isel(time=0).where(clch > f).mean(dim={'ncells'}) print('Saving hourly mean profiles from ' + basedir + '...') np.save('../output/QG_' + acronym + suffix + '.npy',QG) return QG
def meanProfile(basedir, acronym, f, startindx, endindx, fileprefix): # How many vertical levels depends on which set we look at if suffix == '_PL2': c = 120 elif suffix == '_PL': c = 18 WT = np.zeros((2, 24, c)) for i in np.arange(startindx, endindx): print(i) prefix = file_prefix(i) w = xr.open_dataset(basedir + fileprefix + '_icon_tropic_' + prefix + str(i) + suffix + '.nc') clch = xr.open_dataset(basedir + 'CLCONV_2D_icon_tropic_' + prefix + str(i) + '.nc').clch.isel(time=0, lev=0) WT[0, i - startindx] = w.omega.isel(time=0).where(clch > f).mean( dim={'ncells'}) WT[1, i - startindx] = w.temp.isel(time=0).where(clch > f).mean( dim={'ncells'}) print('Saving mean pressure velocity and temperature from ' + basedir + '...') np.save('../output/WT_' + acronym + suffix + '.npy', WT) return WT