#!/bin/bash
. /home/stereo/Software/procenv

BART=$1
PUBPRI=$2

read YS DS YE DE < <( ./yyyydddfmbartels.pl $BART )
read YR MONTH DOM MONTHNUM < <( ./ymdfmyyyyddd.pl $YS $DS )

if [ $PUBPRI != "public" -a $PUBPRI != "private" ]; then
   echo Usage: $0 BART SC pubpri, where pubpri is public or private
   exit 1
fi

# DATE=`date`

export PATH=/usr/local/TeX/bin/sparc-solaris2.5.1:/usr/local/bin:$PATH
export TEXINPUTS=".:/usr/local/lib/tex/inputs2:$HOME/tex/inputs:"

if [ $PUBPRI == "public" ]; then
   WEBDIR=$WEBPLOTS/Level1/Public/Bartels/PDF
   TITLE="LET Public Level 1 Hourly Averages, for Bartels Rotatation $BART: 27-day period starting $MONTH $DOM $YR (${YS}-${DS})"
else
   WEBDIR=$WEBPLOTS/Level1/SRLonly/Bartels/PDF
   TITLE="LET SRL-only Level 1 Hourly Averages, for Bartels Rotation $BART (27-day period starting $MONTH $DOM $YR (${YS}-${DS})"
fi

if [ ! -d $WEBDIR ]; then
   mkdir -p $WEBDIR
fi

cd $STEREOIDL/LETLevel1/plots


sed -e 's/TITLE/'"$TITLE"'/g' -e 's/YEAR_MONTH/'"$BART"'/g' < timeseries4up.tmpl > timeseries4up.tex

latex -interaction=batchmode timeseries4up.tex > /dev/null

$DVIPDF timeseries4up.dvi $WEBDIR/let_${BART}_timeseries.pdf

