Coder Social home page Coder Social logo

slomo's Introduction

slomo

Python bindings for Slomo.jl

Dependencies

You'll have to install pyjulia to get Python and Julia to play nice with each other.

Installation

  1. Download and install Julia

    Link to Julia site

  2. Clone this (slomo) repository

    We need to also copy over the Slomo.jl submodule by using the --recurse-submodules option.

    git clone --recurse-submodules https://github.com/adwasser/slomo.git
  3. Download and install Julia dependencies

    From the shell:

    cd slomo/slomo/Slomo.jl
    julia

    From the Julia REPL:

    using Pkg
    Pkg.activate(".")
    Pkg.instantiate()
    Pkg.resolve()
  4. Build a Julia system image for faster load times (optional)

    This will take a long time. Go make a cup of tea and read a book while you wait. The benefit is that the startup time should be much faster if you have a precompiled Julia system image.

    Run the build script in the Slomo.jl directory:

    cd slomo/slomo/Slomo.jl
    mkdir build
    julia build.jl
  5. Install the python package

    From the top-level package directory:

    pip install .

If all goes well, you should be able to do the following from a Python shell:

import numpy as np
from slomo import *
model = JeansModel(halos.NFWModel(), SersicModel(), ConstantBetaModel())
R = np.logspace(-1, 1)
sigma_profile = sigma_los(model, R)

The first call of sigma_los will be incredibly slow due to the JIT compilation from Julia; subsequent calls should be much faster.

Multi-threading

To set up multi-threading with Julia, set the JULIA_NUM_THREADS environmental variable to the desired number of threads prior to importing slomo, e.g. for bash

export JULIA_NUM_THREADS=4

To do the Jeans integration for a single model structure with multiple parameter sets, pass a list of dictionaries to sigma_los_parallel, where each dictionary contains parameter updates for the model.

parameter_sets = [
	dict(beta=0.5, Re=12.3),
	dict(beta=0.1, Re=12.3),
	dict(beta=0.5, Re=10.9),
	dict(beta=0.1, Re=10.9)
]
sigma_profiles = sigma_los_parallel(model, R, parameter_sets)

slomo's People

Contributors

adwasser avatar

Watchers

 avatar

Forkers

alexavillaume

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.