#!/bin/bash # Script for creating ROFFS GeoTIFF SeaDAS Chlorophyll-a image files. # Kathy.Strabala@ssec.wisc.edu # December 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 SeaDAS ROFFS CHLOR-A Images Using Polar2Grid Version 3.0; started at "$(date -u) #------------------------------------------------------------------------------- # Check arguments #------------------------------------------------------------------------------- # Check input arguments if [ $# -ne 1 ]; then echo "Usage: make_roffs_seadas_images.bash sdr_dir" echo "where" echo "input_dir is the directory containing the SeaDAS CHLOR-A HDF4 files" exit 1 fi # Get input SDR directory input_dir=$1 echo "Input SeaDAS CHLOR-A HDF4 file directory: "$input_dir # Check for existence of the directory if [ ! -d ${input_dir} ]; then echo "VIIRS SeaDAS CHLOR-A file Directory does not exist: "$input_dir exit 1 fi #------------------------------------------------------------------------------- # Run VIIRS POLAR2GRID processing #------------------------------------------------------------------------------- echo echo "(Starting SeaDAS POLAR2GRID processing)" # Set up POLAR2GRID export POLAR2GRID_HOME=$DBVM_HOME/apps/polar2grid/polar2grid source $POLAR2GRID_HOME/bin/polar2grid_env.sh # Set up grid string for use with P2G command SEADAS_GRIDS="wnth_roffs wsth_roffs wmex_roffs" input_file=`basename $(find . -iname \*seadas\*.hdf)` if [ -z "$input_file" ]; then echo "Could not find SeaDAS input file. Exiting" exit 1 fi # Create ROFFS Area of Interest GeoTIFF files using one P2G command for all grids echo polar2grid.sh -r seadas_l2 -w geotiff --method nearest -p chlor_a --grid-coverage 0.01 --compress NONE --fill-value 0 --num-workers 4 --grid-configs ${config_file} -g $SEADAS_GRIDS -f $input_dir/$input_file polar2grid.sh -r seadas_l2 -w geotiff --method nearest -p chlor_a --grid-coverage 0.01 --compress NONE --fill-value 0 --num-workers 4 --grid-configs ${config_file} -g $SEADAS_GRIDS -f $input_dir/$input_file # 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;; noaa20) id=N20;; aqua) id=AMO;; terra) id=TMO;; esac year_mo_day=$(echo ${file} | cut -d"_" -f5) yr2=$(echo ${year_mo_day} | cut -c3-4) mo=$(echo ${year_mo_day} | cut -c5-6) time=$(echo ${file} | cut -d"_" -f6 | cut -c1-4) sector=$(echo ${file} | cut -d"_" -f7) #Get Julian Date jday=`date +%j -d $year_mo_day` #Assemble the new filename newfile=${yr2}${jday}${time}${id}chl.${sector}.tif #Move file to new name cp $file $newfile done # Create JPEG versions echo echo "(Converting to JPEG)" for file in 2*.tif; do convert -quiet -quality 80 $file ${file%.tif}.jpg; done #------------------------------------------------------------------------------- # EXIT #------------------------------------------------------------------------------- echo echo VIIRS SeaDAS CHLOR-A ROFFS image creation script ended at `date -u` exit 0