; =========================================================================== ; $Id: julday_to_dyr365.pro,v 1.1.1.1 2003/03/28 23:23:31 jlin Exp $ ; ; File Description: This file contains only the procedure julday_to_dyr365. ; =========================================================================== ; --------------------------------------------------------------------------- ; function julday_to_dyr365 ; ; Purpose: ; Given the Julian day, returns the day in the year (e.g. Jan 1st is ; day 1, Jan 2nd is day 2, etc.), assuming a 365 day year. Leap days ; are set to day -999. ; ; Syntax: Result=JULDAY_TO_DYR365(julianday) ; ; Parameters Passed: ; In: julianday ; Julian day (scalar or vector, dimension NTout). Should ; be short or long integer. ; Out: Result ; Day in the year, assuming a 365 day year. Same structure ; as julianday. ; ; Keywords (optional unless otherwise noted): None. ; ; File I/O: None ; ; Revision History: ; - 19 Aug 2000: Orig. by Johnny Lin, UCLA Dept. of Atmos. Sci. Passed ; reasonable tests. Email: air_jlin@yahoo.com. ; - 21 Aug 2000: Correct a conflict with input variable name. ; ; Notes: ; - Written in IDL 5.0. ; - Copyright (c) 2000 Johnny Lin. For licensing and contact information ; see http://www.johnny-lin.com/lib.html. ; - No user-written procedures called. ; - No common blocks used. ; --------------------------------------------------------------------------- FUNCTION JULDAY_TO_DYR365, julianday ; -> Error checking and initializing ; ON_ERROR, 0 julday_sub = julianday ;protect input variable NTout = N_ELEMENTS(julday_sub) ;number of elements ; -> Fill month and day array for non-leap year mmdd_not_leap = LONARR(365) jul_d1ofyr = JULDAY(1, 1, 1967) ;day 1 of 1967, not a leap year jul_not_leap = LINDGEN(365) + jul_d1ofyr for it=0,365-1 do begin CALDAT, jul_not_leap[it], month, day mmdd_not_leap[it] = (month * 100) + day endfor ; -> Calculate day of year address_ltm = LONARR(NTout) for it=0L,NTout-1L do begin CALDAT, julday_sub[it], month, day mmdd = (month * 100) + day loc = WHERE(mmdd_not_leap eq mmdd, md_count) if (md_count eq 1) then $ address_ltm[it] = loc + 1 $ else $ address_ltm[it] = -999 endfor ; -> Clean-up for return and end if (NTout eq 1) then $ ;if julianday is a scalar address_ltm = address_ltm[0] Result = address_ltm RETURN, Result END ;=== end of function === ; ========== end file ==========