diff --git a/pyxsim/photon_list.py b/pyxsim/photon_list.py index ee7bebe..ad4cf0d 100644 --- a/pyxsim/photon_list.py +++ b/pyxsim/photon_list.py @@ -417,9 +417,12 @@ def make_photons( p_size *= 2 d["energy"].resize((p_size,)) + if w_field is None: + dx = 0.0 + else: + dx = chunk[w_field][idxs].to_value("kpc") for i, ax in enumerate("xyz"): pos = chunk[p_fields[i]][idxs].to_value("kpc") - dx = chunk[w_field][idxs].to_value("kpc") # Fix photon coordinates for regions crossing a periodic boundary if ds.periodicity[i]: tfl = pos + dx < le[i] @@ -439,9 +442,7 @@ def make_photons( if w_field is None: d["dx"][c_offset : c_offset + chunk_nc] = 0.0 else: - d["dx"][c_offset : c_offset + chunk_nc] = chunk[w_field][idxs].to_value( - "kpc" - ) + d["dx"][c_offset : c_offset + chunk_nc] = dx for field in fields_store: d[field[1]][c_offset : c_offset + chunk_nc] = chunk[field][idxs]