Commit 1e40fd99 authored by Nick Bearson's avatar Nick Bearson
Browse files

adding some basic top of atmosphere radiance computation

parent 94c65aba
#!/usr/bin/env bash
# TODO: do we want to keep files even if processed?
# if so, put them in quarantine right away and make a hard link @ processing dir for recognized files
set -u
set -e
......@@ -17,6 +19,9 @@ filename=$(basename $filepath)
if [ ${filename:0:2} == "LC" ] && [ ${filename: -4} == ".zip" ]; then # landsat zip files
echo "SAW LANDSAT ZIP: ${filename}"
SCRIPT="bash /home/eodn/eodn2realearth/src/process-LCzip.sh"
if [ ${filename:0:2} == "LC" ] && [ ${filename: -7} == ".tar.gz" ]; then # landsat zip files
echo "SAW LANDSAT TAR.GZ: ${filename}"
SCRIPT="bash /home/eodn/eodn2realearth/src/process-LCtgz.sh"
else # not recognized
echo "QUARANTINE (NOT RECOGNIZED): ${filename}"
mkdir -p ${QUARANTINE}
......
#!/usr/bin/env bash
# https://www.mapbox.com/blog/processing-landsat-8/
# http://landsat.usgs.gov/Landsat8_Using_Product.php
#
# landsat-8 tifs are "digital numbers" (counts),
# maybe it will help if we create top-of-atmosphere reflectance (or radiance)?
# the MTL file has scaling factors:
# LC80230282015349LGN00_MTL.txt
set -u
set -e
BANDS=(1 2 3 4 5 6 7 8 9 10 11)
DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
. "$DIR/consts.sh"
LOG=${LOGS}/process-LCtgz.log
exec >> $LOG 2>&1
WMSUPLOAD=${DIR}/wmsupload
SCENE=$1
echo "PROCESSING: $1"
BASE=${SCENE##*/} # filename w/ extension
STRIP=${BASE%%.tar.gz} # filename w/o extension
YEAR=${STRIP:9:4}
DOY=${STRIP:13:3}
YMD=`date -d "Jan 1 $YEAR + $DOY days - 1 day" "+%Y%m%d"`
PART=${STRIP:2:7}
BASE=${STRIP##*/} # filename w/ extension
STRIP=${BASE%%.tar.gz} # filename w/o extension
for band in ${BANDS[@]}; do # FIXME: for when we do multiple bands...
MTL="${STRIP}_MTL.txt"
BN="${STRIP}_B${band}.TIF"
tar xzf $SCENE $BN $MTL
vmul=$(grep "RADIANCE_MULT_BAND_${band} =" $MTL | cut -d " " -f 7)
vadd=$(grep "RADIANCE_ADD_BAND_${band} =" $MTL | cut -d " " -f 7)
# calculate TOA radiance (Watts/( m2 * srad * μm))
# https://landsat.usgs.gov/Landsat8_Using_Product.php
product="nickb-lsat-TOArad-b${band}_${YMD}_120000.part${PART}.tif"
gdal_calc.py -A $BN --outfile=${product} --calc="(A*${vmul})+${vadd}"
$WMSUPLOAD ${product}
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment