specfit

Python code to perform Bayesian fitting of polynomial models for radio spectra

https://github.com/tmolteno/specfit

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.2%) to scientific vocabulary

Keywords

astronomy astronomy-astrophysics radio
Last synced: 7 months ago · JSON representation ·

Repository

Python code to perform Bayesian fitting of polynomial models for radio spectra

Basic Info
  • Host: GitHub
  • Owner: tmolteno
  • License: gpl-3.0
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 671 KB
Statistics
  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 1
Topics
astronomy astronomy-astrophysics radio
Created over 4 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

README.md

Specfit

Infer polynomial coefficients and their covariance structure for fitting radio-astronometric callibrator spectra.

  • Author: Tim Molteno. tim@elec.ac.nz
  • Publication: Molteno, Timothy CA. "Correlation structure in flux-density calibrator models." Monthly Notices of the Royal Astronomical Society 527.3 (2024): 5732-5740.

Data

Machine readable data from this catalogue is available in the HDF file in the data directory. calibrator_catalogue.hdf5

Install

sudo pip3 install specfit

develop

pip3 install -e .

Examples

Here is an example. This code is in the examples directory.

import numpy as np
import specfit as sf
import matplotlib.pyplot as plt

# Data from J.E. Reynolds for J1939-6342
original_data = np.array(
    [[0.408,  6.24, 0.312 ],
     [0.843, 13.65, 0.6825],
     [1.38 , 14.96, 0.748 ],
     [1.413, 14.87, 0.7435],
     [1.612, 14.47, 0.7235],
     [1.66 , 14.06, 0.703 ],
     [1.665, 14.21, 0.7105],
     [2.295, 11.95, 0.5975],
     [2.378, 11.75, 0.5875],
     [4.8  ,  5.81, 0.2905],
     [4.8  ,  5.76, 0.288 ],
     [4.835,  5.72, 0.286 ],
     [4.85 ,  5.74, 0.287 ],
     [8.415,  2.99, 0.1495],
     [8.42 ,  2.97, 0.1485],
     [8.64 ,  2.81, 0.1405],
     [8.64 ,  2.81, 0.1405]])

freq_ghz, mu, sigma = original_data.T
freq = freq_ghz*1e9

names, stats, a_cov, a_corr, idata = \
    sf.spectral_inference("J1939-6342", 
        freq=nu, mu=data, sigma=sigma, order=4, nu0=1.4e9)

Now we can plot the data and show the results.

fig, ax = sf.dataplot(plt, "J1939-6342", freq=freq, mu=data, sigma=sigma)

a = stats[0] # Means

nu = np.linspace(min_freq, max_freq, 100)
S = sf.flux(nu, a, nu0=1.4e9)
ax.plot(nu/1e9, S, label="polynomial fit")
ax.legend()
fig.tight_layout()
plt.show()

print(names, stats)
print(a_cov)

TODO

  • Incorporate some ideas on using variances of parameters and constraints on flux uncertainties in place of requiring an explicit assumption of the sigma (in the case of data-free inference)
  • Use smoothness as a prior (rather than model-order).

Changelog

  • 0.5.0b2 Move to hatchling as the build system, add pyproject.toml.
  • 0.5.0b1 Add spline fits, and piecewise linear fits. (WORK IN PROGRESS). Add a new function for processing marginal likelihood.
  • 0.4.0b1 Update the marginal_likelihood method to correctly no longer use inferenceData objects to avoid a bug in pymc. Return the relative marginal likelihood (rather than the log marginal likelihood)
  • 0.3.0b3 Clean up to use the natural log throughout! (IMPORTANT) Use consistent way to get names of variables from the posterior Add machine readable hdf5 file output.
  • 0.3.0b2 Use pymc and upgrade to newer versions.
  • 0.2.0b4 Include a separate function (marginal_likelihood) for estimating the marginal likelihood using SMC Change the likelihood to use a Student's t distribution for robustness.
  • 0.2.0b3 Fix examples, move to github automation for release information.
  • 0.1.0b3 First functioning release.
  • 0.1.0b4 [In progress] Add the frequency range to the full_column output. Return the inference data to allow further processing Improved plotting and postprocessing. Added posterior PDF helper plotting function (slow) Use different tuning depending on polynomial order Output to a file, including lists of alternate names

Owner

  • Name: Tim Molteno
  • Login: tmolteno
  • Kind: user
  • Location: Dunedin, New Zealand
  • Company: University of Otago

Physicist & Radio Astronomy Newbie. Leader of the Transient Array Radio Telescope projet

Citation (CITATION.cff)

cff-version: 1.2.0
title: >-
  Specfit: Package for inferring the polynomial
  coefficients and their covariance structure for
  radio-astronometric callibrator spectra
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Timothy C. A.
    email: tim@physics.otago.ac.nz
    affiliation: 'Department of Physics, University of Otago'
    orcid: 'https://orcid.org/0000-0002-2022-0380'
    family-names: Molteno
identifiers:
  - type: url
    value: 'https://github.com/tmolteno/specfit'
    description: Github Page
repository-code: 'https://github.com/tmolteno/specfit'
repository-artifact: 'https://pypi.org/project/specfit/'

GitHub Events

Total
  • Push event: 10
Last Year
  • Push event: 10

Committers

Last synced: about 3 years ago

All Time
  • Total Commits: 37
  • Total Committers: 3
  • Avg Commits per committer: 12.333
  • Development Distribution Score (DDS): 0.054
Top Committers
Name Email Commits
tim t****m@e****z 35
Tim Molteno t****m@m****t 1
Tim Molteno t****m@p****z 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 38 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 5
  • Total maintainers: 1
pypi.org: specfit

Infer polynomial spectral models with covariancess

  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 38 Last month
Rankings
Dependent packages count: 10.1%
Dependent repos count: 21.6%
Downloads: 21.6%
Average: 24.4%
Forks count: 29.8%
Stargazers count: 38.8%
Maintainers (1)
Last synced: 7 months ago

Dependencies

setup.py pypi
  • arviz *
  • h5py *
  • matplotlib *
  • numpy *
  • pymc3 *
.github/workflows/specfit.yaml actions
  • actions/checkout master composite
  • actions/setup-python v3 composite
  • pypa/gh-action-pypi-publish master composite
requirements.txt pypi
  • Pillow ==10.1.0
  • arviz ==0.16.1
  • cachetools ==5.3.2
  • cloudpickle ==3.0.0
  • cons ==0.4.6
  • contourpy ==1.1.1
  • cycler ==0.12.1
  • etuples ==0.3.9
  • fastprogress ==1.0.3
  • filelock ==3.12.4
  • fonttools ==4.43.1
  • h5netcdf ==1.2.0
  • h5py ==3.10.0
  • kiwisolver ==1.4.5
  • logical-unification ==0.4.6
  • matplotlib ==3.8.0
  • miniKanren ==1.0.3
  • multipledispatch ==1.0.0
  • numpy ==1.25.2
  • packaging ==23.2
  • pandas ==2.1.1
  • pymc ==5.9.1
  • pyparsing ==3.1.1
  • pytensor ==2.17.3
  • python-dateutil ==2.8.2
  • pytz ==2023.3.post1
  • scipy ==1.11.3
  • six ==1.16.0
  • toolz ==0.12.0
  • typing_extensions ==4.8.0
  • tzdata ==2023.3
  • xarray ==2023.10.1
  • xarray-einstats ==0.6.0