radiation

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 3 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package radiation describes light by wavelength, from gamma rays to radio, and converts between nanometres, metres, frequency, and photon energy.

Named ranges follow ISO 21348:2007 and the Fermi mission’s coverage, as celestial’s research ledger holds them. The standard is sold, so its ends are read in its published first pages to clause 6.5 and in its proof past that; the ledger says where each was read, and range comments, overlaps.

Profile maps wavelength intervals for false-colour use. The resulting colour still belongs to libtheme; this package determines where each wavelength goes, not how it looks on a screen.

Index

Constants

View Source
const (
	// Electronvolt is one electronvolt, the unit energies here are in.
	// Defined: the unit itself.
	Electronvolt = 1.0
	// Hertz is one hertz, the unit frequencies here are in. Defined: the
	// unit itself.
	Hertz = 1.0
)

Base units have one name; multiples use SI prefixes. A keV is si.Kilo(Electronvolt), and the hydrogen line is 1420.405751 * si.Mega(Hertz). Energy and frequency convert through photon relations; metres use MetresToNm.

Variables

This section is empty.

Functions

func Energy

func Energy(nm float64) float64

Energy returns photon energy in electronvolts from wavelength in nanometres, reversing FromEnergy.

func FromEnergy

func FromEnergy(ev float64) float64

FromEnergy returns photon wavelength in nanometres from energy in electronvolts.

func GHzToNm added in v0.0.3

func GHzToNm(ghz float64) (*float64, error)

GHzToNm converts frequency in GHz to wavelength in nanometres. It returns an error if the resulting wavelength is not positive and finite.

func GeVToNm added in v0.0.3

func GeVToNm(gev float64) (*float64, error)

GeVToNm converts photon energy in GeV to wavelength in nanometres. It returns an error if the resulting wavelength is not positive and finite.

func HertzToNm

func HertzToNm(hz float64) float64

HertzToNm converts frequency in hertz to wavelength in nanometres.

func JanskyToSI

func JanskyToSI(jy float64) float64

JanskyToSI is a spectral flux density in janskys as watts a square metre a hertz, the unit every exported flux density here is in. The jansky is outside the SI: radio and infrared catalogues, WISE's among them, still state flux densities in it.

It lives in radiation, not SI, because SI holds the defining constants and the prefixes, and a jansky is a unit of radiation: a power per area per frequency.

func KeVToNm added in v0.0.3

func KeVToNm(kev float64) (*float64, error)

KeVToNm converts photon energy in keV to wavelength in nanometres. It returns an error if the resulting wavelength is not positive and finite.

func MHzToNm added in v0.0.3

func MHzToNm(mhz float64) (*float64, error)

MHzToNm converts frequency in MHz to wavelength in nanometres. It returns an error if the resulting wavelength is not positive and finite.

func MeVToNm added in v0.0.3

func MeVToNm(mev float64) (*float64, error)

MeVToNm converts photon energy in MeV to wavelength in nanometres. It returns an error if the resulting wavelength is not positive and finite.

func MetresToNm

func MetresToNm(metres float64) float64

MetresToNm converts metres to nanometres. For example, MetresToNm(3.4 * si.Micro(length.Metre)) gives WISE W1’s 3400 nm.

func MicronsToNm added in v0.0.3

func MicronsToNm(um float64) (*float64, error)

MicronsToNm converts micrometres to nanometres, rejecting a result that is not positive and finite.

func NmToHertz

func NmToHertz(nm float64) float64

NmToHertz converts nanometres to hertz, reversing HertzToNm.

func NmToMetres

func NmToMetres(nm float64) float64

NmToMetres converts nanometres to metres, reversing MetresToNm.

func Planck added in v0.0.2

func Planck(nm, kelvin float64) float64

Planck returns black-body spectral radiance at wavelength nm and temperature kelvin, in W m^-2 sr^-1 nm^-1:

2hc² / (λ⁵ * (exp(hc / (λkT)) − 1)).

At or below zero kelvin it returns zero. As with the low-level conversions, nm is assumed to be a valid wavelength.

func TeVToNm added in v0.0.3

func TeVToNm(tev float64) (*float64, error)

TeVToNm converts photon energy in TeV to wavelength in nanometres. It returns an error if the resulting wavelength is not positive and finite.

Types

type Profile

type Profile struct {
	// contains filtered or unexported fields
}

Profile maps one wavelength interval to another linearly in log wavelength. A false-colour profile can use it to place invisible radiation in the visible range; libtheme determines the displayed colour.

func NewProfile

func NewProfile(name string, source, render Range) (*Profile, error)

NewProfile constructs a named mapping from source to render range. An invalid range returns an error and no profile.

func (Profile) Back

func (profile Profile) Back(nm float64) (source float64, ok bool)

Back reverses Onto, returning ok=false outside the half-open render range or when either profile range is invalid.

func (Profile) Holds

func (profile Profile) Holds(nm float64) bool

Holds checks the half-open source range. The zero Profile contains no wavelengths.

func (Profile) Onto

func (profile Profile) Onto(nm float64) (mapped float64, ok bool)

Onto maps a source wavelength into the render interval in log space. Wavelengths outside the source return ok=false rather than an extrapolated answer.

Results remain inside the half-open render range so Back can reverse them. If rounding reaches the exclusive long endpoint, Onto uses the preceding float instead.

func (Profile) String

func (profile Profile) String() string

String formats the profile for humans with eyeballs.

type Range

type Range struct {
	// contains filtered or unexported fields
}

Range is a half-open interval of wavelengths in nanometres: the short endpoint is included and the long endpoint excluded.

func ExtremeUltraviolet

func ExtremeUltraviolet() Range

ExtremeUltraviolet is the extreme ultraviolet, under ISO 21348's name, as published: see iso. It overlaps Ultraviolet.

func Fermi

func Fermi() Range

Fermi returns the mission’s energy coverage as wavelengths. The higher energy becomes the shorter wavelength; this differs from the ISO range.

NASA’s High Energy Astrophysics Science Archive Research Center gives 10 keV to 300 GeV, read on 2026-10-31. Use this interval when matching observations collected by the mission.

func Gamma

func Gamma() Range

Gamma is gamma rays, under ISO 21348's name: see iso.

func Infrared

func Infrared() Range

Infrared is the infrared, under ISO 21348's name: see iso. Radio begins inside it.

func Microwave

func Microwave() Range

Microwave is microwaves, under ISO 21348's name: see iso. Radio begins inside it.

func NewRange

func NewRange(short, long float64) (*Range, error)

NewRange constructs a wavelength interval in nanometres. Both ends must be finite, with 0 < short < long; invalid endpoints return an error.

func Radio

func Radio() Range

Radio is radio waves, under ISO 21348's name: see iso. It begins inside Infrared and Microwave.

func Ultraviolet

func Ultraviolet() Range

Ultraviolet is the ultraviolet, under ISO 21348's name: see iso. It overlaps ExtremeUltraviolet.

func XRay

func XRay() Range

XRay is x-rays, hard and soft together, under ISO 21348's name: see iso.

func (Range) Edges

func (span Range) Edges() (short, long float64)

Edges returns the short and long endpoints in nanometres.

func (Range) Holds

func (span Range) Holds(nm float64) bool

Holds checks wavelength membership, including the short endpoint and excluding the long. The zero Range contains nothing.

func (Range) String

func (span Range) String() string

String formats the wavelength interval for a person reading it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL