Tselect = np.squeeze(InVar[Z1:Z2 + 1, :]) Dselect = np.squeeze(DensVar[Z1:Z2 + 1, :]) VertDim = Zdim elif (VcoordType == 'p'): Nvert = Np Tselect = np.squeeze(InVar[P1:P2 + 1, :]) Dselect = np.squeeze(DensVar[P1:P2 + 1, :]) VertDim = Pdim # Smooth the input temperature field in the horizontal. InVarSmooth = np.zeros((Nvert, Nx)) for ivert in range(Nvert): InVarSmooth[ivert, :] = nu.SmoothLine(np.squeeze(InVar[ivert, :])) # Take the horizontal gradient of the 2D field. # Create a 2D delta X array DeltaX_2D = np.tile(DeltaX.reshape((1, Nx)), (Nvert, 1)) InVarGrad = np.gradient(InVarSmooth, DeltaX_2D, axis=1) InVarGradSmooth = np.zeros((Nvert, Nx)) for ivert in range(Nvert): InVarGradSmooth[ivert, :] = nu.SmoothLine( np.squeeze(InVarGrad[ivert, :])) # Do vertical average of layer between bottom and top layer # Use density weighted averaging. Tbar = np.squeeze(np.average(Tselect, axis=0, weights=Dselect)) # Smooth Tbar in order to mitigate noise in the gradient
print("") # finish calculations # entropy deficit Sdef = (SmSat - Sm) / (SsstSat - Sb) # potiential intensity Pi = np.sqrt((Ts - To) * (Ts / To) * CkOverCd * (SsstSat - Sb)) # ventilation index Vi = WindShear * Sdef / Pi ##### Smoothed versions #### # wind shear WindShearSmooth = nu.SmoothLine(WindShear) # entropy deficit SmSmooth = nu.SmoothLine(Sm) SmSatSmooth = nu.SmoothLine(SmSat) SbSmooth = nu.SmoothLine(Sb) SsstSatSmooth = nu.SmoothLine(SsstSat) SdefSmooth = nu.SmoothLine((SmSatSmooth - SmSmooth) / (SsstSatSmooth - Sb)) # potential intensity TsSmooth = nu.SmoothLine(Ts) ToSmooth = nu.SmoothLine(To) PiSmooth = nu.SmoothLine(np.sqrt((TsSmooth - ToSmooth) * (TsSmooth / ToSmooth) * CkOverCd * (SsstSatSmooth - SbSmooth)))