MODIS: Convert Julian Date to MM/DD/YYYY Date format using python

Published: 20 mars 2015

DMCA.com Protection Status

Code

import calendar

def JulianDate_to_MMDDYYY(y,jd):
    month = 1
    day = 0
    while jd - calendar.monthrange(y,month)[1] > 0 and month <= 12:
        jd = jd - calendar.monthrange(y,month)[1]
        month = month + 1
    print month,jd,y

JulianDate_to_MMDDYYY(2008,167)

Result:

6 15 2008

Check Code:

from datetime import date

d0 = date(2008, 1, 1)
d1 = date(2008, 6, 15)
delta = d1 - d0
print delta.days+1

Result:

167

see Julian Day Calendar

Recherches associées