Galactic and gravitational dynamics in Python

Overview

logo

Gala is a Python package for Galactic and gravitational dynamics.

Affiliated package Coverage Status Build status

Documentation

Documentation Status

The documentation for Gala is hosted on Read the docs.

Installation and Dependencies

conda PyPI

The easiest way to get Gala is to install with pip or conda.

The recommended install method is to use pip:

pip install gala

If you are on Linux or Mac, you can also install gala with conda using the conda-forge channel:

conda install gala --channel conda-forge

See the installation instructions in the documentation for more information.

Attribution

JOSS DOI

If you make use of this code, please cite the JOSS paper:

@article{gala,
  doi = {10.21105/joss.00388},
  url = {https://doi.org/10.21105%2Fjoss.00388},
  year = 2017,
  month = {oct},
  publisher = {The Open Journal},
  volume = {2},
  number = {18},
  author = {Adrian M. Price-Whelan},
  title = {Gala: A Python package for galactic dynamics},
  journal = {The Journal of Open Source Software}
}

Please also cite the Zenodo DOI DOI as a software citation - see the documentation for up to date citation information.

License

License

Copyright 2013-2021 Adrian Price-Whelan and contributors.

Gala is free software made available under the MIT License. For details see the LICENSE file.

Contributors

See the AUTHORS.rst file for a complete list of contributors to the project.

Comments
  • Incorporating Mass Evolution into Gala

    Incorporating Mass Evolution into Gala

    I was wondering whether there's a way to incorporate mass evolution or mass accretion over time of a halo into the orbital calculations of gala. I know it only takes a single halo mass numerical value and spits out an orbit, but is it possible to instead include a function for mass rather than a numerical value?

    question feature-request 
    opened by juliaespositon 11
  • [WIP] Simplify PhaseSpacePosition and Orbit classes

    [WIP] Simplify PhaseSpacePosition and Orbit classes

    This makes use of the representation differential classes in astropy/astropy#5871 to clean up a lot of the code. A natural byproduct of this is that CartesianPhaseSpacePosition and CartesianOrbit are no longer needed, since there is now a unified interface to any representations and their respective differentials.

    TODO:

    • [x] support <3D positions so nonlinear integrations work
    • [x] remove the velocity_coord_transforms.py and use the Differential classes instead
    • [x] figure out how to handle velocity frame transforms with the Differential classes
    • [x] update documentation and docstrings
    • [x] clean up all documentation that mentions Orbit or PhaseSpacePosition, check repr's (especially the orbits-in-detail.rst file
    • [x] make sure all mention of Cartesian* is gone
    • [x] make sure all code and doc tests run and don't use the old Cartesian* classes

    API-breaking changes:

    • Velocity frame transforms now return Differential classes
    • Velocity coord transforms are gone
    • CartesianPhaseSpacePosition and CartesianOrbit are deprecated
    opened by adrn 11
  • Add better interaction with and export to sympy, and uses sympy to implement more Hessian functions

    Add better interaction with and export to sympy, and uses sympy to implement more Hessian functions

    Describe your changes

    This adds a .to_sympy() classmethod to the potential classes. I've also then used this method with sympy to compute all of the Hessians, and implemented these using C code generated by sympy.

    Checklist

    • [x] Did you add tests?
    • [x] Did you add documentation for your changes?
    • [x] Did you add a changelog entry? (see CHANGES.rst)
    • [x] Are the CI tests passing?
    • [x] Is the milestone set?

    Amazingly, this closes #159, closes #56, closes #5, and closes #85 !!

    opened by adrn 7
  • plot_contours() requiring optional 'time' argument

    plot_contours() requiring optional 'time' argument

    running plot_contours() on an agama GalaPotential object requires a time object that is supposed to be optional, and forcing the variable to be a single value does not resolve the issue.wasn't encountering this issue until I updated agama and gala to their most recent versions. error stack below:

    grid = np.linspace(-15,15,64)
    fig,ax = plt.subplots(1, 1, figsize=(5,5))
    fig = galapot.plot_contours(grid=(grid,grid,0), cmap='Greys', ax=ax,time=1)
    
    /srv/conda/envs/notebook/lib/python3.8/site-packages/gala/potential/potential/core.py in plot_contours(self, grid, filled, ax, labels, subplots_kw, **kwargs)
        530                 r[ii] = slc
        531 
    --> 532             Z = self.energy(r*self.units['length']).value
        533 
        534             # make default colormap not suck
    
    /srv/conda/envs/notebook/lib/python3.8/site-packages/gala/potential/potential/core.py in energy(self, q, t)
        228         ret_unit = self.units['energy'] / self.units['mass']
        229 
    --> 230         return self._energy(q, t=t).T.reshape(orig_shape[1:]) * ret_unit
        231 
        232     def gradient(self, q, t=0.):
    
    /srv/conda/envs/notebook/lib/python3.8/site-packages/agama/py/pygama.py in <lambda>(q, t)
        898             except TypeError: PotentialBase.__init__(self, dict(), units=units)
        899             _agama.Potential.__init__(self, *args, **kwargs)
    --> 900             self._energy  = lambda q,t=0.: self.potential(q, t=t)
        901             self._density = lambda q,t=0.: _agama.Potential.density(self, q, t=t)
        902             self._gradient= lambda q,t=0.: -self.force(q, t=t)
    
    RuntimeError: Argument 'time', if provided, must be a single number or an array of the same length as points
    
    
    bug 
    opened by liljo0731 6
  • LeapfrogIntegrator will reverse the sign of velocity which may lead to incorrect result

    LeapfrogIntegrator will reverse the sign of velocity which may lead to incorrect result

    Hi, thank you for the great package. I realized the below code in the LeapfrogIntegrator may change the sign of the velocity when _dt is negative, which may change the result of the force function because it could depend on the velocity. In my case I add a dynamical friction term in my force function and LeapfrogIntegrator will give me incorrect results.

    https://github.com/adrn/gala/blob/782a8b1a19c8546d553b7c2122505e6ee82a93db/gala/integrate/pyintegrators/leapfrog.py#L146-L150

    opened by azz147 6
  • Make it so `autolim=True` doesn't set axis limits too small

    Make it so `autolim=True` doesn't set axis limits too small

    Describe your changes

    Added a check of the current axis limits when plotting Orbits with autolim=True to prevent Gala from making the axis limits too small to see everything already plotted.

    Checklist for contributor:

    • [x] Did you add tests?
    • [x] Did you add documentation for your changes?
    • [x] Did you reference any relevant issues?
    • [x] Did you add a changelog entry? (see CHANGES.rst)

    Checklist for maintainers:

    • [x] Are the CI tests passing?
    • [x] Is the milestone set?
    opened by TomWagg 6
  • Installation Issues

    Installation Issues

    Dear Community I´m having some when installing issues. When running the recommended way to install gala, !python -m pip install gala, I get various errors and warnings.

    imagen

    I suspect thsis is the reason why I get errors when running imports such as

    imagen imagen

    Thanks in advance

    opened by jortiz12 6
  • adding STcovar

    adding STcovar

    Describe your changes

    Checklist

    • [ ] Did you add tests?
    • [ ] Did you add documentation for your changes?
    • [ ] Did you reference any relevant issues?
    • [ ] Did you add a changelog entry? (see CHANGES.rst)
    • [ ] Are the CI tests passing?
    • [ ] Is the milestone set?
    opened by jngaravitoc 6
  • allow from_frame to be instance

    allow from_frame to be instance

    so that transformation works on skyoffset frames.

    Signed-off-by: Nathaniel Starkman [email protected]

    Describe your changes

    Checklist

    • [x] Did you add tests? There currently are no tests for get_transform_matrix
    • [x] Did you add documentation for your changes? yes
    • [x] Did you reference any relevant issues? yes
    • [ ] Did you add a changelog entry? (see CHANGES.rst)
    • [x] Are the CI tests passing? yes
    • [x] Is the milestone set?
    opened by nstarman 5
  • Segfault and core dump on manipulating hessians

    Segfault and core dump on manipulating hessians

    python 3.7 gala, numpy versions: 1.0, 1.16.4

    I get core dump / seg fault from doing the follwing:

    import astropy.units as u
    from gala.potential import BovyMWPotential2014
    
    BovyMWPotential2014().hessian([[0, 8, 0]]*u.kpc)
    

    Tracebacks: https://gist.github.com/smoh/0e803684b14d87bba4a97e5bb3e33bb0 1.out: beginning of errors from Red Hat 2.out: full traceback from Mac OSX 10.14.4

    In both I did fresh install with conda

    conda create -n gala-test
    conda install -c conda-forge astro-gala
    

    Any ideas?

    bug 
    opened by smoh 5
  • Add

    Add "fast" option to pericenter/apocenter and support multiple orbits

    Right now, .pericenter() and .apocenter() are slow because they do interpolation to figure out a precise value. There should be a fast=True option that skips the interpolation.

    We also need to support these methods for multiple orbits in the same object.

    bug enhancement priority:medium 
    opened by adrn 5
  • Fixed the oph19_to_icrs function

    Fixed the oph19_to_icrs function

    Describe your changes

    Fixed the bug described in this issue where the OrphanKoposov19 coordinate transformation called the wrong function.

    Checklist

    • [ ] Did you add tests?
    • [ ] Did you add documentation for your changes?
    • [x] Did you reference any relevant issues?
    • [x] Did you add a changelog entry? (see CHANGES.rst)
    • [x] Are the CI tests passing?
    • [x] Is the milestone set?
    opened by sophialilleengen 0
  • OrphanKoposov19 stream-to-ICRS transformation uses wrong fct

    OrphanKoposov19 stream-to-ICRS transformation uses wrong fct

    The OprhanKoposov19 oph19_to_icrs() fct returns OrphanNewberg10 matrix instead of Koposov19 matrix. In this line, galactic_to_orp() should be replaced by icrs_to_orp19().

    opened by sophialilleengen 2
  • CylSpline not C-enabled

    CylSpline not C-enabled

    Bug report from @abonaca: Not able to use the CylSpline potential with MockStream functionality because:

    ValueError: Input potential must be C-enabled: one or more components in the input external potential are Python-only.
    
    bug 
    opened by adrn 0
  • Improve speed of CylSplinePotential

    Improve speed of CylSplinePotential

    Right now it is very slow because it must construct a spline object with the input grids each time the energy/gradient/density functions are called. It might be possible to store this object on the Wrapper class and pass a pointer in to C. To do this, we need to add functionality to the potential classes (actually the struct types) to support having an array of pointers that get passed around.

    enhancement feature-request 
    opened by adrn 0
Releases(v1.6.1)
  • v1.6.1(Nov 7, 2022)

    Changelog included below:

    New Features

    • Added a .replicate() method to Potential classes to enable copying potential objects but modifying some parameter values.

    • Added a new potential class MN3ExponentialDiskPotential based on Smith et al. (2015): an approximation of the potential generated by a double exponential disk using a sum of three Miyamoto-Nagai disks.

    • The Orbit.estimate_period() method now returns period estimates in all phase-space components instead of just the radial period.

    • Added a store_all flag to the integrators to control whether to save phase-space information for all timesteps or only the final timestep.

    • Added a plot_rotation_curve() method to all potential objects to make a 1D plot of the circular velocity curve.

    • Added a new potential for representing multipole expansions MultipolePotential.

    • Added a new potential CylSplinePotential for flexible representation of axisymmetric potentials by allowing passing in grids of potential values evaluated grids of R, z values (like the CylSpline potential in Agama).

    • Added a show_time flag to Orbit.animate() to control whether to show the current timestep.

    • Changed Orbit.animate() to allow for different marker_style and segment_style options for individual orbits by passing a list of dicts instead of just a dict.

    • Added an experimental new class SCFInterpolatedPotential that accepts a time series of coefficients and interpolates the coefficient values to any evaluation time.

    Bug fixes

    • Fixed a bug where the NFWPotential energy was nan when evaluating at the origin, and added tests for all potentials to check for a finite value of the potential at the origin (when expected).

    • Fixed a bug in NFWPotential.from_M200_c() where the incorrect scale radius was computed (Cython does not always use Python 3 division rules for dividing integers!).

    • Fixed a bug in the (C-level/internal) estimation of the 2nd derivative of the potential, used to generate mock streams, that affects non-conservative force fields.

    API changes

    • The Orbit.estimate_period() method now returns period estimates in all phase-space components instead of just the radial period.
    Source code(tar.gz)
    Source code(zip)
  • v1.3(Oct 30, 2020)

  • v1.2(Jul 13, 2020)

  • v0.2.2(Oct 7, 2017)

    gala is an Astropy-affiliated Python package for galactic dynamics. Python enables wrapping low-level languages (e.g., C) for speed without losing flexibility or ease-of-use in the user-interface. The API for gala was designed to provide a class-based and user-friendly interface to fast (C or Cython-optimized) implementations of common operations such as gravitational potential and force evaluation, orbit integration, dynamical transformations, and chaos indicators for nonlinear dynamics. gala also relies heavily on and interfaces well with the implementations of physical units and astronomical coordinate systems in the Astropy package (astropy.units and astropy.coordinates).

    Source code(tar.gz)
    Source code(zip)
  • v0.2.1(Jul 21, 2017)

    Gala is a Python package for Galactic astronomy and gravitational dynamics. The bulk of the package centers around implementations of gravitational potentials, numerical integration, and nonlinear dynamics.

    Source code(tar.gz)
    Source code(zip)
  • v0.1.3(Feb 23, 2017)

    Gala is a Python package for Galactic astronomy and gravitational dynamics. The bulk of the package centers around implementations of gravitational potentials, numerical integration, and nonlinear dynamics.

    Source code(tar.gz)
    Source code(zip)
Owner
Adrian Price-Whelan
Adrian Price-Whelan
A PyTorch Implementation of ViT (Vision Transformer)

ViT - Vision Transformer This is an implementation of ViT - Vision Transformer by Google Research Team through the paper "An Image is Worth 16x16 Word

Quan Nguyen 7 May 11, 2022
Lip Reading - Cross Audio-Visual Recognition using 3D Convolutional Neural Networks

Lip Reading - Cross Audio-Visual Recognition using 3D Convolutional Neural Networks - Official Project Page This repository contains the code develope

Amirsina Torfi 1.7k Dec 18, 2022
A library for building and serving multi-node distributed faiss indices.

About Distributed faiss index service. A lightweight library that lets you work with FAISS indexes which don't fit into a single server memory. It fol

Meta Research 170 Dec 30, 2022
Pytorch implementation of the paper DocEnTr: An End-to-End Document Image Enhancement Transformer.

DocEnTR Description Pytorch implementation of the paper DocEnTr: An End-to-End Document Image Enhancement Transformer. This model is implemented on to

Mohamed Ali Souibgui 74 Jan 07, 2023
Official Implementation of VAT

Semantic correspondence Few-shot segmentation Cost Aggregation Is All You Need for Few-Shot Segmentation For more information, check out project [Proj

Hamacojr 114 Dec 27, 2022
Phy-Q: A Benchmark for Physical Reasoning

Phy-Q: A Benchmark for Physical Reasoning Cheng Xue*, Vimukthini Pinto*, Chathura Gamage* Ekaterina Nikonova, Peng Zhang, Jochen Renz School of Comput

29 Dec 19, 2022
[ICCV 2021] Counterfactual Attention Learning for Fine-Grained Visual Categorization and Re-identification

Counterfactual Attention Learning Created by Yongming Rao*, Guangyi Chen*, Jiwen Lu, Jie Zhou This repository contains PyTorch implementation for ICCV

Yongming Rao 90 Dec 31, 2022
RepVGG: Making VGG-style ConvNets Great Again

This repository is the code that needs to be submitted for OpenMMLab Algorithm Ecological Challenge,the paper is RepVGG: Making VGG-style ConvNets Great Again

Ty Feng 62 May 21, 2022
TensorFlow Metal Backend on Apple Silicon Experiments (just for fun)

tf-metal-experiments TensorFlow Metal Backend on Apple Silicon Experiments (just for fun) Setup This is tested on M1 series Apple Silicon SOC only. Te

Timothy Liu 161 Jan 03, 2023
Conservative Q Learning for Offline Reinforcement Reinforcement Learning in JAX

CQL-JAX This repository implements Conservative Q Learning for Offline Reinforcement Reinforcement Learning in JAX (FLAX). Implementation is built on

Karush Suri 8 Nov 07, 2022
A graph adversarial learning toolbox based on PyTorch and DGL.

GraphWar: Arms Race in Graph Adversarial Learning NOTE: GraphWar is still in the early stages and the API will likely continue to change. 🚀 Installat

Jintang Li 54 Jan 05, 2023
Official code implementation for "Personalized Federated Learning using Hypernetworks"

Personalized Federated Learning using Hypernetworks This is an official implementation of Personalized Federated Learning using Hypernetworks paper. [

Aviv Shamsian 121 Dec 25, 2022
Benchmark tools for Compressive LiDAR-to-map registration

Benchmark tools for Compressive LiDAR-to-map registration This repo contains the released version of code and datasets used for our IROS 2021 paper: "

Allie 9 Nov 24, 2022
Stereo Radiance Fields (SRF): Learning View Synthesis for Sparse Views of Novel Scenes

Stereo Radiance Fields (SRF): Learning View Synthesis for Sparse Views of Novel Scenes

111 Dec 29, 2022
Python Implementation of the CoronaWarnApp (CWA) Event Registration

Python implementation of the Corona-Warn-App (CWA) Event Registration This is an implementation of the Protocol used to generate event and location QR

MaZderMind 17 Oct 05, 2022
A programming language written with python

Kaoft A programming language written with python How to use A simple Hello World: c="Hello World" c Output: "Hello World" Operators: a=12

1 Jan 24, 2022
A web-based application for quick, scalable, and automated hyperparameter tuning and stacked ensembling in Python.

Xcessiv Xcessiv is a tool to help you create the biggest, craziest, and most excessive stacked ensembles you can think of. Stacked ensembles are simpl

Reiichiro Nakano 1.3k Nov 17, 2022
Pocsploit is a lightweight, flexible and novel open source poc verification framework

Pocsploit is a lightweight, flexible and novel open source poc verification framework

cckuailong 208 Dec 24, 2022
[ICML 2021] Towards Understanding and Mitigating Social Biases in Language Models

Towards Understanding and Mitigating Social Biases in Language Models This repo contains code and data for evaluating and mitigating bias from generat

Paul Liang 42 Jan 03, 2023
This repo provides function call to track multi-objects in videos

Custom Object Tracking Introduction This repo provides function call to track multi-objects in videos with a given trained object detection model and

Jeff Lo 51 Nov 22, 2022