#! /bin/bash -f
# Last edited on 2009-12-11 22:15:23 by stolfi

echo "REFORMATTING THE RAW ARTICLE COUNT FILES" 1>&2 
# 
#   Reformat the files to put them in a common format
#   
#      "{TIME} {YEAR} {MONTH} {DAY}  {SZ} {SU}"
#      
#   where {YEAR} is the 4-digit year, {MONTH} is 01 to 12, {DAY} is day
#   of month 01 to 31, {TIME} is elapsed days since Jan 1, 2001, {SZ} is
#   the article count at {TIME}, and {SU} is a status indicator, 
#   presently 1 (OK) or 0 (suspicious).
# 

for ff in 2009-06 ; do
  cat data/wp-size-emo-${ff}-raw.txt \
    | reformat-wp-size-emo-raw.gawk \
        -f lib_date_time.gawk \
        -f lib_functions.gawk \
    > rslt/wp-size-emo-${ff}-rar.txt
done

# We must exclude a very wrong line with duplicated date

for ff in 2009-11 ; do
  cat data/wp-size-irr-${ff}-raw.txt \
    | egrep -v -e 'RAMBOT causing Error' \
    | reformat-wp-size-irr-raw.gawk \
        -f lib_date_time.gawk \
        -f lib_functions.gawk \
    > rslt/wp-size-irr-${ff}-rar.txt
done

#   Plotting the reformatted raw data:

for nodub in 0 1 ; do
  for pha in 0 1 ; do
    for ff in emo-2009-06 irr-2009-11 ; do
      plot-wp-size-rar.sh \
          ${pha} \
          ${nodub} \
          rslt/wp-size-${ff}-rar.txt \
        > rslt/wp-size-${ff}-rar-p${pha}-n${nodub}.eps
    done
  done
done
