0.0.10 • Published 9 months ago

@classmodel/class v0.0.10

Weekly downloads
-
License
GPL-3.0-only
Repository
github
Last release
9 months ago

@classmodel/class package

github repo badge Code quality npmjs.com Checked with Biome Research Software Directory Badge Documentation

This is an implementation of the Chemistry Land-surface Atmosphere Soil Slab (CLASS) model that runs entirely in the browser or any Javascript runtime like NodeJS.

For more information on CLASS, see https://classmodel.github.io/.

Web application

The CLASS web application that uses this package is available at https://classmodel.github.io/class-web.

Command line usage

The class model can be run from the command line.

# Generate default config file
pnpx @classmodel/class generate --output config.json

# Run the model
pnpx @classmodel/class run config.json
# Outputs h variable for each timestep in JSON format

# To output csv use
pnpx @classmodel/class run --output output.csv --formtat csv config.json

# To read from stdin use
cat config.json | pnpx @classmodel/class -

If you do not have pnpx installed you can use npx instead.

In development use pnpx tsx src/cli.ts ./config.json.

To use the reference configuration of a experiment downloaded from the web application extract it with jq using

jq .reference < ~/Downloads/class-MyExperiment.json  > config.json

Package usage

Install with

pnpm install @classmodel/class

Run model with default config use

import { runClass } from "@classmodel/class/runner";
const config = {}
const output = runClass(config)
console.log(output)

Developers

This package is part of a monorepo with other packages and applications.

JSON schema

The Class model uses a JSON schema to validate the input configuration. The schema is defined in the @classmodel/class package and can be found at src/config.json (in repo). The schema is used to validate the input configuration and to generate a form to input the configuration.

The src/config.ts file contains the embedded JSON schema and its Typescript type definition. When runnning pnpm dev or pnpm build the src/config.ts file is generated from the src/config.json file.

To manually generate the src/config.ts file run the following command:

pnpm json2ts

Linter

To check types, you can run the pnpm typecheck command as other commands ignore types.

Tests

The unit tests are written with node:test and node:assert.

The unit tests can be run with the following command:

pnpm test

To get test coverage

# Does not work via pnpm script so need to call node directly
node --import tsx --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info src/*.test.ts
# To generate a html report use genhtml which is part of lcov OS package
genhtml lcov.info --output-directory coverage

API Documentation

The API documention of the package can be generated with

pnpm run docs

Which will write HTML files to docs/ directory.

The documentation of the latest release is published at https://classmodel.github.io/class-web/docs/.

0.0.10

9 months ago

0.0.9

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago