#!/bin/bash # Script for creating ROFFS GeoTIFF ACSPO SST image files. # Kathy.Strabala@ssec.wisc.edu # November 2021 ##### GRID CONFIGURATIONA FILE NAME ################ # Set the grid configuration file that you want to use ##################################################### config_file=${DBVM_HOME}/scripts/roffs_acspo.conf echo echo "Creating VIIRS ACSPO ROFFS SST Images Using Polar2Grid Version 2.3; started at "$(date -u) #------------------------------------------------------------------------------- # Check arguments #------------------------------------------------------------------------------- # Check input arguments if [ $# -ne 1 ]; then echo "Usage: make_roffs_sst_images.bash sdr_dir" echo "where" echo "input_dir is the directory containing the ACSPO SST NetCDF files" exit 1 fi # Get input SDR directory input_dir=$1 echo "Input ACSPO SST NetCDF file directory: "$input_dir # Check for existence of the directory if [ ! -d ${input_dir} ]; then echo "VIIRS ACSPO SST file Directory does not exist: "$input_dir exit 1 fi #------------------------------------------------------------------------------- # Run VIIRS POLAR2GRID processing #------------------------------------------------------------------------------- echo echo "(Starting ACSPO POLAR2GRID processing)" # Set up POLAR2GRID export POLAR2GRID_HOME=$DBVM_HOME/apps/polar2grid/polar2grid_v_2_3 source $POLAR2GRID_HOME/bin/polar2grid_env.sh # Set up grid string for use with P2G command ACSPO_GRIDS="wnth_roffs wsth_roffs wmex_roffs" # Create ROFFS Area of Interest GeoTIFF files using one P2G command for all grids echo polar2grid.sh acspo gtiff --compress NONE --grid-coverage 0.01 --grid-configs ${config_file} -g $ACSPO_GRIDS -f $input_dir/20*ACSPO*.nc polar2grid.sh acspo gtiff --compress NONE --grid-coverage 0.01 --grid-configs ${config_file} -g $ACSPO_GRIDS -f $input_dir/20*ACSPO*.nc # Check for output GeoTIFFs file_list=$(find $PWD -name \*.tif) if [ -z "$file_list" ]; then echo "Error: No output GeoTIFF files were created" exit 1 fi # Rename files for file in *roffs*.tif; do sat=$(echo ${file} | cut -d"_" -f1) case $sat in npp) id=VIR;; n20) id=N20;; aqua) id=AMO;; terra) id=TMO;; esac year_mo_day=$(echo ${file} | cut -d"_" -f4) yr2=$(echo ${year_mo_day} | cut -c3-4) mo=$(echo ${year_mo_day} | cut -c5-6) time=$(echo ${file} | cut -d"_" -f5 | cut -c1-4) sector=$(echo ${file} | cut -d"_" -f6) #Get Julian Date jday=`date +%j -d $year_mo_day` #Assemble the new filename newfile=${yr2}${jday}${time}${id}.${sector}.tif #Move file to new name mv $file $newfile done # Create JPEG versions echo echo "(Converting to JPEG)" for file in 21*.tif; do convert -quiet -quality 80 $file ${file%.tif}.jpg; done #------------------------------------------------------------------------------- # EXIT #------------------------------------------------------------------------------- echo echo VIIRS ACSPO SST ROFFS image creation script ended at `date -u` exit 0