spacetelescope / roman_tools

Instructions and tutorials for Roman software tools distributed by STScI for the science community
BSD 3-Clause "New" or "Revised" License
14 stars 6 forks source link

Errors following tutorial notebook for Imager #37

Open rmjarvis opened 4 years ago

rmjarvis commented 4 years ago

I'm trying to run the Pandeia-WFIRST notebook, and it works if I run it straight through, but not if I try to just run the Imager sections.

I think the following should be the relevant sections for simulating with the Imager:

from pandeia.engine.perform_calculation import perform_calculation
from pandeia.engine.calc_utils import build_default_calc

# Follow the notebook here, selecting sections relevant to Imager:
# https://github.com/spacetelescope/wfirst-tools/blob/master/notebooks/Pandeia-WFIRST.ipynb
calc = build_default_calc('wfirst','wfirstimager','imager')

# This fails already:
#results = perform_calculation(calc)

# Put a galaxy in the scene:
calc['scene'][0]['spectrum']['sed']['sed_type'] = 'brown' # shape
calc['scene'][0]['spectrum']['sed']['key'] = 'ngc_3521' # galaxy profile

calc['scene'][0]['shape']['geometry'] = 'sersic'
calc['scene'][0]['shape']['major'] = 0.5 # arcsec
calc['scene'][0]['shape']['minor'] = 0.2 # arcsec
calc['scene'][0]['shape']['sersic_index'] = 1.0
calc['scene'][0]['shape']['norm_method'] = 'surf_scale'
calc['scene'][0]['shape']['surf_area_units'] = 'sr'

# Set up the imager:
calc['configuration']['instrument']['filter'] = "f087"  # z band
calc['configuration']['instrument']['aperture'] = "any"
calc['configuration']['instrument']['disperser'] = None
calc['configuration']['detector']['ngroup'] = 6 # groups per integration
calc['configuration']['detector']['nint'] = 1 # integrations per exposure
calc['configuration']['detector']['nexp'] = 1 # exposures
calc['configuration']['detector']['readout_pattern'] = "medium8"
calc['configuration']['detector']['subarray'] = "1024x1024"

# Set up observing strategy
calc['strategy']['target_xy'] = [0.0,0.0] # x,y location to extract, in arcsec
calc['strategy']['aperture_size'] = 0.2 # radius of extraction aperture, in arcsec
calc['strategy']['sky_annulus'] = [0.4,0.6] # inner and outer radii of background subtraction annulus, in arcsec

# This also fails
results = perform_calculation(calc)
print(results)

But either place I do perform_calculation(calc), it fails with the following error:

$ python pand.py
Traceback (most recent call last):
  File "pand.py", line 9, in <module>
    results = perform_calculation(calc)
  File "/anaconda3/envs/astroconda/lib/python3.6/site-packages/pandeia/engine/perform_calculation.py", line 39, in perform_calculation
    report = calculate_sn(calc_input, webapp=webapp)
  File "/anaconda3/envs/astroconda/lib/python3.6/site-packages/pandeia/engine/etc3D.py", line 1384, in calculate_sn
    my_detector_signal = DetectorSignal(o, calc_config=calc_config, webapp=webapp, order=None)
  File "/anaconda3/envs/astroconda/lib/python3.6/site-packages/pandeia/engine/etc3D.py", line 115, in __init__
    slice_rate = self.all_rates(flux_cube, add_extended_background=False)
  File "/anaconda3/envs/astroconda/lib/python3.6/site-packages/pandeia/engine/etc3D.py", line 389, in all_rates
    fp_pix_rate_ipc = self.ipc_convolve(fp_pix_rate, kernel)
  File "/anaconda3/envs/astroconda/lib/python3.6/site-packages/pandeia/engine/etc3D.py", line 716, in ipc_convolve
    fp_pix_ipc = sg.fftconvolve(rate, kernel, mode='same')
  File "/anaconda3/envs/astroconda/lib/python3.6/site-packages/scipy/signal/signaltools.py", line 542, in fftconvolve
    ret = _freq_domain_conv(in1, in2, axes, shape, calc_fast_len=True)
  File "/anaconda3/envs/astroconda/lib/python3.6/site-packages/scipy/signal/signaltools.py", line 383, in _freq_domain_conv
    sp2 = fft(in2, fshape, axes=axes)
  File "/anaconda3/envs/astroconda/lib/python3.6/site-packages/scipy/fft/_backend.py", line 23, in __ua_function__
    return fn(*args, **kwargs)
  File "/anaconda3/envs/astroconda/lib/python3.6/site-packages/scipy/fft/_pocketfft/basic.py", line 186, in r2cn
    return pfft.r2c(tmp, axes, forward, norm, None, workers)
RuntimeError: unsupported data type

I don't know if this is a bug in the backend pandeia code or an error in the Notebook. Any help you can offer would be appreciated. I'm trying to learn on how to use these tools. Thanks!

ariedel commented 4 years ago

That is a bug when using the Engine with scipy 1.4+. Try downgrading scipy to 1.3, or upgrading Pandeia to 1.5.2 (out soon)