LSSTDESC / cosmodc2

Python package creating the cosmoDC2 synthetic galaxy catalog for LSST-DESC
Other
7 stars 1 forks source link

V1 bugfix #80

Closed aphearin closed 5 years ago

aphearin commented 5 years ago

This PR resolves a bug leading to the failed job reported by @evevkovacs.

Traceback (most recent call last):
  File "run_cosmoDC2_healpix_production.py", line 156, in <module>
    nzdivs=args.nzdivs, Nside_cosmoDC2=args.nside, z2ts=z2ts)
  File 
"/home/ekovacs/cosmology/cosmodc2/cosmodc2/write_umachine_healpix_mock_to_disk.py", 
line 361, in write_umachine_healpix_mock_to_disk
    halo_unique_id=halo_unique_id, redshift_method='halo', 
use_centrals=use_centrals)
  File 
"/home/ekovacs/cosmology/cosmodc2/cosmodc2/write_umachine_healpix_mock_to_disk.py", 
line 542, in build_output_snapshot_mock
    dc2['mpeak'][ultra_high_mvir_halo_mask], 
dc2['obs_sm'][ultra_high_mvir_halo_mask])
  File 
"/home/ekovacs/cosmology/cosmodc2/cosmodc2/stellar_mass_remapping/remap_high_mass_smhm.py", 
line 26, in remap_stellar_mass_in_snapshot
    np.log10(mpeak), [logmpeak_low, logmpeak_high], [0, 1])
  File 
"/soft/libraries/anaconda-unstable/lib/python2.7/site-packages/numpy/lib/function_base.py", 
line 1663, in interp
    return compiled_interp(x, xp, fp, left, right)
ValueError: object too deep for desired array

I'm a little puzzled by this error and I'm not sure that this is the right fix. This "object too deep" error usually happens when the input array has the wrong shape, for example if np.interp is passed a 2-d array. At the very least, the remap_stellar_mass_in_snapshot function should have been passed a float for the redshift, so that smells like the culprit even though the traceback does not quite make sense; this PR does fix that error by passing in the snapshot redshift rather than an array.

Additionally, before calling the remap_stellar_mass_in_snapshot function from within the write_healpix script, I added in some assert statements to enforce that all arguments have the correct shape. So I think this code is ready to run again, and if it fails again then this time it will be more informative.

@evevkovacs - if it is easy to run an interactive job using a single input file that failed, that would be ideal. If the code passes that trial, then we should resubmit the full job to hop back in the queue.

CC @dkorytov @patricialarsen

aphearin commented 5 years ago

@evevkovacs - I did some offline experiments on how this function behaves when it is passed a redshift array rather than float, and it does indeed raise a ValueError with the "object too deep" error message. So I do think this PR is likely to resolve the bug, and it's probably worth merging, pulling and resubmitting the full job concurrently with testing in the interactive session.