- Timestamp:
- 09/07/07 15:40:51 (17 years ago)
- Location:
- trunk/SRC
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Calendar/date2jul.pro
r278 r279 7 7 ; Calendar 8 8 ; 9 ; @param date {in}{required} {type=string} 10 ; date in yyyymmdd format 9 ; @param date {in}{required} {type=long or double, sacalr or array} 10 ; longword integer with yyyymmdd format or double-precision 11 ; floating-point with yyyymmdd.xx where xx is the fraction of the day 12 ; (xx=0 at 0am and 5 at 12am) 11 13 ; 12 14 ; @keyword GRADS … … 14 16 ; if 50 <= year <= 99 --> year = 1900 + year 15 17 ; 18 ; @keyword MONTH 19 ; Set this keyword equal to a named variable that will receive a 20 ; longword integer or longword integer array representing the number of 21 ; the desired month (1 = January, ..., 12 = December). 22 ; 23 ; @keyword DAY 24 ; Set this keyword equal to a named variable that will receive a 25 ; longword integer or longword integer array representing the number of 26 ; the day of the month (1-31). 27 ; 28 ; @keyword YEAR 29 ; Set this keyword equal to a named variable that will receive a 30 ; longword integer or longword integer array representing the number of 31 ; the desired year (e.g., 1994). 32 ; 33 ; @keyword HOUR 34 ; Set this keyword equal to a named variable that will receive a 35 ; longword integer or longword integer array representing the number of 36 ; the hour of the day (0-23). 37 ; 38 ; @keyword MINUTE 39 ; Set this keyword equal to a named variable that will receive a 40 ; longword integer or longword integer array representing the number of 41 ; the minute of the hour (0-59). 42 ; 43 ; @keyword SECOND 44 ; Set this keyword equal to a named variable that will receive a 45 ; double-precision floating-point value or a double-precision 46 ; floating-point array representing the number of the second of the 47 ; minute (0-59). 48 ; 16 49 ; @returns 17 ; date in Julian day50 ; Julian day with the same format (long or double) as the input parameter 18 51 ; 52 ; @restrictions 53 ; Input param must be longword integer or double-precision floating-point 54 ; 19 55 ; @examples 20 56 ; … … 23 59 ; 1 24 60 ; IDL> print, date2jul(931205,/grads) EQ julday(12,5,1993) 61 ; 1 62 ; IDL> print, date2jul(19931205.5d) EQ julday(12,5,1993,12,0,0) 63 ; 1 64 ; IDL> print, date2jul(19931205.0d) EQ julday(12,5,1993,0,0,0) 25 65 ; 1 26 66 ; … … 33 73 ;- 34 74 ; 35 function date2jul, date, GRADS = grads 75 function date2jul, date, GRADS = grads, MONTH = month, DAY = day, YEAR = year $ 76 , HOUR = hour, MINUTE = minute, SECOND = second 36 77 ; 37 78 compile_opt idl2, strictarrsubs 38 79 ; 39 year = long(date) / 10000 40 month = long(abs(date)/100) MOD 100 41 day = long(abs(date)) MOD 100 80 sztype = size(date, /type) 81 IF sztype NE 3 AND sztype NE 5 AND sztype LT 13 THEN BEGIN 82 dummy = report('Beware of input type, date must be long or double') 83 stop 84 ENDIF 85 ; 86 year = long(date) / 10000 87 month = long(abs(date)/100) MOD 100 88 day = long(abs(date)) MOD 100 42 89 ;------------------------------------------------------------ 43 if keyword_set(grads) then year = year$44 + 1900* (year GE 50 AND year LE 99) $45 + 2000* (year GE 1 AND year LE 49)90 if keyword_set(grads) then $ 91 year = year + 1900L * (year GE 50 AND year LE 99) $ 92 + 2000L * (year GE 1 AND year LE 49) 46 93 ;------------------------------------------------------------ 47 IF s ize(date, /type) LE 3THEN return, julday(month, day, year)94 IF sztype NE 5 THEN return, julday(month, day, year) 48 95 49 96 fraction = date - long(date) 50 97 hour = floor(fraction * 24d) 51 fraction = TEMPORARY(fraction) - hour/24d98 fraction = temporary(fraction) - hour/24d 52 99 minute = floor(fraction*1440d) 53 second = ( TEMPORARY(fraction) - minute/1440d) * 86400d100 second = (temporary(fraction) - minute/1440d) * 86400d 54 101 55 102 return, julday(month, day, year, hour, minute, second) -
trunk/SRC/Calendar/jul2date.pro
r231 r279 7 7 ; Calendar 8 8 ; 9 ; @param jday {in}{required} {type= double}9 ; @param jday {in}{required} {type=long or double, sacalr or array} 10 10 ; Julian day 11 11 ; 12 ; @keyword MONTH 13 ; Set this keyword equal to a named variable that will receive a 14 ; longword integer or longword integer array representing the number of 15 ; the desired month (1 = January, ..., 12 = December). 16 ; 17 ; @keyword DAY 18 ; Set this keyword equal to a named variable that will receive a 19 ; longword integer or longword integer array representing the number of 20 ; the day of the month (1-31). 21 ; 22 ; @keyword YEAR 23 ; Set this keyword equal to a named variable that will receive a 24 ; longword integer or longword integer array representing the number of 25 ; the desired year (e.g., 1994). 26 ; 27 ; @keyword HOUR 28 ; Set this keyword equal to a named variable that will receive a 29 ; longword integer or longword integer array representing the number of 30 ; the hour of the day (0-23). 31 ; 32 ; @keyword MINUTE 33 ; Set this keyword equal to a named variable that will receive a 34 ; longword integer or longword integer array representing the number of 35 ; the minute of the hour (0-59). 36 ; 37 ; @keyword SECOND 38 ; Set this keyword equal to a named variable that will receive a 39 ; double-precision floating-point value or a double-precision 40 ; floating-point array representing the number of the second of the 41 ; minute (0-59). 42 ; 12 43 ; @returns 13 ; date in yyyymmdd format 44 ; the date: longword integer with yyyymmdd format or double-precision 45 ; floating-point with yyyymmdd.xx where xx is the fraction of the day 46 ; (xx=0 at 0am and 5 at 12am) 14 47 ; 48 ; @restrictions 49 ; Input param must be longword integer or double-precision floating-point 50 ; 15 51 ; @examples 16 52 ; 17 53 ; IDL> print, jul2date(julday(12,23,1999)) 18 ; 19991223 54 ; 19991223 55 ; IDL> print, jul2date(julday(12,23,1999,12,0,0)) 56 ; 19991224. 57 ; IDL> print, jul2date(julday(12,23,1999,12,0,0)), format='(f11.2)' 58 ; 19991223.50 59 ; IDL> print, jul2date(julday(12,23,1999,0,0,0)), format='(f11.2)' 60 ; 19991223.00 19 61 ; 20 62 ; @history … … 27 69 ;- 28 70 ; 29 function jul2date, jday 71 function jul2date, jday, MONTH = month, DAY = day, YEAR = year $ 72 , HOUR = hour, MINUTE = minute, SECOND = second 30 73 ; 31 74 compile_opt idl2, strictarrsubs 32 75 ; 33 caldat, jday, month, day, year, hour, min, sec 76 sztype = size(jday, /type) 77 IF sztype NE 3 AND sztype NE 5 AND sztype LT 13 THEN BEGIN 78 dummy = report('Beware of input type, julian date must be long or double') 79 stop 80 ENDIF 81 ; 82 caldat, jday, month, day, year, hour, minute, second 34 83 ; 35 84 res = (10000L*year + 100L*month + day)*(year GE 0) $ 36 85 +( 10000L*year - 100L*month - day)*(year LT 0) 37 86 ; 38 IF total([hour NE 12, min NE 0, abs(sec) GE 1.e-4]) EQ 0THEN return, long(res) $39 ELSE return, double(res) + (hour / 24.0d0) + (min /1440.0d0) + (sec/ 86400.0d0)87 IF sztype NE 5 THEN return, long(res) $ 88 ELSE return, double(res) + (hour / 24.0d0) + (minute/1440.0d0) + (second / 86400.0d0) 40 89 41 90 end -
trunk/SRC/Calendar/julday.pro
r268 r279 97 97 zero = where(year EQ 0, cnt) 98 98 IF cnt NE 0 THEN YEAR[zero] = 654321L 99 100 NP = n_params() 101 ; Process the input, if all are missing, use todays date. 102 IF (np EQ 0) THEN RETURN, SYSTIME(/JULIAN) 103 IF (np LT 3) THEN ras = report('Incorrect number of arguments.') 99 104 ; 100 105 CASE key_caltype OF … … 105 110 GREG = 2299171L ; incorrect Julian day for Oct. 25, 1582 106 111 107 ; Process the input, if all are missing, use todays date.108 NP = n_params()109 IF (np EQ 0) THEN RETURN, SYSTIME(/JULIAN)110 IF (np LT 3) THEN ras= report('Incorrect number of arguments.')111 112 112 113 ; Find the dimensions of the Result: … … 248 249 if n_elements(Second) eq 0 then Second = 0 249 250 250 IF total([hour NE 12, minute NE 0, second NE 0]) EQ 0THEN return, JUL ELSE $251 IF (np LE 3) THEN return, JUL ELSE $ 251 252 return, JUL + (Hour / 24.0d0 - 0.5d) + (Minute/1440.0d0) + (Second / 86400.0d0) 252 253 … … 281 282 if n_elements(Second) eq 0 then Second = 0 282 283 283 IF total([hour NE 12, minute NE 0, second NE 0]) EQ 0THEN return, JUL ELSE $284 IF (np LE 3) THEN return, JUL ELSE $ 284 285 return, JUL + (Hour / 24.0d0 - 0.5d) + (Minute/1440.0d0) + (Second / 86400.0d0) 285 286 -
trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildreadcmd.pro
r262 r279 111 111 date2 = date2jul(date2) - fakecal 112 112 ENDIF 113 sdate1 = strtrim(date1, 1) & sdate2 = strtrim(date2, 1) 113 IF size(date1, /type) EQ 5 THEN sdate1 = string(date1, format='(f15.6)')+'d' $ 114 ELSE sdate1 = string(date1, format='(i10)')+'L' 115 IF size(date2, /type) EQ 5 THEN sdate2 = string(date2, format='(f15.6)')+'d' $ 116 ELSE sdate2 = string(date2, format='(i10)')+'L' 114 117 ;--------------- 115 118 ; find boxzoom -
trunk/SRC/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_calendar.pro
r271 r279 68 68 ; 69 69 @cm_4cal 70 71 70 ; get back the calendar and its related informations 72 71 winfo_id = widget_info(id, find_by_uname = 'infocal') 73 72 widget_control, winfo_id, get_uvalue = infowid 74 73 key_caltype = infowid.caltype 75 76 74 ; high freqeuncy calendar 77 75 IF keyword_set(infowid.fakecal) THEN BEGIN … … 84 82 ENDIF 85 83 ENDIF ELSE BEGIN 86 ; 87 value = long(value[0]) 88 ; make sure the value correspond 89 value = jul2date(date2jul(value)) 90 ; define year month day 91 year = value/10000l 92 month = (value MOD 10000L)/100L 93 day = value MOD 100L 84 jdval = date2jul(value) 94 85 ; check that the date exists in the calendar 95 if (where(abs(infowid.calendar - julday(month, day, year)) LT 1./86400.))[0] EQ - 1 then return86 if (where(abs(infowid.calendar - jdval) LT 1.d/86400.d))[0] EQ - 1 then return 96 87 ; update the value of infocal 97 88 infowid.date = value … … 181 172 if wid_id NE 0 then BEGIN 182 173 widget_control, wid_id, get_value = wid_value 183 date = long(wid_value.combobox_gettext) 174 widget_control, wid_id, get_uvalue = wid_uvalue 175 date = double(wid_value.combobox_gettext) + wid_uvalue.hms[wid_value.combobox_index] 184 176 ENDIF ELSE date = oldate MOD 100L 185 177 ;-------------month--------------- … … 224 216 ; @uses 225 217 ; 226 ; @restrictions 218 ; @restrictions< 227 219 ; 228 220 ; @examples … … 242 234 winfo_id = widget_info(event.handler, find_by_uname = 'infocal') 243 235 widget_control, winfo_id, get_uvalue = infowid 244 caldat, infowid.calendar, monthcal, daycal, yearcal 236 caldat, infowid.calendar, monthcal, daycal, yearcal, hourcal, mincal, seccal 245 237 ; ... and the current date 246 238 IF n_elements(date0) EQ 0 then date0 = get_cal_value(event.handler) 247 year0 = date0/10000L 248 month0 = (date0 MOD 10000L)/100L 249 day0 = date0 MOD 100L 239 jdate0 = date2jul(date0, month = month0, day = day0, year = year0) 250 240 ; index of days/months/years according to date0 251 241 case casename of … … 254 244 index = where(monthcal EQ month0 AND yearcal EQ year0) 255 245 current = daycal[index] 246 hms = hourcal[index] / 24.0d0 + mincal[index]/1440.0d0 + seccal[index] / 86400.0d0 256 247 END 257 248 'month':BEGIN … … 271 262 ENDCASE 272 263 ; we update the uvalue of the widget 273 widget_control, wid_id, set_uvalue = {name:casename}264 IF casename EQ 'day' THEN widget_control, wid_id, set_uvalue = {name:casename, hms:hms} 274 265 ; for event.out = 0, we store the previous position of the combobox to use 275 266 ; it as the default position. … … 334 325 ; $Id$ 335 326 ;- 336 PRO move, event, casename327 PRO cw_cal_move, event, casename 337 328 ; 338 329 compile_opt strictarr, strictarrsubs … … 354 345 widget_control, id, set_value = {combobox_select:selected} 355 346 ; we call move for the next combobox 356 ENDIF ELSE move, event, possiblecase[whichcase+1]347 ENDIF ELSE cw_cal_move, event, possiblecase[whichcase+1] 357 348 ; it is possible to move from +/- 1 358 349 ENDIF ELSE widget_control, id, set_value = {combobox_select:wvalue.combobox_index+event.out} … … 410 401 selected = (widvalue.combobox_number-1)*(event.out EQ -1) 411 402 widget_control, event.id, set_value = {combobox_select:selected} 412 ENDIF ELSE move, event, possiblecase[whichcase+1]403 ENDIF ELSE cw_cal_move, event, possiblecase[whichcase+1] 413 404 ENDIF 414 405 ; if we changed month(year), we need to update the day (and month) list … … 484 475 if keyword_set(caltype) then key_caltype = caltype 485 476 ; months days years found in the calendar 486 caldat, calendar, monthcal, daycal, yearcal, hourcal, mincal, scdcal 477 caldat, calendar, monthcal, daycal, yearcal, hourcal, mincal, seccal 478 hmscal = hourcal / 24.0d0 + mincal/1440.0d0 + seccal / 86400.0d0 487 479 ; starting date 488 480 if n_elements(jdate0) EQ 0 then jdate0 = calendar[0] … … 523 515 currentday = daycal[dayindex] 524 516 currentday = strtrim(currentday, 1) 525 cmbbid = cw_combobox_pm(base, UVALUE = {name:'day'}, UNAME = 'day', value = currentday) 517 hms = hmscal[dayindex] 518 cmbbid = cw_combobox_pm(base, UVALUE = {name:'day', hms:hms}, UNAME = 'day', value = currentday) 526 519 widget_control, cmbbid, set_value = {combobox_select:(where(long(currentday) EQ day0))[0]} 527 520 endif
Note: See TracChangeset
for help on using the changeset viewer.