xm-netcdf-loader 1.0.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.
- package/dist/component/colorLegend.d.ts +25 -0
- package/dist/component/loadFile.d.ts +43 -0
- package/dist/component/loadonMap.d.ts +46 -0
- package/dist/component/statusInfo.d.ts +41 -0
- package/dist/composables/useGridLabels.d.ts +13 -0
- package/dist/composables/useLeafletMap.d.ts +56 -0
- package/dist/composables/useMapRendering.d.ts +38 -0
- package/dist/composables/useNetCdf.d.ts +49 -0
- package/dist/index.d.ts +9 -0
- package/dist/netcdf4-wasm/CONTRIBUTING.md +160 -0
- package/dist/netcdf4-wasm/LICENSE +22 -0
- package/dist/netcdf4-wasm/README.md +81 -0
- package/dist/netcdf4-wasm/dist/constants.d.ts +158 -0
- package/dist/netcdf4-wasm/dist/constants.d.ts.map +1 -0
- package/dist/netcdf4-wasm/dist/constants.js +249 -0
- package/dist/netcdf4-wasm/dist/constants.js.map +1 -0
- package/dist/netcdf4-wasm/dist/dimension.d.ts +9 -0
- package/dist/netcdf4-wasm/dist/dimension.d.ts.map +1 -0
- package/dist/netcdf4-wasm/dist/dimension.js +19 -0
- package/dist/netcdf4-wasm/dist/dimension.js.map +1 -0
- package/dist/netcdf4-wasm/dist/group.d.ts +35 -0
- package/dist/netcdf4-wasm/dist/group.d.ts.map +1 -0
- package/dist/netcdf4-wasm/dist/group.js +189 -0
- package/dist/netcdf4-wasm/dist/group.js.map +1 -0
- package/dist/netcdf4-wasm/dist/index.d.ts +17 -0
- package/dist/netcdf4-wasm/dist/index.d.ts.map +1 -0
- package/dist/netcdf4-wasm/dist/index.js +49 -0
- package/dist/netcdf4-wasm/dist/index.js.map +1 -0
- package/dist/netcdf4-wasm/dist/netcdf-getters.d.ts +120 -0
- package/dist/netcdf4-wasm/dist/netcdf-getters.d.ts.map +1 -0
- package/dist/netcdf4-wasm/dist/netcdf-getters.js +816 -0
- package/dist/netcdf4-wasm/dist/netcdf-getters.js.map +1 -0
- package/dist/netcdf4-wasm/dist/netcdf-worker.d.ts +2 -0
- package/dist/netcdf4-wasm/dist/netcdf-worker.d.ts.map +1 -0
- package/dist/netcdf4-wasm/dist/netcdf-worker.js +154 -0
- package/dist/netcdf4-wasm/dist/netcdf-worker.js.map +1 -0
- package/dist/netcdf4-wasm/dist/netcdf4-wasm.js +2 -0
- package/dist/netcdf4-wasm/dist/netcdf4-wasm.wasm +0 -0
- package/dist/netcdf4-wasm/dist/netcdf4.d.ts +218 -0
- package/dist/netcdf4-wasm/dist/netcdf4.d.ts.map +1 -0
- package/dist/netcdf4-wasm/dist/netcdf4.js +1049 -0
- package/dist/netcdf4-wasm/dist/netcdf4.js.map +1 -0
- package/dist/netcdf4-wasm/dist/slice.d.ts +57 -0
- package/dist/netcdf4-wasm/dist/slice.d.ts.map +1 -0
- package/dist/netcdf4-wasm/dist/slice.js +60 -0
- package/dist/netcdf4-wasm/dist/slice.js.map +1 -0
- package/dist/netcdf4-wasm/dist/test-setup.d.ts +13 -0
- package/dist/netcdf4-wasm/dist/test-setup.d.ts.map +1 -0
- package/dist/netcdf4-wasm/dist/test-setup.js +78 -0
- package/dist/netcdf4-wasm/dist/test-setup.js.map +1 -0
- package/dist/netcdf4-wasm/dist/types.d.ts +444 -0
- package/dist/netcdf4-wasm/dist/types.d.ts.map +1 -0
- package/dist/netcdf4-wasm/dist/types.js +3 -0
- package/dist/netcdf4-wasm/dist/types.js.map +1 -0
- package/dist/netcdf4-wasm/dist/variable.d.ts +36 -0
- package/dist/netcdf4-wasm/dist/variable.d.ts.map +1 -0
- package/dist/netcdf4-wasm/dist/variable.js +152 -0
- package/dist/netcdf4-wasm/dist/variable.js.map +1 -0
- package/dist/netcdf4-wasm/dist/wasm-module.d.ts +6 -0
- package/dist/netcdf4-wasm/dist/wasm-module.d.ts.map +1 -0
- package/dist/netcdf4-wasm/dist/wasm-module.js +1502 -0
- package/dist/netcdf4-wasm/dist/wasm-module.js.map +1 -0
- package/dist/netcdf4-wasm/package.json +78 -0
- package/dist/netcdf4-wasm.wasm +0 -0
- package/dist/types/colorsJson.d.ts +36 -0
- package/dist/types/netcdf.d.ts +70 -0
- package/dist/utils/color.d.ts +277 -0
- package/dist/utils/colorScales.d.ts +28 -0
- package/dist/utils/colorsJsonService.d.ts +24 -0
- package/dist/utils/dataProcessing.d.ts +64 -0
- package/dist/utils/errorHandling.d.ts +69 -0
- package/dist/utils/imageUtils.d.ts +29 -0
- package/dist/utils/performance.d.ts +75 -0
- package/dist/wasm/constants.d.ts +158 -0
- package/dist/wasm/constants.d.ts.map +1 -0
- package/dist/wasm/constants.js +249 -0
- package/dist/wasm/constants.js.map +1 -0
- package/dist/wasm/dimension.d.ts +9 -0
- package/dist/wasm/dimension.d.ts.map +1 -0
- package/dist/wasm/dimension.js +19 -0
- package/dist/wasm/dimension.js.map +1 -0
- package/dist/wasm/group.d.ts +35 -0
- package/dist/wasm/group.d.ts.map +1 -0
- package/dist/wasm/group.js +189 -0
- package/dist/wasm/group.js.map +1 -0
- package/dist/wasm/index.d.ts +17 -0
- package/dist/wasm/index.d.ts.map +1 -0
- package/dist/wasm/index.js +49 -0
- package/dist/wasm/index.js.map +1 -0
- package/dist/wasm/netcdf-getters.d.ts +120 -0
- package/dist/wasm/netcdf-getters.d.ts.map +1 -0
- package/dist/wasm/netcdf-getters.js +816 -0
- package/dist/wasm/netcdf-getters.js.map +1 -0
- package/dist/wasm/netcdf-worker.d.ts +2 -0
- package/dist/wasm/netcdf-worker.d.ts.map +1 -0
- package/dist/wasm/netcdf-worker.js +154 -0
- package/dist/wasm/netcdf-worker.js.map +1 -0
- package/dist/wasm/netcdf4-wasm.js +2 -0
- package/dist/wasm/netcdf4-wasm.wasm +0 -0
- package/dist/wasm/netcdf4.d.ts +218 -0
- package/dist/wasm/netcdf4.d.ts.map +1 -0
- package/dist/wasm/netcdf4.js +1049 -0
- package/dist/wasm/netcdf4.js.map +1 -0
- package/dist/wasm/slice.d.ts +57 -0
- package/dist/wasm/slice.d.ts.map +1 -0
- package/dist/wasm/slice.js +60 -0
- package/dist/wasm/slice.js.map +1 -0
- package/dist/wasm/test-setup.d.ts +13 -0
- package/dist/wasm/test-setup.d.ts.map +1 -0
- package/dist/wasm/test-setup.js +78 -0
- package/dist/wasm/test-setup.js.map +1 -0
- package/dist/wasm/types.d.ts +444 -0
- package/dist/wasm/types.d.ts.map +1 -0
- package/dist/wasm/types.js +3 -0
- package/dist/wasm/types.js.map +1 -0
- package/dist/wasm/variable.d.ts +36 -0
- package/dist/wasm/variable.d.ts.map +1 -0
- package/dist/wasm/variable.js +152 -0
- package/dist/wasm/variable.js.map +1 -0
- package/dist/wasm/wasm-module.d.ts +6 -0
- package/dist/wasm/wasm-module.d.ts.map +1 -0
- package/dist/wasm/wasm-module.js +1502 -0
- package/dist/wasm/wasm-module.js.map +1 -0
- package/dist/xm-netcdf-loader.cjs.js +2 -0
- package/dist/xm-netcdf-loader.cjs.js.map +1 -0
- package/dist/xm-netcdf-loader.es.js +18532 -0
- package/dist/xm-netcdf-loader.es.js.map +1 -0
- package/dist/xm-netcdf-loader.umd.js +2 -0
- package/dist/xm-netcdf-loader.umd.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { DataStats } from '../types/netcdf';
|
|
3
|
+
import { ColorsJsonItem } from '../types/colorsJson';
|
|
4
|
+
export declare const getColorData: (info: {
|
|
5
|
+
colorbarCanvas: Ref<HTMLCanvasElement | null>;
|
|
6
|
+
dataStats?: DataStats | null;
|
|
7
|
+
variableName?: string;
|
|
8
|
+
colormap?: string;
|
|
9
|
+
ColorsJsonItem?: ColorsJsonItem | null;
|
|
10
|
+
}, call: {
|
|
11
|
+
colormapChange: Function;
|
|
12
|
+
}) => {
|
|
13
|
+
minValue: import('vue').ComputedRef<string>;
|
|
14
|
+
midValue: import('vue').ComputedRef<string>;
|
|
15
|
+
maxValue: import('vue').ComputedRef<string>;
|
|
16
|
+
valueRange: import('vue').ComputedRef<string>;
|
|
17
|
+
selectedColormap: Ref<string, string>;
|
|
18
|
+
variableName: import('vue').ComputedRef<string>;
|
|
19
|
+
dataStats: DataStats | null;
|
|
20
|
+
isJsonColormap: import('vue').ComputedRef<boolean>;
|
|
21
|
+
gradientStyle: import('vue').ComputedRef<{
|
|
22
|
+
background: string;
|
|
23
|
+
}>;
|
|
24
|
+
updateColorbar: () => void;
|
|
25
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { VariableDataEntry, NetCdfMetadata, VariableStatsEntry } from '../types/netcdf';
|
|
2
|
+
interface LoadResult {
|
|
3
|
+
success: boolean;
|
|
4
|
+
metadata: NetCdfMetadata;
|
|
5
|
+
variableData: Record<string, VariableDataEntry>;
|
|
6
|
+
dataStats: Record<string, VariableStatsEntry>;
|
|
7
|
+
}
|
|
8
|
+
export declare const useLoadFile: (call: {
|
|
9
|
+
dataLoaded: Function;
|
|
10
|
+
}) => {
|
|
11
|
+
isLoading: import('vue').Ref<boolean, boolean>;
|
|
12
|
+
netcdfLoading: import('vue').Ref<boolean, boolean>;
|
|
13
|
+
displayableVariables: import('vue').ComputedRef<string[]>;
|
|
14
|
+
handleFileSelect: (file: File) => Promise<LoadResult | void>;
|
|
15
|
+
formatFileSize: (bytes: number) => string;
|
|
16
|
+
currentFile: import('vue').Ref<{
|
|
17
|
+
readonly lastModified: number;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly webkitRelativePath: string;
|
|
20
|
+
readonly size: number;
|
|
21
|
+
readonly type: string;
|
|
22
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
23
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
24
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
25
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
26
|
+
text: () => Promise<string>;
|
|
27
|
+
} | null, File | {
|
|
28
|
+
readonly lastModified: number;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly webkitRelativePath: string;
|
|
31
|
+
readonly size: number;
|
|
32
|
+
readonly type: string;
|
|
33
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
34
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
35
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
36
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
37
|
+
text: () => Promise<string>;
|
|
38
|
+
} | null>;
|
|
39
|
+
error: import('vue').Ref<string | null, string | null>;
|
|
40
|
+
loadError: import('vue').Ref<string | null, string | null>;
|
|
41
|
+
validationErrors: import('vue').Ref<string[], string[]>;
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Ref, ComputedRef } from 'vue';
|
|
2
|
+
import { VariableDataEntry, NetCdfMetadata } from '../types/netcdf';
|
|
3
|
+
import { MapInfo } from '../composables/useLeafletMap';
|
|
4
|
+
export declare const getFileData: (mapInfo: MapInfo, info: {
|
|
5
|
+
variableData?: VariableDataEntry | null;
|
|
6
|
+
metadata?: NetCdfMetadata | null;
|
|
7
|
+
bounds?: [[number, number], [number, number]] | null;
|
|
8
|
+
variableName?: string | null;
|
|
9
|
+
}, call: {
|
|
10
|
+
coordChange: Function;
|
|
11
|
+
getCoordinate: Function;
|
|
12
|
+
}) => {
|
|
13
|
+
options: {
|
|
14
|
+
colormap: string;
|
|
15
|
+
opacity: number;
|
|
16
|
+
showBounds: boolean;
|
|
17
|
+
autoFit: boolean;
|
|
18
|
+
resampleTo: [number, number] | null;
|
|
19
|
+
minValue: number | null;
|
|
20
|
+
maxValue: number | null;
|
|
21
|
+
};
|
|
22
|
+
bounds: Ref<[number, number, number, number] | null, [number, number, number, number] | null>;
|
|
23
|
+
currentZoom: Ref<number, number>;
|
|
24
|
+
mapCoords: {
|
|
25
|
+
lat: number;
|
|
26
|
+
lng: number;
|
|
27
|
+
};
|
|
28
|
+
hasDataOverlay: ComputedRef<boolean>;
|
|
29
|
+
isRendering: ComputedRef<boolean>;
|
|
30
|
+
renderingProgress: Ref<{
|
|
31
|
+
current: number;
|
|
32
|
+
total: number;
|
|
33
|
+
percent: number;
|
|
34
|
+
}, {
|
|
35
|
+
current: number;
|
|
36
|
+
total: number;
|
|
37
|
+
percent: number;
|
|
38
|
+
} | {
|
|
39
|
+
current: number;
|
|
40
|
+
total: number;
|
|
41
|
+
percent: number;
|
|
42
|
+
}>;
|
|
43
|
+
removeOverlay: () => void;
|
|
44
|
+
updateOpacity: (opacity: number) => void;
|
|
45
|
+
updateZoom: () => void;
|
|
46
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DataStats } from '../types/netcdf';
|
|
2
|
+
interface Coordinates {
|
|
3
|
+
lat: number | null;
|
|
4
|
+
lng: number | null;
|
|
5
|
+
}
|
|
6
|
+
interface CurrentFile {
|
|
7
|
+
filename: string;
|
|
8
|
+
size: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const getStatusInfo: (info: {
|
|
11
|
+
coordinates?: Coordinates;
|
|
12
|
+
dataValue?: number | string | null;
|
|
13
|
+
dataStats?: DataStats | null;
|
|
14
|
+
currentFile?: CurrentFile | null;
|
|
15
|
+
isLoading?: boolean;
|
|
16
|
+
error?: string | null;
|
|
17
|
+
}) => {
|
|
18
|
+
formattedCoordinates: import('vue').ComputedRef<{
|
|
19
|
+
lat: string;
|
|
20
|
+
lng: string;
|
|
21
|
+
}>;
|
|
22
|
+
currentValue: import('vue').ComputedRef<string>;
|
|
23
|
+
statusText: import('vue').ComputedRef<"错误" | "加载中" | "就绪" | "等待中">;
|
|
24
|
+
statusDetail: import('vue').ComputedRef<string>;
|
|
25
|
+
currentFile: {
|
|
26
|
+
filename: string;
|
|
27
|
+
size: number;
|
|
28
|
+
} | null;
|
|
29
|
+
dataStats: {
|
|
30
|
+
min: number | null;
|
|
31
|
+
max: number | null;
|
|
32
|
+
mean: number | null;
|
|
33
|
+
std?: number | null | undefined;
|
|
34
|
+
count: number;
|
|
35
|
+
validCount: number;
|
|
36
|
+
missingCount: number;
|
|
37
|
+
} | null;
|
|
38
|
+
systemStatus: import('vue').Ref<string, string>;
|
|
39
|
+
formatFileSize: (bytes: number) => string;
|
|
40
|
+
};
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { VariableDataEntry, NetCdfMetadata } from '../types/netcdf';
|
|
3
|
+
import { default as Map } from 'ol/Map';
|
|
4
|
+
type ValueAtCoordinateFn = (latlng: {
|
|
5
|
+
lat: number;
|
|
6
|
+
lng: number;
|
|
7
|
+
}, variableData: VariableDataEntry, metadata: NetCdfMetadata) => number | null;
|
|
8
|
+
/**
|
|
9
|
+
* 在 OpenLayers 地图上方的画布叠加层上绘制格点数据值标签的组合式函数。
|
|
10
|
+
* 地图平移或缩放时标签将重绘。
|
|
11
|
+
*/
|
|
12
|
+
export declare function useGridLabels(map: Ref<Map | null>, variableData: Ref<VariableDataEntry | null | undefined>, metadata: Ref<NetCdfMetadata | null | undefined>, enabled: Ref<boolean>, gridStep: Ref<number>, getValueAtCoordinate: ValueAtCoordinateFn): void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Ref, Reactive } from 'vue';
|
|
2
|
+
import { default as Map } from 'ol/Map';
|
|
3
|
+
interface CurrentCoords {
|
|
4
|
+
lat: number;
|
|
5
|
+
lng: number;
|
|
6
|
+
}
|
|
7
|
+
interface MapBounds {
|
|
8
|
+
southWest: {
|
|
9
|
+
lat: number;
|
|
10
|
+
lng: number;
|
|
11
|
+
};
|
|
12
|
+
northEast: {
|
|
13
|
+
lat: number;
|
|
14
|
+
lng: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface MapInfo {
|
|
18
|
+
map: Ref<Map | null>;
|
|
19
|
+
mapInitialized: Ref<boolean>;
|
|
20
|
+
mapError: Ref<string | null>;
|
|
21
|
+
isLoading: Ref<boolean>;
|
|
22
|
+
currentCoords: Reactive<CurrentCoords>;
|
|
23
|
+
}
|
|
24
|
+
declare function setupEventHandlers(): void;
|
|
25
|
+
export declare const useMapInfo: ({ map, mapInitialized, mapError, isLoading, currentCoords: mapCoords }: MapInfo) => {
|
|
26
|
+
setupEventHandlers: typeof setupEventHandlers;
|
|
27
|
+
};
|
|
28
|
+
export declare function useOpenLayersMap({ map, mapInitialized, mapError, isLoading, currentCoords: mapCoords }: MapInfo): {
|
|
29
|
+
mapState: boolean;
|
|
30
|
+
map: Ref<Map | null, Map | null>;
|
|
31
|
+
mapInitialized: Ref<boolean, boolean>;
|
|
32
|
+
mapError: Ref<string | null, string | null>;
|
|
33
|
+
isLoading: Ref<boolean, boolean>;
|
|
34
|
+
currentCoords: {
|
|
35
|
+
lat: number;
|
|
36
|
+
lng: number;
|
|
37
|
+
};
|
|
38
|
+
mouseEvents: {
|
|
39
|
+
isMoving: boolean;
|
|
40
|
+
lastMoveTime: number;
|
|
41
|
+
moveTimeout: ReturnType<typeof setTimeout> | null;
|
|
42
|
+
};
|
|
43
|
+
destroyMap: () => void;
|
|
44
|
+
setView: (lat: number, lng: number, zoom?: number) => void;
|
|
45
|
+
getCenter: () => {
|
|
46
|
+
lat: number;
|
|
47
|
+
lng: number;
|
|
48
|
+
} | null;
|
|
49
|
+
getZoom: () => number | null | undefined;
|
|
50
|
+
fitBounds: (bounds: MapBounds) => void;
|
|
51
|
+
formatCoords: (coords: CurrentCoords, precision?: number) => {
|
|
52
|
+
lat: string;
|
|
53
|
+
lng: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { default as Map } from 'ol/Map';
|
|
3
|
+
import { default as ImageLayer } from 'ol/layer/Image';
|
|
4
|
+
import { default as ImageStatic } from 'ol/source/ImageStatic';
|
|
5
|
+
import { VariableDataEntry, NetCdfMetadata } from '../types/netcdf';
|
|
6
|
+
export interface DataOverlayOptions {
|
|
7
|
+
colormap: string;
|
|
8
|
+
opacity: number;
|
|
9
|
+
showBounds: boolean;
|
|
10
|
+
autoFit: boolean;
|
|
11
|
+
resampleTo: [number, number] | null;
|
|
12
|
+
minValue: number | null;
|
|
13
|
+
maxValue: number | null;
|
|
14
|
+
}
|
|
15
|
+
export declare function useMapRendering(): {
|
|
16
|
+
isLoading: Ref<boolean>;
|
|
17
|
+
error: Ref<string | null>;
|
|
18
|
+
overlay: Ref<ImageLayer<ImageStatic> | null>;
|
|
19
|
+
bounds: Ref<[number, number, number, number] | null>;
|
|
20
|
+
options: {
|
|
21
|
+
colormap: string;
|
|
22
|
+
opacity: number;
|
|
23
|
+
showBounds: boolean;
|
|
24
|
+
autoFit: boolean;
|
|
25
|
+
resampleTo: [number, number] | null;
|
|
26
|
+
minValue: number | null;
|
|
27
|
+
maxValue: number | null;
|
|
28
|
+
};
|
|
29
|
+
createDataOverlay: (variableData: VariableDataEntry, metadata: NetCdfMetadata, map: Map, overrideBounds?: [number, number, number, number], variableName?: string) => Promise<ImageLayer<ImageStatic>>;
|
|
30
|
+
updateOpacity: (opacity: number) => void;
|
|
31
|
+
updateColormap: (colormapName: string, variableData?: VariableDataEntry, metadata?: NetCdfMetadata, variableName?: string) => Promise<void>;
|
|
32
|
+
removeOverlay: () => void;
|
|
33
|
+
getValueAtCoordinate: (latlng: {
|
|
34
|
+
lat: number;
|
|
35
|
+
lng: number;
|
|
36
|
+
}, variableData: VariableDataEntry, metadata: NetCdfMetadata) => number | null;
|
|
37
|
+
reset: () => void;
|
|
38
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { NetCdfMetadata, VariableDataEntry, VariableStatsEntry } from '../types/netcdf';
|
|
3
|
+
type NetCDF4Dataset = any;
|
|
4
|
+
/**
|
|
5
|
+
* 返回元数据中所有二维非坐标变量的名称。
|
|
6
|
+
* 这些变量适合作为地图叠加层进行渲染。
|
|
7
|
+
*/
|
|
8
|
+
export declare function detect2dVariables(variables: NetCdfMetadata['variables']): string[];
|
|
9
|
+
interface FileInfo {
|
|
10
|
+
filename: string;
|
|
11
|
+
size: number;
|
|
12
|
+
format: string;
|
|
13
|
+
dimensionsCount: number;
|
|
14
|
+
variablesCount: number;
|
|
15
|
+
}
|
|
16
|
+
interface MetadataState extends NetCdfMetadata {
|
|
17
|
+
fileInfo: FileInfo | null;
|
|
18
|
+
}
|
|
19
|
+
interface LoadResult {
|
|
20
|
+
success: true;
|
|
21
|
+
dataset: NetCDF4Dataset;
|
|
22
|
+
metadata: MetadataState;
|
|
23
|
+
variableData: Record<string, VariableDataEntry>;
|
|
24
|
+
dataStats: Record<string, VariableStatsEntry>;
|
|
25
|
+
}
|
|
26
|
+
interface LoadError {
|
|
27
|
+
success: false;
|
|
28
|
+
error: string;
|
|
29
|
+
}
|
|
30
|
+
export interface UseNetCdfReturn {
|
|
31
|
+
isLoading: Ref<boolean>;
|
|
32
|
+
error: Ref<string | null>;
|
|
33
|
+
dataset: Ref<NetCDF4Dataset | null>;
|
|
34
|
+
metadata: MetadataState;
|
|
35
|
+
variableData: Record<string, VariableDataEntry>;
|
|
36
|
+
dataStats: Record<string, VariableStatsEntry>;
|
|
37
|
+
loadNetCdfFile: (file: File) => Promise<LoadResult | LoadError>;
|
|
38
|
+
getVariableData: (variableName: string, groupPath?: string) => Promise<unknown>;
|
|
39
|
+
getSlicedVariableData: (variableName: string, start: number[], count: number[], groupPath?: string) => Promise<unknown>;
|
|
40
|
+
getDataAtCoordinate: (variableName: string, lon: number, lat: number) => Promise<number | null>;
|
|
41
|
+
closeDataset: () => Promise<void>;
|
|
42
|
+
reset: () => void;
|
|
43
|
+
detect2dVariables: () => string[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 用于通过 netcdf4-wasm 加载和解析 netCDF 文件的 Vue 组合式函数。
|
|
47
|
+
*/
|
|
48
|
+
export declare function useNetCdf(): UseNetCdfReturn;
|
|
49
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getColorData } from './component/colorLegend';
|
|
2
|
+
import { useLoadFile } from './component/loadFile';
|
|
3
|
+
import { getFileData } from './component/loadonMap';
|
|
4
|
+
import { getStatusInfo } from './component/statusInfo';
|
|
5
|
+
import { detect2dVariables } from './composables/useNetCdf';
|
|
6
|
+
import { getJsonItemForVariable } from './utils/colorsJsonService';
|
|
7
|
+
import { useMapInfo } from './composables/useLeafletMap';
|
|
8
|
+
declare const version = "0.0.1";
|
|
9
|
+
export { useMapInfo, getColorData, useLoadFile, getFileData, getStatusInfo, detect2dVariables, getJsonItemForVariable, version };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Contributors Guide
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to `netcdf4-wasm`! We welcome everyone, whether you're new to open source, WebAssembly, TypeScript, or scientific computing, or an experienced developer. Every contribution, big or small, helps make this project better.
|
|
4
|
+
|
|
5
|
+
If you have questions, ideas, or just want to chat, please reach out to us anytime. We're happy to help and discuss anything related to `netcdf4-wasm`, NetCDF, or science in general.
|
|
6
|
+
|
|
7
|
+
## How You Can Contribute
|
|
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.
|
|
14
|
+
|
|
15
|
+
### Tips for Creating Issues
|
|
16
|
+
|
|
17
|
+
The most helpful bug reports:
|
|
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.).
|
|
23
|
+
|
|
24
|
+
Discussions are great for questions about usage, implementation, WebAssembly compilation, NetCDF formats, or anything else.
|
|
25
|
+
|
|
26
|
+
## Development Setup
|
|
27
|
+
|
|
28
|
+
To start developing `netcdf4-wasm`:
|
|
29
|
+
|
|
30
|
+
1. [Fork the `netcdf4-wasm` repository](https://docs.github.com/en/github/collaborating-with-pull-requests/working-with-forks) and clone your fork
|
|
31
|
+
2. Navigate to the project directory
|
|
32
|
+
3. Install dependencies:
|
|
33
|
+
```bash
|
|
34
|
+
npm install
|
|
35
|
+
```
|
|
36
|
+
4. Check that you have all build dependencies:
|
|
37
|
+
```bash
|
|
38
|
+
npm run check-deps
|
|
39
|
+
```
|
|
40
|
+
5. If you need Emscripten for building WASM:
|
|
41
|
+
```bash
|
|
42
|
+
npm run install-emscripten
|
|
43
|
+
```
|
|
44
|
+
6. Build the project:
|
|
45
|
+
```bash
|
|
46
|
+
npm run build
|
|
47
|
+
```
|
|
48
|
+
7. Run tests to ensure everything works:
|
|
49
|
+
```bash
|
|
50
|
+
npm test
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
and to build and synchronize with the **demo** do
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm run build-and-sync
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Project Structure
|
|
60
|
+
|
|
61
|
+
Understanding the project structure will help you navigate the codebase:
|
|
62
|
+
```
|
|
63
|
+
netcdf4-wasm/
|
|
64
|
+
├── src/ # TypeScript source code
|
|
65
|
+
│ ├── __tests__/ # Test files
|
|
66
|
+
│ ├── constants.ts # NetCDF constants
|
|
67
|
+
│ ├── dimension.ts # Dimension class
|
|
68
|
+
│ ├── group.ts # Group class
|
|
69
|
+
│ ├── index.ts # Main API exports
|
|
70
|
+
│ ├── netcdf-getters.ts # Data getter utilities
|
|
71
|
+
│ ├── netcdf-worker.ts # Web Worker implementation
|
|
72
|
+
│ ├── netcdf4-wasm.d.ts # TypeScript declarations
|
|
73
|
+
│ ├── netcdf4.ts # Main NetCDF4 class
|
|
74
|
+
│ ├── test-setup.ts # Test configuration
|
|
75
|
+
│ ├── types.ts # Type definitions
|
|
76
|
+
│ ├── variable.ts # Variable class
|
|
77
|
+
│ └── wasm-module.ts # WASM module loader
|
|
78
|
+
├── scripts/ # Build scripts
|
|
79
|
+
│ ├── build-wasm.sh # Main WASM build script
|
|
80
|
+
│ ├── check-dependencies.sh
|
|
81
|
+
│ └── install-emscripten.sh
|
|
82
|
+
├── bindings/ # WASM bindings
|
|
83
|
+
│ ├── pre.js # Pre-run JavaScript
|
|
84
|
+
│ └── post.js # Post-run JavaScript
|
|
85
|
+
├── build/ # Build artifacts (generated)
|
|
86
|
+
├── dist/ # Distribution files (generated)
|
|
87
|
+
└── package.json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Making Your Contribution
|
|
91
|
+
|
|
92
|
+
1. [Fork the repository](https://docs.github.com/en/github/collaborating-with-pull-requests/working-with-forks), make your changes, and [open a pull request](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork). We'll review and help you get it merged.
|
|
93
|
+
2. For small fixes (like typos), you can use the [GitHub editor](https://docs.github.com/en/github/managing-files-in-a-repository/managing-files-on-github/editing-files-in-your-repository) for a quick edit and pull request.
|
|
94
|
+
3. Please try to follow our code style and formatting conventions.
|
|
95
|
+
4. Always test your changes before submitting:
|
|
96
|
+
```bash
|
|
97
|
+
# Run all tests
|
|
98
|
+
npm test
|
|
99
|
+
|
|
100
|
+
# Run tests with coverage
|
|
101
|
+
npm run test:coverage
|
|
102
|
+
|
|
103
|
+
# Run tests in watch mode while developing
|
|
104
|
+
npm run test:watch
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Good First Steps
|
|
108
|
+
|
|
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.
|
|
115
|
+
|
|
116
|
+
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
|
+
|
|
118
|
+
## Useful Commands
|
|
119
|
+
|
|
120
|
+
Here are the main commands you'll use during development:
|
|
121
|
+
```bash
|
|
122
|
+
# Install dependencies
|
|
123
|
+
npm install
|
|
124
|
+
|
|
125
|
+
# Build the entire project (WASM + TypeScript)
|
|
126
|
+
npm run build
|
|
127
|
+
|
|
128
|
+
# Build and synchronize the demo
|
|
129
|
+
npm run build-and-sync
|
|
130
|
+
|
|
131
|
+
# Build only the WASM module
|
|
132
|
+
npm run build:wasm
|
|
133
|
+
|
|
134
|
+
# Build only TypeScript
|
|
135
|
+
npm run build:ts
|
|
136
|
+
|
|
137
|
+
# Clean build artifacts
|
|
138
|
+
npm run clean
|
|
139
|
+
|
|
140
|
+
# Run tests
|
|
141
|
+
npm test
|
|
142
|
+
|
|
143
|
+
# Run tests with coverage
|
|
144
|
+
npm run test:coverage
|
|
145
|
+
|
|
146
|
+
# Run tests in watch mode
|
|
147
|
+
npm run test:watch
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Code of Conduct
|
|
151
|
+
|
|
152
|
+
We are committed to providing a welcoming and inclusive environment. Please be respectful, kind, and constructive in all interactions. We do not tolerate harassment or discriminatory behavior of any kind.
|
|
153
|
+
|
|
154
|
+
## Getting Help
|
|
155
|
+
|
|
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
|
|
159
|
+
|
|
160
|
+
We're excited to have you join our community. Thank you for helping make `netcdf4-wasm` better!
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 netcdf4-wasm
|
|
4
|
+
Copyright (c) 2025 Lazaro Alonso, Jeran Poehls
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# netcdf4-wasm [](https://earthyscience.github.io/netcdf4-wasm/viewer/)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/@earthyscience/netcdf4-wasm)
|
|
5
|
+
[](https://github.com/EarthyScience/netcdf4-wasm/blob/main/LICENSE)
|
|
6
|
+
[](https://www.unidata.ucar.edu/software/netcdf/)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](https://webassembly.org/)
|
|
9
|
+
[](https://emscripten.org/)
|
|
10
|
+
[](https://jestjs.io/)
|
|
11
|
+
[](https://kulshekhar.github.io/ts-jest/)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<img src="https://raw.githubusercontent.com/EarthyScience/netcdf4-wasm/6eecb7eea2da775c139ebddf3f544efc6593ee2f/assets/logo.svg" align="right" style="padding-left:10px;" width="180"/>
|
|
15
|
+
|
|
16
|
+
**Partial WebAssembly port of the NetCDF4 C library with TypeScript bindings for browser and Node.js**
|
|
17
|
+
|
|
18
|
+
`netcdf4-wasm` brings the power of NetCDF4 to web browsers and Node.js through WebAssembly. Read and write NetCDF files directly in JavaScript with a familiar, Python-inspired API.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
**Features:**
|
|
22
|
+
- 🌐 Works in browsers and Node.js
|
|
23
|
+
- 📦 Partial NetCDF4 file format support
|
|
24
|
+
- 🐍 API modeled after [netcdf4-python](https://unidata.github.io/netcdf4-python)
|
|
25
|
+
- 🚀 High-performance WASM compilation
|
|
26
|
+
- 📝 Complete TypeScript type definitions
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
> [!TIP]
|
|
30
|
+
> Want to do more? Plot, visualize, and explore your data at [browzarr.io](https://browzarr.io/)
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install @earthyscience/netcdf4-wasm
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { NetCDF4, DataTree } from '@earthyscience/netcdf4-wasm';
|
|
42
|
+
|
|
43
|
+
// Open existing file
|
|
44
|
+
const ds = await NetCDF4.fromBlobLazy(file);
|
|
45
|
+
const dt = new DataTree(ds);
|
|
46
|
+
await dt.buildTree();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## API Reference
|
|
50
|
+
|
|
51
|
+
The API closely follows [netcdf4-python](https://unidata.github.io/netcdf4-python) conventions, making it intuitive for scientists familiar with Python.
|
|
52
|
+
|
|
53
|
+
## Advanced Usage
|
|
54
|
+
|
|
55
|
+
<details>
|
|
56
|
+
<summary><strong>Memory Configuration</strong></summary>
|
|
57
|
+
|
|
58
|
+
If you encounter memory-related errors with large files, you can increase the initial memory allocation:
|
|
59
|
+
```typescript
|
|
60
|
+
// TODO: Add example once API is stable
|
|
61
|
+
```
|
|
62
|
+
</details>
|
|
63
|
+
|
|
64
|
+
## Building from Source
|
|
65
|
+
|
|
66
|
+
See our [Contributing Guide](CONTRIBUTING.md) for detailed build instructions.
|
|
67
|
+
|
|
68
|
+
## Contributing
|
|
69
|
+
|
|
70
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
71
|
+
|
|
72
|
+
## Resources
|
|
73
|
+
|
|
74
|
+
- [NetCDF4 C Library Documentation](https://docs.unidata.ucar.edu/netcdf-c/current/)
|
|
75
|
+
- [netcdf4-python Documentation](https://unidata.github.io/netcdf4-python)
|
|
76
|
+
- [GitHub Issues](https://github.com/EarthyScience/netcdf4-wasm/issues)
|
|
77
|
+
- [GitHub Discussions](https://github.com/EarthyScience/netcdf4-wasm/discussions)
|
|
78
|
+
|
|
79
|
+
## Acknowledgments
|
|
80
|
+
|
|
81
|
+
This project builds upon the initial work from [oceanum-io/netcdf4-wasm](https://github.com/oceanum-io/netcdf4-wasm). We're grateful for their foundational efforts in bringing NetCDF4 to WebAssembly and are continuing their work with additional features and improvements.
|