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 C implementation for creating 2D voronoi diagrams

Branch OSX/Linux Windows master dev jc_voronoi A fast C/C++ header only implementation for creating 2D Voronoi diagrams from a point set Uses Fortune'

Mathias Westerdahl 481 Dec 29, 2022
TensorFlow implementation of PHM (Parameterization of Hypercomplex Multiplication)

Parameterization of Hypercomplex Multiplications (PHM) This repository contains the TensorFlow implementation of PHM (Parameterization of Hypercomplex

Aston Zhang 9 Oct 26, 2022
Learning and Building Convolutional Neural Networks using PyTorch

Image Classification Using Deep Learning Learning and Building Convolutional Neural Networks using PyTorch. Models, selected are based on number of ci

Mayur 126 Dec 22, 2022
Accelerating BERT Inference for Sequence Labeling via Early-Exit

Sequence-Labeling-Early-Exit Code for ACL 2021 paper: Accelerating BERT Inference for Sequence Labeling via Early-Exit Requirement: Please refer to re

李孝男 23 Oct 14, 2022
Adversarial examples to the new ConvNeXt architecture

Adversarial examples to the new ConvNeXt architecture To get adversarial examples to the ConvNeXt architecture, run the Colab: https://github.com/stan

Stanislav Fort 19 Sep 18, 2022
This is a collection of our NAS and Vision Transformer work.

AutoML - Neural Architecture Search This is a collection of our AutoML-NAS work iRPE (NEW): Rethinking and Improving Relative Position Encoding for Vi

Microsoft 828 Dec 28, 2022
This is the replication package for paper submission: Towards Training Reproducible Deep Learning Models.

This is the replication package for paper submission: Towards Training Reproducible Deep Learning Models.

0 Feb 02, 2022
Code for EMNLP 2021 main conference paper "Text AutoAugment: Learning Compositional Augmentation Policy for Text Classification"

Text-AutoAugment (TAA) This repository contains the code for our paper Text AutoAugment: Learning Compositional Augmentation Policy for Text Classific

LancoPKU 105 Jan 03, 2023
Train Scene Graph Generation for Visual Genome and GQA in PyTorch >= 1.2 with improved zero and few-shot generalization.

Scene Graph Generation Object Detections Ground truth Scene Graph Generated Scene Graph In this visualization, woman sitting on rock is a zero-shot tr

Boris Knyazev 93 Dec 28, 2022
Code for models used in Bashiri et al., "A Flow-based latent state generative model of neural population responses to natural images".

A Flow-based latent state generative model of neural population responses to natural images Code for "A Flow-based latent state generative model of ne

Sinz Lab 5 Aug 26, 2022
Keyhole Imaging: Non-Line-of-Sight Imaging and Tracking of Moving Objects Along a Single Optical Path

Keyhole Imaging Code & Dataset Code associated with the paper "Keyhole Imaging: Non-Line-of-Sight Imaging and Tracking of Moving Objects Along a Singl

Stanford Computational Imaging Lab 20 Feb 03, 2022
Evaluating saliency methods on artificial data with different background types

Evaluating saliency methods on artificial data with different background types This repository contains the relevant code for the MedNeurips 2021 subm

2 Jul 05, 2022
Learning embeddings for classification, retrieval and ranking.

StarSpace StarSpace is a general-purpose neural model for efficient learning of entity embeddings for solving a wide variety of problems: Learning wor

Facebook Research 3.8k Dec 22, 2022
Code repo for "FASA: Feature Augmentation and Sampling Adaptation for Long-Tailed Instance Segmentation" (ICCV 2021)

FASA: Feature Augmentation and Sampling Adaptation for Long-Tailed Instance Segmentation (ICCV 2021) This repository contains the implementation of th

Yuhang Zang 21 Dec 17, 2022
Raindrop strategy for Irregular time series

Graph-Guided Network For Irregularly Sampled Multivariate Time Series Overview This repository contains processed datasets and implementation code for

Zitnik Lab @ Harvard 74 Jan 03, 2023
GraphRNN: Generating Realistic Graphs with Deep Auto-regressive Models

GraphRNN: Generating Realistic Graphs with Deep Auto-regressive Model This repository is the official PyTorch implementation of GraphRNN, a graph gene

Jiaxuan 568 Dec 29, 2022
Complete-IoU (CIoU) Loss and Cluster-NMS for Object Detection and Instance Segmentation (YOLACT)

Complete-IoU Loss and Cluster-NMS for Improving Object Detection and Instance Segmentation. Our paper is accepted by IEEE Transactions on Cybernetics

290 Dec 25, 2022
The ARCA23K baseline system

ARCA23K Baseline System This is the source code for the baseline system associated with the ARCA23K dataset. Details about ARCA23K and the baseline sy

4 Jul 02, 2022
Analysis of rationale selection in neural rationale models

Neural Rationale Interpretability Analysis We analyze the neural rationale models proposed by Lei et al. (2016) and Bastings et al. (2019), as impleme

Yiming Zheng 3 Aug 31, 2022
Pytorch implementation for "Distribution-Balanced Loss for Multi-Label Classification in Long-Tailed Datasets" (ECCV 2020 Spotlight)

Distribution-Balanced Loss [Paper] The implementation of our paper Distribution-Balanced Loss for Multi-Label Classification in Long-Tailed Datasets (

Tong WU 304 Dec 22, 2022