@earthyscience/netcdf4-wasm 0.3.0 → 0.4.0

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 (56) hide show
  1. package/CONTRIBUTING.md +29 -22
  2. package/README.md +12 -10
  3. package/dist/constants.d.ts +165 -146
  4. package/dist/constants.d.ts.map +1 -1
  5. package/dist/constants.js +48 -60
  6. package/dist/constants.js.map +1 -1
  7. package/dist/dimension.js +1 -1
  8. package/dist/errors.d.ts +3 -0
  9. package/dist/errors.d.ts.map +1 -0
  10. package/dist/errors.js +15 -0
  11. package/dist/errors.js.map +1 -0
  12. package/dist/group.d.ts +4 -5
  13. package/dist/group.d.ts.map +1 -1
  14. package/dist/group.js +11 -70
  15. package/dist/group.js.map +1 -1
  16. package/dist/index.d.ts +15 -16
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +13 -14
  19. package/dist/index.js.map +1 -1
  20. package/dist/netcdf-getters.d.ts +5 -5
  21. package/dist/netcdf-getters.d.ts.map +1 -1
  22. package/dist/netcdf-getters.js +78 -50
  23. package/dist/netcdf-getters.js.map +1 -1
  24. package/dist/netcdf-worker.js +15 -105
  25. package/dist/netcdf-worker.js.map +1 -1
  26. package/dist/netcdf4-wasm.js +2 -2
  27. package/dist/netcdf4-wasm.wasm +0 -0
  28. package/dist/netcdf4.d.ts +19 -20
  29. package/dist/netcdf4.d.ts.map +1 -1
  30. package/dist/netcdf4.js +201 -518
  31. package/dist/netcdf4.js.map +1 -1
  32. package/dist/operations.d.ts +67 -0
  33. package/dist/operations.d.ts.map +1 -0
  34. package/dist/operations.js +57 -0
  35. package/dist/operations.js.map +1 -0
  36. package/dist/remote-read.d.ts +4 -4
  37. package/dist/remote-read.d.ts.map +1 -1
  38. package/dist/remote-read.js +22 -18
  39. package/dist/remote-read.js.map +1 -1
  40. package/dist/slice.d.ts.map +1 -1
  41. package/dist/slice.js.map +1 -1
  42. package/dist/types.d.ts +27 -414
  43. package/dist/types.d.ts.map +1 -1
  44. package/dist/variable.d.ts +1 -1
  45. package/dist/variable.d.ts.map +1 -1
  46. package/dist/variable.js +60 -78
  47. package/dist/variable.js.map +1 -1
  48. package/dist/wasm-module.d.ts +468 -2
  49. package/dist/wasm-module.d.ts.map +1 -1
  50. package/dist/wasm-module.js +331 -251
  51. package/dist/wasm-module.js.map +1 -1
  52. package/package.json +17 -14
  53. package/dist/test-setup.d.ts +0 -13
  54. package/dist/test-setup.d.ts.map +0 -1
  55. package/dist/test-setup.js +0 -78
  56. package/dist/test-setup.js.map +0 -1
package/CONTRIBUTING.md CHANGED
@@ -6,20 +6,20 @@ If you have questions, ideas, or just want to chat, please reach out to us anyti
6
6
 
7
7
  ## How You Can Contribute
8
8
 
9
- * **Report bugs or suggest features:** [Open a GitHub issue](https://github.com/EarthyScience/netcdf4-wasm/issues/new/) to let us know about problems or ideas.
10
- * **Start or join a discussion:** [Create a GitHub discussion](https://github.com/EarthyScience/netcdf4-wasm/discussions/new/choose) to ask questions, share experiences, or brainstorm.
11
- * **Improve documentation:** Help us make our docs clearer and more helpful for everyone.
12
- * **Write code:** Fix bugs, add features, or improve performance.
13
- * **Add examples:** Create usage examples or tutorials showing how to use `netcdf4-wasm` in different scenarios.
9
+ - **Report bugs or suggest features:** [Open a GitHub issue](https://github.com/EarthyScience/netcdf4-wasm/issues/new/) to let us know about problems or ideas.
10
+ - **Start or join a discussion:** [Create a GitHub discussion](https://github.com/EarthyScience/netcdf4-wasm/discussions/new/choose) to ask questions, share experiences, or brainstorm.
11
+ - **Improve documentation:** Help us make our docs clearer and more helpful for everyone.
12
+ - **Write code:** Fix bugs, add features, or improve performance.
13
+ - **Add examples:** Create usage examples or tutorials showing how to use `netcdf4-wasm` in different scenarios.
14
14
 
15
15
  ### Tips for Creating Issues
16
16
 
17
17
  The most helpful bug reports:
18
18
 
19
- * Include a clear code snippet (not just a link) that shows the problem in the latest version of `netcdf4-wasm`. A ["minimal working example"](https://en.wikipedia.org/wiki/Minimal_working_example) is ideal.
20
- * Paste the full error message you received, even if it's long.
21
- * Use triple backticks (```` ``` ````) for code, and [markdown formatting](https://docs.github.com/en/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) to keep things readable.
22
- * Share your `netcdf4-wasm` version, Node.js/browser version, and details about your environment (OS, browser, etc.).
19
+ - Include a clear code snippet (not just a link) that shows the problem in the latest version of `netcdf4-wasm`. A ["minimal working example"](https://en.wikipedia.org/wiki/Minimal_working_example) is ideal.
20
+ - Paste the full error message you received, even if it's long.
21
+ - Use triple backticks (` ``` `) for code, and [markdown formatting](https://docs.github.com/en/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) to keep things readable.
22
+ - Share your `netcdf4-wasm` version, Node.js/browser version, and details about your environment (OS, browser, etc.).
23
23
 
24
24
  Discussions are great for questions about usage, implementation, WebAssembly compilation, NetCDF formats, or anything else.
25
25
 
@@ -33,19 +33,23 @@ To start developing `netcdf4-wasm`:
33
33
  ```bash
34
34
  npm install
35
35
  ```
36
+
36
37
  4. Check that you have all build dependencies:
37
38
  ```bash
38
39
  npm run check-deps
39
40
  ```
41
+
40
42
  5. If you need Emscripten for building WASM:
41
43
  ```bash
42
44
  npm run install-emscripten
43
45
  ```
46
+
44
47
  6. Build the project:
45
48
  ```bash
46
49
  npm run build
47
50
  ```
48
- 7. Run tests to ensure everything works:
51
+
52
+ 7. Run tests to ensure everything works (they need the WASM module from step 6, see [tests/README.md](tests/README.md)):
49
53
  ```bash
50
54
  npm test
51
55
  ```
@@ -62,7 +66,6 @@ Understanding the project structure will help you navigate the codebase:
62
66
  ```
63
67
  netcdf4-wasm/
64
68
  ├── src/ # TypeScript source code
65
- │ ├── __tests__/ # Test files
66
69
  │ ├── constants.ts # NetCDF constants
67
70
  │ ├── dimension.ts # Dimension class
68
71
  │ ├── group.ts # Group class
@@ -71,10 +74,14 @@ netcdf4-wasm/
71
74
  │ ├── netcdf-worker.ts # Web Worker implementation
72
75
  │ ├── netcdf4-wasm.d.ts # TypeScript declarations
73
76
  │ ├── netcdf4.ts # Main NetCDF4 class
74
- │ ├── test-setup.ts # Test configuration
77
+ │ ├── operations.ts # Operations shared by the main thread and the worker
75
78
  │ ├── types.ts # Type definitions
76
79
  │ ├── variable.ts # Variable class
77
80
  │ └── wasm-module.ts # WASM module loader
81
+ ├── tests/ # Vitest tests, see tests/README.md
82
+ │ ├── fixtures/ # Small netCDF files and their generator
83
+ │ ├── unit/ # Tests without the WASM module
84
+ │ └── wasm/ # Tests against the real WASM module
78
85
  ├── scripts/ # Build scripts
79
86
  │ ├── build-wasm.sh # Main WASM build script
80
87
  │ ├── check-dependencies.sh
@@ -106,12 +113,12 @@ netcdf4-wasm/
106
113
 
107
114
  ## Good First Steps
108
115
 
109
- * Try out `netcdf4-wasm` using the examples in our documentation. If you hit any problems or have questions, please open an issue!
110
- * Write an example or tutorial showing how to use `netcdf4-wasm` for reading/writing NetCDF files in the browser or Node.js.
111
- * Suggest improvements to documentation or code comments.
112
- * Work on issues labeled `good first issue` or `help wanted`.
113
- * Improve TypeScript type definitions for better developer experience.
114
- * Add or improve test coverage.
116
+ - Try out `netcdf4-wasm` using the examples in our documentation. If you hit any problems or have questions, please open an issue!
117
+ - Write an example or tutorial showing how to use `netcdf4-wasm` for reading/writing NetCDF files in the browser or Node.js.
118
+ - Suggest improvements to documentation or code comments.
119
+ - Work on issues labeled `good first issue` or `help wanted`.
120
+ - Improve TypeScript type definitions for better developer experience.
121
+ - Add or improve test coverage.
115
122
 
116
123
  If you want to work on something, let us know by commenting on an issue or opening a new one. This helps us coordinate and support you.
117
124
 
@@ -153,8 +160,8 @@ We are committed to providing a welcoming and inclusive environment. Please be r
153
160
 
154
161
  ## Getting Help
155
162
 
156
- * **Questions about usage?** Open a [GitHub discussion](https://github.com/EarthyScience/netcdf4-wasm/discussions)
157
- * **Found a bug?** Open an [issue](https://github.com/EarthyScience/netcdf4-wasm/issues)
158
- * **Want to chat?** Reach out to the maintainers
163
+ - **Questions about usage?** Open a [GitHub discussion](https://github.com/EarthyScience/netcdf4-wasm/discussions)
164
+ - **Found a bug?** Open an [issue](https://github.com/EarthyScience/netcdf4-wasm/issues)
165
+ - **Want to chat?** Reach out to the maintainers
159
166
 
160
- We're excited to have you join our community. Thank you for helping make `netcdf4-wasm` better!
167
+ We're excited to have you join our community. Thank you for helping make `netcdf4-wasm` better!
package/README.md CHANGED
@@ -1,14 +1,12 @@
1
1
  # netcdf4-wasm [![viewer](https://img.shields.io/badge/Viewer-Online-654FF0)](https://earthyscience.github.io/netcdf4-wasm/viewer/)
2
2
 
3
-
4
3
  [![npm version](https://img.shields.io/npm/v/@earthyscience/netcdf4-wasm.svg)](https://www.npmjs.com/package/@earthyscience/netcdf4-wasm)
5
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/EarthyScience/netcdf4-wasm/blob/main/LICENSE)
6
5
  [![NetCDF4](https://img.shields.io/badge/NetCDF4-Compatible-008B8B)](https://www.unidata.ucar.edu/software/netcdf/)
7
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178c6)](https://www.typescriptlang.org/)
8
7
  [![WebAssembly](https://img.shields.io/badge/WebAssembly-654FF0)](https://webassembly.org/)
9
- [![Emscripten](https://img.shields.io/badge/Emscripten-4.0.23-0000)](https://emscripten.org/)
10
- [![Jest](https://img.shields.io/badge/Jest-29.x-C21325)](https://jestjs.io/)
11
- [![ts-jest](https://img.shields.io/badge/ts--jest-29.x-3178c6)](https://kulshekhar.github.io/ts-jest/)
8
+ [![Emscripten](https://img.shields.io/badge/Emscripten-6.0.13-0000)](https://emscripten.org/)
9
+ [![Vitest](https://img.shields.io/badge/Vitest-5.x-6E9F18)](https://vitest.dev/)
12
10
 
13
11
 
14
12
  <img src="https://raw.githubusercontent.com/EarthyScience/netcdf4-wasm/6eecb7eea2da775c139ebddf3f544efc6593ee2f/assets/logo.svg" align="right" style="padding-left:10px;" width="180"/>
@@ -38,7 +36,7 @@ npm install @earthyscience/netcdf4-wasm
38
36
  ## Quick Start
39
37
 
40
38
  ```typescript
41
- import { NetCDF4, DataTree } from '@earthyscience/netcdf4-wasm';
39
+ import { NetCDF4, DataTree } from "@earthyscience/netcdf4-wasm";
42
40
 
43
41
  // Open existing file
44
42
  const ds = await NetCDF4.fromBlobLazy(file);
@@ -53,14 +51,18 @@ fetches only the byte ranges netCDF-C reads, and keeps them in a block cache.
53
51
  `Dataset(url)` and `NetCDF4.Dataset(url)` do the same for `http(s)://` strings and `URL` objects.
54
52
 
55
53
  ```typescript
56
- const ds = await NetCDF4.fromUrl('https://example.org/data.nc', {
57
- headers: { Authorization: 'Bearer TOKEN' }, // sent with every request
58
- withCredentials: false, // send cookies cross-origin
54
+ const ds = await NetCDF4.fromUrl("https://example.org/data.nc", {
55
+ headers: { Authorization: "Bearer TOKEN" }, // sent with every request
56
+ withCredentials: false, // send cookies cross-origin
59
57
  });
60
58
  try {
61
- const values = await ds.getSlicedVariableArray('temperature', [0, 0], [1, 10]);
59
+ const values = await ds.getSlicedVariableArray(
60
+ "temperature",
61
+ [0, 0],
62
+ [1, 10],
63
+ );
62
64
  } finally {
63
- await ds.close();
65
+ await ds.close();
64
66
  }
65
67
  ```
66
68
 
@@ -1,147 +1,169 @@
1
1
  export declare const NC_CONSTANTS: {
2
- NC_NOERR: number;
3
- NC_EBADID: number;
4
- NC_ENFILE: number;
5
- NC_EEXIST: number;
6
- NC_EINVAL: number;
7
- NC_EPERM: number;
8
- NC_ENOTINDEFINE: number;
9
- NC_EINDEFINE: number;
10
- NC_EINVALCOORDS: number;
11
- NC_EMAXDIMS: number;
12
- NC_ENAMEINUSE: number;
13
- NC_ENOTATT: number;
14
- NC_EMAXATTS: number;
15
- NC_EBADTYPE: number;
16
- NC_EBADDIM: number;
17
- NC_EUNLIMPOS: number;
18
- NC_EMAXVARS: number;
19
- NC_ENOTVAR: number;
20
- NC_EGLOBAL: number;
21
- NC_ENOTNC: number;
22
- NC_ESTS: number;
23
- NC_EMAXNAME: number;
24
- NC_EUNLIMIT: number;
25
- NC_ENORECVARS: number;
26
- NC_ECHAR: number;
27
- NC_EEDGE: number;
28
- NC_ESTRIDE: number;
29
- NC_EBADNAME: number;
30
- NC_ERANGE: number;
31
- NC_ENOMEM: number;
32
- NC_EVARSIZE: number;
33
- NC_EDIMSIZE: number;
34
- NC_ETRUNC: number;
35
- NC_EAXISTYPE: number;
36
- NC_EDAP: number;
37
- NC_ECURL: number;
38
- NC_EIO: number;
39
- NC_ENODATA: number;
40
- NC_EDAPSVC: number;
41
- NC_EDAS: number;
42
- NC_EDDS: number;
43
- NC_EDATADDS: number;
44
- NC_EDAPURL: number;
45
- NC_EDAPCONSTRAINT: number;
46
- NC_ETRANSLATION: number;
47
- NC_EACCESS: number;
48
- NC_EAUTH: number;
49
- NC_ENOTFOUND: number;
50
- NC_ECANTREMOVE: number;
51
- NC_EINTERNAL: number;
52
- NC_EPNETCDF: number;
53
- NC_EHDFERR: number;
54
- NC_ECANTREAD: number;
55
- NC_ECANTWRITE: number;
56
- NC_ECANTCREATE: number;
57
- NC_EFILEMETA: number;
58
- NC_EDIMMETA: number;
59
- NC_EATTMETA: number;
60
- NC_EVARMETA: number;
61
- NC_ENOCOMPOUND: number;
62
- NC_EATTEXISTS: number;
63
- NC_ENOTNC4: number;
64
- NC_ESTRICTNC3: number;
65
- NC_ENOTNC3: number;
66
- NC_ENOPAR: number;
67
- NC_EPARINIT: number;
68
- NC_EBADGRPID: number;
69
- NC_EBADTYPID: number;
70
- NC_ETYPDEFINED: number;
71
- NC_EBADFIELD: number;
72
- NC_EBADCLASS: number;
73
- NC_EMAPTYPE: number;
74
- NC_ELATEFILL: number;
75
- NC_ELATEDEF: number;
76
- NC_EDIMSCALE: number;
77
- NC_ENOGRP: number;
78
- NC_ESTORAGE: number;
79
- NC_EBADCHUNK: number;
80
- NC_ENOTBUILT: number;
81
- NC_EDISKLESS: number;
82
- NC_ECANTEXTEND: number;
83
- NC_EMPI: number;
84
- NC_NOWRITE: number;
85
- NC_WRITE: number;
86
- NC_CLOBBER: number;
87
- NC_NOCLOBBER: number;
88
- NC_DISKLESS: number;
89
- NC_MMAP: number;
90
- NC_64BIT_DATA: number;
91
- NC_CDF5: number;
92
- NC_CLASSIC_MODEL: number;
93
- NC_64BIT_OFFSET: number;
94
- NC_NETCDF4: number;
95
- NC_SHARE: number;
96
- NC_INMEMORY: number;
97
- NC_FORMAT_CLASSIC: number;
98
- NC_FORMAT_64BIT_OFFSET: number;
99
- NC_FORMAT_64BIT: number;
100
- NC_FORMAT_NETCDF4: number;
101
- NC_FORMAT_NETCDF4_CLASSIC: number;
102
- NC_FORMAT_64BIT_DATA: number;
103
- NC_FORMAT_CDF5: number;
104
- NC_NAT: number;
105
- NC_BYTE: number;
106
- NC_CHAR: number;
107
- NC_SHORT: number;
108
- NC_INT: number;
109
- NC_LONG: number;
110
- NC_FLOAT: number;
111
- NC_DOUBLE: number;
112
- NC_UBYTE: number;
113
- NC_USHORT: number;
114
- NC_UINT: number;
115
- NC_INT64: number;
116
- NC_UINT64: number;
117
- NC_STRING: number;
118
- NC_LONGLONG: number;
119
- NC_ULONGLONG: number;
120
- NC_VLEN: number;
121
- NC_OPAQUE: number;
122
- NC_ENUM: number;
123
- NC_COMPOUND: number;
124
- NC_FIRSTUSERTYPEID: number;
125
- NC_FILL: number;
126
- NC_NOFILL: number;
127
- NC_CHUNKED: number;
128
- NC_CONTIGUOUS: number;
129
- NC_COMPACT: number;
130
- NC_VIRTUAL: number;
131
- NC_ENDIAN_NATIVE: number;
132
- NC_ENDIAN_LITTLE: number;
133
- NC_ENDIAN_BIG: number;
134
- NC_UNLIMITED: number;
135
- NC_GLOBAL: number;
136
- NC_MAX_DIMS: number;
137
- NC_MAX_ATTRS: number;
138
- NC_MAX_VARS: number;
139
- NC_MAX_NAME: number;
140
- NC_MAX_VAR_DIMS: number;
141
- NC_NOCHECKSUM: number;
142
- NC_FLETCHER32: number;
143
- NC_NOSHUFFLE: number;
144
- NC_SHUFFLE: number;
2
+ readonly NC_NOERR: 0;
3
+ readonly NC_EBADID: -33;
4
+ readonly NC_ENFILE: -34;
5
+ readonly NC_EEXIST: -35;
6
+ readonly NC_EINVAL: -36;
7
+ readonly NC_EPERM: -37;
8
+ readonly NC_ENOTINDEFINE: -38;
9
+ readonly NC_EINDEFINE: -39;
10
+ readonly NC_EINVALCOORDS: -40;
11
+ readonly NC_EMAXDIMS: -41;
12
+ readonly NC_ENAMEINUSE: -42;
13
+ readonly NC_ENOTATT: -43;
14
+ readonly NC_EMAXATTS: -44;
15
+ readonly NC_EBADTYPE: -45;
16
+ readonly NC_EBADDIM: -46;
17
+ readonly NC_EUNLIMPOS: -47;
18
+ readonly NC_EMAXVARS: -48;
19
+ readonly NC_ENOTVAR: -49;
20
+ readonly NC_EGLOBAL: -50;
21
+ readonly NC_ENOTNC: -51;
22
+ readonly NC_ESTS: -52;
23
+ readonly NC_EMAXNAME: -53;
24
+ readonly NC_EUNLIMIT: -54;
25
+ readonly NC_ENORECVARS: -55;
26
+ readonly NC_ECHAR: -56;
27
+ readonly NC_EEDGE: -57;
28
+ readonly NC_ESTRIDE: -58;
29
+ readonly NC_EBADNAME: -59;
30
+ readonly NC_ERANGE: -60;
31
+ readonly NC_ENOMEM: -61;
32
+ readonly NC_EVARSIZE: -62;
33
+ readonly NC_EDIMSIZE: -63;
34
+ readonly NC_ETRUNC: -64;
35
+ readonly NC_EAXISTYPE: -65;
36
+ readonly NC_EDAP: -66;
37
+ readonly NC_ECURL: -67;
38
+ readonly NC_EIO: -68;
39
+ readonly NC_ENODATA: -69;
40
+ readonly NC_EDAPSVC: -70;
41
+ readonly NC_EDAS: -71;
42
+ readonly NC_EDDS: -72;
43
+ readonly NC_EDATADDS: -73;
44
+ readonly NC_EDAPURL: -74;
45
+ readonly NC_EDAPCONSTRAINT: -75;
46
+ readonly NC_ETRANSLATION: -76;
47
+ readonly NC_EACCESS: -77;
48
+ readonly NC_EAUTH: -78;
49
+ readonly NC_ENOTFOUND: -90;
50
+ readonly NC_ECANTREMOVE: -91;
51
+ readonly NC_EINTERNAL: -92;
52
+ readonly NC_EPNETCDF: -93;
53
+ readonly NC_EHDFERR: -101;
54
+ readonly NC_ECANTREAD: -102;
55
+ readonly NC_ECANTWRITE: -103;
56
+ readonly NC_ECANTCREATE: -104;
57
+ readonly NC_EFILEMETA: -105;
58
+ readonly NC_EDIMMETA: -106;
59
+ readonly NC_EATTMETA: -107;
60
+ readonly NC_EVARMETA: -108;
61
+ readonly NC_ENOCOMPOUND: -109;
62
+ readonly NC_EATTEXISTS: -110;
63
+ readonly NC_ENOTNC4: -111;
64
+ readonly NC_ESTRICTNC3: -112;
65
+ readonly NC_ENOTNC3: -113;
66
+ readonly NC_ENOPAR: -114;
67
+ readonly NC_EPARINIT: -115;
68
+ readonly NC_EBADGRPID: -116;
69
+ readonly NC_EBADTYPID: -117;
70
+ readonly NC_ETYPDEFINED: -118;
71
+ readonly NC_EBADFIELD: -119;
72
+ readonly NC_EBADCLASS: -120;
73
+ readonly NC_EMAPTYPE: -121;
74
+ readonly NC_ELATEFILL: -122;
75
+ readonly NC_ELATEDEF: -123;
76
+ readonly NC_EDIMSCALE: -124;
77
+ readonly NC_ENOGRP: -125;
78
+ readonly NC_ESTORAGE: -126;
79
+ readonly NC_EBADCHUNK: -127;
80
+ readonly NC_ENOTBUILT: -128;
81
+ readonly NC_EDISKLESS: -129;
82
+ readonly NC_ECANTEXTEND: -130;
83
+ readonly NC_EMPI: -131;
84
+ readonly NC_NOWRITE: 0;
85
+ readonly NC_WRITE: 1;
86
+ readonly NC_CLOBBER: 0;
87
+ readonly NC_NOCLOBBER: 4;
88
+ readonly NC_DISKLESS: 8;
89
+ readonly NC_MMAP: 16;
90
+ readonly NC_64BIT_DATA: 32;
91
+ readonly NC_CDF5: 32;
92
+ readonly NC_CLASSIC_MODEL: 256;
93
+ readonly NC_64BIT_OFFSET: 512;
94
+ readonly NC_NETCDF4: 4096;
95
+ readonly NC_SHARE: 2048;
96
+ readonly NC_INMEMORY: 32768;
97
+ readonly NC_FORMAT_CLASSIC: 1;
98
+ readonly NC_FORMAT_64BIT_OFFSET: 2;
99
+ readonly NC_FORMAT_64BIT: 2;
100
+ readonly NC_FORMAT_NETCDF4: 3;
101
+ readonly NC_FORMAT_NETCDF4_CLASSIC: 4;
102
+ readonly NC_FORMAT_64BIT_DATA: 5;
103
+ readonly NC_FORMAT_CDF5: 5;
104
+ readonly NC_NAT: 0;
105
+ readonly NC_BYTE: 1;
106
+ readonly NC_CHAR: 2;
107
+ readonly NC_SHORT: 3;
108
+ readonly NC_INT: 4;
109
+ readonly NC_LONG: 4;
110
+ readonly NC_FLOAT: 5;
111
+ readonly NC_DOUBLE: 6;
112
+ readonly NC_UBYTE: 7;
113
+ readonly NC_USHORT: 8;
114
+ readonly NC_UINT: 9;
115
+ readonly NC_INT64: 10;
116
+ readonly NC_UINT64: 11;
117
+ readonly NC_STRING: 12;
118
+ readonly NC_LONGLONG: 10;
119
+ readonly NC_ULONGLONG: 11;
120
+ readonly NC_VLEN: 13;
121
+ readonly NC_OPAQUE: 14;
122
+ readonly NC_ENUM: 15;
123
+ readonly NC_COMPOUND: 16;
124
+ readonly NC_FIRSTUSERTYPEID: 32;
125
+ readonly NC_FILL: 0;
126
+ readonly NC_NOFILL: 256;
127
+ readonly NC_CHUNKED: 0;
128
+ readonly NC_CONTIGUOUS: 1;
129
+ readonly NC_COMPACT: 2;
130
+ readonly NC_VIRTUAL: 3;
131
+ readonly NC_ENDIAN_NATIVE: 0;
132
+ readonly NC_ENDIAN_LITTLE: 1;
133
+ readonly NC_ENDIAN_BIG: 2;
134
+ readonly NC_UNLIMITED: 0;
135
+ readonly NC_GLOBAL: -1;
136
+ readonly NC_MAX_DIMS: 1024;
137
+ readonly NC_MAX_ATTRS: 8192;
138
+ readonly NC_MAX_VARS: 8192;
139
+ readonly NC_MAX_NAME: 256;
140
+ readonly NC_MAX_VAR_DIMS: 1024;
141
+ readonly NC_NOCHECKSUM: 0;
142
+ readonly NC_FLETCHER32: 1;
143
+ readonly NC_NOSHUFFLE: 0;
144
+ readonly NC_SHUFFLE: 1;
145
+ };
146
+ export declare const FILE_MODES: {
147
+ readonly r: {
148
+ readonly create: false;
149
+ readonly flags: 0;
150
+ };
151
+ readonly "r+": {
152
+ readonly create: false;
153
+ readonly flags: 1;
154
+ };
155
+ readonly a: {
156
+ readonly create: false;
157
+ readonly flags: 1;
158
+ };
159
+ readonly w: {
160
+ readonly create: true;
161
+ readonly flags: 0;
162
+ };
163
+ readonly "w-": {
164
+ readonly create: true;
165
+ readonly flags: 4;
166
+ };
145
167
  };
146
168
  export declare const DATA_TYPE_MAP: {
147
169
  [key: string]: number;
@@ -152,7 +174,4 @@ export declare const CONSTANT_DTYPE_MAP: {
152
174
  export declare const DATA_TYPE_SIZE: {
153
175
  [key: number]: number;
154
176
  };
155
- export declare const TYPE_NAMES: {
156
- [key: number]: string;
157
- };
158
177
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6KxB,CAAC;AAGF,eAAO,MAAM,aAAa,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAiClD,CAAC;AAGF,eAAO,MAAM,kBAAkB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAcvD,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAcnD,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAkB/C,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Kf,CAAC;AAGX,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;CAMb,CAAC;AAGX,eAAO,MAAM,aAAa,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAiClD,CAAC;AAGF,eAAO,MAAM,kBAAkB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAcvD,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAcnD,CAAC"}
package/dist/constants.js CHANGED
@@ -161,54 +161,62 @@ export const NC_CONSTANTS = {
161
161
  NC_NOSHUFFLE: 0,
162
162
  NC_SHUFFLE: 1,
163
163
  };
164
+ // netcdf4-python modes: whether they create the file, and the nc_open/nc_create flags
165
+ export const FILE_MODES = {
166
+ r: { create: false, flags: NC_CONSTANTS.NC_NOWRITE },
167
+ "r+": { create: false, flags: NC_CONSTANTS.NC_WRITE },
168
+ a: { create: false, flags: NC_CONSTANTS.NC_WRITE },
169
+ w: { create: true, flags: NC_CONSTANTS.NC_CLOBBER },
170
+ "w-": { create: true, flags: NC_CONSTANTS.NC_NOCLOBBER },
171
+ };
164
172
  // Data type mapping from string names to NetCDF constants
165
173
  export const DATA_TYPE_MAP = {
166
174
  // Short names
167
- 'f8': NC_CONSTANTS.NC_DOUBLE,
168
- 'f4': NC_CONSTANTS.NC_FLOAT,
169
- 'i8': NC_CONSTANTS.NC_INT64,
170
- 'i4': NC_CONSTANTS.NC_INT,
171
- 'i2': NC_CONSTANTS.NC_SHORT,
172
- 'i1': NC_CONSTANTS.NC_BYTE,
173
- 'u8': NC_CONSTANTS.NC_UINT64,
174
- 'u4': NC_CONSTANTS.NC_UINT,
175
- 'u2': NC_CONSTANTS.NC_USHORT,
176
- 'u1': NC_CONSTANTS.NC_UBYTE,
177
- 'S1': NC_CONSTANTS.NC_CHAR,
175
+ f8: NC_CONSTANTS.NC_DOUBLE,
176
+ f4: NC_CONSTANTS.NC_FLOAT,
177
+ i8: NC_CONSTANTS.NC_INT64,
178
+ i4: NC_CONSTANTS.NC_INT,
179
+ i2: NC_CONSTANTS.NC_SHORT,
180
+ i1: NC_CONSTANTS.NC_BYTE,
181
+ u8: NC_CONSTANTS.NC_UINT64,
182
+ u4: NC_CONSTANTS.NC_UINT,
183
+ u2: NC_CONSTANTS.NC_USHORT,
184
+ u1: NC_CONSTANTS.NC_UBYTE,
185
+ S1: NC_CONSTANTS.NC_CHAR,
178
186
  // Long names
179
- 'double': NC_CONSTANTS.NC_DOUBLE,
180
- 'float': NC_CONSTANTS.NC_FLOAT,
181
- 'int64': NC_CONSTANTS.NC_INT64,
182
- 'int': NC_CONSTANTS.NC_INT,
183
- 'short': NC_CONSTANTS.NC_SHORT,
184
- 'byte': NC_CONSTANTS.NC_BYTE,
185
- 'uint64': NC_CONSTANTS.NC_UINT64,
186
- 'uint': NC_CONSTANTS.NC_UINT,
187
- 'ushort': NC_CONSTANTS.NC_USHORT,
188
- 'ubyte': NC_CONSTANTS.NC_UBYTE,
189
- 'char': NC_CONSTANTS.NC_CHAR,
190
- 'string': NC_CONSTANTS.NC_STRING,
191
- 'str': NC_CONSTANTS.NC_STRING,
187
+ double: NC_CONSTANTS.NC_DOUBLE,
188
+ float: NC_CONSTANTS.NC_FLOAT,
189
+ int64: NC_CONSTANTS.NC_INT64,
190
+ int: NC_CONSTANTS.NC_INT,
191
+ short: NC_CONSTANTS.NC_SHORT,
192
+ byte: NC_CONSTANTS.NC_BYTE,
193
+ uint64: NC_CONSTANTS.NC_UINT64,
194
+ uint: NC_CONSTANTS.NC_UINT,
195
+ ushort: NC_CONSTANTS.NC_USHORT,
196
+ ubyte: NC_CONSTANTS.NC_UBYTE,
197
+ char: NC_CONSTANTS.NC_CHAR,
198
+ string: NC_CONSTANTS.NC_STRING,
199
+ str: NC_CONSTANTS.NC_STRING,
192
200
  // Aliases
193
- 'longlong': NC_CONSTANTS.NC_LONGLONG,
194
- 'ulonglong': NC_CONSTANTS.NC_ULONGLONG,
195
- 'long': NC_CONSTANTS.NC_INT,
201
+ longlong: NC_CONSTANTS.NC_LONGLONG,
202
+ ulonglong: NC_CONSTANTS.NC_ULONGLONG,
203
+ long: NC_CONSTANTS.NC_INT,
196
204
  };
197
205
  // Reverse mapping: NetCDF type ID to dtype string
198
206
  export const CONSTANT_DTYPE_MAP = {
199
- 0: 'NAT', // NC_NAT
200
- 1: 'i1', // NC_BYTE
201
- 2: 'S1', // NC_CHAR
202
- 3: 'i2', // NC_SHORT
203
- 4: 'i4', // NC_INT
204
- 5: 'f4', // NC_FLOAT
205
- 6: 'f8', // NC_DOUBLE
206
- 7: 'u1', // NC_UBYTE
207
- 8: 'u2', // NC_USHORT
208
- 9: 'u4', // NC_UINT
209
- 10: 'i8', // NC_INT64
210
- 11: 'u8', // NC_UINT64
211
- 12: 'str', // NC_STRING
207
+ 0: "NAT", // NC_NAT
208
+ 1: "i1", // NC_BYTE
209
+ 2: "S1", // NC_CHAR
210
+ 3: "i2", // NC_SHORT
211
+ 4: "i4", // NC_INT
212
+ 5: "f4", // NC_FLOAT
213
+ 6: "f8", // NC_DOUBLE
214
+ 7: "u1", // NC_UBYTE
215
+ 8: "u2", // NC_USHORT
216
+ 9: "u4", // NC_UINT
217
+ 10: "i8", // NC_INT64
218
+ 11: "u8", // NC_UINT64
219
+ 12: "str", // NC_STRING
212
220
  };
213
221
  // Data type sizes in bytes
214
222
  export const DATA_TYPE_SIZE = {
@@ -226,24 +234,4 @@ export const DATA_TYPE_SIZE = {
226
234
  11: 8, // NC_UINT64
227
235
  12: 0, // NC_STRING (variable length)
228
236
  };
229
- // Human-readable type names
230
- export const TYPE_NAMES = {
231
- 0: 'NAT',
232
- 1: 'byte',
233
- 2: 'char',
234
- 3: 'short',
235
- 4: 'int',
236
- 5: 'float',
237
- 6: 'double',
238
- 7: 'ubyte',
239
- 8: 'ushort',
240
- 9: 'uint',
241
- 10: 'int64',
242
- 11: 'uint64',
243
- 12: 'string',
244
- 13: 'vlen',
245
- 14: 'opaque',
246
- 15: 'enum',
247
- 16: 'compound',
248
- };
249
237
  //# sourceMappingURL=constants.js.map