TypeError: 'float' object cannot be interpreted as an index

neb149neb149 Member Posts: 2
This Problem report should go under Pandeia Engine but for some reason there are no categories available for that.


A few users have reported the following problem to me with coords.py. I haven't really been able to figure out what is causing it, although I think its a Python 2.7.10-2.7.12 issue. Line 36 "ones = np.ones((ny, nx))" throws the following error (pasted below). We found a fix to it by forcing ny and nx as ints: ones = np.ones((int(ny), int(nx))). Not an elegant fix, but it seems to work.

/Softwares/anaconda/envs/astroconda/lib/python2.7/site-packages/pandexo/engine/jwst.pyc in compute_maxexptime_per_int(pandeia_input, sat_level)
288 pandeia_input['configuration']['detector']['nexp'] = 1
289
--> 290 report = perform_calculation(pandeia_input, dict_report=False)
291 report_dict = report.as_dict()
292

/Softwares/anaconda/envs/astroconda/lib/python2.7/site-packages/pandeia/engine/perform_calculation.pyc in perform_calculation(calc_input, reverse, dict_report, webapp)
35 report = calculate_exposure_time(calc_input, webapp=webapp)
36 else:
---> 37 report = calculate_sn(calc_input, webapp=webapp)
38
39 if dict_report:

/Softwares/anaconda/envs/astroconda/lib/python2.7/site-packages/pandeia/engine/etc3D.pyc in calculate_sn(input, webapp)
1262 my_detector_signal = CombinedSignal(order_signals)
1263 else:
-> 1264 my_detector_signal = DetectorSignal(o, calc_config=calc_config, webapp=webapp, order=None)
1265
1266 my_detector_noise = DetectorNoise(my_detector_signal, o)

/Softwares/anaconda/envs/astroconda/lib/python2.7/site-packages/pandeia/engine/etc3D.pyc in __init__(self, observation, calc_config, webapp, order)
92 background=self.background,
93 psf_library=self.current_instrument.psf_library,
---> 94 webapp=webapp
95 )
96

/Softwares/anaconda/envs/astroconda/lib/python2.7/site-packages/pandeia/engine/astro_spectrum.pyc in __init__(self, scene, instrument, background, psf_library, webapp)
731
732 self.grid, self.aperture_list, self.flux_cube_list, self.flux_plus_bg_list = \
--> 733 self.create_flux_cube(background=self.background)
734 self.dist = self.grid.dist()
735

/Softwares/anaconda/envs/astroconda/lib/python2.7/site-packages/pandeia/engine/astro_spectrum.pyc in create_flux_cube(self, background)
868 multishutter=self.multishutter,
869 nslice=self.nslice,
--> 870 bg_w=self.bg[iw]
871 )
872 else:

/Softwares/anaconda/envs/astroconda/lib/python2.7/site-packages/pandeia/engine/astro_spectrum.pyc in __init__(self, wave, psf_library, instrument, mode, model_scene, psf_source_offset, aper_width, aper_height, multishutter, nslice, bg_w)
1086 slice_mask_fine = np.ones((scene_npix, scene_npix))
1087 slice_int, slice_int_plus_bg, slice_mask = self._apply_slit_mask(slice_mask_fine, new_shape)
-> 1088 self.grid = Grid(psf_pixscl * psf_upsamp, psf_pixscl * psf_upsamp, npix, npix)
1089 self.slice_int_list = [slice_int]
1090 self.slice_int_plus_bg_list = [slice_int_plus_bg]

/Softwares/anaconda/envs/astroconda/lib/python2.7/site-packages/pandeia/engine/coords.pyc in __init__(self, xsamp, ysamp, nx, ny)
34 yvals = np.linspace(starty, stopy, num=ny)
35
---> 36 ones = np.ones((ny, nx))
37 x = ones * xvals
38 y = np.flipud(ones * yvals.reshape(int(ny), 1))

/Softwares/anaconda/envs/astroconda/lib/python2.7/site-packages/numpy/core/numeric.pyc in ones(shape, dtype, order)
190
191 """
--> 192 a = empty(shape, dtype, order)
193 multiarray.copyto(a, 1, casting='unsafe')
194 return a

TypeError: 'float' object cannot be interpreted as an index

Comments

  • laidlerlaidler Member, Administrator, Institute_Staff, jwst_etc_admin Posts: 10 admin
    Thank you for reporting this; we will post it as a known issue with a workaround.
    Please direct all future communications through the JWST help desk, jwsthelp.stsci.edu. Thank you!
Sign In or Register to comment.