Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow unicode in filter names and other options #18

Closed
mperrin opened this issue Sep 25, 2014 · 2 comments
Closed

Allow unicode in filter names and other options #18

mperrin opened this issue Sep 25, 2014 · 2 comments
Labels
Milestone

Comments

@mperrin
Copy link
Owner

mperrin commented Sep 25, 2014

Bug report from Brian York:

A quick update.

On the one hand, issue diagnosed and worked around. It turns out 
that webbpsf can't deal with filter names in unicode, so by explicitly 
encoding filters as ASCII before passing them in I avoid crashes.

On the other hand, not handling unicode strings is probably something 
to fix if you should ever happen to have the time and resources.
@mperrin mperrin added the bug label Sep 25, 2014
@mperrin mperrin added this to the 0.4 milestone Sep 25, 2014
@mperrin
Copy link
Owner Author

mperrin commented Sep 25, 2014

More detail from Brian, from his email 2014 July 14 :

The errors I'm getting are as follows. When running the simulator, and
creating a MIRI PSF, I get:

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line
240, in trace_task
R = retval = fun(_args, *_kwargs)
File "/webapp/simulator.py", line 52, in call
return TaskBase.call(self, _args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line
437, in protected_call
return self.run(_args, *_kwargs)
File "/webapp/simulator.py", line 113, in simulate
psf_fits = obs.AddError()
File "/webapp/lib/ObservationModule.py", line 198, in AddError
psf_data,psf_pixel_scale_x,psf_pixel_scale_y =
self._image.ConvolvePSF()
File "/webapp/lib/JwstImage.py", line 342, in ConvolvePSF
psf = ins.calcPSF(oversample=self._scaleFactor)
File "/usr/local/lib/python2.7/dist-packages/webbpsf/webbpsf.py", line
367, in calcPSF
wavelens, weights = self._getWeights(source=source, nlambda=nlambda,
monochromatic=monochromatic)
File "build/bdist.linux-x86_64/egg/poppy/instrument.py", line 634, in
_getWeights
File "/usr/local/lib/python2.7/dist-packages/webbpsf/webbpsf.py", line
565, in _getSynphotBandpass
filterdata = atpy.Table(self._filter_files[wf], type='fits')
TypeError: only integer arrays with one element can be converted to an
index

The key point is that calcPSF dies off somewhere in atpy.Table I think,
and I'm not sure what's happening. I do have astropy installed, so if
removing atpy would be helpful I can try that.

The second is in trying to figure out what was happening. In this case, I
started up a shell on the test server and started python and did the
sample webbpsf scripting code, which got me this error:

import os
os.environ['PYSYN_CDBS'] = "/webapp/sim_input/cdbs"
from webbpsf import *
nc = NIRCam()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/webbpsf/webbpsf.py", line
760, in init
JWInstrument.init(self, "NIRCam") # do this after setting the long
& short scales.
File "/usr/local/lib/python2.7/dist-packages/webbpsf/webbpsf.py", line
145, in init
filter_table = atpy.Table(self._WebbPSF_basepath + os.sep+
'filters.txt',type='ascii',delimiter='\t')
File "/usr/local/lib/python2.7/dist-packages/atpy/basetable.py", line
168, in init
self.read(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/atpy/basetable.py", line
214, in read
registry._readers[table_type](self, *args, **kwargs)
File "", line 2, in read_ascii
File "/usr/local/lib/python2.7/dist-packages/atpy/decorators.py", line
44, in _auto_download_to_file
return read(table, filename, _args, *_kwargs)
File "", line 2, in read_ascii
File "/usr/local/lib/python2.7/dist-packages/atpy/decorators.py", line
56, in _auto_decompress_to_fileobj
header = open(filename, 'rb').read(4)
IOError: [Errno 20] Not a directory:
'/usr/local/lib/python2.7/dist-packages/poppy-0.2.8-py2.7.egg/data/filters.
txt'
mi = MIRI()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/webbpsf/webbpsf.py", line
591, in init
JWInstrument.init(self, "MIRI")
File "/usr/local/lib/python2.7/dist-packages/webbpsf/webbpsf.py", line
145, in init
filter_table = atpy.Table(self._WebbPSF_basepath + os.sep+
'filters.txt',type='ascii',delimiter='\t')
File "/usr/local/lib/python2.7/dist-packages/atpy/basetable.py", line
168, in init
self.read(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/atpy/basetable.py", line
214, in read
registry._readers[table_type](self, *args, **kwargs)
File "", line 2, in read_ascii
File "/usr/local/lib/python2.7/dist-packages/atpy/decorators.py", line
44, in _auto_download_to_file
return read(table, filename, _args, *_kwargs)
File "", line 2, in read_ascii
File "/usr/local/lib/python2.7/dist-packages/atpy/decorators.py", line
56, in _auto_decompress_to_fileobj
header = open(filename, 'rb').read(4)
IOError: [Errno 20] Not a directory:
'/usr/local/lib/python2.7/dist-packages/poppy-0.2.8-py2.7.egg/data/filters.
txt'

@mperrin
Copy link
Owner Author

mperrin commented Nov 19, 2014

Cannot reproduce on current master. This was probably an atpy issue, now irrelevant since we switched to astropy.table for the FITS table IO.

Test case added anyway in commit 011022c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant