I have a list of files that I'm lopping through that contain two dates in the filename. How do I extract each date and store it into a variable? And how do I convert it to day of year?
The code I have isn't working because I can't extract the month/day due to some months leading with zero. The code I have is:
sstDataFile=AQUA_MODIS.20100101_20100131.L3m.MO.SST.sst.4km.nc
year1=int(sstDataFile[11:15])
day1=int(sstDataFile[15:19])
year2=int(sstDataFile[20:24])
day2=int(sstDataFile[24:27])
print(year1)
print(year2)
print (day1)
print(day2)
if year1%4==0:
decYr1 = year1 + day1/366.0
else:
decYr1 = year1 + day1/365.0
if year2%4==0:
decYr2 = year2 + day2/366.0
else:
decYr2 = year2 + day2/365.0
decYr=0.5*(decYr1+decYr2) #decimal year between the composite start and end points