From 4f696ad894cafa290d42ec13752d12ea1262599e Mon Sep 17 00:00:00 2001 From: John ZuHone Date: Mon, 7 Oct 2024 12:49:12 -0400 Subject: [PATCH] Bugfix --- pyxsim/photon_list.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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]