By mike
Date 2007-02-23 18:59
Edited 2008-08-21 19:38
How do I annotate and save an image with day, month, and year text?
Two SeaDAS utility binaries that convert date strings can be helpful for this type of exercise:
% $SEADAS/bin/jd2date
USAGE: jd2date jd yyyy
% $SEADAS/bin/date2jd
USAGE: date2jd mmdd yyyy
These binaries can be called within IDL using the SPAWN command or via a UNIX shell script.
The following is an example script to save an image with the day, month, and year of the pass annotated on the image:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; example IDL "cmd_file.txt" that annotates multiple files matching
;; a filename pattern. This command file can be run using runtime
;; or non-runtime SeaDAS, e.g.: seadas -em -b cmd_file.txt
pattern = '*.L2'
filenames = findfile(pattern)
months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
for i=0,n_elements(filenames)-1 do begin & $
BASE = strmid(filenames(i),0,14) & $
YYYY = strmid(filenames(i),1,4) & $
DDD = strmid(filenames(i),5,3) & $
cmd = '$SEADAS/bin/jd2date' + ' ' + DDD + ' ' + YYYY & $
spawn, cmd, datestring & $
DAY = strmid(datestring,2,2) & $
MONTH = strmid(datestring,0,2) & $
MMM = months(fix(MONTH)-1) & $
title = DAY + ' ' + MMM + ' ' + YYYY & $
ofile = BASE + '.png' & $
load, filenames(i), prod_name='chlor_a' & $
loadpal, '$SEADAS/config/color_luts/standard/02-standard_chl.lut' & $
display & $
xyouts,5,5,title,color=255,alignment=0,charsize=2,charthick=2,/device & $
tvlct, r, g, b, /get & $
img_new = TVRD(true=1) & $
write_png, ofile, img_new, r, g, b & $
clear_up & $
endfor