Optimize a transformation from a 2-dim numpy array with day of the year values (doy) into an array with date values
<p>Does anyone know how to optimize a transformation from a 2-dim numpy array with day of the year values (doy) into 
an array with date values?
The function below works but unfortunately in an very inelegant way. I would be very happy if anyone has a good idea
how to avoid the loop over the 2-dim array which should make the calculation faster for large datesets. </p>

<pre><code>import datetime
from datetime import date

#test 2-dim array with doy values
doy = np.array([[272, 272],
                [274, 274]])

#define start and end date
startdat = datetime.datetime.strptime('2012 10 01 0000', '%Y %m %d %H%M')
year_start = int(startdat.strftime('%Y'))
enddat = datetime.datetime.strptime('2013 09 30 0000', '%Y %m %d %H%M')
year_end = int(enddat.strftime('%Y'))

#initialise an tmp array
res_date = np.zeros([2,2]) 

#transform doy into date    
for x in range(2):
    for y in range(2):
        if doy[x,y] &gt;= 274 and doy[x,y] &lt;= 365:
            datum = date.fromordinal(date(year_start, 1, 1).toordinal() + doy[x,y])
            datum = datum.strftime('%Y%m%d')    
            res_date[x,y]= datum
        else:
            datum = date.fromordinal(date(year_end, 1, 1).toordinal() + doy[x,y])
            datum = datum.strftime('%Y%m%d')    
            res_date[x,y]= datum
#that's my result
#res_date = array([[ 20130930.,  20130930.],
                  #[ 20121001.,  20121001.]])  
</code></pre>