aboutsummaryrefslogtreecommitdiffstats
path: root/astro/spectrum
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2019-10-16 13:52:31 +0800
committerAaron LI <aly@aaronly.me>2019-10-16 13:52:31 +0800
commit69831225acd6b3b770bb4bc8b14dfc284e382567 (patch)
treee362a496825d37de51c602a5d6a286892273bb0d /astro/spectrum
parent0ce8c9f568267fc3a697255ee52f7c13055885bb (diff)
downloadatoolbox-69831225acd6b3b770bb4bc8b14dfc284e382567.tar.bz2
astro/sfr_chandra.pl: Support region list with each line a region file
Diffstat (limited to 'astro/spectrum')
-rwxr-xr-xastro/spectrum/sfr_chandra.pl30
1 files changed, 24 insertions, 6 deletions
diff --git a/astro/spectrum/sfr_chandra.pl b/astro/spectrum/sfr_chandra.pl
index f7d86c7..010c7cd 100755
--- a/astro/spectrum/sfr_chandra.pl
+++ b/astro/spectrum/sfr_chandra.pl
@@ -16,10 +16,18 @@
use strict;
use warnings;
use File::Basename;
+use File::Copy;
-my $version = "2015/03/04";
+my $version = "2019/10/16";
#
# ChangeLogs:
+#
+# 2019/10/16: Weitian LI
+# * support region list file with each line representing a region file
+# instead of the region itself (Sanders's contour binning
+# segmentation program output such a region format:
+# http://www-xray.ast.cam.ac.uk/papers/contbin/ )
+#
# 2015/03/04: Weitian LI
# Completely rewrite of this script:
# * add use strict, warnings, many fixes to the syntax
@@ -58,6 +66,9 @@ sub usage {
Usage:
$prog <region_list> <evt> <bkgd> <output> <rmf> <arf> <fit_config>
+Options:
+ region_list: each line can be a region string or a region file
+
Version: $version
);
print $text;
@@ -614,11 +625,18 @@ foreach my $line (@region_lines) {
# Save the current region to a temporary region file
unlink($fit_reg_fn);
- open(my $FIT_REG, ">", $fit_reg_fn)
- or die "ERROR: Could not open file '$fit_reg_fn', $!";
- my @cur_regs = split(/\s+/, $line);
- foreach my $reg (@cur_regs) {
- print $FIT_REG "$reg\n"
+ if (-f $line) {
+ # Each line is a region file
+ copy($line, $fit_reg_fn)
+ or die "ERROR: Could not copy region file '$line', $!";
+ } else {
+ # Each line is a region string
+ open(my $FIT_REG, ">", $fit_reg_fn)
+ or die "ERROR: Could not open file '$fit_reg_fn', $!";
+ my @cur_regs = split(/\s+/, $line);
+ foreach my $reg (@cur_regs) {
+ print $FIT_REG "$reg\n"
+ }
}
close($FIT_REG);