I have another case where a user input wavelength grid crashes Simulator creation. This is related to #60 but was not completely fixed there. I don't completely understand why pixel_edges and sim_edges are different concepts that need to be compared for consistency, so punting this to @dkirkby to take a look.
Crashes on specsim/camera.py line 236 since the pixel_edges and sim_edges arrays have different lengths (traceback below).
It is unclear to me whether config.wavelength_grid.max is inclusive or exclusive (i.e. should I include the + dwave/2.0 part or not), but neither case works. I think it is the user's responsibility to ensure that downsample = delta_wave_out / delta_wave_in can be an integer, but I'm not sure whether the user is responsible for ensuring that len(wavelengths) % downsample == 0 or what the constraints are regarding wavelength grids that extend beyond the instrument coverage or don't cover the full instrument. i.e. it is possible that this case wasn't supposed to work, but it would sure be handy if it did.
Final parts of the traceback:
/Users/sbailey/desi/git/specsim/lib/python3.5/site-packages/specsim-0.9.dev693-py3.5.egg/specsim/camera.py in __init__(self, name, wavelength, throughput, row_size, fwhm_resolution, neff_spatial, read_noise, dark_current, gain, num_sigmas_clip, output_pixel_size)
234 0.5 * wavelength_step)
235 if not np.allclose(
--> 236 pixel_edges, sim_edges, rtol=0., atol=1e-6 * wavelength_step):
237 raise ValueError(
238 'Cannot downsample {0}-camera pixels from {1:f} to {2} {3}.'
/Users/sbailey/anaconda/envs/desi/lib/python3.5/site-packages/numpy/core/numeric.py in allclose(a, b, rtol, atol, equal_nan)
2370
2371 """
-> 2372 res = all(isclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan))
2373 return bool(res)
2374
/Users/sbailey/anaconda/envs/desi/lib/python3.5/site-packages/numpy/core/numeric.py in isclose(a, b, rtol, atol, equal_nan)
2451 yfin = isfinite(y)
2452 if all(xfin) and all(yfin):
-> 2453 return within_tol(x, y, atol, rtol)
2454 else:
2455 finite = xfin & yfin
/Users/sbailey/anaconda/envs/desi/lib/python3.5/site-packages/numpy/core/numeric.py in within_tol(x, y, atol, rtol)
2434 def within_tol(x, y, atol, rtol):
2435 with errstate(invalid='ignore'):
-> 2436 result = less_equal(abs(x-y), atol + rtol * abs(y))
2437 if isscalar(a) and isscalar(b):
2438 result = bool(result)
ValueError: operands could not be broadcast together with shapes (2400,) (2399,)
I have another case where a user input wavelength grid crashes Simulator creation. This is related to #60 but was not completely fixed there. I don't completely understand why
pixel_edges
andsim_edges
are different concepts that need to be compared for consistency, so punting this to @dkirkby to take a look.Crashes on specsim/camera.py line 236 since the
pixel_edges
andsim_edges
arrays have different lengths (traceback below).It is unclear to me whether
config.wavelength_grid.max
is inclusive or exclusive (i.e. should I include the+ dwave/2.0
part or not), but neither case works. I think it is the user's responsibility to ensure thatdownsample = delta_wave_out / delta_wave_in
can be an integer, but I'm not sure whether the user is responsible for ensuring thatlen(wavelengths) % downsample == 0
or what the constraints are regarding wavelength grids that extend beyond the instrument coverage or don't cover the full instrument. i.e. it is possible that this case wasn't supposed to work, but it would sure be handy if it did.Final parts of the traceback: