Welcome to Pygate’s documentation!

This is the master page of pygate documentation

pygate introduction

An python interface to GATE

GATE USER GUIDE

Pygate is a Subsystem based on python ,which runs wtih GATE simultaneously and speeds up GATE process. This Subsystem mainly contains two following functions,file generators and submiting experiments to Subsystem:

  • file generators:

    • .mac file generator
    • .sh file generator
    • .C file generator
  • submit system/experiment run system:

    • dependency system:

      • via slurm
      • easy constructing task train

ref-1. File main.mac generates. reg-2. Submit a task to subsystem

If you want more information,you can go to github to get Pygate.

More efforts needs to be made to perfect *pygate*.
We warmly welcome whom (now just for external members)
are interested in this program to comeforward and find
out more about us,join us and make full use of this platfom.

predefined First step of pygate

Installation

How to get pygate and configuration

  • if you want to run pygate locally,you should following the steps:

    1. We put the source on the Github.You may need an Github account to clone or downoald the files.Here is the Github Guides.

    2. Ensure your python3 version is the most current version.
      • We recommand Anaconda to get python3.Here is the Anaconda.
      • The Anaconda should be set into syspath.
      • source ~/.bashrc or reboot the terminal to update bashrc.
      • $ python --version and get the output Python 3.6.4 :: Anaconda custom(64-bit) (for now).
    3. Install pygate

      • pip install dxl-pygate
    4. Ensure GATE is installed and configured already.

    5. You have already installed pygate.Go to the First step of pygate.

  • if you are an external member(you haven gotten an account),you can run on the server:

    1. Install Anaconda to get latest python3 in your work folder.The recommanded path with high performance is /mnt/Gluster_NoGPU/usr.

    2. Ensure your python3 version is the most current version.
      • We recommand Anaconda to get python3.Here is the Anaconda.
      • The Anaconda should be set into syspath.
      • source ~/.bashrc or reboot the terminal to update bashrc.
      • $ python --version and get the output Python 3.6.4 :: Anaconda custom(64-bit) (for now).
    3. Install pygate

      • pip install dxl-pygate
    4. Configured GATE
      • soure/hqlf/softewares/moudle/simu8.0.sh
    5. You have made pygate ready.Go to the First step of pygate.

    Note

    We will get the environment set up and configured on each node of the server. You need to install and configure the environment in your own work folder at present.

First step of pygate

In this page,we will run a example consists of two steps;

1. File main.mac generates.

  • Before a GATE process,we generally need to make a file of main.mac ,

in which we can set the compomnents( world,system,phantom,soure and digitizer etc. ) for GATE simulation.

  • The question is that the definition of compomnents is too heavy and complicated. A lot of time and ennergy wastes on this.
  • Pygate offers a function of File Gnetators .Users can confirured the compomnents easily by set several arguments of neccessary compomnents you want in a file of make_mac.py (you can name it freely). A file of mac.yml may needed containing some default settings of the main.mac ,or you can set these in make_mac.py directly.
  • The command for main.mac generating is:
    • $ pygate generate mac script -t make_mac.py -o main.mac -c mac.yml .
    • make_mac.py and mac.yml should be included in current work folder.
    • Then you will find the main.mac in the folder.
  • The main work for this step is to code make_mac.py .Usres can modify on the template for first time.

:ref:make_mac.py

2. Submit a task to subsystem

  • Usually there are hundreds of millions,even billions events occuring during a GATE simulation,which is the reason why the process take a long time.
  • However,it a repetable work for a GATE program to generate an event.*Pygate* offers a method to speed up the process.*Pygate* divides the task into a lot of parts,
  • then submits these parts to server.Each part of the original task will be distributed to no-wroking machine of the net by SLurm.Thus,we get a very high speed for GATE simulation.
  • Users should know the following steps to archive it:
    1. Users should get the needed configured files by excuting this command: $ pygate ini ext .You will get the files in folder:
      • main.mac ,you get it last in the fomer.
      • GateMaterials.db ,significant file for GATE configuration,can’t be lack.
      • Hits2CSV.C ,may needed if you want the data of csv format.
      • Materials.xml
      • Surface.xml ,set the surface rendering.Or you can seclect volume rendering.
    2. When you get the neccessary files in the work folder,you need to divide the task into parts.
      • $ pygate init subdir -n --INTGER -f --STR ,you can set the number of parts and the name of subdirectories as you want.The default option is “sub.[10]” and you will get 10 subdirectories of “sub.[x]”(x~[0-10]).
      • $ pygate init bcast ,broadcast the files to subdirectories maken last step.
      • $ pygate generate shell ,generate run.sh for SLurm to distribute the task and post.sh to merge the results of each parts.
      • $ pygate submit ,submit the task to subsystem. SLurm will do the disribution.The details information of disribution will print on the screen.You can easily know which machine each part run.
      • There are two procedures before getting results:
        • First,the machines absorbs the mission and complete it,then feedback the results to subdirectories. run.sh is for this step.
        • Then the results from subdirectories are merged into one file of optical.root ,containing all collected data of Hits. post.sh is for this.

You can refer the detail of commands in Here is the command list of pygate

pygate

pygate docomentions’ index

analysis

  • _init_.py
  • results.py

api

  • cli
    • _init_.py
    • base.py
    • commands.py
  • _init_.py

archive

  • macs
    • mct2d_source.mac
  • _init_.py
  • mac_templates.yml
  • maxdepth_bash_sample.sh
  • map_bash.sh
  • map_zsh.sh
  • merge_bash.sh
  • merge_bash_zsh.sh
  • pygate.yml

components

  • geometry
    • camera
      • _init_.py
      • camera.py
      • system.py
    • _init_.py
    • geometry.py
    • phantom.py
    • surface.py
    • volume.py
  • templates
  • _init_.py
  • base.py
  • digitizer.py
  • misc.py
  • parameter.py
  • physics.py
  • simulation.py
  • source.py
  • utils.py

predefined

  • _init_.py
  • _camaera.py
  • _sources.py
  • cameras.py
  • digitizers.py
  • parameters.py
  • phantoms.py
  • physice.py
  • simulations.py
  • source.py

routine

  • _init_.py
  • analysis.py
  • base.py
  • cleaner.py
  • initialize.py
  • merger.py
  • submit.py
  • utils.py

scripts

  • templates
  • _init_.py
  • base.py
  • helper.py
  • shell.py

tests

  • components
  • predifined
  • routine
  • scripts
  • _init_.py
  • test_methods.py
  • test_shell.py

utils

  • _init_.py
  • object_with_template.py
  • strs.py
  • typing.py

pygate

  • analysis
    • _init_.py
    • results.py
  • api
    • cli
      • _init_.py
      • base.py
      • commands.py
    • _init_.py
  • archive
    • macs
      • mct2d_source.mac
    • _init_.py
    • mac_templates.yml
    • maxdepth_bash_sample.sh
    • map_bash.sh
    • map_zsh.sh
    • merge_bash.sh
    • merge_bash_zsh.sh
    • pygate.yml
  • componets
    • geometry
      • camera
        _init_.py camera.py system.py
      • _init_.py
      • geometry.py
      • phantom.py
      • surface.py
      • volume.py
    • templates
    • _init_.py
    • base.py
    • digitizer.py
    • misc.py
    • parameter.py
    • physics.py
    • simulation.py
    • source.py
    • utils.py
  • predefined
    • _init_.py
    • _camaera.py
    • _sources.py
    • cameras.py
    • digitizers.py
    • parameters.py
    • phantoms.py
    • physice.py
    • simulations.py
    • source.py
  • routine
    • _init_.py
    • analysis.py
    • base.py
    • cleaner.py
    • initialize.py
    • merger.py
    • submit.py
    • utils.py
  • scripts
    • templates
    • _init_.py
    • base.py
    • helper.py
    • shell.py
  • tests
    • components
    • predifined
    • routine
    • scripts
    • _init_.py
    • test_methods.py
    • test_shell.py
  • utils
    • _init_.py
    • object_with_template.py
    • strs.py
    • typing.py
  • _init_.py
  • cleaner.py
  • config_maker.py
  • config.py
  • configs.py
  • initializer.py
  • merger.py
  • phantom.py
  • remderable.py
  • service.py
  • shell.py
  • submitter.py
  • utils.py

API

for each file

analysis

api

archive

components

predefined

routine

scripts

tests

utils

Here is the command list of pygate

  • pygate
    • analysis
      • predefined
      • script
    • clean
    • generate
      • cfg
      • mac
        • predefined
        • script
      • mac_template
      • shell
    • init
      • auto
      • bcast
      • ext
      • subdir
    • merge
    • submit

$ pygate

Usage: pygate [OPTIONS] COMMAND [ARGS]…

Options:
-c, --config TEXT
 config file name
--no-config ignore config file
--dryrun Do not do anything, just show expected results.
--help Show this message and exit.

Commands:

analysis
clean
generate
init
merge
submit

$ pygate analysis

Usage: pygate analysis [OPTIONS] COMMAND [ARGS]…

Options:
--help Show this message and exit.

Commands:

predefined
script

$ pygate analysis predefined

Usage: pygate analysis predefined [OPTIONS]

Options:
-n, --name TEXT
 Predefined analysis type name.
-s, --source TEXT
 Analysis source data filename.
-o, --output TEXT
 Analysis target data filename.
--help Show this message and exit.

$ pygate analysis script

Usage: pygate analysis script [OPTIONS]

Options:
-t, --target TEXT
 Analysis .py filename.
-s, --source TEXT
 Analysis source data filename.
-o, --output TEXT
 Output filename.
--help Show this message and exit.

$ pygate clean

Usage: pygate clean [OPTIONS]

Options:
-d, --subdirectories
 remove subdirectories
-f, --root-files TEXT
 remove files in work directory
-s, --slurm-outputs
 remove *.out *.err files
--help Show this message and exit.

$ pygate generate

Usage: pygate generate [OPTIONS] COMMAND [ARGS]…

Options:
--help Show this message and exit.

Commands:

cfg           Generate initial config file.
mac           Generate mac file.
mac_template
shell         Generate shell script, pre run or post run.

$ pygate generate cfg

Usage: pygate generate cfg [OPTIONS]

Generate initial config file.
Options:
-t, --target TEXT
 Config file name.
-f, --format TEXT
 Format of config file, json or yml
--help Show this message and exit.

$ pygate generate mac

Usage: pygate generate mac [OPTIONS] COMMAND [ARGS]…

Generate mac file.
Options:
--help Show this message and exit.

Commands:

predefined  Generate mac file by predefined system.
script      Generate mac file by running a .py file.

$ pygate generate mac predefined

Usage: pygate generate mac predefined [OPTIONS]

Generate mac file by predefined system.
Options:
-p, --predefined TEXT
 Name of predefined system to generate mac file.
-c, --config TEXT
 config filename to generate macs.
-t, --target TEXT
 MAC filename, will passed to script or predefined method.
--help Show this message and exit.

$ pygate generate mac script

Usage: pygate generate mac script [OPTIONS]

Generate mac file by running a .py file.
Options:
-t, --target TEXT
 Filename of script to run to generate mac file.
-c, --config TEXT
 config filename to generate macs.
-o, --output TEXT
 MAC filename, will passed to script or predefined method.
--help Show this message and exit.

$ pygate generate mac_template

Usage: pygate generate mac_template [OPTIONS]
Options:
-f, --filename TEXT
 Show the file name.
--help Show this message and exit.

$ pygate generate shell

Usage: pygate generate shell [OPTIONS]

Generate shell script, pre run or post run.
Options:
--help Show this message and exit.

$ pygate init

Usage: pygate init [OPTIONS] COMMAND [ARGS]…

Options:
--help Show this message and exit.

Commands:

auto
bcast
ext     Copy external files.
subdir

$ pygate init auto

Usage: pygate init auto [OPTIONS]

Options:
–mac-auto –mac-no-create –mac-force-create –help Show this message and exit.

$ pygate init bcast

Usage: pygate init bcast [OPTIONS]

Options:
-t, --target INTEGER
 Files to broadcast to subdirectories.
-e, --no-ext Include all external files.
--help Show this message and exit.

$ pygate init ext

Usage: pygate init ext [OPTIONS]

Copy external files.
Options:
--help Show this message and exit.

$ pygate init subdir

Usage: pygate init subdir [OPTIONS]

Options:
-n, --nb-split INTEGER
 Number of subdirectories.
-f, --sub-format TEXT
 Subdirectories format str.
--help Show this message and exit.

$ pygate merge

Usage: pygate merge [OPTIONS]

Options:
-t, --target TEXT
 Target str.
-m, --method TEXT
 Method str.
--help Show this message and exit.

$ pygate submit

Usage: pygate submit [OPTIONS]

Options:
-b, --broadcast TEXT
 Broadcast file str.
-s, --single TEXT
 Single str.
--help Show this message and exit.

F

Indices and tables