Skip to main content

Scale-free DF velocity moments and VP calculations with a Fortran backend.

Project description

scalefree

pipeline status coverage report pypi python license

logo

Scale-free dynamical models (Fortran backend) with a small Python interface for computing intrinsic/projected velocity moments and (optionally) reconstructed velocity profiles (VPs) and Gauss–Hermite summaries.

The guiding principles are:

  • Keep the user-facing API small and predictable
  • Delegate heavy computation to a compiled backend
  • Provide structured, parseable outputs for reproducible workflows

This code was developped in the context of the HSTPROMO collaboration.


What this package provides

vprofile(...)

Runs the ScaleFree Fortran backend and returns intrinsic/projected velocity moments and (optionally) VP / Gauss–Hermite summaries.

Typical uses:

  • Line-of-sight (LOS) kinematics
  • Proper-motion (plane-of-sky) kinematics (POSr, POSt)
  • VP reconstruction from moments (when enabled)

scalefree.hermite

Utilities to fit Gauss–Hermite coefficients to a velocity-profile file and to evaluate analytic Gauss–Hermite profiles.

mock(...)

A convenience routine for generating synthetic 6D samples (x, y, z, vx, vy, vz) from a chosen model configuration (internally uses vprofile() to obtain GH parameters across angular bins).


Installation

From source (recommended for development)

poetry install

With pip

pip install scalefree

Fortran requirement

vprofile() uses a Fortran executable. If you do not provide a precompiled binary, a local build requires gfortran.

Install gfortran:

  • Debian/Ubuntu: sudo apt-get install gfortran
  • Fedora: sudo dnf install gcc-gfortran
  • macOS (Homebrew): brew install gcc

Quickstart

1) Run vprofile()

from scalefree import vprofile

res = vprofile(
    potential="logarithmic",  # or "kepler", 1, 2, or a callable returning 1/2
    gamma=2.0,
    q=0.8,
    df=1,
    beta=0.0,
    s=0.5,
    t=0.0,
    inclination=60.0,
    xi=0.0,
    theta=0.0,
    usevp=True,
    algorithm=3,
)

print(res.blocks.keys())
print(res.blocks["vp"]["by_iproj"][1])  # iproj=1 LOS, 2 POSr, 3 POSt

2) Fit Gauss–Hermite moments from a VP file

from scalefree import hermite  # module

gauss_info, gaussh_info, h_moments = hermite.hermite("my_vp.dat")
print(gaussh_info)
print(h_moments["h3"], h_moments["h4"])

3) Generate a simple mock

from scalefree import mock

X = mock(
    potential=lambda: 1,
    gamma=4.0,
    q=0.9,
    beta=0.0,
    inclination=90.0,
    nsamples=10_000,
    nbins=180,
    usevp=True,
)

print(X.shape)  # (N, 6): (x, y, z, vx, vy, vz)

Documentation

To keep this README short, more detailed guides are intended to live under docs/:

  • docs/getting-started.md
  • docs/api.md
  • docs/vprofile.md
  • docs/gauss-hermite.md
  • docs/mock-generator.md
  • docs/troubleshooting.md
  • Theory notes:
    • docs/theory/rotation.md
    • docs/theory/vp-shapes.md
    • docs/theory/pos-velocity.md

References and citation guidance

If you use this code in research, please cite the foundational scale-free modelling reference and any additional methodological references relevant to your workflow.

Core scale-free models (foundational)

  • de Bruijne, van der Marel & de Zeeuw (1996), MNRAS, 282, 909–925. arXiv: astro-ph/9601044

Plane of sight moments equations

  • Vitral et al. (2024), ApJ, 970, 1. DOI: 10.3847/1538-4357/ad571c. aeXiv: astro-ph/2407.07769

BibTeX (copy/paste)

@ARTICLE{1996MNRAS.282..909D,
  author  = {de Bruijne, Jos H. J. and van der Marel, Roeland P. and de Zeeuw, P. Tim},
  title   = {Scale-free dynamical models for galaxies: flattened densities in spherical potentials},
  journal = {Monthly Notices of the Royal Astronomical Society},
  year    = {1996},
  volume  = {282},
  number  = {3},
  pages   = {909--925},
  doi     = {10.1093/mnras/282.3.909},
  eprint  = {astro-ph/9601044},
  archivePrefix = {arXiv}
}

@ARTICLE{2024ApJ...970....1V,
       author = {{Vitral}, Eduardo and {van der Marel}, Roeland P. and {Sohn}, Sangmo Tony and {Libralato}, Mattia and {del Pino}, Andr{\'e}s and {Watkins}, Laura L. and {Bellini}, Andrea and {Walker}, Matthew G. and {Besla}, Gurtina and {Pawlowski}, Marcel S. and {Mamon}, Gary A.},
        title = "{HSTPROMO Internal Proper-motion Kinematics of Dwarf Spheroidal Galaxies. I. Velocity Anisotropy and Dark Matter Cusp Slope of Draco}",
      journal = {\apj},
     keywords = {Dark matter, Dwarf spheroidal galaxies, Astronomy data analysis, Proper motions, Stellar kinematics, Stellar dynamics, Galaxy dynamics, Galaxy structure, 353, 420, 1858, 1295, 1608, 1596, 591, 622, Astrophysics - Astrophysics of Galaxies, Astrophysics - Cosmology and Nongalactic Astrophysics},
         year = 2024,
        month = jul,
       volume = {970},
        pages = {1},
          doi = {10.3847/1538-4357/ad571c},
       eprint = {2407.07769},
}

Authors:

  • Roeland P. van der Marel,

    1994-1995 :
      development of code
    address : Space Telescope Science Institute
    Research Programs Office (RPO)
    3700 San Martin Drive
    Baltimore, MD 21218
    Tel : (+1) 410 338 4931
    Fax : (+1) 410 338 4596
    e-mail : marel@stsci.edu
    homepage : https://www.stsci.edu/~marel/

  • Jos H. J. de Bruijne,

    1994-1995 :
      testing and application of code
    address : Sterrewacht Leiden
    Postbus 9513
    2300 RA Leiden
    The Netherlands
    Tel : (+31) 71 5275878
    Fax : (+31) 71 5275819
    e-mail : debruyne@strw.LeidenUniv.nl
    homepage : http://www.strw.leidenuniv.nl/~debruyne/

  • Eduardo Vitral,

    2023-present :
      development of the Python interface
      implementation of plane-of-sky routines
      testing and application of code
    address : Royal Observatory of Edinburgh
    Edinburgh, UK
    e-mail : eduardo.vitral@roe.ac.uk
    homepage : https://eduardo-vitral.github.io

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scalefree-0.1.7.tar.gz (53.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scalefree-0.1.7-py3-none-any.whl (55.5 kB view details)

Uploaded Python 3

File details

Details for the file scalefree-0.1.7.tar.gz.

File metadata

  • Download URL: scalefree-0.1.7.tar.gz
  • Upload date:
  • Size: 53.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for scalefree-0.1.7.tar.gz
Algorithm Hash digest
SHA256 fe27a3e512f852aaf056c5cc42ea5bf3eb3c33b7363b2704ad02c1350e6479eb
MD5 6c842ad2c39051a4b6c53f1d9acb4458
BLAKE2b-256 bb6f067d46c57976a534374089ef1c7ed57d8e81f1b0ad6947400848a56b6c00

See more details on using hashes here.

File details

Details for the file scalefree-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: scalefree-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 55.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for scalefree-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e94c93b53541cb75ff70b83f0958bc3ae71037ce950fc40e1cd64b63d26b3129
MD5 d4493994367fea70028900db9a273472
BLAKE2b-256 54a6855d1a1fd0b207a434d8c1a7a58b5c336089d435bb28a9537cc6e1ad181d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page