Created
November 23, 2012 05:52
-
-
Save cynici/4134176 to your computer and use it in GitHub Desktop.
MODIS dbvm user script to run mod14hdf4_to_fireloc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Sample Script for User Defined Processing in DBVM | |
# [email protected] | |
# Place this file in $DBVM_HOME/user/ | |
# | |
echo | |
echo "Creating User Defined Products; started at "$(date -u) | |
# Check input arguments | |
if [ $# -ne 1 ]; then | |
echo "Usage: run_user.bash file_1km " | |
echo "where" | |
echo "file_1km is the full path and name of the input MODIS Level 1B 1KM HDF file" | |
exit 1 | |
fi | |
#------------------------------------------------------------------------------ | |
# GET INFORMATION ABOUT THE SATELLITE NAME, DATE, AND TIME | |
#------------------------------------------------------------------------------ | |
# Get name of MODIS 1KM file | |
file_1km=$1 | |
# Get satellite name (terra or aqua) | |
sat_id=$(basename $file_1km | cut -c1-2) | |
if [ "$sat_id" == "t1" ]; then | |
sat_name="terra" | |
else | |
sat_name="aqua" | |
fi | |
# Get satellite/date/time (e.g., a1.06260.2057) from L1B 1KM file name (e.g., a1.06260.2057.1000m.hdf) | |
date_time=$(basename $file_1km | cut -d. -f1-3) | |
# Get pass year, day of year, time (e.g, 06 260 2057) from L1B 1KM file name (e.g., a1.06260.2057.1000m.hdf) | |
year=$(basename $file_1km | cut -c4-5) | |
jday=$(basename $file_1km | cut -c6-8) | |
time=$(basename $file_1km | cut -c10-13) | |
# Get names of MODIS HKM, QKM, and GEO files | |
file_hkm=${file_1km%.1000m.hdf}.500m.hdf | |
file_qkm=${file_1km%.1000m.hdf}.250m.hdf | |
file_geo=${file_1km%.1000m.hdf}.geo.hdf | |
#------------------------------------------------------------------------------ | |
# START OF USER DEFINED COMMANDS | |
#------------------------------------------------------------------------------ | |
# Include user directory in the PATH | |
export PATH=$DBVM_HOME/user:$PATH | |
file_mod14=/home/afis/dbvm/data/level2/$(basename ${file_1km%.1000m.hdf}.mod14.hdf) | |
file_csv=$HOME/csirdata/mod14csv/$(basename ${file_1km%.1000m.hdf}.csv) | |
#20121012 probably a race condition problem | |
for i in $(seq 15); do | |
sleep 180 | |
if [ -s $file_mod14 ]; then | |
echo "Loop $i: " $(ls -l $file_mod14) | |
break | |
fi | |
done | |
# If daytime MODIS data exists, create regional true color images | |
if [ -e $file_mod14 ]; then | |
echo | |
echo "(Creating MOD14 fireloc csv file)" | |
mod14hdf4_to_fireloc.py --loglevel=debug $file_mod14 | |
#mod14hdf4_to_fireloc.py --loglevel=debug $file_mod14 $file_csv | |
#if [ -e $file_csv ]; then | |
# ncftpput -u af_modis_ssec -p cess_sidom_fa afisfeeder.meraka.org.za . $file_csv | |
#else | |
# echo "No output from mod14hdf4_to_fireloc.py $file_mod14" >&2 | |
#fi | |
else | |
echo "Required mod14 HDF not found: $file_mod14" >&2 | |
fi | |
#------------------------------------------------------------------------------ | |
# END OF USER DEFINED COMMANDS | |
#------------------------------------------------------------------------------ | |
echo | |
echo "Finished User Defined Products at "$(date -u) | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment