#! /bin/csh set name = $argv[1] set device = $argv[2] set ext0 = "L0_LAC" set ext1 = "L1B_QKM" set ext4 = "L1B_HKM" set ext2 = "GEO" set ext3 = "asc1" set dir = "/data/modis/raw" # if (-e $name.$ext1) then echo $ext1 "File exists in current directory, no download necessary" else if (-e $device$dir/L1B/$name.$ext1) then echo $ext1 "File exists, no download necessary" else if (-e $device$dir/$name.$ext0) then echo $ext0 "File exists, no downloading necessary" else if (-e $name.$ext0) then echo $ext0 "File exists, but in wrong directory, moving file .." cp $name.$ext0 $device$dir/L0/$name.$ext0 . else echo "Downloading data now" wget -r -nd -l1 --no-check-certificate http://oceancolor.gsfc.nasa.gov/cgi/getfile/$name.$ext0.bz2 bunzip2 $name.$ext0.bz2 endif # set in1 = $name.$ext1 set in2 = $name.$ext2 if (-e $name.dat) then echo ".dat file exists, no processing necessary" else if (-e dat/$name.dat) then echo ".dat file exists, no processing necessary" else if (-e $name.$ext1) then echo $ext1 "file exists in current directory, no moving necessary" else if (-e $device$dir/L1B/$name.$ext1) then echo $ext1 "file exists, resetting" $in1 $in2 set in1 = $device$dir/L1B/$name.$ext1 set in2 = $device$dir/GEO/$name.$ext2 else if (-e $name.$ext0) then echo $ext0 "file exists in current directory, no moving necessary" # W E N S $SEADAS/seabatch1.1/master_script.sh 0 2 -180 180 89 -89 else echo $ext0 "file missing, fix step-2.csh, bailing out at" $name goto end endif # echo "Processing data now" # # extract ascii from .hdf data # echo "load, '"$in1"', gfile='"$in2"', prod_ix=[1,2]" >test.cmd echo "out, 'bin1', /data, band=1, ftype='FLAT',/geo" >>test.cmd echo "out, 'nav', /nav, band=1, ftype='FLAT'" >>test.cmd echo "out, 'bin2', /data, band=2, ftype='FLAT',/geo" >>test.cmd seadas -em -b test.cmd >log # # prepare input file for getbin.f # hdfdump -h $in1 >ascii.out nawk '$1 ~"netcdf" {print $2}' ascii.out >hdf0 nawk '$1 ~"reflectance_scales" {print substr($3,1,13),substr($4,1,13)}' ascii.out >hdf1 nawk '$1 ~"radiance_scales" {print substr($3,1,9),substr($4,1,9)}' ascii.out >hdf2 paste hdf0 hdf1 hdf2 | nawk '{printf("%14s %13s %13s %9s %9s\n",$1,$2,$3,$4,$5)}' >log.dat g77 getbin.f ./a.out mv loc $name.dat nawk '{print}' fort.99 >>filelist.dat endif # if (-e $device$dir/L1B/$name.ext1) then echo 'Cleaning up, no file moving necessary' else echo 'Moving processed files' if (-e $name.$ext0) mv $name.$ext0 $device$dir/L0/$name.$ext0 if (-e $name.$ext2) mv $name.$ext2 $device$dir/GEO/$name.$ext2 if (-e $name.$ext1) mv $name.$ext1 $device$dir/L1B/$name.$ext1 if (-e $name.$ext4) mv $name.$ext4 $device$dir/L1B/$name.$ext4 endif # rm -f $name.$ext3 rm -f $name.bin rm -f $name.nav rm -f *_list rm -f *_parfile rm -f $name.L1A* rm -f $name.L1B* rm -f $name.GEO* rm -f $name.L2* rm $name.L1B_LAC end: