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
PyBullet CartPole and Quadrotor environments—with CasADi symbolic a priori dynamics—for learning-based control and reinforcement learning

safe-control-gym Physics-based CartPole and Quadrotor Gym environments (using PyBullet) with symbolic a priori dynamics (using CasADi) for learning-ba

Dynamic Systems Lab 300 Dec 28, 2022
A python implementation of Physics-informed Spline Learning for nonlinear dynamics discovery

PiSL A python implementation of Physics-informed Spline Learning for nonlinear dynamics discovery. Sun, F., Liu, Y. and Sun, H., 2021. Physics-informe

Fangzheng (Andy) Sun 8 Jul 13, 2022
A Python framework for developing parallelized Computational Fluid Dynamics software to solve the hyperbolic 2D Euler equations on distributed, multi-block structured grids.

pyHype: Computational Fluid Dynamics in Python pyHype is a Python framework for developing parallelized Computational Fluid Dynamics software to solve

Mohamed Khalil 21 Nov 22, 2022
Python Rapid Artificial Intelligence Ab Initio Molecular Dynamics

Python Rapid Artificial Intelligence Ab Initio Molecular Dynamics

null 14 Nov 6, 2022
Dataset Cartography: Mapping and Diagnosing Datasets with Training Dynamics

Dataset Cartography Code for the paper Dataset Cartography: Mapping and Diagnosing Datasets with Training Dynamics at EMNLP 2020. This repository cont

AI2 125 Dec 22, 2022
Code for ECCV 2020 paper "Contacts and Human Dynamics from Monocular Video".

Contact and Human Dynamics from Monocular Video This is the official implementation for the ECCV 2020 spotlight paper by Davis Rempe, Leonidas J. Guib

Davis Rempe 207 Jan 5, 2023
source code for https://arxiv.org/abs/2005.11248 "Accelerating Antimicrobial Discovery with Controllable Deep Generative Models and Molecular Dynamics"

Accelerating Antimicrobial Discovery with Controllable Deep Generative Models and Molecular Dynamics This work will be published in Nature Biomedical

International Business Machines 71 Nov 15, 2022
Pytorch implementation of CVPR2020 paper “VectorNet: Encoding HD Maps and Agent Dynamics from Vectorized Representation”

VectorNet Re-implementation This is the unofficial pytorch implementation of CVPR2020 paper "VectorNet: Encoding HD Maps and Agent Dynamics from Vecto

null 120 Jan 6, 2023
Official implementation of "Learning Forward Dynamics Model and Informed Trajectory Sampler for Safe Quadruped Navigation" (RSS 2022)

Intro Official implementation of "Learning Forward Dynamics Model and Informed Trajectory Sampler for Safe Quadruped Navigation" Robotics:Science and

Yunho Kim 21 Dec 7, 2022
Pytorch code for "State-only Imitation with Transition Dynamics Mismatch" (ICLR 2020)

This repo contains code for our paper State-only Imitation with Transition Dynamics Mismatch published at ICLR 2020. The code heavily uses the RL mach

null 20 Sep 8, 2022
PyTorch Code of "Memory In Memory: A Predictive Neural Network for Learning Higher-Order Non-Stationarity from Spatiotemporal Dynamics"

Memory In Memory Networks It is based on the paper Memory In Memory: A Predictive Neural Network for Learning Higher-Order Non-Stationarity from Spati

Yang Li 12 May 30, 2022
VID-Fusion: Robust Visual-Inertial-Dynamics Odometry for Accurate External Force Estimation

VID-Fusion VID-Fusion: Robust Visual-Inertial-Dynamics Odometry for Accurate External Force Estimation Authors: Ziming Ding , Tiankai Yang, Kunyi Zhan

ZJU FAST Lab 86 Nov 18, 2022
Official PyTorch implementation of "Physics-aware Difference Graph Networks for Sparsely-Observed Dynamics".

Physics-aware Difference Graph Networks for Sparsely-Observed Dynamics This repository is the official PyTorch implementation of "Physics-aware Differ

USC-Melady 46 Nov 20, 2022
Official repository of the paper "A Variational Approximation for Analyzing the Dynamics of Panel Data". Mixed Effect Neural ODE. UAI 2021.

Official repository of the paper (UAI 2021) "A Variational Approximation for Analyzing the Dynamics of Panel Data", Mixed Effect Neural ODE. Panel dat

Jurijs Nazarovs 7 Nov 26, 2022
Code of the paper "Deep Human Dynamics Prior" in ACM MM 2021.

Code of the paper "Deep Human Dynamics Prior" in ACM MM 2021. Figure 1: In the process of motion capture (mocap), some joints or even the whole human

Shinny cui 3 Oct 31, 2022
Online Pseudo Label Generation by Hierarchical Cluster Dynamics for Adaptive Person Re-identification

Online Pseudo Label Generation by Hierarchical Cluster Dynamics for Adaptive Person Re-identification

TANG, shixiang 6 Nov 25, 2022
Digan - Official PyTorch implementation of Generating Videos with Dynamics-aware Implicit Generative Adversarial Networks

DIGAN (ICLR 2022) Official PyTorch implementation of "Generating Videos with Dyn

Sihyun Yu 147 Dec 31, 2022