Processing/Wavelengths: create_band_info_csv.sh

File create_band_info_csv.sh, 1.0 KB (added by mggr, 11 years ago)

Script to produce a CSV file containing band information from an HDF file

Line 
1#!/bin/sh
2
3if [ "$#" != "2" ]
4 then
5  echo "Usage:"
6  echo "$0 LEVEL1_HDF_FILENAME OUTPUT_FILE.csv"
7  echo
8  echo "This will produce a CSV file of band no vs. wavelength centre vs. wavelength half-bandwidth"
9  echo "Only for use on CCD sensors (CASI, Eagle, Hawk), not ATM"
10  echo "Requires azexhdf to be in the path"
11  exit
12fi
13
14azexhdf -vn CAwavc -vf /tmp/wavc.txt -h $1 > /dev/null
15if [ "$?" == "127" ]
16 then
17  echo azexhdf command failed - is it in the PATH?
18  exit 1
19fi
20
21azexhdf -vn CAwavh -vf /tmp/wavh.txt -h $1 > /dev/null
22if [ "$?" == "127" ]
23 then
24  echo azexhdf command failed - is it in the PATH?
25  exit 1
26fi
27
28cat /tmp/wavc.txt | tr ' ' \\n | tail -n +2 > /tmp/wavc-transposed.txt
29cat /tmp/wavh.txt | tr ' ' \\n | tail -n +2 > /tmp/wavh-transposed.txt
30
31echo '"Band number","Wavelength centre frequency (nm)","Wavelength half-bandwidth (nm)"' > $2
32
33paste /tmp/wavc-transposed.txt /tmp/wavh-transposed.txt | cat -n | sed -e 's/^\s*//' | sed -e 's/\s\s*/,/g' >> $2
34
35rm -f /tmp/wavc.txt /tmp/wavh.txt /tmp/wavc-transposed.txt /tmp/wavh-transposed.txt