Skip to main content
# 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)

Metadata

Release files for HowManyPhotons 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for HowManyPhotons 0.3.0
File Size Uploaded
howmanyphotons-0.3.0.tar.gz 18.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for HowManyPhotons 0.3.0
File Interpreter ABI Platform
howmanyphotons-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 38.1 kB

Release files / howmanyphotons-0.3.0.tar.gz

Download URL howmanyphotons-0.3.0.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d52433f7ee0d39f0181745daf64f06eae772be2ab6bcf1a2ff9b54d962e52b28
BLAKE2b-256 checksum
How to use checksums
54f4307a07098de1df27f61fe5140f4a9efb86d6b4dcc9b4f292192fb5de7994
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.12 Linux/6.11.0-1012-azure

Release files / howmanyphotons-0.3.0-py3-none-any.whl

Download URL howmanyphotons-0.3.0-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0560d4fa29b0929221ca3153b0582042c27d5d357a3cea4d12e211795fa4b416
BLAKE2b-256 checksum
How to use checksums
5efcca5471293bb180883d371a5b57d9dce22a925ad9bb0fbf3b41ebd72f3979
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.12 Linux/6.11.0-1012-azure

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page