package Routines; # # implemented functions: # # * find_location ......... find location of data region in spectrum # require Exporter; @EXPORT = qw( find_location ); use PDL; ###################################################################### # find location of data region in spectrum # call : &find_location($data) # return : min ...... # max ...... # signal ... # start .... start of data section # end ...... end of data section ###################################################################### sub find_location ($) { my ($data) = @_; my $threshold = 0.05; my $header = $image->gethdr; my $na1 = ${$header}{"NAXIS1"}; my $na2 = ${$header}{"NAXIS2"}; my $a1s = int($na1*0.5-5); my $a1e = int($na1*0.5+5); my $slice = ushort($image->slice(($a1s-1).':'.($a1e-1).',0:'.($na2-1))); my $cut = oddmedover($slice); my $max = max($cut); my $min = min($cut); my $signal = $min + $threshold*($max-$min); my $cols = which($cut > $signal); my $cols = $cols + 1; return ($min,$max,$signal,$cols->min,$cols->max); }