#!/bin/csh

set titre_du_graphique = "'Profile humidite lame 1 rainure de 1 mm'"
set titre_axe_des_x    = "'Epaisseur z (mm)'"
set titre_axe_des_y    = "'Humidite (%)'"

set axe_des_x = '$3'
set axe_des_y = '$4'
set echelle_x = "1000"
set echelle_y = "1."
set variation_x = "[0:9.5]"
set variation_y = "[4.75:12.25]"

set options_grapf = "not w l"

if ($# == 0 | "$1" == "-h" | "$1" == "-help") then
    echo ""
    echo "     usage: $0 numero_premier numero_dernier prefixe postfixe"
    echo ""
    echo "numero_premier : numero du premier fichier de donnees"
    echo "numero_dernier : numero du dernier fichier de donnees"
    echo ""
    echo "Le format du nom des fichiers de donnees est: PrefixeNumero.Postfixe"
    echo ""
    echo "Une serie de fichier png sera creee via gnuplot. Editer le fichier $0"
    echo "pour modifier les titres etc."
    echo ""
    ##
    exit
endif

set i = $1
set fin = $2
set prefixe = $3
set postfixe=$4

echo "Pour le moment on a: "
echo "titre     : $titre_du_graphique"
echo "axe des x : $titre_axe_des_x"
echo "axe des y : $titre_axe_des_y"
echo ""
echo "Le graphe est trace avec la commande "
echo "plot $variation_x$variation_y '$prefixe"numero".$postfixe' u ($axe_des_x*$echelle_x):($axe_des_y*$echelle_y) $options_grapf"
echo ""
echo -n "On continu ? (o/n) "
set PROCEED = $<
if ($PROCEED == "n") then
    exit
endif

while ($i <= $fin)

  echo "Creation de $prefixe.$i.png"

  echo "set terminal png" > plot
  echo "unset mouse" >>plot
  echo "set output '$prefixe.$i.png'" >>plot

  echo "set title $titre_du_graphique" >>plot
  echo "set xlabel $titre_axe_des_x" >>plot
  echo "set ylabel $titre_axe_des_y" >>plot
  echo "plot $variation_x$variation_y '$prefixe$i.$postfixe' u ($axe_des_x*$echelle_x):($axe_des_y*$echelle_y) $options_grapf" >>plot

  gnuplot plot

  set i = `expr $i + 1 `
  rm plot
end

