{"action":"opened","issue":{"url":"https://api.github.com/repos/mperrin/webbpsf/issues/148","repository_url":"https://api.github.com/repos/mperrin/webbpsf","labels_url":"https://api.github.com/repos/mperrin/webbpsf/issues/148/labels{/name}","comments_url":"https://api.github.com/repos/mperrin/webbpsf/issues/148/comments","events_url":"https://api.github.com/repos/mperrin/webbpsf/issues/148/events","html_url":"https://github.com/mperrin/webbpsf/issues/148","id":187217804,"number":148,"title":"NIRISS GR700XD filter PSF calculation fails on Quantity comparison","user":{"login":"josePhoenix","id":172886,"avatar_url":"https://avatars.githubusercontent.com/u/172886?v=3","gravatar_id":"","url":"https://api.github.com/users/josePhoenix","html_url":"https://github.com/josePhoenix","followers_url":"https://api.github.com/users/josePhoenix/followers","following_url":"https://api.github.com/users/josePhoenix/following{/other_user}","gists_url":"https://api.github.com/users/josePhoenix/gists{/gist_id}","starred_url":"https://api.github.com/users/josePhoenix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josePhoenix/subscriptions","organizations_url":"https://api.github.com/users/josePhoenix/orgs","repos_url":"https://api.github.com/users/josePhoenix/repos","events_url":"https://api.github.com/users/josePhoenix/events{/privacy}","received_events_url":"https://api.github.com/users/josePhoenix/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-03T23:33:05Z","updated_at":"2016-11-03T23:33:05Z","closed_at":null,"body":"Kevin Volk reports being unable to calculate a GR700XD PSF. Other pupil masks work. Seems to be the result of using Astropy units internally without some necessary conversion.\r\n\r\nMinimal example:\r\n\r\n```python\r\nimport webbpsf\r\nniriss = webbpsf.NIRISS()\r\nniriss.pupil_mask = 'GR700XD'\r\nniriss.calc_psf(monochromatic=1e-6, fov_pixels=2)\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nIn [1]: %paste\r\nimport webbpsf\r\nniriss = webbpsf.NIRISS()\r\nniriss.pupil_mask = 'GR700XD'\r\nniriss.calc_psf(monochromatic=1e-6, fov_pixels=2)\r\n\r\n## -- End pasted text --\r\n/Users/jlong/software/webbpsf/webbpsf/optics.py:341: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 1024 but corresponding boolean dimension is 1\r\n  sag[self.amplitude == 0] = 0 # no OPD in opaque regions (makes no difference in propagation but improves display)\r\n---------------------------------------------------------------------------\r\nUnitsError                                Traceback (most recent call last)\r\n<ipython-input-1-1ad50033a008> in <module>()\r\n      2 niriss = webbpsf.NIRISS()\r\n      3 niriss.pupil_mask = 'GR700XD'\r\n----> 4 niriss.calc_psf(monochromatic=1e-6, fov_pixels=2)\r\n\r\n/Users/jlong/software/poppy/poppy/instrument.py in calc_psf(self, outfile, source, nlambda, monochromatic, fov_arcsec, fov_pixels, oversample, detector_oversample, fft_oversample, rebin, clobber, display, save_intermediates, return_intermediates, normalize)\r\n    263         self.optsys = self._getOpticalSystem(fov_arcsec=fov_arcsec, fov_pixels=fov_pixels,\r\n    264                                              fft_oversample=fft_oversample, detector_oversample=detector_oversample,\r\n--> 265                                              options=local_options)\r\n    266         self._check_for_aliasing(wavelens)\r\n    267         # and use it to compute the PSF (the real work happens here, in code in poppy.py)\r\n\r\n/Users/jlong/software/webbpsf/webbpsf/webbpsf_core.py in _getOpticalSystem(self, fft_oversample, detector_oversample, fov_arcsec, fov_pixels, options)\r\n    591         optsys = SpaceTelescopeInstrument._getOpticalSystem(self,\r\n    592             fft_oversample=fft_oversample, detector_oversample=detector_oversample, fov_arcsec=fov_arcsec, fov_pixels=fov_pixels,\r\n--> 593             options=options)\r\n    594         optsys.planes[0].display_annotate = utils.annotate_ote_entrance_coords\r\n    595         #optsys.planes[-2].display_annotate = utils.annotate_sky_pupil_coords\r\n\r\n/Users/jlong/software/webbpsf/webbpsf/webbpsf_core.py in _getOpticalSystem(self, fft_oversample, detector_oversample, fov_arcsec, fov_pixels, options)\r\n    444         if self.image_mask is not None or self.pupil_mask is not None or ('force_coron' in options and options['force_coron']):\r\n    445             _log.debug(\"Adding coronagraph/spectrograph optics...\")\r\n--> 446             optsys, trySAM, SAM_box_size = self._addAdditionalOptics(optsys, oversample=fft_oversample)\r\n    447         else: trySAM = False\r\n    448\r\n\r\n/Users/jlong/software/webbpsf/webbpsf/webbpsf_core.py in _addAdditionalOptics(self, optsys, oversample)\r\n   1273             optsys.planes[-1].wavefront_display_hint='intensity'\r\n   1274         elif self.pupil_mask == 'GR700XD':\r\n-> 1275             optsys.add_pupil(optic = NIRISS_GR700XD_Grism(shift=shift))\r\n   1276\r\n   1277         elif (self.pupil_mask  is None and self.image_mask is not None):\r\n\r\n/Users/jlong/software/webbpsf/webbpsf/optics.py in __init__(self, name, which, shift)\r\n    266\r\n    267         # perform an initial population of the OPD array for display etc.\r\n--> 268         tmp = self.get_phasor(poppy.Wavefront(2e-6))\r\n    269\r\n    270     def get_opd(self, wave):\r\n\r\n/Users/jlong/software/poppy/poppy/optics.py in get_phasor(self, wave)\r\n    106         scale = 2. * np.pi / wavelength.to(u.meter).value\r\n    107\r\n--> 108         return self.get_transmission(wave) * np.exp (1.j * self.get_opd(wave) * scale)\r\n    109\r\n    110     def getPhasor(self,wave):\r\n\r\n/Users/jlong/software/webbpsf/webbpsf/optics.py in get_opd(self, wave)\r\n    345\r\n    346         # scale for index of refraction\r\n--> 347         index = self.ZnS_index(wavelength)\r\n    348         opd = sag *  ( index-1)\r\n    349         _log.debug(\" Scaling for ZnS index of refraction {0} at {1:.3g} microns\".format(index, wavelength*1e6))\r\n\r\n/Users/jlong/software/webbpsf/webbpsf/optics.py in ZnS_index(self, wavelength, temperature)\r\n    403             S_i =       S_ij[i,0]      + S_ij[i,1]     *T + S_ij[i,2]     *T**2.0 + S_ij[i,3]     *T**3.0 + S_ij[i,4]     *T**4.0\r\n    404             lambda_i =  lambda_ij[i,0] + lambda_ij[i,1]*T + lambda_ij[i,2]*T**2.0 + lambda_ij[i,3]*T**3.0 + lambda_ij[i,4]*T**4.0\r\n--> 405             n2minus1 += S_i*lambda_micron**2.0/(lambda_micron**2.0 - lambda_i**2.0)\r\n    406\r\n    407         cleartran_index = np.sqrt(1.0 + n2minus1)\r\n\r\n/Users/jlong/software/astropy/astropy/units/quantity.py in __array_prepare__(self, obj, context)\r\n    376                                      \"argument is not a quantity (unless the \"\r\n    377                                      \"latter is all zero/infinity/nan)\"\r\n--> 378                                      .format(function.__name__))\r\n    379             except TypeError:\r\n    380                 # _can_have_arbitrary_unit failed: arg could not be compared\r\n\r\nUnitsError: Can only apply 'subtract' function to dimensionless quantities when other argument is not a quantity (unless the latter is all zero/infinity/nan)\r\n```"}}
{"actor":{"display_login":"josePhoenix"}}