Skip to content
Snippets Groups Projects
Commit e47897ab authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

import old scripts from exe/

parent 227c0089
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/ruby
require 'rlib2'
opth = scanarg( "", 1, 1 )
infile = ARGV[0]
unless infile =~ /(.*)\.hfbs$/
exxx( "input file must have extension .hfbs" )
end
fname = $1
outfile = fname + ".a01"
fin = File.new( infile )
begin
fout = File.new( outfile, "r" )
rescue
else
exxx( "outfile already exists" )
end
fout = File.new( outfile, "w" )
## skip header
unless fin.readline =~ /^\#Comment/ then exxx( "line 1 invalid" ) end
while true
lin = fin.readline
break if lin =~ /^\# Detector/
end
## read blocks
data = [ [] ]
while lin = fin.gets
if lin =~ /^\# Detector/
data.push []
next
end
data[-1].push( lin.split[1].to_f )
end
## output header
fout.printf( "ASCII-01 JWu\n")
fout.printf( "typ D\n")
fout.printf( "fil #{fname}\n")
fout.printf( "doc HBFS raw data\n")
fout.printf( "x ch\n")
fout.printf( "y cnts\n")
fout.printf( "z0 det\n")
fout.printf( "#j #{data.size-1}\n")
## output spectra
ni = 0
data[0][1..-1].each{ |y| ni += 1 if y!=0 }
jout = 0
data.each_with_index do |spec,j|
next if j==17
fout.printf( "scn #{jout}\n")
fout.printf( "Z 1\n")
fout.printf( " %2i\n", j)
fout.printf( "XY #{ni}\n")
spec.each_with_index do |y,i|
next if i==0 || data[0][i]==0
fout.printf( "%20.15g %20.15g\n", data[17][i], y )
end
jout += 1
end
fout.printf( "eof\n")
#!/usr/bin/env perl
use strict;
use warnings;
while (<>) {
if ( m/z\s*\=\s*(\S+)/ ) { print "$1\n"; }
elsif ( m/pstyle/ ) {}
elsif ( m/(\S+)\s*(\S+)/ ) { print "$1 $2\n"; }
elsif ( m/^\s*$/ ) { print "\n"; }
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment