function yyyydoy_2_dfs, yyyydoy,lat ;------------------------------------------------------------------------------------------------ ; Routine computes days from summer solstice. ; ; Input: ; yyyydoy.....date as year & day of year (e.g., 2007212), scalar or vector ; lat.........1 = northern hemisphere, -1 = south, scalar ; ; Output: ; dfs.........days from summer solstice ; ; Required subroutines: solstice.pro (http://gwest.gats-inc.com/software/software_page.html) ; ; Source: Mark Hervig ;------------------------------------------------------------------------------------------------ nd = n_elements(yyyydoy) dfs = intarr(nd) ;- parse out YYYY & DOY yy = long(yyyydoy / 1000L) doy = long(yyyydoy - yy * 1000L) dfs = fltarr(nd) for i = 0,nd-1 do begin sols = solstice(yy(i),lat) dfs(i) = doy(i) - sols ;- Southern Hemisphere, could be exceptions if (lat lt 0) then begin leapyr = yy(i) - fix(yy(i)/4) * 4 ; leapyr = 0 if it is a leap year doy_mx = 365. if (leapyr eq 0) then doy_mx = 366. if (doy(i) lt 180) then dfs(i) = doy_mx - sols + doy(i) ; for Jan 1 on endif endfor ;- trim if nd eq 1 then dfs = dfs(0) ;- done return, dfs end