Skip to content

Commit

Permalink
update output path
Browse files Browse the repository at this point in the history
  • Loading branch information
dsarrut committed Jan 12, 2024
1 parent 7aaceda commit 003dcb1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
29 changes: 15 additions & 14 deletions opengate/tests/src/test060_phsp_source_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import gatetools.phsp as phsp
import opengate as gate
from opengate.tests import utility
from pathlib import Path

# units
m = gate.g4_units.m
Expand All @@ -19,7 +20,7 @@

def create_test_phs(
particle="proton",
phs_name="output/test_proton.root",
phs_name=Path("output") / "test_proton.root",
number_of_particles=1,
translation=[0 * mm, 0 * mm, 0 * mm],
):
Expand Down Expand Up @@ -169,7 +170,7 @@ def create_test_phs(


def create_phs_without_source(
phs_name="output/test_proton.root",
phs_name=Path("output") / "test_proton.root",
):
# create the simulation
sim = gate.Simulation()
Expand Down Expand Up @@ -259,8 +260,8 @@ def create_phs_without_source(


def test_source_name(
source_file_name="output/test_proton_offset.root",
phs_file_name_out="output/output/test_source_electron.root",
source_file_name=Path("output") / "test_proton_offset.root",
phs_file_name_out=Path("output") / "output/test_source_electron.root",
) -> None:
sim = create_phs_without_source(
phs_name=phs_file_name_out,
Expand All @@ -286,8 +287,8 @@ def test_source_name(


def test_source_particle_info_from_phs(
source_file_name="output/test_proton_offset.root",
phs_file_name_out="output/test_source_PDG_proton.root",
source_file_name=Path("output") / "test_proton_offset.root",
phs_file_name_out=Path("output") / "test_source_PDG_proton.root",
) -> None:
sim = create_phs_without_source(
phs_name=phs_file_name_out,
Expand All @@ -312,8 +313,8 @@ def test_source_particle_info_from_phs(


def test_source_translation(
source_file_name="output/test_proton_offset.root",
phs_file_name_out="output/output/test_source_electron.root",
source_file_name=Path("output") / "test_proton_offset.root",
phs_file_name_out=Path("output") / "output/test_source_electron.root",
) -> None:
sim = create_phs_without_source(
phs_name=phs_file_name_out,
Expand All @@ -340,8 +341,8 @@ def test_source_translation(


def test_source_rotation(
source_file_name="output/test_proton_offset.root",
phs_file_name_out="output/output/test_source_electron.root",
source_file_name=Path("output") / "test_proton_offset.root",
phs_file_name_out=Path("output") / "output/test_source_electron.root",
) -> None:
sim = create_phs_without_source(
phs_name=phs_file_name_out,
Expand Down Expand Up @@ -372,8 +373,8 @@ def test_source_rotation(


def test_source_untilPrimary(
source_file_name="output/test_proton_offset.root",
phs_file_name_out="output/output/test_source_electron.root",
source_file_name=Path("output") / "test_proton_offset.root",
phs_file_name_out=Path("output") / "output/test_source_electron.root",
) -> None:
sim = create_phs_without_source(
phs_name=phs_file_name_out,
Expand Down Expand Up @@ -402,7 +403,7 @@ def test_source_untilPrimary(


def get_first_entry_of_key(
file_name_root="output/test_source_electron.root", key="ParticleName"
file_name_root=Path("output") / "test_source_electron.root", key="ParticleName"
) -> None:
# read root file
data_ref, keys_ref, m_ref = phsp.load(file_name_root)
Expand All @@ -415,7 +416,7 @@ def get_first_entry_of_key(


def check_value_from_root_file(
file_name_root="output/test_source_electron.root",
file_name_root=Path("output") / "test_source_electron.root",
key="ParticleName",
ref_value="e-",
):
Expand Down
21 changes: 7 additions & 14 deletions opengate/tests/src/test061_TPPhsSource_helpers.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import opengate as gate

# import numpy as np
# import matplotlib.pyplot as plot
from scipy.spatial.transform import Rotation
import gatetools.phsp as phsp
import os
from opengate.tests import utility
from opengate.contrib.tps.treatmentPlanPhsSource import TreatmentPlanPhsSource
from opengate.contrib.tps.ionbeamtherapy import spots_info_from_txt, TreatmentPlanSource


# paths = gate.get_default_test_paths(
# __file__, "gate_test019_linac_phsp", output_folder="test019"
# )
# paths = {output: "output"}
from pathlib import Path

# units
m = gate.g4_units.m
Expand All @@ -27,7 +20,7 @@

def create_test_Phs(
particle="proton",
phs_name="output/test_proton.root",
phs_name=Path("output") / "test_proton.root",
number_of_particles=1,
translation=[0 * mm, 0 * mm, 0 * mm],
):
Expand Down Expand Up @@ -116,7 +109,7 @@ def create_test_Phs(


def create_PhS_withoutSource(
phs_name="output/test_proton.root",
phs_name=Path("output") / "test_proton.root",
):
# create the simulation
sim = gate.Simulation()
Expand Down Expand Up @@ -197,10 +190,10 @@ def create_PhS_withoutSource(


def test_source_rotation_A(
plan_file_name="output/test_proton_offset.root",
plan_file_name=Path("output") / "test_proton_offset.root",
phs_list_file_name="PhsList.txt",
phs_folder_name="",
phs_file_name_out="output/output/test_source_electron.root",
phs_file_name_out=Path("output") / "output/test_source_electron.root",
) -> None:
sim, plane = create_PhS_withoutSource(
phs_name=phs_file_name_out,
Expand Down Expand Up @@ -230,7 +223,7 @@ def test_source_rotation_A(


def get_first_entry_of_key(
file_name_root="output/test_source_electron.root", key="ParticleName"
file_name_root=Path("output") / "test_source_electron.root", key="ParticleName"
) -> None:
# read root file
data_ref, keys_ref, m_ref = phsp.load(file_name_root)
Expand All @@ -243,7 +236,7 @@ def get_first_entry_of_key(


def check_value_from_root_file(
file_name_root="output/test_source_electron.root",
file_name_root=Path("output") / "test_source_electron.root",
key="ParticleName",
ref_value="e-",
):
Expand Down

0 comments on commit 003dcb1

Please sign in to comment.