@climateriskcommons/crc-framework 0.6.0 → 1.0.0-alpha.1
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.
- package/README.md +59 -29
- package/contracts/api/public-api.json +2631 -0
- package/contracts/api/release.json +17 -0
- package/contracts/dataset/dataset-2.0.schema.json +1193 -0
- package/contracts/dataset/fixtures.json +7040 -0
- package/contracts/numerical/fitting-1.0.schema.json +886 -0
- package/contracts/numerical/fixtures-1.0.json +4180 -0
- package/contracts/numerical/numerical-1.0.schema.json +757 -0
- package/contracts/scientific/fixtures-1.0.json +1094 -0
- package/contracts/scientific/impact-2.0.schema.json +409 -0
- package/contracts/scientific/impact-context-1.0.schema.json +367 -0
- package/contracts/scientific/impact-reference-2.0.schema.json +45 -0
- package/contracts/scientific/kernel-bindings-1.0.json +44 -0
- package/contracts/scientific/measurement-1.0.schema.json +612 -0
- package/contracts/scientific/models-1.0.json +3759 -0
- package/contracts/taxonomy/fixtures.json +200 -0
- package/contracts/taxonomy/taxonomy-1.0.schema.json +313 -0
- package/package.json +6 -3
- package/src/bindings.js +107 -0
- package/src/index.d.ts +41 -70
- package/src/index.js +4 -209
- package/src/node.js +14 -0
- package/wasm/crc_framework.d.ts +21 -32
- package/wasm/crc_framework.js +146 -115
- package/wasm/crc_framework_bg.wasm +0 -0
- package/wasm/crc_framework_bg.wasm.d.ts +12 -10
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# CRC Framework for JavaScript
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Consume the same current numerical and scientific documents used by Python and
|
|
4
|
+
canonical datasets. The package includes WebAssembly, TypeScript declarations,
|
|
5
|
+
and the current JSON Schemas. Dataset workflows and data acquisition belong to
|
|
6
|
+
CRC-SDK.
|
|
6
7
|
|
|
7
8
|
## Contributors
|
|
8
9
|
|
|
@@ -37,39 +38,68 @@ both on and off GitHub using [All Contributors](https://allcontributors.org/).
|
|
|
37
38
|
## Installation and quick start
|
|
38
39
|
|
|
39
40
|
```sh
|
|
40
|
-
npm install @climateriskcommons/crc-framework
|
|
41
|
+
npm install @climateriskcommons/crc-framework@alpha
|
|
41
42
|
```
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
Create numerical evidence in Python without authoring a serialization envelope:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from pathlib import Path
|
|
48
|
+
from crc_framework import QuantileCurve
|
|
49
|
+
|
|
50
|
+
curve = QuantileCurve([0.9, 0.99, 0.999], [0.5, 2, 5])
|
|
51
|
+
Path("depth.numerical.json").write_text(curve.to_json(), encoding="utf-8")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Read that document in Node:
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
import { readFile } from "node:fs/promises";
|
|
58
|
+
import init, { prepareNumerical } from "@climateriskcommons/crc-framework";
|
|
59
|
+
|
|
60
|
+
await init();
|
|
61
|
+
const text = await readFile("depth.numerical.json", "utf8");
|
|
62
|
+
const curve = prepareNumerical(text);
|
|
54
63
|
try {
|
|
55
|
-
|
|
64
|
+
console.log(curve.quantile(0.99)); // 2: the supplied 100-year upper-tail level
|
|
65
|
+
console.log(curve.quantile([0.9, 0.99])); // Float64Array
|
|
56
66
|
} finally {
|
|
57
|
-
curve.free();
|
|
67
|
+
curve.free();
|
|
58
68
|
}
|
|
59
69
|
```
|
|
60
70
|
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
Import the package during server rendering or in browser code. Call
|
|
72
|
+
`await init()` before running queries or validation. Node.js and browser
|
|
73
|
+
bundlers load the packaged WebAssembly asset. To use your own copy, pass a
|
|
74
|
+
WebAssembly module, bytes, or a URL to `init`.
|
|
75
|
+
|
|
76
|
+
`quantile(text, probabilities)` performs a one-shot query. `prepareNumericals`
|
|
77
|
+
accepts an array of numerical documents as JSON text and returns one result per
|
|
78
|
+
document for each scalar probability query. Prepared handles own their native
|
|
79
|
+
memory; `free()` is idempotent and further queries fail.
|
|
80
|
+
|
|
81
|
+
Partial evidence is queried only on its actual interval. Invalid coordinates,
|
|
82
|
+
malformed documents, historical records, and out-of-support queries fail.
|
|
83
|
+
Mathematical infinite endpoints remain JavaScript infinities. Missing data is a
|
|
84
|
+
retained dataset failure, never a fictional numerical distribution or a silent
|
|
85
|
+
null result.
|
|
63
86
|
|
|
64
|
-
|
|
87
|
+
Use shared structural and scientific validation without guessing schema URIs:
|
|
65
88
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
89
|
+
```javascript
|
|
90
|
+
import init, { DocumentSchema, validateDocument } from "@climateriskcommons/crc-framework";
|
|
91
|
+
|
|
92
|
+
await init();
|
|
93
|
+
const response = await fetch("/dataset.json");
|
|
94
|
+
validateDocument(DocumentSchema.DATASET, await response.text());
|
|
95
|
+
```
|
|
72
96
|
|
|
73
|
-
|
|
97
|
+
Supply original JSON text to preserve unsigned 64-bit cell identifiers and arbitrary
|
|
98
|
+
scientific integers. JavaScript's ordinary JSON parser cannot represent every
|
|
99
|
+
integer exactly. Current schemas are also available under the package's
|
|
100
|
+
`contracts/` export. Model provenance, scientific references, fit execution
|
|
101
|
+
records, spatial support, and row-key integrity are validated consistently with
|
|
102
|
+
Python.
|
|
74
103
|
|
|
75
|
-
|
|
104
|
+
See the repository's [scientific measurement reference](https://github.com/RiskThinking/crc-framework-rs/blob/v1.0.0-alpha.1/docs/measurements.md)
|
|
105
|
+
and [Python guide](https://github.com/RiskThinking/crc-framework-rs/blob/v1.0.0-alpha.1/docs/python.md) for scientific declarations and fitting.
|