#!/bin/bash


# makes a human-readale table and an illuminance png from a photometric file

F=$1
  S=${F/*\.}
  G=${F/\.*}
  echo $S
  E='non-photometric'
  if [[ $S == eld || $S == ldt || $S == LDT || $S == ELD ]] 
  then 
   EM='-eicurr_lum.ies'
   E='-e'
   O='curr_lum.ldt'
  else
   if [[ $S == ies || $S == IES ]]
   then 
    EM='-emcurr_lum.ldt' 
    E='' 
    O='curr_lum.ies'
   fi    
  fi 
  if [[ $E != 'non-photometric' ]]
  then
   URL=`echo $1 | sed -n '/tp:\/\//p'`
   if [[ $URL != '' ]]
   then 
     wget -O $O $URL
   /home/jhollan/bin/ies2tab $EM -ncurr_lum.ppm $@ $O >curr_lum.txt
   convert curr_lum.ppm curr_lum.png  
   rm curr_lum.ppm 
   else
     O=     
   fi  
  else
    echo "$1 Seems to be a $E file" 
  fi

