desihub / specsim

Quick simulations of spectrograph response
2 stars 9 forks source link

Calculate PSF truncation based on actual wavelength grid and PSF size #13

Closed dkirkby closed 9 years ago

dkirkby commented 9 years ago

Fixes #12

Use the following regression test for changes:

specsim% quickspecsim --infile specsim/data/spectra/spec-ABmag22.0.dat --model qso --verbose
spec-ABmag22.0.dat g=22.00 r=22.00 i=22.00
Will simulate wavelengths 3500.300000 - 9999.700000 Ang with 0.100000 Ang spacing.
Running quick simulation.
Median S/N = 0.934, Total (S/N)^2 = 10441.6
dkirkby commented 9 years ago

@weaverba137 TravisCI tests are failing with an error I have not seen before, but which does not seem to be related to any changes I made:

...
$ conda update --yes conda
/home/travis/build.sh: line 41: conda: command not found
The command "conda update --yes conda" failed and exited with 127 during .

Have you seen this before, or any suggestions?

dkirkby commented 9 years ago

@sbailey The following test now gives more reasonable results:

import specsim
import astropy.units as u
import os

model = os.environ['SPECSIM_MODEL']
atmosphere = specsim.atmosphere.Atmosphere(skyConditions='dark', basePath=model)
qsim = specsim.quick.Quick(atmosphere=atmosphere, basePath=model)
qsim.setWavelengthGrid(5000.1, 5010-0.1, 0.1)

w = np.arange(5000, 5010, 0.1)
influx = np.ones(len(w)) * 1e-17
influx[50] = 10e-17
spectrum = specsim.spectrum.SpectralFluxDensity(
    w, influx, fluxUnits=u.erg/(u.s*u.cm**2*u.angstrom))

results = qsim.simulate('elg', spectrum, downsampling=1)
plt.plot(results.wave, results.srcflux / 10, label='Template / 10')
plt.plot(results.wave, results.obsflux, label='Observed')
plt.legend()

pr12

You should generally specify a simulation wavelength grid that extends ~5 sigma beyond the camera coverage, otherwise you get the unphysical edge effects seen here.

weaverba137 commented 9 years ago

In the build script, where you have the line:

./miniconda.sh -b

Replace that with

./miniconda.sh -b -p $HOME/miniconda
dkirkby commented 9 years ago

@weaverba137 That works, thanks!

dkirkby commented 9 years ago

@sbailey I am ready to merge this, but let me know if you want to review the changes first.

sbailey commented 9 years ago

Whoops, sorry, I had missed that you had assigned it to me to review. Go ahead and merge. Thanks.