@pikaa-ai/pikaa 0.3.23 → 0.3.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/assets/brand/orbit-logo-option4-whale.jpg +0 -0
  2. package/assets/brand/orbit-logo.jpg +0 -0
  3. package/assets/brand/orbit-logo.png +0 -0
  4. package/assets/brand/orbit-logo.svg +3 -0
  5. package/dist/cli.js +407 -219
  6. package/dist/index.js +7 -2
  7. package/package.json +1 -2
  8. package/skills/adaptyv/SKILL.md +0 -240
  9. package/skills/aeon/SKILL.md +0 -402
  10. package/skills/analytical-method-validation/SKILL.md +0 -299
  11. package/skills/anndata/SKILL.md +0 -431
  12. package/skills/arbor/SKILL.md +0 -152
  13. package/skills/arboreto/SKILL.md +0 -267
  14. package/skills/astropy/SKILL.md +0 -353
  15. package/skills/autoskill/SKILL.md +0 -233
  16. package/skills/benchling-integration/SKILL.md +0 -229
  17. package/skills/bgpt-paper-search/SKILL.md +0 -75
  18. package/skills/bids/SKILL.md +0 -237
  19. package/skills/biopython/SKILL.md +0 -472
  20. package/skills/bioservices/SKILL.md +0 -399
  21. package/skills/bulk-rnaseq/SKILL.md +0 -198
  22. package/skills/cellxgene-census/SKILL.md +0 -283
  23. package/skills/cirq/SKILL.md +0 -370
  24. package/skills/citation-management/SKILL.md +0 -329
  25. package/skills/clinical-decision-support/SKILL.md +0 -238
  26. package/skills/clinical-decision-support/references/README.md +0 -62
  27. package/skills/clinical-reports/SKILL.md +0 -248
  28. package/skills/clinical-reports/references/README.md +0 -34
  29. package/skills/cobrapy/SKILL.md +0 -496
  30. package/skills/consciousness-council/SKILL.md +0 -151
  31. package/skills/dask/SKILL.md +0 -482
  32. package/skills/database-lookup/SKILL.md +0 -386
  33. package/skills/datamol/SKILL.md +0 -200
  34. package/skills/deepchem/SKILL.md +0 -244
  35. package/skills/deepspot-m/SKILL.md +0 -175
  36. package/skills/deeptools/SKILL.md +0 -412
  37. package/skills/depmap/SKILL.md +0 -301
  38. package/skills/dhdna-profiler/SKILL.md +0 -184
  39. package/skills/diffdock/SKILL.md +0 -488
  40. package/skills/dnanexus-integration/SKILL.md +0 -325
  41. package/skills/docx/SKILL.md +0 -99
  42. package/skills/esm/SKILL.md +0 -334
  43. package/skills/etetoolkit/SKILL.md +0 -327
  44. package/skills/exa-search/SKILL.md +0 -102
  45. package/skills/executing-plans/SKILL.md +0 -14
  46. package/skills/experimental-design/SKILL.md +0 -234
  47. package/skills/exploratory-data-analysis/SKILL.md +0 -280
  48. package/skills/flowio/SKILL.md +0 -310
  49. package/skills/fluidsim/SKILL.md +0 -279
  50. package/skills/frontend-design/SKILL.md +0 -100
  51. package/skills/generate-image/SKILL.md +0 -304
  52. package/skills/geniml/SKILL.md +0 -310
  53. package/skills/genomic-coordinates/SKILL.md +0 -189
  54. package/skills/genomic-intelligence/SKILL.md +0 -243
  55. package/skills/geomaster/README.md +0 -105
  56. package/skills/geomaster/SKILL.md +0 -366
  57. package/skills/geopandas/SKILL.md +0 -250
  58. package/skills/get-available-resources/SKILL.md +0 -260
  59. package/skills/gget/SKILL.md +0 -153
  60. package/skills/ginkgo-cloud-lab/SKILL.md +0 -106
  61. package/skills/glycoengineering/SKILL.md +0 -339
  62. package/skills/gtars/SKILL.md +0 -282
  63. package/skills/guardian-rails/SKILL.md +0 -54
  64. package/skills/histolab/SKILL.md +0 -243
  65. package/skills/hugging-science/SKILL.md +0 -132
  66. package/skills/hypogenic/SKILL.md +0 -290
  67. package/skills/hypothesis-generation/SKILL.md +0 -264
  68. package/skills/imaging-data-commons/SKILL.md +0 -496
  69. package/skills/infographics/SKILL.md +0 -315
  70. package/skills/iso-standards-readiness/SKILL.md +0 -352
  71. package/skills/lab-hardware-cad/SKILL.md +0 -372
  72. package/skills/labarchive-integration/SKILL.md +0 -216
  73. package/skills/lamindb/SKILL.md +0 -408
  74. package/skills/latchbio-integration/SKILL.md +0 -227
  75. package/skills/latex-posters/SKILL.md +0 -369
  76. package/skills/latex-posters/references/README.md +0 -439
  77. package/skills/liteparse/SKILL.md +0 -295
  78. package/skills/literature-review/SKILL.md +0 -263
  79. package/skills/markdown-mermaid-writing/SKILL.md +0 -322
  80. package/skills/market-research-reports/SKILL.md +0 -337
  81. package/skills/markitdown/SKILL.md +0 -264
  82. package/skills/matchms/SKILL.md +0 -276
  83. package/skills/matlab/SKILL.md +0 -274
  84. package/skills/matplotlib/SKILL.md +0 -378
  85. package/skills/medchem/SKILL.md +0 -321
  86. package/skills/modal/SKILL.md +0 -468
  87. package/skills/molecular-dynamics/SKILL.md +0 -458
  88. package/skills/molfeat/SKILL.md +0 -348
  89. package/skills/ncats-arax/SKILL.md +0 -178
  90. package/skills/networkx/SKILL.md +0 -440
  91. package/skills/neurokit2/SKILL.md +0 -323
  92. package/skills/neuropixels-analysis/SKILL.md +0 -412
  93. package/skills/nextflow/SKILL.md +0 -195
  94. package/skills/omero-integration/SKILL.md +0 -222
  95. package/skills/onekgpd/SKILL.md +0 -371
  96. package/skills/ontology-term-resolution/SKILL.md +0 -147
  97. package/skills/open-notebook/SKILL.md +0 -297
  98. package/skills/openpiv/SKILL.md +0 -469
  99. package/skills/opentrons-integration/SKILL.md +0 -322
  100. package/skills/optimize-for-gpu/SKILL.md +0 -176
  101. package/skills/owasp-top10/SKILL.md +0 -48
  102. package/skills/pacsomatic/LICENSE +0 -21
  103. package/skills/pacsomatic/SKILL.md +0 -150
  104. package/skills/paper-lookup/SKILL.md +0 -263
  105. package/skills/paperclip/SKILL.md +0 -413
  106. package/skills/paperzilla/SKILL.md +0 -159
  107. package/skills/parallel-web/SKILL.md +0 -128
  108. package/skills/pathml/SKILL.md +0 -222
  109. package/skills/pathogen-variant-surveillance/SKILL.md +0 -208
  110. package/skills/pathway-enrichment/SKILL.md +0 -194
  111. package/skills/pdf/SKILL.md +0 -322
  112. package/skills/peer-review/SKILL.md +0 -288
  113. package/skills/penetration-testing/SKILL.md +0 -31
  114. package/skills/pennylane/SKILL.md +0 -240
  115. package/skills/phylogenetics/SKILL.md +0 -409
  116. package/skills/pi-agent/SKILL.md +0 -83
  117. package/skills/pkpd-modeling/SKILL.md +0 -381
  118. package/skills/polars/SKILL.md +0 -393
  119. package/skills/polars-bio/SKILL.md +0 -379
  120. package/skills/ponytail/SKILL.md +0 -31
  121. package/skills/ponytail-audit/SKILL.md +0 -18
  122. package/skills/pptx/SKILL.md +0 -246
  123. package/skills/pptx-posters/SKILL.md +0 -258
  124. package/skills/primekg/SKILL.md +0 -99
  125. package/skills/protocolsio-integration/SKILL.md +0 -236
  126. package/skills/pufferlib/SKILL.md +0 -328
  127. package/skills/pydeseq2/SKILL.md +0 -369
  128. package/skills/pydicom/SKILL.md +0 -381
  129. package/skills/pyhealth/SKILL.md +0 -124
  130. package/skills/pylabrobot/SKILL.md +0 -216
  131. package/skills/pymatgen/SKILL.md +0 -404
  132. package/skills/pymc/SKILL.md +0 -310
  133. package/skills/pymoo/SKILL.md +0 -276
  134. package/skills/pyopenms/SKILL.md +0 -179
  135. package/skills/pysam/SKILL.md +0 -330
  136. package/skills/pytdc/SKILL.md +0 -297
  137. package/skills/pytorch-lightning/SKILL.md +0 -191
  138. package/skills/pyzotero/SKILL.md +0 -137
  139. package/skills/qiskit/SKILL.md +0 -259
  140. package/skills/qutip/SKILL.md +0 -317
  141. package/skills/rdkit/SKILL.md +0 -94
  142. package/skills/relsa-severity-assessment/SKILL.md +0 -354
  143. package/skills/research-grants/SKILL.md +0 -296
  144. package/skills/research-grants/references/README.md +0 -287
  145. package/skills/research-lookup/README.md +0 -106
  146. package/skills/research-lookup/SKILL.md +0 -338
  147. package/skills/rowan/SKILL.md +0 -398
  148. package/skills/scanpy/SKILL.md +0 -303
  149. package/skills/scholar-evaluation/SKILL.md +0 -296
  150. package/skills/scientific-brainstorming/SKILL.md +0 -282
  151. package/skills/scientific-critical-thinking/SKILL.md +0 -180
  152. package/skills/scientific-schematics/SKILL.md +0 -370
  153. package/skills/scientific-slides/SKILL.md +0 -379
  154. package/skills/scientific-visualization/SKILL.md +0 -285
  155. package/skills/scientific-writing/SKILL.md +0 -356
  156. package/skills/scikit-bio/SKILL.md +0 -470
  157. package/skills/scikit-learn/SKILL.md +0 -324
  158. package/skills/scikit-survival/SKILL.md +0 -313
  159. package/skills/scvelo/SKILL.md +0 -328
  160. package/skills/scvi-tools/SKILL.md +0 -201
  161. package/skills/seaborn/SKILL.md +0 -254
  162. package/skills/security-auditor/SKILL.md +0 -37
  163. package/skills/shap/SKILL.md +0 -282
  164. package/skills/simpy/SKILL.md +0 -283
  165. package/skills/stable-baselines3/SKILL.md +0 -325
  166. package/skills/statistical-analysis/SKILL.md +0 -446
  167. package/skills/statistical-power/SKILL.md +0 -200
  168. package/skills/statsmodels/SKILL.md +0 -238
  169. package/skills/sympy/SKILL.md +0 -354
  170. package/skills/systematic-debugging/SKILL.md +0 -35
  171. package/skills/tamarind/SKILL.md +0 -285
  172. package/skills/tdd/SKILL.md +0 -26
  173. package/skills/tiledbvcf/SKILL.md +0 -456
  174. package/skills/timesfm-forecasting/SKILL.md +0 -408
  175. package/skills/timesfm-forecasting/examples/global-temperature/README.md +0 -178
  176. package/skills/torch-geometric/SKILL.md +0 -458
  177. package/skills/torchdrug/SKILL.md +0 -241
  178. package/skills/transformers/SKILL.md +0 -195
  179. package/skills/treatment-plans/SKILL.md +0 -174
  180. package/skills/treatment-plans/references/README.md +0 -19
  181. package/skills/umap-learn/SKILL.md +0 -488
  182. package/skills/uncertainty-and-units/SKILL.md +0 -384
  183. package/skills/usfiscaldata/SKILL.md +0 -171
  184. package/skills/vaex/SKILL.md +0 -204
  185. package/skills/venue-templates/SKILL.md +0 -269
  186. package/skills/verification-before-completion/SKILL.md +0 -22
  187. package/skills/waypoint-bio/SKILL.md +0 -273
  188. package/skills/what-if-oracle/SKILL.md +0 -184
  189. package/skills/writing-plans/SKILL.md +0 -15
  190. package/skills/xlsx/SKILL.md +0 -110
  191. package/skills/zarr-python/SKILL.md +0 -241
@@ -1,384 +0,0 @@
1
- ---
2
- name: uncertainty-and-units
3
- description: Track physical units and propagate measurement uncertainty in scientific calculations using pint and uncertainties. Use for unit conversion and dimensional checking, GUM uncertainty budgets, Type A and Type B evaluation, coverage factors and expanded uncertainty, Monte Carlo propagation, significant-figure and plus-minus reporting, error propagation through curve fits, CODATA constants, auditing Python code for stripped units or broken uncertainty propagation, and order-of-magnitude plausibility checks using dimensionless groups (Reynolds, Peclet, Damkohler, Knudsen, Biot, Womersley), characteristic scales such as diffusion time or Debye length, and observed magnitude ranges. Trigger on "is this number physically reasonable", "sanity check these units", "what regime is this flow in", or a result that looks off by orders of magnitude.
4
- license: MIT
5
- compatibility: Requires Python 3.12+. The numeric CLIs need pint, uncertainties, NumPy, and SciPy; the static auditor is standard-library only. All bundled tooling runs locally with no network access.
6
- allowed-tools: Read Write Edit Bash
7
- metadata:
8
- version: "1.0"
9
- skill-author: K-Dense Inc.
10
- ---
11
-
12
- # Uncertainty and units
13
-
14
- ## Scope
15
-
16
- Use this skill whenever a calculation carries physical units or a reported number needs
17
- an uncertainty. Concretely:
18
-
19
- - converting between units, including conversions that need a physical context
20
- (wavelength to photon energy, mass to amount of substance, energy to temperature);
21
- - propagating uncertainty through a measurement model, with or without correlated inputs;
22
- - building a GUM uncertainty budget from calibration certificates, specifications, and
23
- repeatability data;
24
- - choosing a coverage factor and deciding whether `k = 2` is defensible;
25
- - rounding and writing a result so a reader knows what the `±` means;
26
- - extracting parameter uncertainties from a curve fit without discarding correlations;
27
- - reviewing existing analysis code for silent unit and uncertainty defects;
28
- - checking that a dimensionally consistent answer is also physically possible — the
29
- order of magnitude, the dimensionless group, and the regime it implies.
30
-
31
- This skill covers the metrology and the two libraries that implement it. It does not
32
- cover statistical inference, model selection, or study design — see `statistical-analysis`,
33
- `statistical-power`, and `experimental-design`.
34
-
35
- ## Current release and installation
36
-
37
- Verified 2026-07-26:
38
-
39
- - **pint 0.25.3**, released 2026-03-19; requires Python 3.11+.
40
- - **uncertainties 3.2.3**, released 2025-04-21; requires Python 3.8+.
41
- - **NumPy 2.5.1** and **SciPy 1.18.0**; both require Python 3.12+.
42
- - `scipy.constants` in SciPy 1.18.0 serves **CODATA 2022**. SciPy 1.11 and earlier
43
- served CODATA 2018, and several recommended values differ between them.
44
-
45
- ```bash
46
- uv venv --python 3.13
47
- source .venv/bin/activate
48
- uv pip install "pint==0.25.3" "uncertainties==3.2.3" "numpy==2.5.1" "scipy==1.18.0"
49
- ```
50
-
51
- `pint-pandas` and `pint-xarray` add unit-aware columns and arrays and are separate
52
- installs.
53
-
54
- ## Non-negotiable workflow
55
-
56
- 1. **Attach units at input and strip them only at output.** Convert at function
57
- boundaries with `ureg.wraps` or `m_as("unit")`, never mid-calculation.
58
- 2. **Write the measurement model explicitly** before computing anything, including
59
- corrections whose estimated value is zero. A correction left out of the model leaves
60
- its uncertainty out of the budget.
61
- 3. **Give every input four things**: an estimate, a standard uncertainty, the
62
- distribution the uncertainty came from, and its degrees of freedom.
63
- 4. **Convert Type B statements with the right divisor.** A certificate's expanded
64
- uncertainty divides by its stated `k`; rectangular limits divide by `sqrt(3)`.
65
- 5. **Identify correlations before combining.** Inputs calibrated against the same
66
- standard, measured on the same instrument, or drawn from the same fit are correlated.
67
- 6. **Compute sensitivity coefficients**, and read the budget from `c_i * u(x_i)` rather
68
- than from the raw uncertainties.
69
- 7. **Check the linearization.** Run Monte Carlo alongside the GUM framework and apply
70
- the JCGM 101 clause 8 comparison. Report the Monte Carlo result when it fails.
71
- 8. **Choose `k` from the effective degrees of freedom**, not by habit.
72
- 9. **Round the uncertainty first, then the value to the same decimal place.**
73
- 10. **State what the `±` is** — standard or expanded, with `k`, the coverage probability,
74
- and the method.
75
- 11. **Sanity-check the magnitude before reporting.** A dimensionally consistent result can
76
- still be impossible. Compare it against a known scale or a dimensionless group, and
77
- confirm every assumption you relied on still holds in that regime.
78
-
79
- ## The failures this skill exists to prevent
80
-
81
- Each of the following runs without error and produces a plausible number.
82
-
83
- ### A unit stripped at an unknown scale
84
-
85
- ```python
86
- length = (12.7 * ureg.mm).magnitude # 12.7 -- of what?
87
- length = (12.7 * ureg.mm).m_as("m") # 0.0127 metres, stated
88
- ```
89
-
90
- `.magnitude` returns whatever the quantity happened to be carrying. Name the unit at the
91
- point of extraction, every time.
92
-
93
- ### Offset temperature arithmetic
94
-
95
- ```python
96
- Q(20, "degC") + Q(5, "degC") # OffsetUnitCalculusError -- correctly refused
97
- Q(20, "degC") + Q(5, "delta_degC") # 25 degree_Celsius
98
- Q(25, "degC") - Q(20, "degC") # 5 delta_degree_Celsius
99
- ```
100
-
101
- Celsius and Fahrenheit are interval scales. An uncertainty on a temperature is always a
102
- difference and belongs in a `delta_` unit: converting `20 ± 0.5 degC` to Fahrenheit
103
- gives `68 degF ± 0.9 delta_degF`, two different conversions on one line.
104
-
105
- ### Logarithmic units that add by multiplying
106
-
107
- ```python
108
- Q(10, "dBm") + Q(10, "dBm") # 0.0001 kilogram**2 * meter**4 / second**6
109
- ```
110
-
111
- That is 10 mW × 10 mW, not 20 mW and not 13 dBm. Nothing raises. Convert to a linear
112
- unit before any arithmetic.
113
-
114
- ### A correlation destroyed by a round trip
115
-
116
- ```python
117
- x = ufloat(1.0, 0.1)
118
- x - x # 0.0+/-0
119
- x - ufloat(x.nominal_value, x.std_dev) # 0.00+/-0.14
120
- ```
121
-
122
- Rebuilding a variable from its nominal value and standard deviation creates an
123
- independent variable. So does any serialization that passes through a pair of floats.
124
- Use `correlated_values(values, covariance_matrix)` to rebuild a correlated set.
125
-
126
- ### A covariance matrix silently rescaled
127
-
128
- ```python
129
- popt, pcov = curve_fit(f, x, y, sigma=sigma) # default
130
- popt, pcov = curve_fit(f, x, y, sigma=sigma, absolute_sigma=True)
131
- ```
132
-
133
- The default rescales `pcov` by the reduced chi-square, so the parameter uncertainties
134
- absorb the goodness of fit and match what you would get by passing no `sigma` at all. On
135
- one synthetic straight-line fit the two give `[0.0364, 0.2154]` and `[0.0477, 0.2820]` —
136
- a 31% difference. Pass `absolute_sigma=True` whenever `sigma` holds real standard
137
- uncertainties.
138
-
139
- ### A linearization that was never checked
140
-
141
- For `y = x²` with `x = 1.0 ± 0.5`, the GUM framework gives `y = 1.0`, `u_c = 1.0`, and a
142
- 95% interval of `[-0.96, 2.96]` — mostly negative, for a squared quantity. Monte Carlo
143
- gives a mean of 1.25, `u_c = 1.06`, and a shortest 95% interval of `[0, 3.32]`. Nothing
144
- in a linear-propagation library will tell you this happened.
145
-
146
- ## Bundled local CLIs
147
-
148
- All helpers run offline, reject URLs and symlinks, bound their inputs, write output
149
- atomically with private permissions, and refuse to overwrite without `--force`.
150
-
151
- ```bash
152
- python skills/uncertainty-and-units/scripts/propagate_uncertainty.py --help
153
- python skills/uncertainty-and-units/scripts/uncertainty_budget.py --help
154
- python skills/uncertainty-and-units/scripts/format_result.py --help
155
- python skills/uncertainty-and-units/scripts/convert_units.py --help
156
- python skills/uncertainty-and-units/scripts/audit_units.py --help
157
- python skills/uncertainty-and-units/scripts/check_plausibility.py --help
158
- ```
159
-
160
- ### propagate_uncertainty.py
161
-
162
- Runs both propagation methods on the same model and applies the JCGM 101 clause 8
163
- validation test.
164
-
165
- ```bash
166
- python skills/uncertainty-and-units/scripts/propagate_uncertainty.py \
167
- --expression "m / (pi * (d / 2) ** 2 * h)" \
168
- --variable "m=250.0,0.05" \
169
- --variable "d=20.0,0.02,rectangular" \
170
- --variable "h=40.0,0.05,rectangular" \
171
- --measurand density --unit "g/cm3" --format markdown
172
- ```
173
-
174
- Each `--variable` is `name=value,standard_uncertainty[,distribution[,dof]]`, where the
175
- distribution is `normal`, `rectangular`, `triangular`, `arcsine`, or `exact` and controls
176
- Monte Carlo sampling only. Correlations go in as `--correlation "a,b=0.9"`. A JSON
177
- `--spec` file holds the same model for anything long-lived.
178
-
179
- The expression is parsed into an abstract syntax tree and reduced by an explicit walk
180
- over `+ - * / **` and a fixed list of functions. It is never compiled or executed.
181
-
182
- The report gives the estimate, `u_c`, sensitivity coefficients, the budget in percent,
183
- effective degrees of freedom, `k`, `U`, both Monte Carlo coverage intervals, and the
184
- verdict on whether the linearized result may be reported.
185
-
186
- ### uncertainty_budget.py
187
-
188
- Combines components stated the way certificates and data sheets state them.
189
-
190
- ```bash
191
- python skills/uncertainty-and-units/scripts/uncertainty_budget.py --template > budget.json
192
- python skills/uncertainty-and-units/scripts/uncertainty_budget.py --spec budget.json --format markdown
193
- ```
194
-
195
- Each component names a `distribution` that fixes its divisor — `expanded` divides by its
196
- `coverage_factor`, `rectangular` by `sqrt(3)`, `triangular` by `sqrt(6)`, `arcsine` by
197
- `sqrt(2)`, `normal` by 1 — with an optional `sensitivity`, `dof`, and `relative: true`.
198
- The tool computes `u_c`, the Welch-Satterthwaite effective degrees of freedom, `k` from
199
- the t-distribution, and `U`, and warns when a Type A component has no degrees of
200
- freedom, when `nu_eff` is small enough that `k = 2` is wrong, when one component
201
- dominates, and when a Type B component declared `normal` is probably an undivided
202
- expanded uncertainty.
203
-
204
- ### format_result.py
205
-
206
- ```bash
207
- python skills/uncertainty-and-units/scripts/format_result.py \
208
- --value 12.34567 --uncertainty 0.02345 --unit mm \
209
- --coverage-factor 2.26 --coverage-probability 0.95
210
- ```
211
-
212
- Returns `12.346 ± 0.023 mm`, `12.346(23) mm`, the scientific and LaTeX forms, and the
213
- sentence that has to accompany the number. Warns when one significant digit is requested
214
- for an uncertainty beginning in 1 or 2, and when the uncertainty exceeds the estimate.
215
-
216
- ### convert_units.py
217
-
218
- ```bash
219
- python skills/uncertainty-and-units/scripts/convert_units.py \
220
- --value 532 --unit nm --to eV --context spectroscopy --uncertainty 0.5
221
-
222
- python skills/uncertainty-and-units/scripts/convert_units.py \
223
- --value 1.0 --unit g --to mol --context chemistry --context-parameter "mw=180.156 g/mol"
224
- ```
225
-
226
- Carries the uncertainty through the conversion's local derivative, which matters because
227
- context conversions are reciprocal rather than proportional. Names the context in the
228
- error message when a conversion needs one, and flags offset and logarithmic units.
229
- `--list-contexts` shows what the registry defines.
230
-
231
- ### audit_units.py
232
-
233
- Static review of existing analysis code. Parses, never imports or runs.
234
-
235
- ```bash
236
- python skills/uncertainty-and-units/scripts/audit_units.py \
237
- --input analysis.py --format markdown --fail-on medium
238
- ```
239
-
240
- | Rule | Severity | Detects |
241
- | --- | --- | --- |
242
- | `UNIT001` | medium | a second `UnitRegistry` in one module — cross-registry `ValueError` |
243
- | `UNIT002` | medium | offset temperature units with no `delta_` unit anywhere |
244
- | `UNIT003` | high | `.magnitude` without a preceding `.to(...)` or `.m_as(...)` |
245
- | `UNIT004` | medium | logarithmic units, whose `+` multiplies |
246
- | `UNC001` | high | `curve_fit` without `absolute_sigma` |
247
- | `UNC002` | medium | `np.std` / `np.var` without `ddof` |
248
- | `UNC003` | medium | `math` or `numpy` functions in a module that uses `uncertainties` |
249
- | `UNC004` | high | a `ufloat` rebuilt from `.nominal_value` and `.std_dev` |
250
- | `CONST001` | low | a literal within 0.1% of a CODATA constant |
251
-
252
- Exit status is 1 when a finding meets `--fail-on` (default `high`), which makes it usable
253
- as a pre-commit or CI check.
254
-
255
- The rules are heuristics, so a false positive is suppressed with a directive comment —
256
- trailing to cover its own line, or alone on a line to cover the next one:
257
-
258
- ```python
259
- value = quantity.magnitude # audit-units: ignore UNIT003 -- already converted upstream
260
-
261
- # audit-units: ignore UNC003 -- the argument here is a plain float array
262
- scaled = np.log10(counts)
263
- ```
264
-
265
- `# audit-units: ignore-file CONST001` covers a whole module, and naming no rule
266
- suppresses all of them. Suppressions are counted in the report rather than hidden, so a
267
- file that silences everything still says so.
268
-
269
- ### check_plausibility.py
270
-
271
- Dimensional consistency is not physical possibility. A cell 2 m across and a Reynolds
272
- number of 4e7 in a capillary both pass every unit check. This tool tests a set of
273
- quantities against dimensionless groups, characteristic scales, and curated magnitude
274
- bands, and verifies each formula's dimensionality before reporting a number.
275
-
276
- ```bash
277
- python skills/uncertainty-and-units/scripts/check_plausibility.py \
278
- --quantity "density=1060 kg/m**3" --quantity "velocity=0.5 mm/s" \
279
- --quantity "length=8 um" --quantity "viscosity=3.5 mPa*s" \
280
- --group reynolds --format markdown
281
- # Re = 0.001211 -- laminar (circular pipe, length = diameter)
282
-
283
- python skills/uncertainty-and-units/scripts/check_plausibility.py \
284
- --quantity "diameter=2 m" --band "eukaryotic_cell_diameter=diameter"
285
- # implausible: 4.3 decades outside the 5-100 um range
286
- ```
287
-
288
- `--group` evaluates one of 14 dimensionless groups and names the regime it places the
289
- system in; `--scale` computes a characteristic scale such as a diffusion time, Debye
290
- length, or Stokes settling velocity; `--band` compares a supplied quantity against an
291
- observed range. `--list` prints the whole catalogue with the inputs each formula needs.
292
-
293
- Physical constants (`k_B`, `N_A`, `R_gas`, `g_earth`, and the rest) are available to every
294
- formula without being supplied, and are read from `scipy.constants` at run time rather
295
- than written as literals, so they track the CODATA release SciPy ships.
296
-
297
- The dimensionality check is the point. Passing a kinematic viscosity where the formula
298
- needs a dynamic one — both called "viscosity", both tabulated for water, differing by a
299
- factor of ρ — is refused before any number is computed:
300
-
301
- ```
302
- error: viscosity must have dimensionality [mass] / ([length] * [time]),
303
- but m²/s is [length] ** 2 / [time]
304
- ```
305
-
306
- Exit status is 1 when the verdict meets `--fail-on` (default `implausible`; a value
307
- within one decade of a band is `questionable`). The thresholds are conventions with soft
308
- edges and assume the geometry their correlation was fitted for — see
309
- `references/plausibility-scales.md` for the characteristic length to use in each case.
310
-
311
- ## Choosing a propagation method
312
-
313
- | Situation | Method |
314
- | --- | --- |
315
- | Linear or near-linear model, normal-ish inputs, large dof | GUM framework alone |
316
- | Any nonlinearity across ±2u of an input | run both, apply the clause 8 test |
317
- | Relative uncertainty above ~20% on any input | Monte Carlo |
318
- | Dominant rectangular or otherwise non-normal component | Monte Carlo |
319
- | Output bounded below (variance, concentration, squared quantity) | Monte Carlo |
320
- | Asymmetric output distribution | Monte Carlo, shortest coverage interval |
321
- | Correlated inputs | either, but supply the covariance matrix, not the standard uncertainties alone |
322
-
323
- A model dominated by rectangular contributions fails the clause 8 test even when it is
324
- perfectly linear: the framework's `k = 1.96` over-covers a nearly trapezoidal output.
325
- The estimate and `u_c` are still right; only the interval is too wide.
326
-
327
- ## Constants
328
-
329
- Never type a constant from memory. The 2019 SI redefinition fixed `c`, `h`, `e`, `k`,
330
- and `N_A` exactly, so their relative standard uncertainty is zero; everything else is a
331
- measured value that moves between CODATA releases.
332
-
333
- ```python
334
- import scipy.constants as constants
335
-
336
- constants.value("electron mass") # 9.1093837139e-31
337
- constants.unit("electron mass") # kg
338
- constants.precision("electron mass") # 3.07e-10, relative standard uncertainty
339
- constants.precision("Planck constant") # 0.0, exact by definition
340
- ```
341
-
342
- `precision` returns a *relative* standard uncertainty; multiply by the value for the
343
- absolute one.
344
-
345
- ## Reference files
346
-
347
- - `references/gum-methodology.md` — Type A and Type B evaluation, distribution divisors,
348
- the law of propagation, Welch-Satterthwaite, when the framework fails, the Monte Carlo
349
- procedure, and the clause 8 validation test.
350
- - `references/pint-recipes.md` — registries, offset and logarithmic units, contexts,
351
- boundary enforcement with `wraps` and `check`, NumPy interoperability, custom units,
352
- formatting.
353
- - `references/uncertainties-recipes.md` — variable identity and correlation,
354
- `correlated_values`, `umath` and `unumpy`, format specs, fit covariance matrices, and
355
- the package's limits.
356
- - `references/domain-conversions.md` — the energy ladder, spectroscopy, concentration,
357
- pressure, radiation and magnetism, mass spectrometry, logarithmic quantities, and the
358
- pairs that share dimensions without sharing meaning.
359
- - `references/reporting-rules.md` — rounding, notations, the sentence that must
360
- accompany a result, SD versus SEM versus CI in figures, non-detects, and conformity
361
- decision rules.
362
- - `references/plausibility-scales.md` — choosing the characteristic length, the
363
- dimensionless groups and the modelling assumption each one gates, characteristic
364
- scales, the observed magnitude bands and their sources, and the caveats on every
365
- threshold.
366
-
367
- ## Dated sources
368
-
369
- Checked 2026-07-26:
370
-
371
- - [JCGM 100:2008, Evaluation of measurement data — Guide to the expression of
372
- uncertainty in measurement](https://www.bipm.org/documents/20126/2071204/JCGM_100_2008_E.pdf)
373
- - [JCGM 101:2008, Supplement 1 — Propagation of distributions using a Monte Carlo
374
- method](https://www.bipm.org/documents/20126/2071204/JCGM_101_2008_E.pdf)
375
- - [NIST Technical Note 1297](https://nvlpubs.nist.gov/nistpubs/Legacy/TN/nbstechnicalnote1297.pdf)
376
- - [CODATA internationally recommended values](https://physics.nist.gov/cuu/Constants/)
377
- - [Pint on PyPI](https://pypi.org/project/Pint/) — 0.25.3, released 2026-03-19.
378
- - [Pint documentation](https://pint.readthedocs.io/en/stable/), including
379
- [non-multiplicative units](https://pint.readthedocs.io/en/stable/user/nonmult.html)
380
- and [contexts](https://pint.readthedocs.io/en/stable/user/contexts.html).
381
- - [uncertainties on PyPI](https://pypi.org/project/uncertainties/) — 3.2.3, released
382
- 2025-04-21.
383
- - [uncertainties documentation](https://uncertainties.readthedocs.io/en/latest/)
384
- - [scipy.constants reference](https://docs.scipy.org/doc/scipy/reference/constants.html)
@@ -1,171 +0,0 @@
1
- ---
2
- name: usfiscaldata
3
- description: Query the U.S. Treasury Fiscal Data REST API for federal financial data. No API key required. Use for national debt (Debt to the Penny), Daily Treasury Statements, Monthly Treasury Statements, Treasury securities auctions, interest rates, foreign exchange rates, savings bonds, or U.S. government revenue and spending statistics.
4
- license: MIT
5
- allowed-tools: Read Write Edit Bash
6
- metadata:
7
- version: "1.1"
8
- skill-author: K-Dense Inc.
9
- ---
10
-
11
- # U.S. Treasury Fiscal Data API
12
-
13
- Free, open REST API from the U.S. Department of the Treasury for federal financial data. No API key or registration required.
14
-
15
- **Base URL:** `https://api.fiscaldata.treasury.gov/services/api/fiscal_service`
16
-
17
- Browse [54 datasets and 179 data tables](https://fiscaldata.treasury.gov/datasets/) via the dataset search. Verify endpoint paths on each dataset's API Quick Guide — paths change over time.
18
-
19
- ## Installation
20
-
21
- ```bash
22
- uv pip install requests pandas
23
- ```
24
-
25
- ## Quick Start
26
-
27
- ```python
28
- import requests
29
- import pandas as pd
30
-
31
- BASE_URL = "https://api.fiscaldata.treasury.gov/services/api/fiscal_service"
32
-
33
- # Get the current national debt (Debt to the Penny)
34
- resp = requests.get(f"{BASE_URL}/v2/accounting/od/debt_to_penny", params={
35
- "sort": "-record_date",
36
- "page[size]": 1
37
- })
38
- data = resp.json()["data"][0]
39
- print(f"Total public debt as of {data['record_date']}: ${float(data['tot_pub_debt_out_amt']):,.0f}")
40
- ```
41
-
42
- ```python
43
- # Get Treasury exchange rates for recent quarters
44
- resp = requests.get(f"{BASE_URL}/v1/accounting/od/rates_of_exchange", params={
45
- "fields": "country_currency_desc,exchange_rate,record_date",
46
- "filter": "record_date:gte:2024-01-01",
47
- "sort": "-record_date",
48
- "page[size]": 100
49
- })
50
- df = pd.DataFrame(resp.json()["data"])
51
- ```
52
-
53
- ## Authentication
54
-
55
- None required. The API is fully open and free.
56
-
57
- ## Core Parameters
58
-
59
- | Parameter | Example | Description |
60
- |-----------|---------|-------------|
61
- | `fields=` | `fields=record_date,tot_pub_debt_out_amt` | Select specific columns |
62
- | `filter=` | `filter=record_date:gte:2024-01-01` | Filter records |
63
- | `sort=` | `sort=-record_date` | Sort (prefix `-` for descending) |
64
- | `format=` | `format=json` | Output format: `json`, `csv`, `xml` |
65
- | `page[size]=` | `page[size]=100` | Records per page (default 100) |
66
- | `page[number]=` | `page[number]=2` | Page index (starts at 1) |
67
-
68
- **Filter operators:** `lt`, `lte`, `gt`, `gte`, `eq`, `in`
69
-
70
- ```python
71
- # Multiple filters separated by comma
72
- "filter=country_currency_desc:in:(Canada-Dollar,Mexico-Peso),record_date:gte:2024-01-01"
73
- ```
74
-
75
- ## Key Datasets & Endpoints
76
-
77
- ### Debt
78
-
79
- | Dataset | Endpoint | Frequency |
80
- |---------|----------|-----------|
81
- | Debt to the Penny | `/v2/accounting/od/debt_to_penny` | Daily |
82
- | Historical Debt Outstanding | `/v2/accounting/od/debt_outstanding` | Annual |
83
- | Schedules of Federal Debt | `/v1/accounting/od/schedules_fed_debt` | Monthly |
84
-
85
- ### Daily & Monthly Statements
86
-
87
- | Dataset | Endpoint | Frequency |
88
- |---------|----------|-----------|
89
- | DTS Operating Cash Balance | `/v1/accounting/dts/operating_cash_balance` | Daily |
90
- | DTS Deposits & Withdrawals | `/v1/accounting/dts/deposits_withdrawals_operating_cash` | Daily |
91
- | Monthly Treasury Statement (MTS) | `/v1/accounting/mts/mts_table_1` (18 tables — see [datasets-fiscal.md](references/datasets-fiscal.md)) | Monthly |
92
-
93
- ### Interest Rates & Exchange
94
-
95
- | Dataset | Endpoint | Frequency |
96
- |---------|----------|-----------|
97
- | Average Interest Rates on Treasury Securities | `/v2/accounting/od/avg_interest_rates` | Monthly |
98
- | Treasury Reporting Rates of Exchange | `/v1/accounting/od/rates_of_exchange` | Quarterly |
99
- | Interest Expense on Public Debt | `/v2/accounting/od/interest_expense` | Monthly |
100
-
101
- ### Securities & Auctions
102
-
103
- | Dataset | Endpoint | Frequency |
104
- |---------|----------|-----------|
105
- | Treasury Securities Auctions Data | `/v1/accounting/od/auctions_query` | As Needed |
106
- | Treasury Securities Upcoming Auctions | `/v1/accounting/od/upcoming_auctions` | As Needed |
107
- | Treasury Securities Buybacks | `/v1/accounting/od/buybacks_operations` | As Needed |
108
-
109
- ### Savings Bonds
110
-
111
- | Dataset | Endpoint | Frequency |
112
- |---------|----------|-----------|
113
- | I Bonds Interest Rates | `/v1/accounting/od/i_bonds_interest_rates` | Semi-Annual |
114
- | Savings Bonds Issues, Redemptions & Maturities | `/v1/accounting/od/savings_bonds_report` | Monthly |
115
-
116
- ## Response Structure
117
-
118
- ```json
119
- {
120
- "data": [...],
121
- "meta": {
122
- "count": 100,
123
- "total-count": 3790,
124
- "total-pages": 38,
125
- "labels": {"field_name": "Human Readable Label"},
126
- "dataTypes": {"field_name": "STRING|NUMBER|DATE|CURRENCY"},
127
- "dataFormats": {"field_name": "String|10.2|YYYY-MM-DD"}
128
- },
129
- "links": {"self": "...", "first": "...", "prev": null, "next": "...", "last": "..."}
130
- }
131
- ```
132
-
133
- **Note:** All values are returned as strings. Convert as needed (e.g., `float()`, `pd.to_datetime()`). Null values appear as the string `"null"`.
134
-
135
- ## Common Patterns
136
-
137
- ### Load all pages into a DataFrame
138
-
139
- Use the bounded `fetch_all()` helper in [parameters.md](references/parameters.md). For small result sets, a single request with `page[size]=10000` may suffice when `meta.total-pages` is 1.
140
-
141
- ```python
142
- # Single-page fetch when total-pages == 1
143
- params = {"sort": "-record_date", "page[size]": 10000}
144
- resp = requests.get(f"{BASE_URL}/v2/accounting/od/debt_outstanding", params=params)
145
- result = resp.json()
146
- if result["meta"]["total-pages"] > 1:
147
- raise ValueError("Use fetch_all() from parameters.md for multi-page results")
148
- df = pd.DataFrame(result["data"])
149
- ```
150
-
151
- ### Aggregation (automatic sum)
152
-
153
- Omitting grouping fields triggers automatic aggregation:
154
-
155
- ```python
156
- # Sum all deposits/withdrawals by record_date and transaction type
157
- resp = requests.get(f"{BASE_URL}/v1/accounting/dts/deposits_withdrawals_operating_cash", params={
158
- "fields": "record_date,transaction_type,transaction_today_amt"
159
- })
160
- ```
161
-
162
- ## Reference Files
163
-
164
- - **[api-basics.md](references/api-basics.md)** — URL structure, HTTP methods, versioning, data types
165
- - **[parameters.md](references/parameters.md)** — All parameters with detailed examples and edge cases
166
- - **[datasets-debt.md](references/datasets-debt.md)** — Debt datasets: Debt to the Penny, Historical Debt, Schedules of Federal Debt, TROR
167
- - **[datasets-fiscal.md](references/datasets-fiscal.md)** — Daily Treasury Statement, Monthly Treasury Statement, revenue, spending
168
- - **[datasets-interest-rates.md](references/datasets-interest-rates.md)** — Average interest rates, exchange rates, TIPS/CPI, certified interest rates
169
- - **[datasets-securities.md](references/datasets-securities.md)** — Treasury auctions, savings bonds, SLGS, buybacks
170
- - **[response-format.md](references/response-format.md)** — Response objects, error handling, pagination, response codes
171
- - **[examples.md](references/examples.md)** — Python, R, and pandas code examples for common use cases