#!/bin/ksh ##---------------------------------------------------------------------------------------- ## Name: pushSMOKEAREAssh ## ## Author: Jianbin Yang 03/13/2008 ## Purpose: pushing Local SMOKE Area file to Satepsdist1 for DPD dataset there ## ## Notes: ## Here is the dsserve info for DPD, the remote dataset on satepsdist1 ## DPD: LOC/SMOKE IMAGE AREA 4296-4399 ## satepsdist1: redirect.k LIST|grep AREA09 ## AREA09* /data/ftp/pub/smoke ## ## Last Modified : 03/05/2011 ## pushAODAREAs.sh Edited by Laura Kowal to work for SMOKE data May 2008 ## modified by L. Chen 3/5/2011 with CCR1017 ## ##---------------------------------------------------------------------------------------- # Set up path PATH=$PATH:$HOME/mcidas/bin:/home/mcidas/bin: MCPATH=$HOME/mcidas/data:/home/mcidas/data export PATH MCPATH # Check that we know which area files to push if [ $# -ne 1 ] then echo "Usage: $0 " exit 1 fi startAreaRange=$1 if [[ $startAreaRange -lt 4296 || $staretAreaRange -gt 4399 ]] then echo "Out of bounds: startAreaRange should be between 4296 and 4399" exit 1 fi smokeMciDir="/home/oper/new_SMOKE/" logDir="/data/SMOKE/logs" smokeDesDir="/data/ftp/pub/smoke" remoteDir=/data/ftp/pub/smoke remoteUser=spider #remoteServer=satepsdist1.nesdis.noaa.gov remoteServer=10.144.3.38 starDes=4296 dhm=`date +%d%H%M` logFile="$logDir/push.$dhm.log" srcDS="LOC/SMOKE" desDS="DPD/SMOKE" #exec >> $logFile 2>&1 echo "$0 starting at `date`" # Loop over the 25 images # Note - Even if s timeslot did not have a product, # there should still be a blank image to send. areaBase=$(dsserve.k |grep "$srcDS "|awk '{print $4}'|cut -c1-2) smokeFile='AREA'$areaBase echo "smokeFile_1 is "$smokeFile smokeDir=$( redirect.k LIST|grep $smokeFile|head -1 |awk '{print $2}' ) #smokeDir="/data/SMOKE/SMOKE-DATASET" echo " smokeDir=" $smokeDir if [[ $smokeDir = "" ]]; then smokeDir="/data/SMOKE/SMOKE-DATASET" # smokeDir=$HOME/mcidas/data fi cd $HOME/mcidas/data pwd imgtimSrc=`imglist.k $srcDS |sed -n '5 p'|awk '{print $6$7}'|cut -c 6-10` imgtimDes=`imglist.k $desDS |sed -n '5 p'|awk '{print $6$7}'|cut -c 6-10` latestposSrc=`imglist.k $srcDS | tail -2 | head -1 | awk '{print $1}'` latestposDes=`imglist.k $desDS | tail -2 | head -1 | awk '{print $1}'` echo "latestposSrc is "$latestposSrc echo "latestposDes is "$latestposDes # to check if the dataset is empty if [ $latestposDes = "imglist.k:" ] #if [ $latestposDes != [0-9]* ] then echo "This is the first one in the dataset" latestposDes=0 fi cd $smokeDir #remo_beginNum=`imglist.k DPD/SMOKE | tail -2 | head -1 | awk '{print $1}'` #echo "remo_beginNum=" $remo_beginNum #remo_beginNum_1=$(expr $remo_beginNum + 4296 ) #echo "remo_beginNum 2='" $remo_beginNum_1 pwd for II in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 do areaNum=$(expr $startAreaRange + $II ) if [ $areaNum -gt 4399 ] then areaNum=$( expr $areaNum - 104 ) fi smokeFileName=$( echo $areaNum |awk '{printf "AREA%4.4d",$1}' ) # smokeFileName=AREA$areaNum echo "smokeFileName = " $smokeFileName smokeFile=$smokeDir/$smokeFileName echo "smokeFile 2 =" $smokeFile mcDSN="LOC/POS.$areaNum" # mcidas dataset name for area file echo "mcDSN=$mcDSN" echo "smokeFile=$smokeFile" ls -l $smokeFile nextposDes=$(expr $latestposDes + $starDes + $II ) echo " nextposDes= $nextposDes $areaNum $latestposDes $starDes " if [ $nextposDes -gt 4399 ] then nextposDes=$( expr $nextposDes - 104 ) fi if [ -s $smokeFile ] then # imgremap the raw projection to RECT projection, even if blank imgremap.k $mcDSN $mcDSN PRO=RECT SIZE=ALL RES=4 # echo "Sending $smokeFile to $smokeDesDir on $remoteServer" # nextremoDes=$( expr $remo_beginNum_1 + $II ) # if [ $nextremoDes -gt 4399 ] # then # nextremoDes=$($nextremoDes - 104) # fi # nextremoDes=AREA$nextremoDes # echo "nextremoDes= " $nextremoDes= # send the area file to the server sftp $remoteUser@$remoteServer << EOF cd $smokeDesDir put $smokeFile AREA$nextposDes quit EOF fi done echo "$0 ending at `date`" echo "$0 ending at `date`" exit 0