spacetelescope / stsci.skypac

Sky matching for image mosaic.
https://stsci-skypac.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
2 stars 9 forks source link

Exception raised when running under Python 3 #15

Closed stsci-hack closed 7 years ago

stsci-hack commented 7 years ago

The sky subtraction step in astrodrizzle will raise an exception, at least when run under Python 3; namely,

Exception in Tkinter callback Traceback (most recent call last): File "/user/hack/dev/release/anaconda3/envs/rtdev35/lib/python3.5/site-packages/drizzlepac/util.py", line 219, in wrapper func(*args, **kwargs) File "/user/hack/dev/release/anaconda3/envs/rtdev35/lib/python3.5/site-packages/drizzlepac/astrodrizzle.py", line 204, in run sky.subtractSky(imgObjList, configobj, procSteps=procSteps) File "/user/hack/dev/release/anaconda3/envs/rtdev35/lib/python3.5/site-packages/drizzlepac/sky.py", line 203, in subtractSky _skymatch(imageObjList, paramDict, inmemory, clean, log) File "/user/hack/dev/release/anaconda3/envs/rtdev35/lib/python3.5/site-packages/drizzlepac/sky.py", line 312, in _skymatch fi.mask_images[k], fi.maskext[k], in_memory) File "/user/hack/dev/release/anaconda3/envs/rtdev35/lib/python3.5/site-packages/drizzlepac/sky.py", line 450, in _buildStaticDQUserMask randomize_prefix=False) File "/user/hack/dev/release/anaconda3/envs/rtdev35/lib/python3.5/site-packages/stsci.skypac-0.9.5-py3.5.egg/stsci/skypac/utils.py", line 280, in temp_mask_file

write data to the "temporary" file

File "/user/hack/dev/release/anaconda3/envs/rtdev35/lib/python3.5/site-packages/astropy/utils/decorators.py", line 492, in wrapper return function(*args, *kwargs) File "/user/hack/dev/release/anaconda3/envs/rtdev35/lib/python3.5/site-packages/astropy/io/fits/hdu/hdulist.py", line 864, in writeto fileobj = _File(fileobj, mode='ostream', overwrite=overwrite) File "/user/hack/dev/release/anaconda3/envs/rtdev35/lib/python3.5/site-packages/astropy/utils/decorators.py", line 492, in wrapper return function(args, **kwargs) File "/user/hack/dev/release/anaconda3/envs/rtdev35/lib/python3.5/site-packages/astropy/io/fits/file.py", line 128, in init objmode = _normalize_fits_mode(fileobj_mode(fileobj)) File "/user/hack/dev/release/anaconda3/envs/rtdev35/lib/python3.5/site-packages/astropy/io/fits/file.py", line 86, in _normalize_fits_mode "files must be opened in binary mode".format(mode)) ValueError: Text mode 'w' not supported: files must be opened in binary mode

This looks to be caused by a change in the behavior of io in Python 3.

mcara commented 7 years ago

@stsci-hack This error fundamentally appears to be related to https://github.com/spacetelescope/drizzlepac/issues/84 - see this issue for more details. Specifically, I have identified the reason for this error to be in the https://github.com/astropy/astropy/pull/6373 PR by @drdavella (as the trigger; I will have to see exactly what in skypac disagrees with https://github.com/astropy/astropy/pull/6373).

mcara commented 7 years ago

@stsci-hack Did you set in_memory to "yes"?

mcara commented 7 years ago

Fixed by @stsci-hack in https://github.com/spacetelescope/stsci.skypac/pull/16