Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions DS9.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
import RO.OS
import subprocess

_DebugSetup = False
_DebugSetup = True

def _addToPATH(newPath):
"""Add newPath to the PATH environment variable.
Expand Down Expand Up @@ -440,8 +440,8 @@ def xpaset(cmd, data=None, dataFunc=None, template=_DefTemplate, doRaise = False
dataFunc(p.stdin)
elif data:
p.stdin.write(data)
if data[-1] != "\n":
p.stdin.write("\n")
if data[-1] != b"\n":
p.stdin.write(b"\n")
p.stdin.close()
reply = p.stdout.read()
if reply:
Expand Down Expand Up @@ -511,7 +511,6 @@ def _splitDict(inDict, keys):
outDict[key] = inDict.pop(key)
return outDict


class DS9Win:
"""An object that talks to a particular window on ds9

Expand Down Expand Up @@ -632,13 +631,16 @@ def showArray(self, arr, **kargs):
arryDict["arch"] = "bigendian"
else:
arryDict["arch"] = "littleendian"

self.xpaset(
cmd = "array [%s]" % (_formatOptions(arryDict),),
dataFunc = arr.tofile,
#dataFunc = arr.tofile,
#fix for python3
dataFunc = lambda f: f.write(arr.tobytes()) ,
)

for keyValue in kargs.items():

self.xpaset(cmd=" ".join(keyValue))

# showBinFile is commented out because it is broken with ds9 3.0.3
Expand Down Expand Up @@ -726,6 +728,10 @@ def xpaset(self, cmd, data=None, dataFunc=None):

Raises RuntimeError if anything is written to stdout or stderr.
"""
if data is not None:
#fix python3
data=data.encode()

return xpaset(
cmd = cmd,
data = data,
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# RO3

Russel Owen's library ported to Python 3.

Modification of original RO3 (https://github.com/ApachePointObservatory/RO3) to work with Python 3.12 and the newest version of numpy and astropy. Fixed only the DS9.py file (open images in SAO DS9)! Tested on numpy 1.26.0 and astropy 6.1.2.