NOAA Center for Satellite Applications and Research banner
 
National Oceanic & Atmospheric Administration website NOAA Center for Satellite Applications and Research website

STAR - Global Vegetation Health Products : Procedure for automatically downloading VH data

If Vegetation Health data file are available online, we can set up to download recent weeks' data by the following procedure.

Step1. add a line to the file ".netrc" in user's home directory

This will avoid user to manually provide ID and password when calling "ftp" command.
default login anonymous password xxx.yyy@noaa.gov
(please replace xxx.yyy@noaa.gov by user's email address)

Step 2: We need a parameter file in ASCII format for "ftp" command

filename= ftp_VHP4km.txt (for example)
file content:

open ftp.star.nesdis.noaa.gov
cd /pub/corp/scsb/wguo/data/Blended_VH_4km/VH/
bin
prompt off
mget *2013051.VH.nc

Step 3: write a script to automatically create above parameter file base on compute time

file name : createFTPparam.sh
content:
YEAR=`date +%Y`
YOFYEAR=`date +%j`
WEEK=$[(10#$(date +"%j") -1)/ 7]

Week2=$WEEK
if [ $WEEK -lt 10 ]; then
Week2="0$WEEK"
fi

echo "open ftp.star.nesdis.noaa.gov"
echo "cd /pub/corp/scsb/wguo/data/Blended_VH_4km/VH/"
echo "bin"
echo "prompt off"

echo "mget *${YEAR}0${Week2}.VH.nc"
exit

Step 4: write a script (example: "download_VH.sh") to create parameter file abd run "ftp" command

file name=download_VH.sh
content:
createFTPparam.sh > ftp_VHP4km.txt
ftp < ftp_VHP4km.txt

Step 5: schedule to run "download_VH.sh" command on every Tuesday 18:50 by "crontab"

$ crontab -e
50 18 * * 2 download_VH.sh