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

add options to disable sky model, and read noise, bias level, and dark current #224

Merged
merged 6 commits into from
Aug 2, 2019

Conversation

jchiang87
Copy link
Collaborator

Also add version info to raw file primary HDU

@jchiang87 jchiang87 requested a review from cwwalter July 8, 2019 00:16
@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 73.531% when pulling 4b3e1f0 on u/jchiang/disable_read_noise_and_bias_option into 9950955 on master.

@kadrlica
Copy link

kadrlica commented Jul 9, 2019

Thanks @jchiang87. We've been trying to run this update with a simple instcat containing a single point source and a single extended source. The new code runs with the extended source, but fails on the point source with the error message below. We believe we've tracked this back to this line in galSimInterpreter.py, which is setting folding_threshold=0 when there is no sky bacgkround.

> imsim.py instcat_test_g.txt --config_file imsim_configs.txt --outdir imsim_out --sensor "R:2,2 S:1,1" --log_level DEBUG
DEBUG:ImageSimulator:parsing instance catalog for 1 sensor(s)
DEBUG:parsePhoSimInstanceFile:creating InstCatTrimmer object
DEBUG:InstCatTrimmer:read 22 objects
DEBUG:InstCatTrimmer:getting objects for R:2,2 S:1,1
DEBUG:InstCatTrimmer:computing object offsets from R:2,2 S:1,1 center
DEBUG:InstCatTrimmer:sorting by magnorm
DEBUG:R:2,2 S:1,1:allocating object arrays, 0.5932502746582031 GB
DEBUG:R:2,2 S:1,1:looping over 2 objects; 0.5932502746582031 GB
DEBUG:R:2,2 S:1,1:computing pupil coords, 0.5932502746582031 GB
DEBUG:R:2,2 S:1,1:down-selecting by chip, 0.5933723449707031 GB
DEBUG:R:2,2 S:1,1:constructing GalSimCelestialObjects for 2 objects; 0.5934333801269531 GB
DEBUG:R:2,2 S:1,1:objects remaining 2
DEBUG:R:2,2 S:1,1:about to return from sources_from_list, 0.5934333801269531 GB
INFO:R:2,2 S:1,1:drawing 2 objects
DEBUG:R:2,2 S:1,1:3  3900542.963636501  sersic
DEBUG:R:2,2 S:1,1:12  276829.1254957789  pointSource
Traceback (most recent call last):
  File "/global/u2/k/kadrlica/software/imSim/bin/imsim.py", line 94, in <module>
    image_simulator.run(processes=args.processes)
  File "/global/u2/k/kadrlica/software/imSim/python/desc/imsim/ImageSimulator.py", line 255, in run
    results.append(simulate_sensor(self.gs_obj_dict[det_name]))
  File "/global/u2/k/kadrlica/software/imSim/python/desc/imsim/ImageSimulator.py", line 396, in __call__
    fft_sb_thresh=fft_sb_thresh)
  File "/cvmfs/sw.lsst.eu/linux-x86_64/lsst_sims/sims_w_2019_19/stack/miniconda3-4.5.12-1172c30/Linux64/sims_GalSimInterface/2.13.0.sims-3-g15a03cb+11/python/lsst/sims/GalSimInterface/galSimInterpreter.py", line 899, in drawObject
    keep_sb_level, 3*keep_sb_level)
  File "/cvmfs/sw.lsst.eu/linux-x86_64/lsst_sims/sims_w_2019_19/stack/miniconda3-4.5.12-1172c30/Linux64/sims_GalSimInterface/2.13.0.sims-3-g15a03cb+11/python/lsst/sims/GalSimInterface/galSimInterpreter.py", line 1125, in getStampBounds
    image_size = obj.getGoodImageSize(pixel_scale)
  File "/cvmfs/sw.lsst.eu/linux-x86_64/lsst_sims/sims_w_2019_19/stack/miniconda3-4.5.12-1172c30/Linux64/galsim/2.1.4.lsst+5/lib/python/galsim/gsobject.py", line 1765, in getGoodImageSize
    Nd = 2. * math.pi / (pixel_scale * self.stepk)
  File "/cvmfs/sw.lsst.eu/linux-x86_64/lsst_sims/sims_w_2019_19/stack/miniconda3-4.5.12-1172c30/Linux64/galsim/2.1.4.lsst+5/lib/python/galsim/gsobject.py", line 304, in stepk
    return self._stepk
  File "/cvmfs/sw.lsst.eu/linux-x86_64/lsst_sims/sims_w_2019_19/stack/miniconda3-4.5.12-1172c30/Linux64/galsim/2.1.4.lsst+5/lib/python/galsim/utilities.py", line 1454, in __get__
    value = self.fget(obj)
  File "/cvmfs/sw.lsst.eu/linux-x86_64/lsst_sims/sims_w_2019_19/stack/miniconda3-4.5.12-1172c30/Linux64/galsim/2.1.4.lsst+5/lib/python/galsim/convolve.py", line 297, in _stepk
    inv_stepksq_list = [obj.stepk**(-2) for obj in self.obj_list]
  File "/cvmfs/sw.lsst.eu/linux-x86_64/lsst_sims/sims_w_2019_19/stack/miniconda3-4.5.12-1172c30/Linux64/galsim/2.1.4.lsst+5/lib/python/galsim/convolve.py", line 297, in <listcomp>
    inv_stepksq_list = [obj.stepk**(-2) for obj in self.obj_list]
  File "/cvmfs/sw.lsst.eu/linux-x86_64/lsst_sims/sims_w_2019_19/stack/miniconda3-4.5.12-1172c30/Linux64/galsim/2.1.4.lsst+5/lib/python/galsim/gsobject.py", line 304, in stepk
    return self._stepk
  File "/cvmfs/sw.lsst.eu/linux-x86_64/lsst_sims/sims_w_2019_19/stack/miniconda3-4.5.12-1172c30/Linux64/galsim/2.1.4.lsst+5/lib/python/galsim/gaussian.py", line 159, in _stepk
    R = max(math.sqrt(-2.*math.log(self.gsparams.folding_threshold)),
ValueError: math domain error

imsim_configs.txt
instcat_test_g.txt

@kadrlica
Copy link

kadrlica commented Jul 9, 2019

We hacked this line in ImageSimulator.py to set sky_bg_per_pixel to a non-zero value.

            self.gs_interpreters[det_name].sky_bg_per_pixel \
                = max(noise_and_background.sky_counts(det_name),1e-5)

This seems to work (or at least imsim runs), but seems unsafe.

@jchiang87
Copy link
Collaborator Author

I have a plan for doing this correctly. I'll try to find time to do it today.

Copy link
Member

@cwwalter cwwalter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code so far looks good.

I made one forward-looking suggestion.

@@ -4,6 +4,10 @@ dark_current = 0.02
bias_level = 1000.
pcti = 1e-6
scti = 1e-6
disable_readnoise_bias_darkcurrent = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are adding this functionality now, perhaps we should explicitly allow reach of read, noise, bias, and dark current to be turned off.

So there would be:

disable_readnoise
disable_bias
disable_darkcurrent

If we set this pattern up you might imagine other things in the future too (e.g. x-talk or CTE). This way you could choose to have only one on for studies.

I see this would require a little more changes though since currently readnoise and bias are added in one step in one routine.

@jchiang87 jchiang87 merged commit c7654ac into master Aug 2, 2019
@jchiang87 jchiang87 deleted the u/jchiang/disable_read_noise_and_bias_option branch August 2, 2019 21:08
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

Successfully merging this pull request may close these issues.

None yet

4 participants