/
ds9put
77 lines (67 loc) · 1.24 KB
/
ds9put
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env perl
$XPAID=$ENV{XPAID};
if ($XPAID !~ /\S/) {
$XPAID="ds9";
}
while (@ARGV) {
push(@files,$ARGV[0]);
if ($#ARGV >=1) {
if ($ARGV[1] =~ /^\d*$/) {
$frames[$#files]=$ARGV[1];
shift(@ARGV);
}
else {
if ($#files > 0) {
$frames[$#files]=-$#files;
}
else {
$frames[$#files]=0;
}
}
}
else {
if ($#files > 0) {
$frames[$#files]=-$#files;
}
else {
$frames[$#files]=0;
}
}
shift(@ARGV);
}
for ($i=0;$i<=$#files;$i++) {
$file=$files[$i];
$frame=$frames[$i];
if ($frame < 0) {
$frameold=`xpaget $XPAID frame`;
$frame=$frameold+1;
}
$spec="";
if ($file =~ /\[/) {
($file,@spec)=split(/\[/,$file);
$spec = "[" . join("[",@spec);
}
if (!(-e $file) && (-e "${file}.fits")) {
$file .=".fits";
}
if ($file =~ /\.reg/ && !(-e "{$file}.fits")) {
system("ds9reg $file $frame");
next;
}
die "Could not open file $file\n" if (!(-e $file));
$file="`pwd`/$file" unless ($file=~/^\//);
xpaset("frame $frame") unless ($frame==0);
if ($spec =~ /\S/) {
xpaset("file $file$spec");
}
else {
xpaset("file $file");
}
}
exit(0);
sub xpaset {
foreach $cmd (@_) {
system("xpaset -p $XPAID $cmd");
}
}
__END__