#! /bin/csh -xf

cp leer erg1

set ref_file = erg1
set erg_file = erg2

foreach file ( $argv )

	emathp \
		file1_vars='flag_data interp_mcsst orig_mcsst good_interp good_orig' \
		file2_vars='flag_data interp_mcsst orig_mcsst' \
		num_exprs='5' \
		y1_expr='x1==254 || x6==254? 254:x1+x6' \
		y2_expr='x2==-254|| x7==254?-254:x2+x7' \
		y3_expr='x3==-254|| x6==254?-254:x3+x8' \
		y4_expr='(x7!=254) && (x7 != 0 ) ?x4+1:x4' \
		y5_expr='(x8!=254) && (x8 != 0 ) ?x5+1:x5' \
		save_exprs='1 2 3 4 5 ' \
		var_names='flag_data interp_mcsst orig_mcsst good_interp good_orig' \
		var_units='- - - - -' \
		var_types='byte sh sh byte byte' \
		scale_offsets='0 0 0 0 0' \
		scale_factors='1 1 1 1 1' \
	$ref_file $file $erg_file

	set tmp = $ref_file
	set ref_file = $erg_file
	set erg_file = $tmp

end

emathp \
        expr_vars='flag_data interp_mcsst orig_mcsst good_interp good_orig' \
        num_exprs='3' \
        y1_expr='x1' \
        y2_expr='(x2==-254)?254:(x2==0)?0:x2 / x4' \
        y3_expr='(x3==-254)?254:(x3==0)?0:x3 / x5' \
        save_exprs='1 2 3' \
        var_names='flag_data interp_mcsst orig_mcsst' \
        var_units='- - - ' \
        var_types='byte byte byte' \
        scale_offsets='0 0 0' \
        scale_factors='1 1 1' \
$ref_file sn199812

rm erg1 erg2 
