#!/bin/bash

# set ncl script and levelscale files
ncl_script=DV.UAA_noGA.ncl
#levelscale=o3.mda8.lvl
levelscale=o3.mda8.tst.lvl2

NCARG_COLORMAPS=/models/NCL/colormaps

mkdir -p ./png/noGA

# computational domain dimensions
# without buffer because we removed buffer in SMAT calcs
NI=171
NJ=126

# full 4km
NX=":"
NY=":"
SW_lat=36.4371
SW_lon=-109.14
NE_lat=41.51185
NE_lon=-101.804

# Titles
str1="Denver CAMx 4km"
str3="O3 Design Value UAA"


#####################################   BASE and SCEN1
# set input file

#scen=(runS17b_2026)
#Sc_title=("runS17b_2026")

#scen=(runS17b_2023)
#Sc_title=("runS17b_2023")

#scen=(2026ctrl_EV_RFG)
#Sc_title=("2026ctrl_EV_RFG")

#scen=(2026_scen1)
#Sc_title=("2026_scen1")

scen=(Denver_2026_runS20)
Sc_title=("Denver_2026_runS20")

for i in {0..1}
do


DV_index=0
infile=/disk40/Denver_O3_2023/camx/postproc/3.SMAT/SMAT_output/${scen}/${scen}_UAA_cleaned.csv
outf=".\/png\/noGA\/Denver4km_DVC_UAA.${scen}.png"

if [ $i -gt 0 ];then
  DV_index=1
  infile=/disk40/Denver_O3_2023/camx/postproc/3.SMAT/SMAT_output/${scen}/${scen}_UAA_cleaned.csv
  outf=".\/png\/noGA\/Denver4km_DVF_UAA.${scen}.png"
fi

ln -snf $infile ./infile.in

inf=infile.in
str2=${Sc_title}

cat $ncl_script \
  | sed s/INF/$inf/g \
  | sed s/NI/"$NI"/g \
  | sed s/NJ/"$NJ"/g \
  | sed s/STR1/"$str1"/g \
  | sed s/STR2/"$str2"/g \
  | sed s/STR3/"$str3"/g \
  | sed s/OUTF/"$outf"/g \
  | sed s/DVINDEX/"$DV_index"/g \
  | sed s/NX/"$NX"/g \
  | sed s/NY/"$NY"/g \
  | sed s/SWLAT/"$SW_lat"/g \
  | sed s/SWLON/"$SW_lon"/g \
  | sed s/NELAT/"$NE_lat"/g \
  | sed s/NELON/"$NE_lon"/g \
  | sed s/LEVELSCALE/$levelscale/g \
> tmp2
ncl tmp2

rm -f tmp2 infile.in

done
