#!/bin/bash # Create a VIIRS M-band quicklook image # Liam.Gumley@ssec.wisc.edu 2012/03/12 # Check arguments if [ $# -eq 0 ]; then echo "Usage: viirs_quicklook.bash band file1 file2 file3 ..." exit 1 fi # Get band number band=$1 shift # Get list of files and number of files list=$@ count=$# # Set dataset name visible='yes' dataset='/All_Data/VIIRS-M'$band'-SDR_All/Reflectance' if [ $band -ge 12 ]; then visible='no' dataset='/All_Data/VIIRS-M'$band'-SDR_All/BrightnessTemperature' fi # Build a 16-bit grayscale array of image data for file in $list; do h5dump -d $dataset -b LE -o temp_image.dat $file cat temp_image.dat >> temp_image.gray done rm -f temp_image.dat # Get image dimensions (width and height) size=$(stat -c "%s" temp_image.gray) width=3200 height=$(echo "($size/2)/$width" | bc) # Set output file name header=$(basename $1 | cut -d_ -f 1-4) etime=$(basename $file | cut -d_ -f 5) out_file=$header"_"$etime.png # Convert the 16-bit grayscale array to a PNG image if [ "$visible" == "yes" ]; then convert -size ${width}x${height} -depth 16 -equalize -geometry 20% -rotate 180 temp_image.gray $out_file else convert -size ${width}x${height} -depth 16 -negate -equalize -geometry 20% -rotate 180 temp_image.gray $out_file fi rm -f temp_image.gray echo "Created "$out_file exit 0