MCPcopy Create free account
hub / github.com/IQEngine/IQEngine / getIQDataBlocks

Method getIQDataBlocks

client/src/api/iqdata/ApiClient.ts:15–58  ·  view source on GitHub ↗
(
    meta: SigMFMetadata,
    indexes: number[],
    blockSize: number, // we fetch 2x this many ints/floats
    signal: AbortSignal
  )

Source from the content-addressed store, hash-verified

13 this.authUtil = new AuthUtil(instance, account);
14 }
15 async getIQDataBlocks(
16 meta: SigMFMetadata,
17 indexes: number[],
18 blockSize: number, // we fetch 2x this many ints/floats
19 signal: AbortSignal
20 ): Promise<IQDataSlice[]> {
21 if (!meta || indexes.length === 0) {
22 return [];
23 }
24 const { account, container, file_path } = meta.getOrigin();
25 const format = meta.getDataType();
26
27 const dataUrl = `/api/datasources/${account}/${container}/${file_path}/iq-data`;
28 const queryParams = {
29 block_indexes_str: indexes.join(','),
30 block_size: blockSize,
31 format: format,
32 };
33 const binaryResponse = await this.authUtil.requestWithAuthIfRequired({
34 method: 'get',
35 url: dataUrl,
36 responseType: 'arraybuffer',
37 params: queryParams,
38 signal: signal,
39 });
40
41 if (binaryResponse.status !== 200) {
42 throw new Error(`Unexpected status code: ${binaryResponse.status}`);
43 }
44 if (!binaryResponse.data) {
45 return null;
46 }
47 // convert to float32
48 const iqArray = convertToFloat32(binaryResponse.data, format);
49
50 const result = indexes.map((index, i) => {
51 return {
52 index,
53 iqArray: iqArray.slice(i * blockSize * 2, (i + 1) * blockSize * 2),
54 };
55 });
56 //console.log('getIQDataBlocks', result);
57 return result;
58 }
59
60 async getMinimapIQ(meta: SigMFMetadata, signal: AbortSignal): Promise<Float32Array[]> {
61 const { account, container, file_path } = meta.getOrigin();

Callers

nothing calls this directly

Calls 4

convertToFloat32Function · 0.90
getOriginMethod · 0.80
getDataTypeMethod · 0.80

Tested by

no test coverage detected