Giter Club home page Giter Club logo

vts.scripting.python's Introduction

Using VTS in a Jupyter notebook

This is likely to change once python scripting is formally supported by VTS.

macOS installation details

This is a record of how I got vts working in JupyterLab.

Step 1: Install .NET 6

You will need version 6 of .NET which is available from Microsoft below

https://dotnet.microsoft.com/en-us/download/dotnet/6.0

I saved everything to $HOME/Documents/Code/dotnet6

Do not forget to update your ~/.bash_profile or whatever you use so that this directory is in your path. Also define DOTNET_ROOT

PATH=$PATH:$HOME/Documents/Code/dotnet6

export DOTNET_ROOT=$HOME/Documents/Code/dotnet6

Step 2: Install VTS

Follow the guidelines at https://github.com/VirtualPhotonics/VTS/wiki/Getting-Started-on-Mac Briefly, clone the .git repo

git clone https://github.com/VirtualPhotonics/vts.git

This will create the directory vts that is needed for the next step

Install both powershell and nuget using Homebrew

brew install powershell
brew install nuget

Now build VTS. If you don't have matlab don't worry, it seemed to work fine without completing the matlab tests

pwsh
cd vts
./BuildTestRelease.ps1 
exit

Step 3: Install pythonnet

pip install pythonnet

Because pythonnet under macOS (or linux) defaults to mono, two more things need to added to ~/.bash_profile

export PYTHONNET_RUNTIME=coreclr
export PYTHONNET_PYDLL=/usr/local/bin/python3   

Obviously use the path for python on your system (which python3 will tell you)

Next start a JupyterLab notebook to verify that things are installed correctly

import clr

clr.AddReference("System")
from System import Console
Console.WriteLine("Hello from .NET 6!")

The final test is importing from Vts.dll

import clr
clr.AddReference("/path/to/vts/src/Vts/publish/local/Vts.dll")    
from Vts import *

where, of course, "/path/to" above has been adapted to your system

Step 4: Run programs

To run VTS programs in python include the following the header

import clr
clr.AddReference("/path/to/vts/src/Vts/publish/local/Vts.dll")    

from Vts import *
from Vts.Common import *
from Vts.Extensions import *
from Vts.Modeling.Optimizers import *
from Vts.Modeling.ForwardSolvers import *
from Vts.Factories import *
from Vts.MonteCarlo import *
from Vts.MonteCarlo.Sources import *
from Vts.MonteCarlo.Tissues import *
from Vts.MonteCarlo.Detectors import *
from Vts.MonteCarlo.Factories import *
from Vts.MonteCarlo.PhotonData import *
from Vts.MonteCarlo.PostProcessing import *
from System import Array, Double

vts.scripting.python's People

Contributors

scottprahl avatar lmalenfant avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.