;*************************************************** ; This program takes in the julian date (day of year) and year. It ; calculates the month,day ;*************************************************** pro julian_date_to_standard_date,year,month,day,juldate ;******************************************** ; Sample Inputs ;******************************************** ;juldate=[195,196,197] ;year=[2006,2007,2008] ;******************************************** ; Create some arrays to hold the month and day ;******************************************** month=make_array(/int,n_elements(juldate)) day=make_array(/int,n_elements(juldate)) ;******************************************** ; Loop through all the julian days in the array ;******************************************** for j=0,n_elements(juldate)-1 do begin ;****************************** ; Check if the year is a leap year ;****************************** leap_flag=0 ;not a leap year check4=(year[j]) mod 4 ;years divisible by 4 are leap years, unless........... check100=(year[j]) mod 100 ;years also divisible by 100 are not leap years, except....... check400=(year[j])mod 400 ;years divisible by 400 are leap years. if ( (check4 eq 0 and check100 ne 0) or (check400 eq 0) ) then leap_flag=1 ;leap year ;****************************** ; Make an array of the number of days ;****************************** if leap_flag eq 0 then begin ; J F M A M J J A S O N D num_days=[31,28,31,30,31,30,31,31,30,31,30,31] endif else if leap_flag eq 1 then begin num_days=[31,29,31,30,31,30,31,31,30,31,30,31] endif ;****************************** ; Loop through and subtract off the days for each whole month ;****************************** i=0 while juldate[j] gt num_days[i] do begin ;print,juldate[j],num_days[i] juldate[j]=juldate[j]-num_days[i] i=i+1 endwhile ; Month and day values month[j]=fix(i+1) day[j]=fix(juldate[j]) endfor return end