@iiasa/ixmp4-ts 0.6.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/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 +10 -0
- package/dist/cjs/core/region.js +10 -0
- package/dist/cjs/core/run.js +14 -4
- package/dist/cjs/core/scenario.js +10 -0
- package/dist/cjs/core/unit.js +10 -0
- package/dist/cjs/core/utils.js +187 -55
- package/dist/cjs/data/base.js +25 -7
- 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/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 +8 -0
- package/dist/esm/core/region.js +8 -0
- package/dist/esm/core/run.js +8 -0
- package/dist/esm/core/scenario.js +8 -0
- package/dist/esm/core/unit.js +8 -0
- package/dist/esm/core/utils.js +176 -50
- package/dist/esm/data/base.js +16 -0
- 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 +6 -0
- package/dist/types/core/region.d.ts +6 -0
- package/dist/types/core/run.d.ts +6 -0
- package/dist/types/core/scenario.d.ts +6 -0
- package/dist/types/core/unit.d.ts +6 -0
- package/dist/types/core/utils.d.ts +30 -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
@@ -18,23 +18,23 @@ var DataPointType;
|
|
18
18
|
DataPointType["DATETIME"] = "DATETIME";
|
19
19
|
})(DataPointType || (exports.DataPointType = DataPointType = {}));
|
20
20
|
class DataPointRepository extends base_1.BaseRepository {
|
21
|
-
list(
|
22
|
-
joinParameters
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
list() {
|
22
|
+
return __awaiter(this, arguments, void 0, function* ({ joinParameters = false, filter = {}, } = {
|
23
|
+
joinParameters: false,
|
24
|
+
filter: {},
|
25
|
+
}) {
|
26
26
|
return (yield this._list({
|
27
27
|
filter,
|
28
28
|
params: { joinParameters },
|
29
29
|
}));
|
30
30
|
});
|
31
31
|
}
|
32
|
-
tabulate(
|
33
|
-
joinParameters
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
tabulate() {
|
33
|
+
return __awaiter(this, arguments, void 0, function* ({ joinParameters = false, joinRuns = false, filter = {}, } = {
|
34
|
+
joinParameters: false,
|
35
|
+
joinRuns: false,
|
36
|
+
filter: {},
|
37
|
+
}) {
|
38
38
|
return yield this._tabulate({
|
39
39
|
filter,
|
40
40
|
params: {
|
@@ -44,6 +44,13 @@ class DataPointRepository extends base_1.BaseRepository {
|
|
44
44
|
});
|
45
45
|
});
|
46
46
|
}
|
47
|
+
count() {
|
48
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
49
|
+
return yield this._count({
|
50
|
+
filter,
|
51
|
+
});
|
52
|
+
});
|
53
|
+
}
|
47
54
|
bulkUpsert(df) {
|
48
55
|
return __awaiter(this, void 0, void 0, function* () {
|
49
56
|
yield this._bulkUpsert(df);
|
@@ -49,30 +49,30 @@ class TimeSeriesRepository extends base_1.BaseRepository {
|
|
49
49
|
}
|
50
50
|
});
|
51
51
|
}
|
52
|
-
list(
|
53
|
-
joinParameters
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
list() {
|
53
|
+
return __awaiter(this, arguments, void 0, function* ({ joinParameters = false, filter = {}, } = {
|
54
|
+
joinParameters: false,
|
55
|
+
filter: {},
|
56
|
+
}) {
|
57
57
|
return (yield this._list({
|
58
58
|
filter,
|
59
59
|
params: { joinParameters },
|
60
60
|
}));
|
61
61
|
});
|
62
62
|
}
|
63
|
-
tabulate(
|
64
|
-
joinParameters
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
tabulate() {
|
64
|
+
return __awaiter(this, arguments, void 0, function* ({ joinParameters = false, filter = {}, } = {
|
65
|
+
joinParameters: false,
|
66
|
+
filter: {},
|
67
|
+
}) {
|
68
68
|
return yield this._tabulate({
|
69
69
|
filter,
|
70
70
|
params: { joinParameters },
|
71
71
|
});
|
72
72
|
});
|
73
73
|
}
|
74
|
-
bulkUpsert(
|
75
|
-
return __awaiter(this,
|
74
|
+
bulkUpsert(df_1) {
|
75
|
+
return __awaiter(this, arguments, void 0, function* (df, createRelated = false) {
|
76
76
|
yield this._bulkUpsert(df, { create_related: createRelated });
|
77
77
|
});
|
78
78
|
}
|
@@ -17,16 +17,21 @@ class VariableRepository extends base_1.BaseRepository {
|
|
17
17
|
super(client);
|
18
18
|
this.docs = new docs_1.DocsRepository(client, 'docs/iamc/variables/');
|
19
19
|
}
|
20
|
-
list(
|
21
|
-
return __awaiter(this,
|
20
|
+
list() {
|
21
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
22
22
|
return yield this._list({ filter });
|
23
23
|
});
|
24
24
|
}
|
25
|
-
tabulate(
|
26
|
-
return __awaiter(this,
|
25
|
+
tabulate() {
|
26
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
27
27
|
return yield this._tabulate({ filter });
|
28
28
|
});
|
29
29
|
}
|
30
|
+
count() {
|
31
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
32
|
+
return yield this._count({ filter });
|
33
|
+
});
|
34
|
+
}
|
30
35
|
create(name) {
|
31
36
|
return __awaiter(this, void 0, void 0, function* () {
|
32
37
|
return yield this._post({ name });
|
package/dist/cjs/data/meta.js
CHANGED
@@ -19,16 +19,21 @@ var MetaIndicatorType;
|
|
19
19
|
MetaIndicatorType["BOOL"] = "BOOL";
|
20
20
|
})(MetaIndicatorType || (MetaIndicatorType = {}));
|
21
21
|
class MetaIndicatorRepository extends base_1.BaseRepository {
|
22
|
-
list(
|
23
|
-
return __awaiter(this,
|
22
|
+
list() {
|
23
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
24
24
|
return yield this._list(filter);
|
25
25
|
});
|
26
26
|
}
|
27
|
-
tabulate(
|
28
|
-
return __awaiter(this,
|
27
|
+
tabulate() {
|
28
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}, joinRunIndex) {
|
29
29
|
return yield this._tabulate({ filter, params: { joinRunIndex } });
|
30
30
|
});
|
31
31
|
}
|
32
|
+
count() {
|
33
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
34
|
+
return yield this._count({ filter });
|
35
|
+
});
|
36
|
+
}
|
32
37
|
create(run__id, key, value) {
|
33
38
|
return __awaiter(this, void 0, void 0, function* () {
|
34
39
|
const res = yield this._post({
|
package/dist/cjs/data/model.js
CHANGED
@@ -17,16 +17,21 @@ class ModelRepository extends base_1.BaseRepository {
|
|
17
17
|
super(client);
|
18
18
|
this.docs = new docs_1.DocsRepository(client, 'docs/models/');
|
19
19
|
}
|
20
|
-
list(
|
21
|
-
return __awaiter(this,
|
20
|
+
list() {
|
21
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
22
22
|
return yield this._list({ filter });
|
23
23
|
});
|
24
24
|
}
|
25
|
-
tabulate(
|
26
|
-
return __awaiter(this,
|
25
|
+
tabulate() {
|
26
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
27
27
|
return yield this._tabulate({ filter });
|
28
28
|
});
|
29
29
|
}
|
30
|
+
count() {
|
31
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
32
|
+
return yield this._count({ filter });
|
33
|
+
});
|
34
|
+
}
|
30
35
|
create(name) {
|
31
36
|
return __awaiter(this, void 0, void 0, function* () {
|
32
37
|
const res = yield this._post({ name });
|
package/dist/cjs/data/region.js
CHANGED
@@ -17,17 +17,22 @@ class RegionRepository extends base_1.BaseRepository {
|
|
17
17
|
super(client);
|
18
18
|
this.docs = new docs_1.DocsRepository(client, 'docs/regions/');
|
19
19
|
}
|
20
|
-
list(
|
21
|
-
return __awaiter(this,
|
20
|
+
list() {
|
21
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
22
22
|
const Regions = yield this._list({ filter });
|
23
23
|
return Regions;
|
24
24
|
});
|
25
25
|
}
|
26
|
-
tabulate(
|
27
|
-
return __awaiter(this,
|
26
|
+
tabulate() {
|
27
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
28
28
|
return yield this._tabulate({ filter });
|
29
29
|
});
|
30
30
|
}
|
31
|
+
count() {
|
32
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
33
|
+
return yield this._count({ filter });
|
34
|
+
});
|
35
|
+
}
|
31
36
|
create(name, hierarchy) {
|
32
37
|
return __awaiter(this, void 0, void 0, function* () {
|
33
38
|
const res = yield this._post({
|
package/dist/cjs/data/run.js
CHANGED
@@ -13,16 +13,21 @@ exports.RunRepository = void 0;
|
|
13
13
|
const base_1 = require("./base");
|
14
14
|
const exceptions_1 = require("../core/exceptions");
|
15
15
|
class RunRepository extends base_1.BaseRepository {
|
16
|
-
list(
|
17
|
-
return __awaiter(this,
|
16
|
+
list() {
|
17
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
18
18
|
return yield this._list({ filter });
|
19
19
|
});
|
20
20
|
}
|
21
|
-
tabulate(
|
22
|
-
return __awaiter(this,
|
21
|
+
tabulate() {
|
22
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
23
23
|
return yield this._tabulate({ filter });
|
24
24
|
});
|
25
25
|
}
|
26
|
+
count() {
|
27
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
28
|
+
return yield this._count({ filter });
|
29
|
+
});
|
30
|
+
}
|
26
31
|
create(modelName, scenarioName) {
|
27
32
|
return __awaiter(this, void 0, void 0, function* () {
|
28
33
|
const res = yield this._post({
|
@@ -17,16 +17,21 @@ class ScenarioRepository extends base_1.BaseRepository {
|
|
17
17
|
super(client);
|
18
18
|
this.docs = new docs_1.DocsRepository(client, 'docs/scenarios/');
|
19
19
|
}
|
20
|
-
list(
|
21
|
-
return __awaiter(this,
|
20
|
+
list() {
|
21
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
22
22
|
return (yield this._list({ filter }));
|
23
23
|
});
|
24
24
|
}
|
25
|
-
tabulate(
|
26
|
-
return __awaiter(this,
|
25
|
+
tabulate() {
|
26
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
27
27
|
return yield this._tabulate({ filter });
|
28
28
|
});
|
29
29
|
}
|
30
|
+
count() {
|
31
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
32
|
+
return yield this._count({ filter });
|
33
|
+
});
|
34
|
+
}
|
30
35
|
create(name) {
|
31
36
|
return __awaiter(this, void 0, void 0, function* () {
|
32
37
|
return (yield this._post({ name }));
|
package/dist/cjs/data/unit.js
CHANGED
@@ -32,16 +32,21 @@ class UnitRepository extends base_1.BaseRepository {
|
|
32
32
|
return (yield this._get({ name }));
|
33
33
|
});
|
34
34
|
}
|
35
|
-
list(
|
36
|
-
return __awaiter(this,
|
35
|
+
list() {
|
36
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
37
37
|
return (yield this._list({ filter }));
|
38
38
|
});
|
39
39
|
}
|
40
|
-
tabulate(
|
41
|
-
return __awaiter(this,
|
40
|
+
tabulate() {
|
41
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
42
42
|
return yield this._tabulate({ filter });
|
43
43
|
});
|
44
44
|
}
|
45
|
+
count() {
|
46
|
+
return __awaiter(this, arguments, void 0, function* (filter = {}) {
|
47
|
+
return yield this._count({ filter });
|
48
|
+
});
|
49
|
+
}
|
45
50
|
}
|
46
51
|
exports.UnitRepository = UnitRepository;
|
47
52
|
UnitRepository.prefix = 'units/';
|
package/dist/cjs/data/utils.js
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.convertToSnakeCase = convertToSnakeCase;
|
4
|
+
exports.convertStringToSnakeCase = convertStringToSnakeCase;
|
5
|
+
exports.dfToJson = dfToJson;
|
6
|
+
exports.jsonToDf = jsonToDf;
|
4
7
|
const dataframe_1 = require("../dataframe");
|
5
8
|
function convertStringToSnakeCase(name) {
|
6
9
|
return name.replaceAll(/([A-Z_])/g, '_$1').toLowerCase();
|
7
10
|
}
|
8
|
-
exports.convertStringToSnakeCase = convertStringToSnakeCase;
|
9
11
|
function convertToSnakeCase(obj) {
|
10
12
|
const snakeCaseObj = {};
|
11
13
|
for (const [key, value] of Object.entries(obj)) {
|
@@ -18,7 +20,6 @@ function convertToSnakeCase(obj) {
|
|
18
20
|
}
|
19
21
|
return snakeCaseObj;
|
20
22
|
}
|
21
|
-
exports.convertToSnakeCase = convertToSnakeCase;
|
22
23
|
function dfToJson(df) {
|
23
24
|
return {
|
24
25
|
index: df.index,
|
@@ -44,7 +45,6 @@ function dfToJson(df) {
|
|
44
45
|
data: df.values,
|
45
46
|
};
|
46
47
|
}
|
47
|
-
exports.dfToJson = dfToJson;
|
48
48
|
function jsonToDf(json) {
|
49
49
|
return new dataframe_1.DataFrame(json.data, {
|
50
50
|
index: json.index,
|
@@ -67,4 +67,3 @@ function jsonToDf(json) {
|
|
67
67
|
}),
|
68
68
|
});
|
69
69
|
}
|
70
|
-
exports.jsonToDf = jsonToDf;
|
@@ -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.
|
@@ -1,6 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.concat = concat;
|
4
|
+
exports.toJson = toJson;
|
5
|
+
exports.toCsv = toCsv;
|
6
|
+
exports.merge = merge;
|
4
7
|
const dataframe_1 = require("./dataframe");
|
5
8
|
/**
|
6
9
|
* Concatenates multiple DataFrames along a specified axis.
|
@@ -18,7 +21,6 @@ function concat(options) {
|
|
18
21
|
else
|
19
22
|
throw new Error('Invalid value for axis parameter');
|
20
23
|
}
|
21
|
-
exports.concat = concat;
|
22
24
|
/**
|
23
25
|
* Converts a DataFrame to a JSON object.
|
24
26
|
*
|
@@ -33,7 +35,6 @@ function toJson(df) {
|
|
33
35
|
data: df.values,
|
34
36
|
};
|
35
37
|
}
|
36
|
-
exports.toJson = toJson;
|
37
38
|
/**
|
38
39
|
* Converts a DataFrame to a CSV string.
|
39
40
|
*
|
@@ -63,7 +64,6 @@ function toCsv(options) {
|
|
63
64
|
});
|
64
65
|
return header + rows.join('\n');
|
65
66
|
}
|
66
|
-
exports.toCsv = toCsv;
|
67
67
|
/**
|
68
68
|
* Merges two DataFrames based on specified columns.
|
69
69
|
*
|
@@ -190,7 +190,6 @@ function merge(options) {
|
|
190
190
|
dtypes,
|
191
191
|
});
|
192
192
|
}
|
193
|
-
exports.merge = merge;
|
194
193
|
/* PRIVATE */
|
195
194
|
function concatRows(dataFrames, addMissingColumns) {
|
196
195
|
if (!arraysEqual(...dataFrames.map((df) => df.columns))) {
|
package/dist/cjs/index.js
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.InvalidIndex = exports.InvalidColumn = exports.DataFrameError = exports.merge = exports.toCsv = exports.toJson = exports.concat = exports.DType = exports.DataFrame = exports.InvalidCredentials = exports.BadFilterArguments = exports.InvalidRunMeta = exports.NoDefaultRunVersion = exports.SchemaError = exports.OperationNotSupported = exports.DeletionPrevented = exports.NotUnique = exports.NotFound = exports.Forbidden = exports.InvalidToken = exports.MissingToken = exports.PlatformNotUnique = exports.PlatformNotFound = exports.UnknownApiError = exports.ManagerApiError = exports.ImproperlyConfigured = exports.BadRequest = exports.InconsistentIamcType = exports.ProgrammingError = exports.IxmpError = exports.Platform = void 0;
|
3
|
+
exports.InvalidIndex = exports.InvalidColumn = exports.DataFrameError = exports.merge = exports.toCsv = exports.toJson = exports.concat = exports.DType = exports.DataFrame = exports.InvalidCredentials = exports.BadFilterArguments = exports.InvalidRunMeta = exports.NoDefaultRunVersion = exports.SchemaError = exports.OperationNotSupported = exports.DeletionPrevented = exports.NotUnique = exports.NotFound = exports.Forbidden = exports.InvalidToken = exports.MissingToken = exports.PlatformNotUnique = exports.PlatformNotFound = exports.UnknownApiError = exports.ManagerApiError = exports.ImproperlyConfigured = exports.BadRequest = exports.InconsistentIamcType = exports.ProgrammingError = exports.IxmpError = exports.DataPointType = exports.Platform = void 0;
|
4
4
|
var platform_1 = require("./core/platform");
|
5
5
|
Object.defineProperty(exports, "Platform", { enumerable: true, get: function () { return platform_1.Platform; } });
|
6
|
+
var datapoint_1 = require("./data/iamc/datapoint");
|
7
|
+
Object.defineProperty(exports, "DataPointType", { enumerable: true, get: function () { return datapoint_1.DataPointType; } });
|
6
8
|
var exceptions_1 = require("./core/exceptions");
|
7
9
|
Object.defineProperty(exports, "IxmpError", { enumerable: true, get: function () { return exceptions_1.IxmpError; } });
|
8
10
|
Object.defineProperty(exports, "ProgrammingError", { enumerable: true, get: function () { return exceptions_1.ProgrammingError; } });
|
@@ -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"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { merge } from '../../dataframe';
|
2
2
|
import { BaseFacade } from '../base';
|
3
|
-
import {
|
3
|
+
import { DataPointType } from '../../data/iamc/datapoint';
|
4
|
+
import { dfToDimensionless, substitudeType, toIamcWide, splitDataFrameByType, standardizeIamcDf, } from '../utils';
|
4
5
|
import { VariableRepository } from './variable';
|
5
6
|
/**
|
6
7
|
* Represents IAMC format data for a specific Run.
|
@@ -48,15 +49,9 @@ class RunIamcData extends BaseFacade {
|
|
48
49
|
df = df.dropColumns(['unit', 'variable', 'region']);
|
49
50
|
await this.backend.iamc.datapoints.bulkDelete(df);
|
50
51
|
}
|
51
|
-
|
52
|
-
* Tabulates IAMC format timeseries data with optional filtering.
|
53
|
-
* @param filter Optional. Filter for tabulating IAMC format timeseries data.
|
54
|
-
* @param wide Optional. Whether to return the data in IAMC wide format or not, defaults to false.
|
55
|
-
* @returns A DataFrame representing the tabulated data.
|
56
|
-
* @throws An error if illegal filters are applied.
|
57
|
-
*/
|
58
|
-
async tabulate({ wide = false, ...filter } = {
|
52
|
+
async tabulate({ wide = false, splitByType = false, ...filter } = {
|
59
53
|
wide: false,
|
54
|
+
splitByType: false,
|
60
55
|
}) {
|
61
56
|
if (filter !== undefined && filter !== null) {
|
62
57
|
// these filters do not make sense when applied from a Run
|
@@ -67,12 +62,14 @@ class RunIamcData extends BaseFacade {
|
|
67
62
|
throw new Error(`Illegal filter for 'iamc.tabulate()': ${illegalFilter}`);
|
68
63
|
}
|
69
64
|
}
|
70
|
-
|
65
|
+
const df = await this.repository.tabulate({
|
66
|
+
...filter,
|
71
67
|
run: { id: this.run.id, defaultOnly: false },
|
72
68
|
joinRuns: false,
|
73
69
|
wide,
|
74
|
-
|
70
|
+
splitByType,
|
75
71
|
});
|
72
|
+
return df;
|
76
73
|
}
|
77
74
|
async contractParameters(df) {
|
78
75
|
let timeseriesDf = df
|
@@ -116,17 +113,7 @@ class PlatformIamcData extends BaseFacade {
|
|
116
113
|
super(backend);
|
117
114
|
this.variables = new VariableRepository(this.backend);
|
118
115
|
}
|
119
|
-
|
120
|
-
* Tabulates IAMC data with optional filtering.
|
121
|
-
* @param filter Optional. Filter for retrieving IAMC data.
|
122
|
-
* @param joinRuns Optional. Whether to join runs or not, defaults to true.
|
123
|
-
* @param wide Optional. Whether to return the data in IAMC wide format or not, defaults to false.
|
124
|
-
* @returns A Promise that resolves to a DataFrame containing the tabulated data.
|
125
|
-
*/
|
126
|
-
async tabulate({ joinRuns = true, wide = false, ...filter } = {
|
127
|
-
joinRuns: true,
|
128
|
-
wide: false,
|
129
|
-
}) {
|
116
|
+
async tabulate({ joinRuns = true, wide = false, splitByType = false, ...filter } = { joinRuns: true, wide: false, splitByType: false }) {
|
130
117
|
if (filter === undefined) {
|
131
118
|
filter = {};
|
132
119
|
}
|
@@ -135,19 +122,52 @@ class PlatformIamcData extends BaseFacade {
|
|
135
122
|
filter['run'] = { defaultOnly: true };
|
136
123
|
}
|
137
124
|
const joinParameters = true;
|
138
|
-
let df = await this.backend.iamc.datapoints.tabulate({
|
125
|
+
let df = (await this.backend.iamc.datapoints.tabulate({
|
139
126
|
joinRuns,
|
140
127
|
joinParameters,
|
141
128
|
filter,
|
142
|
-
});
|
143
|
-
|
144
|
-
|
145
|
-
|
129
|
+
}));
|
130
|
+
if (splitByType) {
|
131
|
+
const splitDfs = splitDataFrameByType(df);
|
132
|
+
const typeMapping = {
|
133
|
+
annual: DataPointType.ANNUAL,
|
134
|
+
categorical: DataPointType.CATEGORICAL,
|
135
|
+
datetime: DataPointType.DATETIME,
|
136
|
+
};
|
137
|
+
const presentTypes = [];
|
138
|
+
Object.entries(typeMapping).forEach(([key, type]) => {
|
139
|
+
const typedKey = key;
|
140
|
+
if (splitDfs[typedKey]) {
|
141
|
+
presentTypes.push(type);
|
142
|
+
if (wide) {
|
143
|
+
splitDfs[typedKey] = toIamcWide(splitDfs[typedKey]);
|
144
|
+
}
|
145
|
+
splitDfs[typedKey] = standardizeIamcDf(splitDfs[typedKey]);
|
146
|
+
}
|
147
|
+
});
|
148
|
+
return { presentTypes, ...splitDfs };
|
146
149
|
}
|
147
|
-
|
148
|
-
|
150
|
+
else {
|
151
|
+
if (wide) {
|
152
|
+
df = toIamcWide(df);
|
153
|
+
}
|
154
|
+
return standardizeIamcDf(df);
|
155
|
+
}
|
156
|
+
}
|
157
|
+
/**
|
158
|
+
* Counts IAMC datapoints with optional filtering.
|
159
|
+
* @param filter Optional. Filter for counting IAMC datapoints.
|
160
|
+
* @returns A promise that resolves to the count of datapoints.
|
161
|
+
*/
|
162
|
+
async count(filter) {
|
163
|
+
if (filter === undefined) {
|
164
|
+
filter = {};
|
165
|
+
}
|
166
|
+
// return only default runs unless a run-filter is provided
|
167
|
+
if (!Object.hasOwn(filter, 'run')) {
|
168
|
+
filter['run'] = { defaultOnly: true };
|
149
169
|
}
|
150
|
-
return
|
170
|
+
return this.backend.iamc.datapoints.count(filter);
|
151
171
|
}
|
152
172
|
}
|
153
173
|
export { RunIamcData, PlatformIamcData };
|
@@ -109,5 +109,13 @@ class VariableRepository extends BaseFacade {
|
|
109
109
|
async tabulate(filter) {
|
110
110
|
return this.backend.iamc.variables.tabulate(filter);
|
111
111
|
}
|
112
|
+
/**
|
113
|
+
* Counts Variables with optional filtering.
|
114
|
+
* @param filter Optional. Filter for counting Variables.
|
115
|
+
* @returns A Promise that resolves to the count of Variables.
|
116
|
+
*/
|
117
|
+
async count(filter) {
|
118
|
+
return this.backend.iamc.variables.count(filter);
|
119
|
+
}
|
112
120
|
}
|
113
121
|
export { Variable, VariableRepository };
|
package/dist/esm/core/meta.js
CHANGED
@@ -18,6 +18,14 @@ class MetaIndicatorRepository extends BaseFacade {
|
|
18
18
|
}
|
19
19
|
return await this.backend.meta.tabulate(filter, joinRunIndex);
|
20
20
|
}
|
21
|
+
/**
|
22
|
+
* Counts meta indicators with optional filtering.
|
23
|
+
* @param filter Optional. Filter for counting meta indicators.
|
24
|
+
* @returns A promise that resolves to the count of meta indicators.
|
25
|
+
*/
|
26
|
+
async count(filter) {
|
27
|
+
return this.backend.meta.count(filter || {});
|
28
|
+
}
|
21
29
|
}
|
22
30
|
/**
|
23
31
|
* Repository for accessing meta indicators of a specific run.
|
package/dist/esm/core/model.js
CHANGED
@@ -110,5 +110,13 @@ class ModelRepository extends BaseFacade {
|
|
110
110
|
async tabulate(filter) {
|
111
111
|
return this.backend.models.tabulate(withIamcDefault(filter));
|
112
112
|
}
|
113
|
+
/**
|
114
|
+
* Counts models with optional filtering.
|
115
|
+
* @param filter Optional. Filter for counting models.
|
116
|
+
* @returns A promise that resolves to the count of models.
|
117
|
+
*/
|
118
|
+
async count(filter) {
|
119
|
+
return this.backend.models.count(withIamcDefault(filter));
|
120
|
+
}
|
113
121
|
}
|
114
122
|
export { Model, ModelRepository };
|
package/dist/esm/core/region.js
CHANGED
@@ -139,5 +139,13 @@ class RegionRepository extends BaseFacade {
|
|
139
139
|
async tabulate(filter) {
|
140
140
|
return this.backend.regions.tabulate(withIamcDefault(filter));
|
141
141
|
}
|
142
|
+
/**
|
143
|
+
* Counts regions with optional filtering.
|
144
|
+
* @param filter Optional. Filter for counting regions.
|
145
|
+
* @returns A promise that resolves to the count of regions.
|
146
|
+
*/
|
147
|
+
async count(filter) {
|
148
|
+
return this.backend.regions.count(withIamcDefault(filter));
|
149
|
+
}
|
142
150
|
}
|
143
151
|
export { Region as Region, RegionRepository };
|
package/dist/esm/core/run.js
CHANGED
@@ -167,5 +167,13 @@ class RunRepository extends BaseFacade {
|
|
167
167
|
columns: ['id', 'model', 'scenario', 'version', 'is_default'],
|
168
168
|
});
|
169
169
|
}
|
170
|
+
/**
|
171
|
+
* Counts runs with optional filtering.
|
172
|
+
* @param filter Optional. Filter for counting runs.
|
173
|
+
* @returns A promise that resolves to the count of runs.
|
174
|
+
*/
|
175
|
+
async count(filter = {}) {
|
176
|
+
return this.backend.runs.count(withIamcDefault(filter));
|
177
|
+
}
|
170
178
|
}
|
171
179
|
export { Run, RunRepository };
|
@@ -118,5 +118,13 @@ class ScenarioRepository extends BaseFacade {
|
|
118
118
|
async tabulate(filter) {
|
119
119
|
return this.backend.scenarios.tabulate(withIamcDefault(filter));
|
120
120
|
}
|
121
|
+
/**
|
122
|
+
* Counts scenarios with optional filtering.
|
123
|
+
* @param filter Optional. Filter for counting scenarios.
|
124
|
+
* @returns A promise that resolves to the count of scenarios.
|
125
|
+
*/
|
126
|
+
async count(filter) {
|
127
|
+
return this.backend.scenarios.count(withIamcDefault(filter));
|
128
|
+
}
|
121
129
|
}
|
122
130
|
export { Scenario, ScenarioRepository };
|
package/dist/esm/core/unit.js
CHANGED
@@ -151,5 +151,13 @@ class UnitRepository extends BaseFacade {
|
|
151
151
|
async tabulate(filter) {
|
152
152
|
return this.backend.units.tabulate(withIamcDefault(filter));
|
153
153
|
}
|
154
|
+
/**
|
155
|
+
* Counts units with optional filtering.
|
156
|
+
* @param filter Optional. Filter for counting units.
|
157
|
+
* @returns A promise that resolves to the count of units.
|
158
|
+
*/
|
159
|
+
async count(filter) {
|
160
|
+
return this.backend.units.count(withIamcDefault(filter));
|
161
|
+
}
|
154
162
|
}
|
155
163
|
export { Unit, UnitRepository };
|