thrustcurve-db 0.3.13 → 1.0.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 +53 -47
- package/index.js +1 -5
- package/package.json +5 -2
- package/thrustcurve-db.d.ts +4 -14
- package/thrustcurve-db.json +1345 -174
- package/util.js +0 -101
package/README.md
CHANGED
|
@@ -3,63 +3,69 @@
|
|
|
3
3
|
ThrustCurve.org model rocket motor data as a static data structure (plus misc.
|
|
4
4
|
utility functions).
|
|
5
5
|
|
|
6
|
-
This module is a rebundling of the rocket motor data
|
|
7
|
-
[thrustcurve.org](https://thrustcurve.org) website ("TC").
|
|
8
|
-
|
|
9
|
-
* Where available, thrust curve data (from the 'download' endpoint) is included as a `samples` array. These are normalized to always have `[0, 0]` as the first data point. In cases where a motor has more than one thrust sample file the first "cert"(ified) file found is used, otherwise the samples are from whichever file the API returned first. (This typically isn't an issue since most thrust curves are very similar, but there are some cases where they differ significantly).
|
|
6
|
+
This module is a rebundling of the model rocket motor data found at John Coker's
|
|
7
|
+
[thrustcurve.org](https://thrustcurve.org) website ("TC"). It is available here
|
|
8
|
+
in JSON format, or as an ESM or CommonJS module.
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
The format of this data is identical to that of the TC [/api/v1/search response](https://github.com/JohnCoker/thrustcurve3/blob/8bd8571fe0791fb9a68a6a96eb36c276d58c339b/config/api_v1.yml#L428-L526), with one additional field (where available):
|
|
12
11
|
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* Issues with incorrect motor data should be directed to the TC site.
|
|
12
|
+
* `samples`: `Array[[number, number]]` of thrust`samples`. This is the `samples` data from the TC "/api/vi/download" endpoint normalized to always have `[0, 0]` as the first data point. in cases where more than one sample file is available for a motor, the first "cert"(ified) data file is used. Otherwise it will be whichever data file the API returns first.
|
|
13
|
+
|
|
14
|
+
See also, the included [TypeScript definition`](./thrustcurve.d.ts).
|
|
17
15
|
|
|
18
|
-
## Installation
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
## Installation
|
|
21
18
|
|
|
22
19
|
```
|
|
23
20
|
npm i thrustcurve-db
|
|
24
21
|
```
|
|
25
22
|
|
|
23
|
+
... or with `yarn`:
|
|
24
|
+
```
|
|
25
|
+
yarn add thrustcurve-db
|
|
26
|
+
```
|
|
27
|
+
|
|
26
28
|
## Usage
|
|
27
29
|
|
|
30
|
+
ES Modules
|
|
31
|
+
|
|
28
32
|
```js
|
|
29
|
-
import MOTORS
|
|
30
|
-
|
|
31
|
-
// `MOTORS` is a Motor[] array.
|
|
32
|
-
|
|
33
|
-
for (const motor of MOTORS) {
|
|
34
|
-
// See `thrustcurve-db.d.ts` for Motor structure details.
|
|
35
|
-
console.log(motor); // Spew data for ~1,100 motors to console
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// parseDelays() parses a motor `delays` value to determine the
|
|
39
|
-
// delay options. The returned Object has the following properties:
|
|
40
|
-
//
|
|
41
|
-
// times: Number[] array of possible delay times (seconds)
|
|
42
|
-
// plugged: true if motor has a "Plugged" configuration
|
|
43
|
-
//
|
|
44
|
-
// Aerotech delays (S, M, L, X) are transformed as follows:
|
|
45
|
-
// S -> 0-6
|
|
46
|
-
// M -> 0-10
|
|
47
|
-
// L -> 0-14
|
|
48
|
-
// X -> 0-18
|
|
49
|
-
//
|
|
50
|
-
// Note: `times` are guaranteed to be unique and in ascending order.
|
|
51
|
-
// E.g. `parseDelays('L, S')` and `parseDelays('1, 5, M, L')` will
|
|
52
|
-
// produce the same result.
|
|
53
|
-
|
|
54
|
-
parseDelays('S, 16, P'); // -> {
|
|
55
|
-
// times: [0,1,2,3,4,5,6,16],
|
|
56
|
-
// plugged: true
|
|
57
|
-
// }
|
|
58
|
-
|
|
59
|
-
// unparseDelays(parsed) is the inverse operation of parseDelays() (sort of).
|
|
60
|
-
|
|
61
|
-
unparseDelays({
|
|
62
|
-
times: [0,1,2,3,4,5,6,16],
|
|
63
|
-
plugged: true
|
|
64
|
-
}); // -> "0-6,16,P"
|
|
33
|
+
import MOTORS from 'thrustcurve-db';
|
|
65
34
|
```
|
|
35
|
+
|
|
36
|
+
... or for CommonJS:
|
|
37
|
+
```js
|
|
38
|
+
const MOTORS = require('thrustcurve-db');
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
... or for CommonJS w/ `import()` (NodeJS):
|
|
42
|
+
|
|
43
|
+
Note: At present this requires you run `node` with the `--experimental-json-modules` flag
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const MOTORS = await import('thrustcurve-db');
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
... or to fetch from jsDelvr CDN:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
const MOTORS = await fetch('https://cdn.jsdelivr.net/npm/thrustcurve-db@latest/thrustcurve-db.json')
|
|
53
|
+
.then(res => res.json());
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Example
|
|
57
|
+
|
|
58
|
+
After importing (above)...
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
// Find all J motors currently in production
|
|
62
|
+
MOTORS.filter(m => m.availability === 'regular' && m.impulseClass === 'J');
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Issues & Contributions
|
|
66
|
+
|
|
67
|
+
The data provided here is sourced from thrustcurve.org. Omissions and errors in
|
|
68
|
+
rocket data should be directed there. Any systematic problems or suggestions
|
|
69
|
+
for how the data here is presented may be [reported
|
|
70
|
+
here](https://github.com/broofa/thrustcurve-db/issues).
|
|
71
|
+
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "thrustcurve-db",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ThrustCurve.org model rocket motor and thrust curve data as a single JSON file",
|
|
6
|
-
"
|
|
6
|
+
"exports": {
|
|
7
|
+
"import": "./index.js",
|
|
8
|
+
"require": "./index.cjs"
|
|
9
|
+
},
|
|
7
10
|
"types": "thrustcurve-db.d.ts",
|
|
8
11
|
"files": [
|
|
9
12
|
"index.js",
|
package/thrustcurve-db.d.ts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
type ThrustPoint = [number, number];
|
|
2
2
|
|
|
3
|
-
type Samples = ThrustPoint[];
|
|
4
|
-
|
|
5
|
-
type ParsedDelays = {
|
|
6
|
-
times: Number[],
|
|
7
|
-
plugged: Boolean
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export function parseDelays(string) : ParsedDelays;
|
|
11
|
-
export function unparseDelays(ParsedDelays) : string;
|
|
12
|
-
|
|
13
3
|
export declare type Motor = {
|
|
4
|
+
availability : 'regular' | 'OOP';
|
|
14
5
|
avgThrustN : number;
|
|
15
6
|
burnTimeS : number;
|
|
16
7
|
certOrg : string;
|
|
@@ -19,8 +10,7 @@ export declare type Motor = {
|
|
|
19
10
|
delays : string;
|
|
20
11
|
designation : string;
|
|
21
12
|
diameter : number;
|
|
22
|
-
|
|
23
|
-
impulseClass : string;
|
|
13
|
+
impulseClass : 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O';
|
|
24
14
|
infoUrl : string;
|
|
25
15
|
length : number;
|
|
26
16
|
manufacturer : string;
|
|
@@ -29,11 +19,11 @@ export declare type Motor = {
|
|
|
29
19
|
motorId : string;
|
|
30
20
|
propInfo : string;
|
|
31
21
|
propWeightG : number;
|
|
32
|
-
samples ?:
|
|
22
|
+
samples ?: ThrustPoint[];
|
|
33
23
|
sparky ?: boolean;
|
|
34
24
|
totImpulseNs : number;
|
|
35
25
|
totalWeightG : number;
|
|
36
|
-
type :
|
|
26
|
+
type : 'SU' | 'hybrid' | 'reload';
|
|
37
27
|
updatedOn : string;
|
|
38
28
|
}
|
|
39
29
|
|