bhavya_7 0 Newbie Poster

I have daily scatsat level4 data for wind for year 2017 in a single folder I need to calculate the windspeed of the data and average of windspeed for 8 days for the whole year and need to plot it in a image using quiver plot
*I am able to do it for 2 days but have no idea using ' for loop' as I am very new to python
this is the code i have written for 2 days averaging:

from mpl_toolkits.basemap import Basemap
from netCDF4 import Dataset, date2index
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
from IPython.display import Image
from IPython.core.display import HTML 
import netCDF4 as nc
import numpy.ma as ma
nc_file = '/scratch/Trainee_DATA/BHAVYA/data/L4AWV/2017/jan/S1L4AW_2017003.nc'
nc_file2 = '/scratch/Trainee_DATA/BHAVYA/data/L4AWV/2017/jan/S1L4AW_2017004.nc'
v = Dataset(nc_file, mode='r')
u = Dataset(nc_file2, mode='r')
print u.variables
print v.variables
alat= u.variables['lat'][:]
alon= v.variables['lon'][:]
uvel= np.squeeze(u.variables['U'][:])
vvel= np.squeeze(v.variables['V'][:])
blat= v.variables['lat'][:]
blon= v.variables['lon'][:]
uvelo= np.squeeze(u.variables['U'][:])
vvelo= np.squeeze(v.variables['V'][:])
uvel=ma.masked_where(uvel<-999990.0, uvel)
vvel=ma.masked_where(vvel<-999990.0, vvel)
uvelo=ma.masked_where(uvelo<-999990.0, uvelo)
vvelo=ma.masked_where(vvelo<-999990.0, vvelo)
uwspd=np.sqrt(uvelo*uvelo + vvelo*vvelo)
vwspd=np.sqrt(uvel*uvel + vvel*vvel)
uvwspd=((uwspd+vwspd)/2)
uvwspd=ma.masked_where(uvwspd<-999990.000000,uvwspd)
ll,lt=np.meshgrid(alon,alat)
ll,lt=np.meshgrid(blon,blat)
inc=2
f1= plt.figure(1)
f1= plt.figure(figsize=(10,10))
m = Basemap(projection='merc',llcrnrlon=77.0,llcrnrlat=5.9,urcrnrlon=95.0,urcrnrlat=24.0,resolution='l')
xv,yv=m(ll,lt)
parallels = np.arange(05,30,5.)
meridians = np.arange(50,95,5.)
m.drawparallels(parallels,labels=[1,0,0,0], color = 'black',dashes=[4, 2], linewidth = 0.40)
m.drawmeridians(meridians,labels=[0,0,0,1], color = 'black', dashes=[4, 2], linewidth = 0.40)
m.drawcoastlines(linewidth=1.0)
m.drawmapboundary(fill_color='white')
m.fillcontinents(color='white',lake_color='white')
im1=m.pcolormesh(ll,lt,uvwspd,latlon=True,shading='smooth',cmap='jet',vmin=0,vmax=20)
q=m.quiver(xv[::inc,::inc],yv[::inc,::inc],uvel[::inc,::inc],vvel[::inc,::inc],scale=500)
cb=f1.colorbar(im1)
plt.show()

**can anyone pls help me with the code using for loop to calculate the avg for 8 days.