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
Code for Discriminative Sounding Objects Localization (NeurIPS 2020)

Discriminative Sounding Objects Localization Code for our NeurIPS 2020 paper Discriminative Sounding Objects Localization via Self-supervised Audiovis

51 Dec 11, 2022
Continual World is a benchmark for continual reinforcement learning

Continual World Continual World is a benchmark for continual reinforcement learning. It contains realistic robotic tasks which come from MetaWorld. Th

41 Dec 24, 2022
10x faster matrix and vector operations

Bolt is an algorithm for compressing vectors of real-valued data and running mathematical operations directly on the compressed representations. If yo

2.3k Jan 09, 2023
Spatio-Temporal Entropy Model (STEM) for end-to-end leaned video compression.

Spatio-Temporal Entropy Model A Pytorch Reproduction of Spatio-Temporal Entropy Model (STEM) for end-to-end leaned video compression. More details can

16 Nov 28, 2022
Tools for investing in Python

InvestOps Original repository on GitHub Original author is Magnus Erik Hvass Pedersen Introduction This is a Python package with simple and effective

24 Nov 26, 2022
[ICML 2021] “ Self-Damaging Contrastive Learning”, Ziyu Jiang, Tianlong Chen, Bobak Mortazavi, Zhangyang Wang

Self-Damaging Contrastive Learning Introduction The recent breakthrough achieved by contrastive learning accelerates the pace for deploying unsupervis

VITA 51 Dec 29, 2022
Implementation of TransGanFormer, an all-attention GAN that combines the finding from the recent GanFormer and TransGan paper

TransGanFormer (wip) Implementation of TransGanFormer, an all-attention GAN that combines the finding from the recent GansFormer and TransGan paper. I

Phil Wang 146 Dec 06, 2022
A PyTorch Implementation of Neural IMage Assessment

NIMA: Neural IMage Assessment This is a PyTorch implementation of the paper NIMA: Neural IMage Assessment (accepted at IEEE Transactions on Image Proc

yunxiaos 418 Dec 29, 2022
Code repo for "Cross-Scale Internal Graph Neural Network for Image Super-Resolution" (NeurIPS'20)

IGNN Code repo for "Cross-Scale Internal Graph Neural Network for Image Super-Resolution" [paper] [supp] Prepare datasets 1 Download training dataset

Shangchen Zhou 278 Jan 03, 2023
Official repository of OFA. Paper: Unifying Architectures, Tasks, and Modalities Through a Simple Sequence-to-Sequence Learning Framework

Paper | Blog OFA is a unified multimodal pretrained model that unifies modalities (i.e., cross-modality, vision, language) and tasks (e.g., image gene

OFA Sys 1.4k Jan 08, 2023
A Transformer-Based Siamese Network for Change Detection

ChangeFormer: A Transformer-Based Siamese Network for Change Detection (Under review at IGARSS-2022) Wele Gedara Chaminda Bandara, Vishal M. Patel Her

Wele Gedara Chaminda Bandara 214 Dec 29, 2022
phylotorch-bito is a package providing an interface to BITO for phylotorch

phylotorch-bito phylotorch-bito is a package providing an interface to BITO for phylotorch Dependencies phylotorch BITO Installation Get the source co

Mathieu Fourment 2 Sep 01, 2022
Style-based Neural Drum Synthesis with GAN inversion

Style-based Drum Synthesis with GAN Inversion Demo TensorFlow implementation of a style-based version of the adversarial drum synth (ADS) from the pap

Sound and Music Analysis (SoMA) Group 29 Nov 19, 2022
This repository contains project created during the Data Challenge module at London School of Hygiene & Tropical Medicine

LSHTM_RCS This repository contains project created during the Data Challenge module at London School of Hygiene & Tropical Medicine (LSHTM) in collabo

Lukas Kopecky 3 Jan 30, 2022
Quantile Regression DQN a Minimal Working Example, Distributional Reinforcement Learning with Quantile Regression

Quantile Regression DQN Quantile Regression DQN a Minimal Working Example, Distributional Reinforcement Learning with Quantile Regression (https://arx

Arsenii Senya Ashukha 80 Sep 17, 2022
Real-Time and Accurate Full-Body Multi-Person Pose Estimation&Tracking System

News! Aug 2020: v0.4.0 version of AlphaPose is released! Stronger tracking! Include whole body(face,hand,foot) keypoints! Colab now available. Dec 201

Machine Vision and Intelligence Group @ SJTU 6.7k Dec 28, 2022
rliable is an open-source Python library for reliable evaluation, even with a handful of runs, on reinforcement learning and machine learnings benchmarks.

Open-source library for reliable evaluation on reinforcement learning and machine learning benchmarks. See NeurIPS 2021 oral for details.

Google Research 529 Jan 01, 2023
Computationally efficient algorithm that identifies boundary points of a point cloud.

BoundaryTest Included are MATLAB and Python packages, each of which implement efficient algorithms for boundary detection and normal vector estimation

6 Dec 09, 2022
PyTorch implementation for our paper Learning Character-Agnostic Motion for Motion Retargeting in 2D, SIGGRAPH 2019

Learning Character-Agnostic Motion for Motion Retargeting in 2D We provide PyTorch implementation for our paper Learning Character-Agnostic Motion for

Rundi Wu 367 Dec 22, 2022
Deep learning algorithms for muon momentum estimation in the CMS Trigger System

Deep learning algorithms for muon momentum estimation in the CMS Trigger System The Compact Muon Solenoid (CMS) is a general-purpose detector at the L

anuragB 2 Oct 06, 2021