#!/bin/bash #-------------------------------------------------------------------------- # # Name: L2ProdFile.sh # # Purpose: File NOAAPort GOES-R/S Level 2 products in daily directories, # and create product links to "current" directories # # Notes: Modify the 'LOG' file to suit your needs # # Invocation from pattern action file: # # Product ID examples: # # /data/ldm/pub/native/satellite/GOES/GOES17/Products/CloudAndMoistureImagery/CONUS/Channel15/20190411/OR_ABI-L2-CMIPC-M6C15_G17_s20191011706190_e20191011706190_c20191011706190.nc # /data/ldm/pub/native/satellite/GOES/GOES17/Products/CloudAndMoistureImagery/CONUS/Channel14/20190411/OR_ABI-L2-CMIPC-M6C14_G17_s20191011706190_e20191011706190_c20191011706190.nc # /data/ldm/pub/native/satellite/GOES/GOES16/Products/AerosolDetection/FullDisk/20180114/OR_ABI-L2-ADPF-M3_G16_s20180141930422_e20180141941189_c20180141941453.nc # /data/ldm/pub/native/satellite/GOES/GOES16/Products/FireHotSpot/CONUS/20190227/OR_ABI-L2-FDCC-M3_G16_s20190582142135_e20190582144508_c20190582145071.nc # /data/ldm/pub/native/satellite/GOES/GOES16/Products/DerivedStabilityIndices/Mesoscale-2/20190227/OR_ABI-L2-DSIM2-M3_G16_s20190582144514_e20190582144572_c20190582145379.nc # /data/ldm/pub/native/satellite/GOES/GOES16/Products/DerivedStabilityIndices/Mesoscale-1/20190227/OR_ABI-L2-DSIM1-M3_G16_s20190582145214_e20190582145271_c20190582145518.nc # /data/ldm/pub/native/satellite/GOES/GOES16/Products/DerivedStabilityIndices/CONUS/20190227/OR_ABI-L2-DSIC-M3_G16_s20190582142135_e20190582144508_c20190582146079.nc # /data/ldm/pub/native/satellite/GOES/GOES16/Products/TotalPrecipitableWater/CONUS/20190227/OR_ABI-L2-TPWC-M3_G16_s20190582142135_e20190582144508_c20190582146079.nc # /data/ldm/pub/native/satellite/GOES/GOES16/Products/TotalPrecipitableWater/Mesoscale-1/20190227/OR_ABI-L2-TPWM1-M3_G16_s20190582145214_e20190582145271_c20190582145518.nc # /data/ldm/pub/native/satellite/GOES/GOES16/Products/TotalPrecipitableWater/Mesoscale-2/20190227/OR_ABI-L2-TPWM2-M3_G16_s20190582145514_e20190582145571_c20190582146350.nc # /data/ldm/pub/native/satellite/GOES/GOES16/Products/CloudParticleSize/CONUS/20190227/OR_ABI-L2-CPSC-M3_G16_s20190582142135_e20190582144508_c20190582145584.nc # /data/ldm/pub/native/satellite/GOES/GOES16/Products/CloudParticleSize/Mesoscale-2/20190227/OR_ABI-L2-CPSM2-M3_G16_s20190582144514_e20190582144572_c20190582146075.nc # /data/ldm/pub/native/satellite/GOES/GOES16/Products/DerivedMotionWinds/Mesoscale-1/Channel08/20190227/OR_ABI-L2-DMWM1-M3C08_G16_s20190582140214_e20190582140271_c20190582146211.nc # /data/ldm/pub/native/satellite/GOES/GOES16/Products/DerivedMotionWinds/Mesoscale-1/Channel14/20190227/OR_ABI-L2-DMWM1-M3C14_G16_s20190582140214_e20190582140271_c20190582146218.nc # # Examples AerosolDetection Mesoscale-1 Derived Motion Winds Mesoscale-1 Channel08 # $1 - \1 -> topdir - /data/ldm/pub/native/satellite/GOES /data/ldm/pub/native/satellite/GOES # $2 - \2 -> platform - GOES16 GOES16 # $3 - \3 -> products - Products Products # $4 - \4 -> prodtype - AerosolDetection DerivedMotionWinds # $5 - \5 -> coverage - Mesoscale-1 Mesoscale-1/Channel08 # $6 - \7 -> date - ccyymmdd 20190227 # $7 - \8 -> filename - CSPP GEO FIT file name OR_ABI-L2-DMWM1-M3C08 # #EXP ^(.*)/(GOES1.)/(Products)/(.*)/((CONUS|FullDisk|Mesoscale-1|Mesoscale-2).*)/(20......)/(OR_ABI-L2.*.nc) # PIPE -close # util/L2ProdFile.sh \1 \2 \3 \4 \5 \7 \8 logs/L2ProdFile.log # # History: 20170114 - Adapted from ScmiFile.sh NOAAPort L2 product filing # 20190228 - Modified to handle Derived Motion Winds where the # coverage could be coverage/Channelnn. Change # requires a corresponding change to LDM pqact action # 20190411 - Added example Product IDs for CMI L2 imager products # Add explicit support for PuertoRico, Alaska and Hawaii # coverages # #-------------------------------------------------------------------------- SHELL=/bin/bash export SHELL # Date format for LOG file follows: 20170901T000001.826060Z, and default # number of files to keep in 'current' directories dfmt="%Y%m%dT%H%M%S" # Home directory of 'ldm' LDMHOME=`echo ~ldm` # Program name and time hack program="`date -u +$dfmt`.`date -u +'%N' | cut -b 1-6`Z `basename $0`[$$]:" # Set log file name if [ $# -ge 8 ]; then logfile=$8 else logfile=$LDMHOME/logs/L2ProdFile.log fi # Make sure that the log directory exists dname=`dirname $logfile` if [ ! -d "$dname" ]; then mkdir -p $dname >/dev/null 2>&1 if [ $? -ne 0 ]; then message="ERROR: unable to create LOG directory $dname, exiting" echo $program $message cat > /dev/null exit 1 fi fi # Send all messages to the log file exec >>$logfile 2>&1 # Top level output directory topdir=$1/$2/$3/$4/$5 dname=$topdir/$6 # Create output directory if [ ! -d "$dname" ]; then mkdir -p $dname >/dev/null 2>&1 if [ $? -ne 0 ]; then message="ERROR: unable to create output directory $dname" echo $program $message cat > /dev/null exit 1 fi fi # Write the log message and output pathname=$dname/$7 program="`date -u +$dfmt`.`date -u +'%N' | cut -b 1-6`Z `basename $0`[$$]:" message="FILE: $pathname" echo $program $message cat > $pathname # Create link directory curdir=$topdir/current if [ ! -d "$curdir" ]; then mkdir -p $curdir >/dev/null 2>&1 if [ $? -ne 0 ]; then message="ERROR: unable to create current directory $curdir" echo $program $message exit 1 fi fi # Create a link to the file just written program="`date -u +$dfmt`.`date -u +'%N' | cut -b 1-6`Z `basename $0`[$$]:" message="LINK: $curdir/$7" echo $program $message ln $pathname $curdir/$7 status=$? if [ $status -ne 0 ]; then message="LINKFAIL: $curdir/$7" echo $program $message fi # Keep a maximum of $KEEP files in the current directory # 20171229 - decrease the number of files kept to: # # CONUS - 1 day if every 5 minutes # FullDisk - 1 day if every 15 minutes, 16 hours if every 10 minutes # Mesoscale-1 - 6 hours if every minute # Mesoscale-2 - 6 hours if every minute # PuertoRico - 1 day if every 15 minutes, 16 hours if every 10 minutes # Alaska - 1 day if every 15 minutes, 16 hours if every 10 minutes # Hawaii - 1 day if every 15 minutes, 16 hours if every 10 minutes # - 32 files otherwise # $5 could be coverage for most products or coverage/Channelnn for # Derived Motion Winds. Extract the coverage (covr) for use in # setting the scouring. covr=`echo $5 | cut -d '/' -f 1` # Set number to keep based on coverage case "$covr" in CONUS) KEEP=288 ;; FullDisk) KEEP=96 ;; Mesoscale-1) KEEP=360 ;; Mesoscale-2) KEEP=360 ;; PuertoRico) KEEP=96 ;; Alaska) KEEP=96 ;; Hawaii) KEEP=96 ;; *) KEEP=32 ;; esac message="COVR: $covr" #echo $program $message # Keep a maximum of $KEEP files in the 'current' directory cd $curdir KEEP=$(expr $KEEP + 1) case `uname -s` in SunOS) files=`ls -1t | tail +${KEEP}` ;; *) files=`ls -1t | tail --lines=+${KEEP}` ;; esac KEEP=$(expr $KEEP - 1) if [ ! -z "$files" ]; then program="`date -u +$dfmt`.`date -u +'%N' | cut -b 1-6`Z `basename $0`[$$]:" message="KEEP: $KEEP in $curdir" #echo $program $message rm -f $files fi # Done # Program name and date/time hack program="`date -u +$dfmt`.`date -u +'%N' | cut -b 1-6`Z ${prognam}[$$]:" message="END" #echo $program $message exit 0