@climateriskcommons/crc-framework 0.5.4 → 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 CHANGED
@@ -1,8 +1,9 @@
1
- # @climateriskcommons/crc-framework
1
+ # CRC Framework for JavaScript
2
2
 
3
- Official JavaScript/WebAssembly bindings for CRC Framework: consume canonical
4
- climate curves, evaluate quantiles, and reuse prepared collections. The ESM
5
- package includes TypeScript declarations and has no runtime npm dependencies.
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,40 +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
- ```js
44
- import init, { evaluateCurve, evaluateCurves, prepareCurve, prepareCurves } from '@climateriskcommons/crc-framework';
45
-
46
- await init(); // client startup, once; imports themselves are safe during SSR
47
- const properties = {
48
- curve_kind: 'fitted', curve_type: 'gumbel_r',
49
- curve_location: 1, curve_scale: 2,
50
- };
51
- const value = evaluateCurve(properties, 0.99);
52
- const values = evaluateCurves([properties, properties], 0.99);
53
- const curve = prepareCurve(properties);
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
- const quantiles = curve.quantiles([0.5, 0.9, 0.99]);
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(); // prepared handles own WASM memory
67
+ curve.free();
58
68
  }
59
69
  ```
60
70
 
61
- Use `@alpha` for prereleases and omit it for stable releases. From
62
- `0.5.3-alpha.1`, replace imports of `@riskthinking.ai/crc-framework` with
63
- `@climateriskcommons/crc-framework`, including the WASM asset subpath.
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.
64
86
 
65
- ## Guides
87
+ Use shared structural and scientific validation without guessing schema URIs:
66
88
 
67
- - [JavaScript guide](https://github.com/RiskThinking/crc-framework-rs/blob/v0.5.4/docs/javascript.md): browser/bundler/Node initialization,
68
- prepared handles, canonical inputs, support ranges, and errors.
69
- - [Project README](https://github.com/RiskThinking/crc-framework-rs/blob/v0.5.4/README.md): Python quick start and framework scope.
70
- - [Documentation index](https://github.com/RiskThinking/crc-framework-rs/blob/v0.5.4/docs/README.md): reading order and responsibility boundaries.
71
- - [Development](https://github.com/RiskThinking/crc-framework-rs/blob/v0.5.4/docs/development.md): build, test, and packaging.
72
- - [Releases](https://github.com/RiskThinking/crc-framework-rs/blob/v0.5.4/docs/releases.md): versions and publishing.
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
+ ```
73
96
 
74
- ## License
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.
75
103
 
76
- AGPL-3.0-or-later. See the packaged `LICENSE` and `THIRD_PARTY_NOTICES.md`.
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.