vai
  data "uploads/file.dat"
  #data sat26867.txt
  lines 1 1
  read {yy 1 mm 2 dd 3}
  lines 2 0
  read {hr 1 min 2 sec 3 ra 4 dec 5} 

  define giorno (dd[0])
  define mese (mm[0])
  define anno (yy[0])
 
  !rm output/convertidata.sh
  write + output/convertidata.sh "year="$anno 
  write + output/convertidata.sh "month="$mese 
  write + output/convertidata.sh "day="$giorno 
  write + output/convertidata.sh "echo data:  $day $month  $year"
  !chmod ugo+x output/convertidata.sh
  !output/convertidata.sh
  echo data: $giorno $mese $anno 
  
  !rm  output/calcolaJD
  write + output/calcolaJD "<?php"
  write + output/calcolaJD "$jd = GregorianToJD("$mese"," $giorno"," $anno");"
  write + output/calcolaJD "echo \"$jd\n\";"
  write + output/calcolaJD "$gregorian = JDToGregorian($jd);"
  write + output/calcolaJD "echo \"$gregorian\n\";"
  write + output/calcolaJD "?>"
  !rm output/JD.dat
  !php output/calcolaJD > output/JD.dat
  data output/JD.dat
  lines 1 1 
  read {mioJD 1}
  print '%7.6f' {mioJD}




 set tempout = hr+min/60+sec/3600
 define n dimen(ra)
 echo $n
 define nn ($n)
 set  dimen(diffRA)=$nn
 set  dimen(diffRAcheck)=$nn
 set  dimen(diffDEC)=$nn
 set  dimen(dt)=$nn
 do i=0,$n-3,1{
               set dt[$i+1]=tempout[$i+2]-tempout[$i+1]
               set diffRA[$i+1]=(ra[$i+2]-ra[$i+1])
               define checkRA (ra[$i+2]-ra[$i+1])
               #echo $checkRA
               if($checkRA<-350){set diffRAcheck[$i+1]=($checkRA+360)}
               if($checkRA<-350){set diffRA[$i+1]=($checkRA+360)}
               set diffDEC[$i+1]=(dec[$i+2]-dec[$i+1])            
               
                 }
 
   #print{tempout ra dec diffRA diffDEC dt}
   set dt1=dt if(dt>0)
   set tempout1=tempout if(dt>0)
   set ra1=ra if(dt>0)
   set dec1=dec if(dt>0)
   set diffRA1=diffRA if(dt>0)
   set diffDEC1=diffDEC if(dt>0)
   #print{tempout1 ra1 dec1 diffRA1 diffDEC1 dt1}

   set diffRA2=diffRA1/dt1
   set diffDEC2=diffDEC1/dt1
   !rm output/dati1.dat
   print output/dati1.dat '%2.6f %3.8f %3.8f %3.8f %3.8f \n'  {tempout1 ra1 dec1 diffRA2 diffDEC2}
   !cat output/JD.dat output/dati1.dat > output/output.dat
