Ocean Color Forum - Not logged in
Forum Ocean Color Home Help Search Login
Previous Next Up Topic Frequently Asked Questions / SeaDAS 6 FAQ / How do I annotate and save an image with day, month, and year text? (locked) (11269 hits)
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
By mike Date 2007-02-23 19:00 Edited 2007-02-23 19:06
The following is a UNIX shell script that converts a <YYYY><DDD> date string to a <DAY><MONTH><YEAR> date string, e.g. "1999365" to "31121999":

#!/bin/sh
# modify "S*L2" to match filename pattern of SeaWiFS files
# Example filename: S1999365235959.L2
for NAME in S*L2
do
  YYYY=`echo $NAME |cut -c2-5`
  DDD=`echo $NAME |cut -c6-8`

  datestring=`$SEADAS/bin/jd2date $DDD $YYYY`
  month=`echo $datestring |cut -c1-2`
  day=`echo $datestring |cut -c3-4`
  pngfile=${day}${month}${YYYY}.png
  echo $pngfile
done
Previous Next Up Topic Frequently Asked Questions / SeaDAS 6 FAQ / How do I annotate and save an image with day, month, and year text? (locked) (11269 hits)



Responsible NASA Official: Gene C. Feldman
Curator: OceanColor Webmaster
Authorized by: Gene C. Feldman
Updated: 27 November 2007
Privacy Policy and Important Notices NASA logo