So I have multiple loops like this:
HPBL = grbs[15].values
lat = input('Enter lat:')
lon = input('Enter lon:')
print 'PBL Height:',HPBL[int(lat),int(lon)],'m'
HGT_1000 = grbs[256].values
if HGT_1000[int(lat),int(lon)]<HPBL[int(lat),int(lon)]:
UGRD_1000 = grbs[260].values
VGRD_1000 = grbs[261].values
UGRD_1000_val = UGRD_1000[int(lat),int(lat)]
VGRD_1000_val = VGRD_1000[int(lat),int(lat)]
wind_1000 = math.sqrt(UGRD_1000_val**2+VGRD_1000_val**2)
print '1000mb wind is:',wind_1000,'m/s'
else:
print '1000mb winds not below PBL'
Where the end goal is to print an average of wind_1000, wind_975, wind_950, and etc but only if each wind_xxxx variable has a value. Per the loop, I have it skip if the 'if' requirement is not met. So what I am having trouble thinking of is how I would go about computing the average
wind_ave=np.mean(wind_1000,wind_975,wind_950,...wind_xxx)
but of course my problem is that the wind variables won't always have a value per the if loops. How can I compute the wind_ave only if the wind_xxx variables have values to them?
Aucun commentaire:
Enregistrer un commentaire