diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2018-06-25 20:32:45 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2018-06-25 20:32:45 (GMT) |
commit | 945cefd1c2cea28c63615cd19a197c465b32c48c (patch) | |
tree | 9399df61a03a5d215e17ebaef1b81779256f87d0 /ds9/library/marker.tcl | |
parent | 0e20becb38cf971f8382a6d45b56d2eb9f6d3a12 (diff) | |
download | blt-945cefd1c2cea28c63615cd19a197c465b32c48c.zip blt-945cefd1c2cea28c63615cd19a197c465b32c48c.tar.gz blt-945cefd1c2cea28c63615cd19a197c465b32c48c.tar.bz2 |
add support for compressed regions files
Diffstat (limited to 'ds9/library/marker.tcl')
-rw-r--r-- | ds9/library/marker.tcl | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/ds9/library/marker.tcl b/ds9/library/marker.tcl index 4c2ebf6..317a1a7 100644 --- a/ds9/library/marker.tcl +++ b/ds9/library/marker.tcl @@ -1124,7 +1124,25 @@ proc MarkerLoadFile {filename which format sys sky} { return } + # is it compressed? + set app {} + switch [file extension $filename] { + .gz {set app gunzip} + .bz - + .bz2 {set app bunzip2} + .Z {set app uncompress} + } + if {$app != {}} { + set srcfilename $filename + set filename [tmpnam [file ext [file rootname $filename]]] + if {[catch {exec $app < $srcfilename > $filename} rr]} { + Error "[msgcat::mc {Unable to load compressed region file}]\n$rr" + return -code error + } + } + # determine if its a fits file + # look for hdu ext in the filename # first, strip the filename if {![regexp -nocase {(.*)(\[.*\])} $filename foo base ext]} { set base $filename @@ -1143,15 +1161,15 @@ proc MarkerLoadFile {filename which format sys sky} { if {$ll == "SIMPLE ="} { # see if we need to add an extension if {$ext == {}} { - set filename "$base\[REGION\]" + set regfilename "$base\[REGION\]" } # open it - if {[catch {$which marker load fits "\{$filename\}" $marker(color) $marker(dashlist) $marker(width) "\{$marker(font) $marker(font,size) $marker(font,weight) $marker(font,slant)\}"}]} { + if {[catch {$which marker load fits "\{$regfilename\}" $marker(color) $marker(dashlist) $marker(width) "\{$marker(font) $marker(font,size) $marker(font,weight) $marker(font,slant)\}"}]} { if {$ext == {}} { # ok now try the first extension - set filename "$base\[1\]" - if {[catch {$which marker load fits "\{$filename\}" $marker(color) $marker(dashlist) $marker(width) "\{$marker(font) $marker(font,size) $marker(font,weight) $marker(font,slant)\}"}]} { + set regfilename "$base\[1\]" + if {[catch {$which marker load fits "\{$regfilename\}" $marker(color) $marker(dashlist) $marker(width) "\{$marker(font) $marker(font,size) $marker(font,weight) $marker(font,slant)\}"}]} { Error [msgcat::mc {Unable to load region file}] return -code error } @@ -1171,6 +1189,9 @@ proc MarkerLoadFile {filename which format sys sky} { } } + if {$app != {}} { + file delete -force $filename + } FileLast markerfbox $filename UpdateGroupDialog } |