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

config wavelength grid crashing Simulator creation #64

Closed
sbailey opened this issue Apr 24, 2017 · 0 comments
Closed

config wavelength grid crashing Simulator creation #64

sbailey opened this issue Apr 24, 2017 · 0 comments

Comments

@sbailey
Copy link
Contributor

sbailey commented Apr 24, 2017

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.

import specsim.config
import specsim.simulator

config = specsim.config.load_config('desi')
dwave = 0.2
config.wavelength_grid.min = 3554.05
config.wavelength_grid.max = 9912.85 # + dwave/2.0
config.wavelength_grid.step = dwave
config.instrument.cameras.b.constants.output_pixel_size = "1.0 Angstrom"
config.instrument.cameras.r.constants.output_pixel_size = "1.0 Angstrom"
config.instrument.cameras.z.constants.output_pixel_size = "1.0 Angstrom"
config.update()

desi = specsim.simulator.Simulator(config)

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,) 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant