Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion applications/pctpairprotons/pctpairprotons.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ def load_tree_as_df(root_file, tree_name):
tree = uproot.open(root_file)[tree_name]
branches = tree.arrays(library="np")

dtype = [(name, branch.dtype) for name, branch in branches.items()]
# Some versions of uproot return a dictionnary, and some others a numpy.ndarray
# We handle both cases here to generate the dtype
if isinstance(branches, dict):
dtype = [(name, branch.dtype) for name, branch in branches.items()]
elif isinstance(branches, np.ndarray):
dtype = branches.dtype.descr
else:
raise NotImplementedError

ps = np.rec.recarray((len(branches["RunID"]),), dtype=dtype)
for branch_name, _ in dtype:
ps[branch_name] = branches[branch_name]
Expand Down
7 changes: 7 additions & 0 deletions documentation/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,10 @@ in the user's `.bashrc` file. This allows to run PCT applications from anywhere
pip install opengate
```
An example of proton CT GATE simulation can be found in [`gate/protonct.py`](https://github.com/RTKConsortium/PCT/blob/main/gate/protonct.py).

### Uproot

[Uproot](https://uproot.readthedocs.io/) is a library for reading and writing ROOT files in pure Python and NumPy. Some applications of PCT require Uproot, such as `pctpairprotons` and `pctweplfit`. The simplest way to install Uproot is by running
```bash
pip install uproot
```
Loading