Skip to content
Back to skills

Units Constants

ASecurity

"Use Astropy units, quantities, equivalencies, custom units,

  • 247 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 8, 2026
content-marketingexpressapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill units-constants --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Units Constants?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Units Constants
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-units-constants/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-units-constants)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: units-constants
description: "Use Astropy units, quantities, equivalencies, custom units,
  physical types, and physical constants safely in astronomy calculations."
metadata:
  disco-role: operating
disable-model-invocation: true
license: BSD 3-Clause
---

# Units and Constants Router

Use this sub-skill when a task centers on Astropy physical units, unit-aware
arrays, conversions, equivalencies, constants, or unit validation.

## Load This When

- The user asks for `Quantity`, `Unit`, `u.Quantity`, `.to()`, `.to_value()`,
  `.decompose()`, `.si`, `.cgs`, or unit arithmetic.
- A value must carry units through NumPy operations or an astronomy formula.
- A conversion needs an equivalency: spectral wavelength/frequency/energy,
  Doppler velocity, temperature, parallax, brightness temperature, or
  dimensionless angles.
- The task defines custom units, parses unit strings, validates physical types,
  or needs VOUnit/FITS/CDS formatting.
- Constants such as `c`, `G`, `h`, `M_sun`, or versioned CODATA/IAU constants
  are involved.

## Route Away When

- Coordinate frames, `SkyCoord`, `Time`, or observation locations dominate; use
  `../time-coordinates/SKILL.md`.
- Unit-bearing table serialization is the main issue; use
  `../tables-io/SKILL.md`.
- Cosmological units or built-in cosmology realizations dominate; use
  `../cosmology/SKILL.md`.
- The problem is installation or optional dependency setup; use
  `../cli-config-data/SKILL.md` or the root troubleshooting reference.

## First Actions

1. Identify whether each input is a scalar, NumPy array, `Quantity`, `Unit`,
   string unit, or constant.
2. Convert to a `Quantity` early: `value * u.unit` or `u.Quantity(value, unit)`.
3. Keep quantities unit-aware until an external package requires raw values.
4. Use `.to(target_unit, equivalencies=...)` for conversion and `.to_value(...)`
   only at boundaries.
5. If `.to()` fails, decide whether an equivalency is scientifically justified.
6. For constants, inspect the attached unit and whether SI/CGS ambiguity exists
   before using a raw `.value`.
7. Validate output with a dimensional check: `quantity.unit.is_equivalent(...)`
   or `quantity.physical_type`.

## References

- [references/api-reference.md](references/api-reference.md) lists the verified
  constructors and key APIs for units, quantities, equivalencies, and constants.
- [references/workflows.md](references/workflows.md) gives self-contained
  recipes for unit-aware calculations, equivalencies, custom units, NumPy
  interop, and constants.
- [references/troubleshooting.md](references/troubleshooting.md) covers
  conversion errors, cgs electromagnetic ambiguity, lost units, parser strictness,
  and formatting pitfalls.

## Safety and Validation

- Never silently strip units for convenience. If a raw number is required,
  state the target unit used for `.to_value()`.
- Do not apply an equivalency unless the science context warrants it; record
  which equivalency was used.
- Avoid comparing raw `.value` across quantities with different but compatible
  units.
- Use constants as quantities (`const.c`, `const.G`) rather than copying numeric
  values into code.
- For publication or reproducibility, mention the constants version if a result
  depends sensitively on CODATA/IAU revisions.

## Native-Backed Validation Ideas

- Convert `42 * u.km / u.s` to `u.m / u.s` and assert `42000`.
- Convert wavelength to frequency with `u.spectral()` and assert the output unit
  is equivalent to Hz.
- Use a constant in an expression and assert the resulting unit is physically
  expected.

Files in this skill

  • SKILL.md3.5 KB
  • references/api-reference.md2.4 KB
  • references/troubleshooting.md1.6 KB
  • references/workflows.md1.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.