endpath = plume.wrfdir + 'interp/end/wrfend_' + Case + '.npy' if not os.path.isfile(endpath): continue print('Opening data: %s' % endpath) enddict = np.load(endpath, allow_pickle=True).item() #create an interpolated profile of temperature if Case[-1:] == 'T' or Case[-1:] == 'E': levels = plume.lvltall else: levels = plume.lvl T0 = np.load(plume.wrfdir + 'interp/profT0' + Case + '.npy') zi[nCase] = plume.get_zi(T0) dimX = np.shape(enddict['PM25'])[2] #RANDOM SAMPLING--------------------------------- maxPM = np.max(enddict['PM25'], (0, 1, 2)) plume_mask = np.where(enddict['PM25'][:, :, :int(dimX / 3)] > maxPM * 0.01) for nTrial in range(points): randI = randint(0, len(plume_mask[0]) - 1) nZ, nY, nX = plume_mask[0][randI], plume_mask[1][randI], plume_mask[2][ randI] Sd[nCase, nTrial] = Cp * (enddict['T'][nZ, nX, nY] + 300) pm[nCase, nTrial] = enddict['PM25'][nZ, nX, nY] height[nCase, nTrial] = levels[nZ] / zi[nCase] plt.figure()
levels = plume.lvltall if Case[-1:] == 'E': pmlvl = np.arange( 0, 4001, 40) #extra tall domain for the concentrations only else: pmlvl = levels else: levels = plume.lvl pmlvl = levels interpT = interp1d(levels, T0, fill_value='extrapolate') T0interp = interpT(interpZ) #mask plume with cutoff value--------------------------------- dimT, dimZ, dimX = np.shape(csdict['temp']) #get shape of data zi[nCase] = plume.get_zi(T0) #calculate BL height pm = ma.masked_where(csdict['pm25'][-1, :, :] <= plume.PMcutoff, csdict['pm25'][-1, :, :]) #mask all non-plume cells #locate centerline ctrZidx = pm.argmax(0) #locate maxima along height ctrXidx = pm.argmax(1) #locate maxima downwind pmCtr = np.array([pm[ctrZidx[nX], nX] for nX in range(dimX) ]) #get concentration along the centerline xmax, ymax = np.nanargmax(ctrZidx), np.nanmax( ctrZidx) #get location of maximum centerline height centerline = ma.masked_where( pmlvl[ctrZidx] == 0, pmlvl[ctrZidx] ) #make sure centerline is only calculated inside the plume centerline.mask[:int(1000 / plume.dx)] = True