def expFit(x,y): ''' Deprecated. Please update yr code to call this from NumUtils.py ''' print('Deprecated. Please update yr code to call this from NumUtils.py') import NumUtils as nu a,b = nu.expFit(x,y) return a,b
def linFit(x,y): ''' Deprecated. Please update yr code to call this from NumUtils.py ''' print('Deprecated. Please update yr code to call this from NumUtils.py') import NumUtils as nu model, R_out = nu.linFit(x,y) return model, R_out
def upperYieldStress(rheoData, rheoInfo): import numpy as np import NumUtils as nu g, t, gd = (rheoData['gamma'], rheoData['tau'], rheoData['gammadot']) UI = rheoInfo['upperN'] # upper yield stress gdU1 = gd[UI[0,0]:UI[0,1]] tU1 = t[UI[0,0]:UI[0,1]] gdU2 = gd[UI[1,0]:UI[1,1]] tU2 = t[UI[1,0]:UI[1,1]] mU1, rU1 = nu.linFit(gdU1, tU1) m1, b1 = (mU1[0], mU1[1]) mU2, rU2 = nu.linFit(gdU2, tU2) m2, b2 = (mU2[0], mU2[1]) tau_y = (b2-b1)/(m1-m2) uys = {'upperYS' : tau_y, 'gammadot_y' : (tau_y-b1)/m1, 'fit' : np.array([[m1,b1],[m2,b2]])}
def lowerYieldStress(rheoData, rheoInfo): import numpy as np import NumUtils as nu g, t, gd = (rheoData['gamma'], rheoData['tau'], rheoData['gammadot']) LI = rheoInfo['lowerN'] # lower yield stress gL1 = g[LI[0,0]:LI[0,1]] tL1 = t[LI[0,0]:LI[0,1]] gL2 = g[LI[1,0]:LI[1,1]] tL1 = g[LI[1,0]:LI[1,1]] aL1, bL1 = nu.powerFit(tL1, gL1) aL2, bL2 = nu.powerFit(tL2, gL2) tau_y = np.exp(np.log(aL2/aL1)/(bL1/bL2)) lys = {'lowerYS' : tau_y, 'gamma_y' : aL1 * tau_y**bL1, 'fit' : np.array([[aL1, bL1],[aL2, bL2]])} return ys
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)))