Skip to main content

Simple photon count utility for astronomical fluxes

Project description

# How Many Photons

Build Status Poetry dev version

codecov PyPI - Version PyPI - Python Version

License: GPL v3

Tiny repo to calculate astronomical photon counts for various instruments

[!NOTE] The python package must be called using the abbreviation hmbp.

The abbreviation ("how many bloody photons") is an expression of the authors frustration with the various convoluted legacy units still used in modern day Astronomy.

Install

pip install HowManyPhotons

Basic usage

HowManyPhotons is mainly used to determine how many photons fall within the wavelength range of any instrument filter contained in the spanish VO filter database.

from astropy import units as u
import hmbp

hmbp.for_flux_in_filter("V", 10*u.ABmag)
hmbp.convert(from_quantity=10*u.mJy, to_unit=u.mag, filter_name="J", 
             instrument="HAWKI", observatory="Paranal")

Input and output units

hmbp accepts and converts between u.mag (Vega), u.ABmag and u.Jy.

ALL functions return photons counts in units of [ph s-1 m-2].

[!WARNING] ONLY the filter curve is included in the calclutation. The following instrumental transmission profiles are NOT included in the photon flux calculation:

  • atmospheric transmission
  • mirror reflection
  • detector quantum efficiency

These spectral profiles may be included in later releases of HowManyBloodyPhotons, but they are currently NOT considered.

Main functions

The are two main functions: for_flux_in_filter and convert:

hmbp.for_flux_in_filter

Returns the number of incoming photons through a specific filter. If no instrument and observatory are provided, hmbp looks for a corresponding filter_name in the dictionary hmbp.FILTER_DEFAULTS.

The result is an astropy.Quantity with the units [ph s-1 m-2].

Function signature:

hmbp.for_flux_in_filter(filter_name, flux, instrument=None, observatory=None)

Some short examples:

hmbp.for_flux_in_filter("V", 10*u.ABmag)
hmbp.for_flux_in_filter("Ks", 20*u.mag, instrument="HAWKI", observatory="Paranal")
hmbp.for_flux_in_filter("Si6", 1*u.Jy, instrument="Michelle", observatory="Gemini")

hmbp.convert

Converts one common flux unit into another common flux: (mag, ABmag, Jy)

Function signature:

hmbp.convert(from_quantity, to_unit, filter_name, instrument=None, observatory=None)

Some short examples:

hmbp.convert(10*u.mag, u.Jy, "BrGamma")
hmbp.convert(from_quantity=0*u.mag, to_unit=u.ABmag, filter_name="J",
             instrument="HAWKI", observatory="Paranal")

Convenience functions

We have also provided a few helper functions for several common flux conversions:

  • hmbp.in_zero_vega_mags
  • hmbp.in_zero_AB_mags
  • hmbp.in_one_jansky
  • hmbp.in_skycalc_background

The function signatures follow the same pattern as hmbp.for_flux_in_filter, just without needing to explicitly specify the flux parameter.

Returned units are [ph s-1 m-2]

Some short examples:

hmbp.in_zero_vega_mags("V")
hmbp.in_zero_AB_mags("Ks", "HAWKI", "Paranal")
hmbp.in_one_jansky("NeII", instrument="VISIR", observatory="Paranal")
hmbp.in_skycalc_background("M", airmass=2.0, pwv=5.0)

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

howmanyphotons-0.3.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

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

howmanyphotons-0.3.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file howmanyphotons-0.3.0.tar.gz.

File metadata

  • Download URL: howmanyphotons-0.3.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.12 Linux/6.11.0-1012-azure

File hashes

Hashes for howmanyphotons-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d52433f7ee0d39f0181745daf64f06eae772be2ab6bcf1a2ff9b54d962e52b28
MD5 b0744d7d97273a0c20a17328601ce86a
BLAKE2b-256 54f4307a07098de1df27f61fe5140f4a9efb86d6b4dcc9b4f292192fb5de7994

See more details on using hashes here.

File details

Details for the file howmanyphotons-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: howmanyphotons-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.12 Linux/6.11.0-1012-azure

File hashes

Hashes for howmanyphotons-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0560d4fa29b0929221ca3153b0582042c27d5d357a3cea4d12e211795fa4b416
MD5 117d8444798660a4e46483b09e99529d
BLAKE2b-256 5efcca5471293bb180883d371a5b57d9dce22a925ad9bb0fbf3b41ebd72f3979

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