Skip to content

pmcx.utils.detweight method does not support native detp['w0'] generated from pmcx.mcxlab() #254

@MABansept

Description

@MABansept

When passing a detp dictionary containing the photon initial weight w0 as natively produced by the simulation, to the detweight util method it returns an array of shape (nphotons, nphotons). The issue seems to arise from the fact that detp['w0'] is of shape (nphotons,1) and detweight expects an array of shape (nphotons). When no w0 is present in the detp the method correctly produces a w0 vector of the correct shape. A simple fix would seem to be to add an np.squeeze(). I'm assuming however that detp['w0'] is supposed to be of shape (nphotons, nsource) in which case the method would still not work as expected.

if isinstance(detp, dict):
        if "w0" not in detp:
            detw = np.ones(detp["ppath"].shape[0])
        else:
            detw = np.squeeze(detp["w0"]) <----------

        for i in range(medianum - 1):
            detw = detw * np.exp(-prop[i + 1, 0] * detp["ppath"][:, i] * unitinmm)
    else:
        raise ValueError('The first input must be a dict with a key named "ppath"')

    return detw

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions