@iiasa/ixmp4-ts 0.5.0 → 0.7.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/cjs/backend.js +7 -4
- package/dist/cjs/core/exceptions.js +2 -2
- package/dist/cjs/core/iamc/data.js +56 -34
- package/dist/cjs/core/iamc/variable.js +10 -0
- package/dist/cjs/core/meta.js +15 -5
- package/dist/cjs/core/model.js +13 -2
- package/dist/cjs/core/region.js +13 -2
- package/dist/cjs/core/run.js +17 -6
- package/dist/cjs/core/scenario.js +15 -2
- package/dist/cjs/core/unit.js +12 -2
- package/dist/cjs/core/utils.js +207 -54
- package/dist/cjs/data/base.js +29 -7
- package/dist/cjs/data/docs.js +2 -2
- package/dist/cjs/data/iamc/datapoint.js +18 -11
- package/dist/cjs/data/iamc/timeseries.js +12 -12
- package/dist/cjs/data/iamc/variable.js +9 -4
- package/dist/cjs/data/meta.js +9 -4
- package/dist/cjs/data/model.js +9 -4
- package/dist/cjs/data/region.js +9 -4
- package/dist/cjs/data/run.js +9 -4
- package/dist/cjs/data/scenario.js +9 -4
- package/dist/cjs/data/unit.js +9 -4
- package/dist/cjs/data/utils.js +4 -5
- package/dist/cjs/dataframe/dataframe.js +1 -5
- package/dist/cjs/dataframe/utils.js +4 -5
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/esm/backend.js +7 -4
- package/dist/esm/core/iamc/data.js +50 -30
- package/dist/esm/core/iamc/variable.js +8 -0
- package/dist/esm/core/meta.js +8 -0
- package/dist/esm/core/model.js +11 -2
- package/dist/esm/core/region.js +11 -2
- package/dist/esm/core/run.js +11 -2
- package/dist/esm/core/scenario.js +13 -2
- package/dist/esm/core/unit.js +11 -3
- package/dist/esm/core/utils.js +196 -50
- package/dist/esm/data/base.js +20 -0
- package/dist/esm/data/docs.js +2 -2
- package/dist/esm/data/iamc/datapoint.js +5 -0
- package/dist/esm/data/iamc/variable.js +3 -0
- package/dist/esm/data/meta.js +3 -0
- package/dist/esm/data/model.js +3 -0
- package/dist/esm/data/region.js +3 -0
- package/dist/esm/data/run.js +3 -0
- package/dist/esm/data/scenario.js +3 -0
- package/dist/esm/data/unit.js +3 -0
- package/dist/esm/dataframe/dataframe.js +1 -5
- package/dist/esm/index.js +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/dist/types/core/iamc/data.d.ts +33 -5
- package/dist/types/core/iamc/variable.d.ts +6 -0
- package/dist/types/core/meta.d.ts +6 -0
- package/dist/types/core/model.d.ts +9 -2
- package/dist/types/core/region.d.ts +7 -1
- package/dist/types/core/run.d.ts +7 -1
- package/dist/types/core/scenario.d.ts +7 -1
- package/dist/types/core/unit.d.ts +7 -1
- package/dist/types/core/utils.d.ts +43 -1
- package/dist/types/data/base.d.ts +4 -0
- package/dist/types/data/iamc/datapoint.d.ts +1 -0
- package/dist/types/data/iamc/variable.d.ts +1 -0
- package/dist/types/data/meta.d.ts +1 -0
- package/dist/types/data/model.d.ts +1 -0
- package/dist/types/data/region.d.ts +1 -0
- package/dist/types/data/run.d.ts +1 -0
- package/dist/types/data/scenario.d.ts +1 -0
- package/dist/types/data/unit.d.ts +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -0
- package/package.json +4 -5
package/dist/esm/core/utils.js
CHANGED
@@ -29,79 +29,225 @@ function unitToDimensionless(name) {
|
|
29
29
|
function dfToDimensionless(df) {
|
30
30
|
if (df
|
31
31
|
.loc({ columns: ['unit'] })
|
32
|
-
.values.map(
|
32
|
+
.values.map(String)
|
33
33
|
.includes('dimensionless')) {
|
34
34
|
throw new Error("Unit name 'dimensionless' is reserved, use an empty string '' instead.");
|
35
35
|
}
|
36
36
|
df.replaceValue('', 'dimensionless', 'unit');
|
37
37
|
return df;
|
38
38
|
}
|
39
|
+
/**
|
40
|
+
* Standardizes the columns of a DataFrame in IAMC format.
|
41
|
+
* @param df DataFrame in IAMC format
|
42
|
+
* @returns DataFrame in IAMC format with standardized columns
|
43
|
+
*/
|
44
|
+
function standardizeIamcDf(df) {
|
45
|
+
if (df.columns.includes('time_series__id')) {
|
46
|
+
df = df.dropColumns(['time_series__id']);
|
47
|
+
}
|
48
|
+
if (df.columns.includes('unit')) {
|
49
|
+
df = df.replaceValue('dimensionless', ' ', 'unit');
|
50
|
+
}
|
51
|
+
// Rename step_category to subannual
|
52
|
+
if (df.columns.includes('step_category')) {
|
53
|
+
df = df.renameColumns({ step_category: 'subannual' });
|
54
|
+
}
|
55
|
+
return df;
|
56
|
+
}
|
57
|
+
/**
|
58
|
+
* Converts a DataFrame in IAMC long format to wide format.
|
59
|
+
* @param df The DataFrame to convert
|
60
|
+
* @returns A DataFrame in IAMC wide format
|
61
|
+
*/
|
39
62
|
function toIamcWide(df) {
|
40
|
-
//
|
63
|
+
// empty df: drop long-format columns if present
|
41
64
|
if (df.shape[0] === 0) {
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
const
|
57
|
-
|
58
|
-
|
59
|
-
const
|
60
|
-
|
65
|
+
const longCols = [
|
66
|
+
'step_year',
|
67
|
+
'step_datetime',
|
68
|
+
'step_category',
|
69
|
+
'subannual',
|
70
|
+
'value',
|
71
|
+
];
|
72
|
+
const toDrop = longCols.filter((c) => df.columns.includes(c));
|
73
|
+
return toDrop.length ? df.dropColumns(toDrop) : df;
|
74
|
+
}
|
75
|
+
// column index map
|
76
|
+
const colIdx = Object.fromEntries(df.columns.map((c, i) => [c, i]));
|
77
|
+
// collect unique, non-null times
|
78
|
+
const uniqueNonNull = (arr) => [...new Set(arr.filter((v) => v !== null && v !== undefined))];
|
79
|
+
const years = df.columns.includes('step_year')
|
80
|
+
? uniqueNonNull(df.columnValues('step_year')).sort((a, b) => a - b)
|
81
|
+
: [];
|
82
|
+
const datetimes = df.columns.includes('step_datetime')
|
83
|
+
? uniqueNonNull(df.columnValues('step_datetime')).sort()
|
84
|
+
: [];
|
85
|
+
const allTimes = sortTimesWithYearFirst(years, datetimes);
|
86
|
+
// indices to carry over (everything but time and value)
|
87
|
+
const takeOverIdx = df.columns
|
61
88
|
.map((_, i) => i)
|
62
|
-
.filter((i) => i !==
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
const
|
70
|
-
|
71
|
-
|
89
|
+
.filter((i) => i !== (colIdx['step_year'] ?? -1) &&
|
90
|
+
i !== (colIdx['step_datetime'] ?? -1) &&
|
91
|
+
i !== (colIdx['value'] ?? -1));
|
92
|
+
// base schema (carry-over columns + dtypes)
|
93
|
+
const columns = takeOverIdx.map((i) => df.columns[i]);
|
94
|
+
const dtypes = takeOverIdx.map((i) => df.dtypes[i]);
|
95
|
+
// add time columns
|
96
|
+
const yearColIdx = new Map();
|
97
|
+
const dtColIdx = new Map();
|
98
|
+
for (const time of allTimes) {
|
99
|
+
columns.push(String(time));
|
72
100
|
dtypes.push(DType.FLOAT32);
|
73
|
-
|
101
|
+
const newIdx = columns.length - 1;
|
102
|
+
if (typeof time === 'number')
|
103
|
+
yearColIdx.set(time, newIdx);
|
104
|
+
else
|
105
|
+
dtColIdx.set(time, newIdx);
|
74
106
|
}
|
75
|
-
|
107
|
+
// row identifiers: prefer step_category, fall back to subannual if present
|
108
|
+
const stepCategoryCol = df.columns.includes('step_category')
|
109
|
+
? 'step_category'
|
110
|
+
: df.columns.includes('subannual')
|
111
|
+
? 'subannual'
|
112
|
+
: undefined;
|
113
|
+
const idCols = [
|
76
114
|
'model',
|
77
115
|
'scenario',
|
78
116
|
'version',
|
79
117
|
'region',
|
80
118
|
'variable',
|
81
119
|
'unit',
|
82
|
-
|
120
|
+
'type',
|
121
|
+
stepCategoryCol,
|
122
|
+
].filter(Boolean);
|
123
|
+
const idIdxs = idCols.map((c) => colIdx[c]);
|
124
|
+
// data mapping
|
83
125
|
const dataMap = new Map();
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
126
|
+
const yearIdx = colIdx['step_year'];
|
127
|
+
const dtIdx = colIdx['step_datetime'];
|
128
|
+
const valueIdx = colIdx['value'];
|
129
|
+
for (const dfRow of df.values) {
|
130
|
+
const key = getIamcRowIndex(dfRow, idIdxs);
|
131
|
+
let wideRow = dataMap.get(key);
|
132
|
+
if (!wideRow) {
|
133
|
+
wideRow = takeOverIdx
|
134
|
+
.map((i) => dfRow[i])
|
135
|
+
.concat(Array(allTimes.length).fill(null));
|
136
|
+
dataMap.set(key, wideRow);
|
89
137
|
}
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
138
|
+
const year = yearIdx !== undefined ? dfRow[yearIdx] : undefined;
|
139
|
+
const dt = dtIdx !== undefined ? dfRow[dtIdx] : undefined;
|
140
|
+
let targetIdx;
|
141
|
+
if (year !== undefined && year !== null)
|
142
|
+
targetIdx = yearColIdx.get(year);
|
143
|
+
else if (dt !== undefined && dt !== null)
|
144
|
+
targetIdx = dtColIdx.get(dt);
|
145
|
+
if (targetIdx !== undefined) {
|
146
|
+
wideRow[targetIdx] = dfRow[valueIdx];
|
96
147
|
}
|
97
148
|
}
|
98
|
-
const wideIamcData =
|
99
|
-
for (const wideRow of dataMap.values()) {
|
100
|
-
wideIamcData.push(wideRow);
|
101
|
-
}
|
149
|
+
const wideIamcData = Array.from(dataMap.values());
|
102
150
|
return new DataFrame(wideIamcData, { columns, dtypes });
|
103
151
|
}
|
152
|
+
/**
|
153
|
+
* Generates a unique row index for IAMC data based on the row's identifiers.
|
154
|
+
* @param row The row data as an array
|
155
|
+
* @param rowIdentifiers The indices of the identifiers in the row
|
156
|
+
* @returns A string that uniquely identifies the row
|
157
|
+
*/
|
104
158
|
function getIamcRowIndex(row, rowIdentifiers) {
|
105
159
|
return rowIdentifiers.map((i) => row[i]).join('_');
|
106
160
|
}
|
107
|
-
|
161
|
+
/**
|
162
|
+
* Processes the filter to ensure that IAMC filter is enabled by default unless explicitly disabled.
|
163
|
+
* When enabled, only entities with associated datapoints are returned.
|
164
|
+
* @param filter The filter to process
|
165
|
+
* @returns The processed filter with IAMC default settings
|
166
|
+
*/
|
167
|
+
function withIamcDefault(filter) {
|
168
|
+
if (!filter) {
|
169
|
+
return { iamc: true };
|
170
|
+
}
|
171
|
+
else if (filter.iamc === undefined) {
|
172
|
+
// If the IAMC filter is not explicitly set, default to true
|
173
|
+
filter.iamc = true;
|
174
|
+
}
|
175
|
+
else if (filter.iamc === null) {
|
176
|
+
// If the IAMC filter is explicitly set to null, leave it as is
|
177
|
+
return filter;
|
178
|
+
}
|
179
|
+
return filter;
|
180
|
+
}
|
181
|
+
function sortTimesWithYearFirst(years, dateTimes) {
|
182
|
+
// Create a combined array with type information
|
183
|
+
const combined = [];
|
184
|
+
// Add years with their metadata
|
185
|
+
for (const year of years) {
|
186
|
+
combined.push({ value: year, isYear: true, year });
|
187
|
+
}
|
188
|
+
// Add datetimes with their extracted year
|
189
|
+
for (const dateTime of dateTimes) {
|
190
|
+
// Extract year from datetime string (format: 2005-03-01T01:00:00)
|
191
|
+
const year = parseInt(dateTime.substring(0, 4), 10);
|
192
|
+
combined.push({ value: dateTime, isYear: false, year });
|
193
|
+
}
|
194
|
+
// Sort by year first, then by type (years before datetimes), then by value
|
195
|
+
combined.sort((a, b) => {
|
196
|
+
// First sort by year
|
197
|
+
if (a.year !== b.year) {
|
198
|
+
return a.year - b.year;
|
199
|
+
}
|
200
|
+
// Within the same year, years come before datetimes
|
201
|
+
if (a.isYear && !b.isYear) {
|
202
|
+
return -1;
|
203
|
+
}
|
204
|
+
if (!a.isYear && b.isYear) {
|
205
|
+
return 1;
|
206
|
+
}
|
207
|
+
// If both are the same type, sort by value
|
208
|
+
if (a.value < b.value) {
|
209
|
+
return -1;
|
210
|
+
}
|
211
|
+
if (a.value > b.value) {
|
212
|
+
return 1;
|
213
|
+
}
|
214
|
+
return 0;
|
215
|
+
});
|
216
|
+
// Return just the values
|
217
|
+
return combined.map((item) => item.value);
|
218
|
+
}
|
219
|
+
/**
|
220
|
+
* Splits a DataFrame into separate DataFrames based on DataPointType.
|
221
|
+
* @param df The DataFrame to split
|
222
|
+
* @returns An object containing DataFrames for each type present in the data
|
223
|
+
*/
|
224
|
+
function splitDataFrameByType(df) {
|
225
|
+
const result = {};
|
226
|
+
// If no type column exists, return the original dataframe as annual
|
227
|
+
if (!df.columns.includes('type')) {
|
228
|
+
result.annual = df;
|
229
|
+
return result;
|
230
|
+
}
|
231
|
+
// Get unique types in the dataframe
|
232
|
+
const typeValues = df.columnValues('type');
|
233
|
+
const uniqueTypes = [...new Set(typeValues)];
|
234
|
+
// Filter dataframe for each type present
|
235
|
+
for (const type of uniqueTypes) {
|
236
|
+
const filteredDf = df.query({
|
237
|
+
conditions: { column: 'type', predicate: (value) => value === type },
|
238
|
+
});
|
239
|
+
switch (type) {
|
240
|
+
case DataPointType.ANNUAL:
|
241
|
+
result.annual = filteredDf;
|
242
|
+
break;
|
243
|
+
case DataPointType.CATEGORICAL:
|
244
|
+
result.categorical = filteredDf;
|
245
|
+
break;
|
246
|
+
case DataPointType.DATETIME:
|
247
|
+
result.datetime = filteredDf;
|
248
|
+
break;
|
249
|
+
}
|
250
|
+
}
|
251
|
+
return result;
|
252
|
+
}
|
253
|
+
export { substitudeType, unitToDimensionless, dfToDimensionless, standardizeIamcDf, toIamcWide, withIamcDefault, getIamcRowIndex, sortTimesWithYearFirst, splitDataFrameByType, };
|
package/dist/esm/data/base.js
CHANGED
@@ -91,6 +91,10 @@ class BaseRepository {
|
|
91
91
|
}
|
92
92
|
}
|
93
93
|
async _list({ filter, params, }) {
|
94
|
+
if (this.enumerationMethod === 'GET') {
|
95
|
+
params = { ...params, ...filter };
|
96
|
+
filter = undefined;
|
97
|
+
}
|
94
98
|
const data = await this._requestEnumeration(params, filter, false);
|
95
99
|
const pagination = data.pagination;
|
96
100
|
if (pagination !== undefined) {
|
@@ -122,6 +126,22 @@ class BaseRepository {
|
|
122
126
|
return jsonToDf(data);
|
123
127
|
}
|
124
128
|
}
|
129
|
+
async _count({ filter, params, }) {
|
130
|
+
if (this.enumerationMethod === 'GET') {
|
131
|
+
params = { ...params, ...filter, limit: 0 };
|
132
|
+
filter = undefined;
|
133
|
+
}
|
134
|
+
else {
|
135
|
+
params = { ...params, limit: 0 };
|
136
|
+
}
|
137
|
+
const data = await this._requestEnumeration(params, filter, true);
|
138
|
+
if (data === undefined || data.total === undefined) {
|
139
|
+
throw new UnknownApiError({
|
140
|
+
message: 'Count result does not contain total count.',
|
141
|
+
});
|
142
|
+
}
|
143
|
+
return data.total;
|
144
|
+
}
|
125
145
|
async _bulkUpsert(df, params) {
|
126
146
|
return await this._request(`${this.prefix}bulk/`, 'POST', params, dfToJson(df));
|
127
147
|
}
|
package/dist/esm/data/docs.js
CHANGED
@@ -2,7 +2,7 @@ import { BaseRepository } from './base';
|
|
2
2
|
class DocsRepository extends BaseRepository {
|
3
3
|
static enumerationMethod = 'GET';
|
4
4
|
async get(dimensionId) {
|
5
|
-
return await this._get({
|
5
|
+
return await this._get({ dimensionId });
|
6
6
|
}
|
7
7
|
async set(dimensionId, description) {
|
8
8
|
return (await this._post({
|
@@ -11,7 +11,7 @@ class DocsRepository extends BaseRepository {
|
|
11
11
|
}));
|
12
12
|
}
|
13
13
|
async list(dimensionId) {
|
14
|
-
return await this._list({ filter: {
|
14
|
+
return await this._list({ filter: { dimensionId } });
|
15
15
|
}
|
16
16
|
async delete(dimensionId) {
|
17
17
|
await this._delete(dimensionId);
|
@@ -13,6 +13,9 @@ class VariableRepository extends BaseRepository {
|
|
13
13
|
async tabulate(filter = {}) {
|
14
14
|
return await this._tabulate({ filter });
|
15
15
|
}
|
16
|
+
async count(filter = {}) {
|
17
|
+
return await this._count({ filter });
|
18
|
+
}
|
16
19
|
async create(name) {
|
17
20
|
return await this._post({ name });
|
18
21
|
}
|
package/dist/esm/data/meta.js
CHANGED
@@ -14,6 +14,9 @@ class MetaIndicatorRepository extends BaseRepository {
|
|
14
14
|
async tabulate(filter = {}, joinRunIndex) {
|
15
15
|
return await this._tabulate({ filter, params: { joinRunIndex } });
|
16
16
|
}
|
17
|
+
async count(filter = {}) {
|
18
|
+
return await this._count({ filter });
|
19
|
+
}
|
17
20
|
async create(run__id, key, value) {
|
18
21
|
const res = await this._post({
|
19
22
|
run__id,
|
package/dist/esm/data/model.js
CHANGED
@@ -13,6 +13,9 @@ class ModelRepository extends BaseRepository {
|
|
13
13
|
async tabulate(filter = {}) {
|
14
14
|
return await this._tabulate({ filter });
|
15
15
|
}
|
16
|
+
async count(filter = {}) {
|
17
|
+
return await this._count({ filter });
|
18
|
+
}
|
16
19
|
async create(name) {
|
17
20
|
const res = await this._post({ name });
|
18
21
|
return res;
|
package/dist/esm/data/region.js
CHANGED
@@ -14,6 +14,9 @@ class RegionRepository extends BaseRepository {
|
|
14
14
|
async tabulate(filter = {}) {
|
15
15
|
return await this._tabulate({ filter });
|
16
16
|
}
|
17
|
+
async count(filter = {}) {
|
18
|
+
return await this._count({ filter });
|
19
|
+
}
|
17
20
|
async create(name, hierarchy) {
|
18
21
|
const res = await this._post({
|
19
22
|
name: name,
|
package/dist/esm/data/run.js
CHANGED
@@ -8,6 +8,9 @@ class RunRepository extends BaseRepository {
|
|
8
8
|
async tabulate(filter = {}) {
|
9
9
|
return await this._tabulate({ filter });
|
10
10
|
}
|
11
|
+
async count(filter = {}) {
|
12
|
+
return await this._count({ filter });
|
13
|
+
}
|
11
14
|
async create(modelName, scenarioName) {
|
12
15
|
const res = await this._post({
|
13
16
|
model_name: modelName,
|
@@ -13,6 +13,9 @@ class ScenarioRepository extends BaseRepository {
|
|
13
13
|
async tabulate(filter = {}) {
|
14
14
|
return await this._tabulate({ filter });
|
15
15
|
}
|
16
|
+
async count(filter = {}) {
|
17
|
+
return await this._count({ filter });
|
18
|
+
}
|
16
19
|
async create(name) {
|
17
20
|
return (await this._post({ name }));
|
18
21
|
}
|
package/dist/esm/data/unit.js
CHANGED
@@ -191,11 +191,7 @@ class DataFrame {
|
|
191
191
|
values = options.rows.map((i) => values[i]);
|
192
192
|
index = options.rows.map((i) => index[i]);
|
193
193
|
}
|
194
|
-
return new DataFrame(values, {
|
195
|
-
index,
|
196
|
-
columns,
|
197
|
-
dtypes,
|
198
|
-
});
|
194
|
+
return new DataFrame(values, { index, columns, dtypes });
|
199
195
|
}
|
200
196
|
/**
|
201
197
|
* Returns the value at the specified index and column.
|
package/dist/esm/index.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
1
|
export { Platform } from './core/platform';
|
2
|
+
export { DataPointType } from './data/iamc/datapoint';
|
2
3
|
export { IxmpError, ProgrammingError, InconsistentIamcType, BadRequest, ImproperlyConfigured, ManagerApiError, UnknownApiError, PlatformNotFound, PlatformNotUnique, MissingToken, InvalidToken, Forbidden, NotFound, NotUnique, DeletionPrevented, OperationNotSupported, SchemaError, NoDefaultRunVersion, InvalidRunMeta, BadFilterArguments, InvalidCredentials, } from './core/exceptions';
|
3
4
|
export { DataFrame, DType, concat, toJson, toCsv, merge, DataFrameError, InvalidColumn, InvalidIndex, } from './dataframe';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"root":["../../src/backend.ts","../../src/index.ts","../../src/core/base.ts","../../src/core/exceptions.ts","../../src/core/meta.ts","../../src/core/model.ts","../../src/core/platform.ts","../../src/core/region.ts","../../src/core/run.ts","../../src/core/scenario.ts","../../src/core/unit.ts","../../src/core/utils.ts","../../src/core/iamc/data.ts","../../src/core/iamc/variable.ts","../../src/data/base.ts","../../src/data/docs.ts","../../src/data/filters.ts","../../src/data/info.ts","../../src/data/meta.ts","../../src/data/model.ts","../../src/data/region.ts","../../src/data/run.ts","../../src/data/scenario.ts","../../src/data/unit.ts","../../src/data/utils.ts","../../src/data/iamc/datapoint.ts","../../src/data/iamc/index.ts","../../src/data/iamc/timeseries.ts","../../src/data/iamc/variable.ts","../../src/dataframe/dataframe.ts","../../src/dataframe/exceptions.ts","../../src/dataframe/index.ts","../../src/dataframe/utils.ts"],"version":"5.9.2"}
|
@@ -11,6 +11,15 @@ import { RunFilter as BaseRunFilter } from '../../data/run';
|
|
11
11
|
import { ScenarioFilter as BaseScenarioFilter } from '../../data/scenario';
|
12
12
|
import { IamcDataFilter as BaseIamcDataFilter } from '../../data/iamc/datapoint';
|
13
13
|
import { VariableRepository } from './variable';
|
14
|
+
/**
|
15
|
+
* Represents the result of tabulating IAMC data with metadata about present types.
|
16
|
+
*/
|
17
|
+
type IamcDataResult = {
|
18
|
+
presentTypes: DataPointType[];
|
19
|
+
annual?: DataFrame;
|
20
|
+
categorical?: DataFrame;
|
21
|
+
datetime?: DataFrame;
|
22
|
+
};
|
14
23
|
/**
|
15
24
|
* Represents a filter for tabulating IAMC format data.
|
16
25
|
*/
|
@@ -56,11 +65,17 @@ declare class RunIamcData extends BaseFacade {
|
|
56
65
|
* Tabulates IAMC format timeseries data with optional filtering.
|
57
66
|
* @param filter Optional. Filter for tabulating IAMC format timeseries data.
|
58
67
|
* @param wide Optional. Whether to return the data in IAMC wide format or not, defaults to false.
|
59
|
-
* @
|
68
|
+
* @param splitByType Optional. Whether to return separate DataFrames for different DataPointTypes, defaults to false.
|
69
|
+
* @returns A DataFrame representing the tabulated data, or a IamcDataResult with metadata and separate DataFrames by type if splitByType is true.
|
60
70
|
* @throws An error if illegal filters are applied.
|
61
71
|
*/
|
62
|
-
tabulate(
|
72
|
+
tabulate(params: {
|
73
|
+
wide?: boolean;
|
74
|
+
splitByType: true;
|
75
|
+
} & IamcDataFilter): Promise<IamcDataResult>;
|
76
|
+
tabulate(params?: {
|
63
77
|
wide?: boolean;
|
78
|
+
splitByType?: boolean;
|
64
79
|
} & IamcDataFilter): Promise<DataFrame>;
|
65
80
|
private contractParameters;
|
66
81
|
}
|
@@ -82,12 +97,25 @@ declare class PlatformIamcData extends BaseFacade {
|
|
82
97
|
* @param filter Optional. Filter for retrieving IAMC data.
|
83
98
|
* @param joinRuns Optional. Whether to join runs or not, defaults to true.
|
84
99
|
* @param wide Optional. Whether to return the data in IAMC wide format or not, defaults to false.
|
85
|
-
* @
|
100
|
+
* @param splitByType Optional. Whether to return separate DataFrames for different DataPointTypes, defaults to false.
|
101
|
+
* @returns A Promise that resolves to a DataFrame containing the tabulated data, or a IamcDataResult with metadata and separate DataFrames by type if splitByType is true.
|
86
102
|
*/
|
87
|
-
tabulate(
|
103
|
+
tabulate(params: {
|
88
104
|
joinRuns?: boolean;
|
89
105
|
wide?: boolean;
|
106
|
+
splitByType: true;
|
107
|
+
} & IamcDataFilter): Promise<IamcDataResult>;
|
108
|
+
tabulate(params?: {
|
109
|
+
joinRuns?: boolean;
|
110
|
+
wide?: boolean;
|
111
|
+
splitByType?: boolean;
|
90
112
|
} & IamcDataFilter): Promise<DataFrame>;
|
113
|
+
/**
|
114
|
+
* Counts IAMC datapoints with optional filtering.
|
115
|
+
* @param filter Optional. Filter for counting IAMC datapoints.
|
116
|
+
* @returns A promise that resolves to the count of datapoints.
|
117
|
+
*/
|
118
|
+
count(filter?: IamcDataFilter): Promise<number>;
|
91
119
|
}
|
92
120
|
export { RunIamcData, PlatformIamcData };
|
93
|
-
export type { IamcDataFilter };
|
121
|
+
export type { IamcDataFilter, IamcDataResult };
|
@@ -93,6 +93,12 @@ declare class VariableRepository extends BaseFacade {
|
|
93
93
|
* @returns A Promise that resolves to the tabulated result.
|
94
94
|
*/
|
95
95
|
tabulate(filter?: VariableFilter): Promise<any>;
|
96
|
+
/**
|
97
|
+
* Counts Variables with optional filtering.
|
98
|
+
* @param filter Optional. Filter for counting Variables.
|
99
|
+
* @returns A Promise that resolves to the count of Variables.
|
100
|
+
*/
|
101
|
+
count(filter?: VariableFilter): Promise<number>;
|
96
102
|
}
|
97
103
|
export { Variable, VariableRepository };
|
98
104
|
export type { VariableFilter };
|
@@ -28,6 +28,12 @@ declare class MetaIndicatorRepository extends BaseFacade {
|
|
28
28
|
tabulate({ joinRunIndex, ...filter }?: {
|
29
29
|
joinRunIndex?: boolean;
|
30
30
|
} & MetaIndicatorFilter): Promise<DataFrame>;
|
31
|
+
/**
|
32
|
+
* Counts meta indicators with optional filtering.
|
33
|
+
* @param filter Optional. Filter for counting meta indicators.
|
34
|
+
* @returns A promise that resolves to the count of meta indicators.
|
35
|
+
*/
|
36
|
+
count(filter?: MetaIndicatorFilter): Promise<number>;
|
31
37
|
}
|
32
38
|
/**
|
33
39
|
* Repository for accessing meta indicators of a specific run.
|
@@ -7,6 +7,7 @@ import { VariableFilter as BaseVariableFilter } from '../data/iamc/variable';
|
|
7
7
|
import { UnitFilter as BaseUnitFilter } from '../data/unit';
|
8
8
|
import { RunFilter as BaseRunFilter } from '../data/run';
|
9
9
|
import { ScenarioFilter as BaseScenarioFilter } from '../data/scenario';
|
10
|
+
import { DataFrame } from '../dataframe';
|
10
11
|
/**
|
11
12
|
* Represents a filter for listing and tabulating models.
|
12
13
|
*/
|
@@ -18,7 +19,7 @@ type ModelFilter = BaseModelFilter & {
|
|
18
19
|
run?: BaseRunFilter & {
|
19
20
|
scenario?: BaseScenarioFilter;
|
20
21
|
};
|
21
|
-
};
|
22
|
+
} | boolean;
|
22
23
|
};
|
23
24
|
/**
|
24
25
|
* Represents a model in the assessment modeling system.
|
@@ -94,7 +95,13 @@ declare class ModelRepository extends BaseFacade {
|
|
94
95
|
* @param filter Optional. Filter for tabulating models.
|
95
96
|
* @returns A promise that resolves to the tabulated result.
|
96
97
|
*/
|
97
|
-
tabulate(filter?: ModelFilter): Promise<
|
98
|
+
tabulate(filter?: ModelFilter): Promise<DataFrame>;
|
99
|
+
/**
|
100
|
+
* Counts models with optional filtering.
|
101
|
+
* @param filter Optional. Filter for counting models.
|
102
|
+
* @returns A promise that resolves to the count of models.
|
103
|
+
*/
|
104
|
+
count(filter?: ModelFilter): Promise<number>;
|
98
105
|
}
|
99
106
|
export { Model, ModelRepository };
|
100
107
|
export type { ModelFilter };
|
@@ -19,7 +19,7 @@ type RegionFilter = BaseRegionFilter & {
|
|
19
19
|
scenario?: BaseScenarioFilter;
|
20
20
|
model?: BaseModelFilter;
|
21
21
|
};
|
22
|
-
};
|
22
|
+
} | boolean;
|
23
23
|
};
|
24
24
|
/**
|
25
25
|
* Represents a unit in the system.
|
@@ -108,6 +108,12 @@ declare class RegionRepository extends BaseFacade {
|
|
108
108
|
* @returns A promise that resolves to a DataFrame containing the tabulated regions.
|
109
109
|
*/
|
110
110
|
tabulate(filter?: RegionFilter): Promise<DataFrame>;
|
111
|
+
/**
|
112
|
+
* Counts regions with optional filtering.
|
113
|
+
* @param filter Optional. Filter for counting regions.
|
114
|
+
* @returns A promise that resolves to the count of regions.
|
115
|
+
*/
|
116
|
+
count(filter?: RegionFilter): Promise<number>;
|
111
117
|
}
|
112
118
|
export { Region as Region, RegionRepository };
|
113
119
|
export type { RegionFilter };
|
package/dist/types/core/run.d.ts
CHANGED
@@ -22,7 +22,7 @@ type RunFilter = BaseRunFilter & {
|
|
22
22
|
variable?: BaseVariableFilter;
|
23
23
|
region?: BaseRegionFilter;
|
24
24
|
unit?: BaseUnitFilter;
|
25
|
-
};
|
25
|
+
} | boolean;
|
26
26
|
};
|
27
27
|
/**
|
28
28
|
* Represents a Modeling Run.
|
@@ -123,6 +123,12 @@ declare class RunRepository extends BaseFacade {
|
|
123
123
|
* @returns A promise that resolves to a DataFrame containing the tabulated runs.
|
124
124
|
*/
|
125
125
|
tabulate(filter?: RunFilter): Promise<DataFrame>;
|
126
|
+
/**
|
127
|
+
* Counts runs with optional filtering.
|
128
|
+
* @param filter Optional. Filter for counting runs.
|
129
|
+
* @returns A promise that resolves to the count of runs.
|
130
|
+
*/
|
131
|
+
count(filter?: RunFilter): Promise<number>;
|
126
132
|
}
|
127
133
|
export { Run, RunRepository };
|
128
134
|
export type { RunFilter };
|
@@ -19,7 +19,7 @@ type ScenarioFilter = BaseScenarioFilter & {
|
|
19
19
|
run?: BaseRunFilter & {
|
20
20
|
model?: BaseModelFilter;
|
21
21
|
};
|
22
|
-
};
|
22
|
+
} | boolean;
|
23
23
|
};
|
24
24
|
/**
|
25
25
|
* Represents a Modeling Scenario.
|
@@ -101,6 +101,12 @@ declare class ScenarioRepository extends BaseFacade {
|
|
101
101
|
* @returns A Promise that resolves to a DataFrame containing the tabulated data.
|
102
102
|
*/
|
103
103
|
tabulate(filter?: ScenarioFilter): Promise<DataFrame>;
|
104
|
+
/**
|
105
|
+
* Counts scenarios with optional filtering.
|
106
|
+
* @param filter Optional. Filter for counting scenarios.
|
107
|
+
* @returns A promise that resolves to the count of scenarios.
|
108
|
+
*/
|
109
|
+
count(filter?: ScenarioFilter): Promise<number>;
|
104
110
|
}
|
105
111
|
export { Scenario, ScenarioRepository };
|
106
112
|
export type { ScenarioFilter };
|
@@ -19,7 +19,7 @@ type UnitFilter = BaseUnitFilter & {
|
|
19
19
|
scenario?: BaseScenarioFilter;
|
20
20
|
model?: BaseModelFilter;
|
21
21
|
};
|
22
|
-
};
|
22
|
+
} | boolean;
|
23
23
|
};
|
24
24
|
/**
|
25
25
|
* Represents a unit in the system.
|
@@ -114,6 +114,12 @@ declare class UnitRepository extends BaseFacade {
|
|
114
114
|
* @returns A promise that resolves with a DataFrame object.
|
115
115
|
*/
|
116
116
|
tabulate(filter?: UnitFilter): Promise<DataFrame>;
|
117
|
+
/**
|
118
|
+
* Counts units with optional filtering.
|
119
|
+
* @param filter Optional. Filter for counting units.
|
120
|
+
* @returns A promise that resolves to the count of units.
|
121
|
+
*/
|
122
|
+
count(filter?: UnitFilter): Promise<number>;
|
117
123
|
}
|
118
124
|
export { Unit, UnitRepository };
|
119
125
|
export type { UnitFilter };
|