use constant PI    => 4 * atan2(1, 1);
print PI," \n";
$infile="ha.dat";
    $path="/scatn/scos/Halpha/HARMC";
open (CFILE, "/home/mar/stock.lis");
while (<CFILE>){
    chomp;
    $line=$_;
	$line =~ s/^\s+//;
	$line =~ s/\s+$//;

    print "$line \n";
    @bits = split (/\s+/,$line);
    $ra=$bits[0]*15.0;
    if ($ra <0){
	$ra=$ra+360.0;
    }
    $dec=$bits[1];
    $xPix=&round($bits[3]*3600.0/(100*0.6714))*100;
    $yPix=&round($bits[3]*3600.0/(100*0.6714))*100;
    $name=$bits[4];
    $log=$name.".log";
    $fitsFile="/scatn/scos/Halpha/fits/$name"."_sr.fits";
    $field=sprintf("%02d",$bits[2]);
    $fullPath=$path.$field."/";
    print "$ra $dec $xPix $yPix $fullPath\n";
    print "$fitsFile $log \n";
    if (-e $infile) {
	unlink $infile;
    }
   open (INFILE, ">$infile");
    print INFILE "12345\n";
    print INFILE "$fullPath\n";
 print INFILE "$ra $dec\n";
 print INFILE "$xPix $yPix\n";
 print INFILE "11\n";
 print INFILE "1\n";
 print INFILE "0\n";
    close INFILE;
    system ("nice /home/nch/bin/xymmdata_siap < $infile > $log");
    print "$fitsFile \n";
    if (-e "12345.fits") {
print "exists $fitsFile\n";
    rename ("12345.fits", $fitsFile);
unlink <12345*>;
}

#    exit;
}



sub round {
    my($number) = shift;
    return int($number + .5);
}

