You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+160Lines changed: 160 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -442,6 +442,154 @@ To construct a GME Public Offer Extraction the following must be provided.
442
442
443
443
</table>
444
444
445
+
### Unit of Measure Conversion Functionality
446
+
447
+
### Overview
448
+
449
+
The unit of measure conversion functionality allows users to request a conversion of units for Market Data that was registered using a different unit. This feature is supported only for Actual and Versioned Time Series.
450
+
Supported units are defined in the CommonUnitOfMeasure object and conform to ISO/IEC 80000 (i.e., `kW`, `MW`, `kWh`, `MWh`, `m`, `km`, `day`, `min`, `h`, `s`, `mo`, `yr`).
451
+
452
+
Note: Duration-based units are interpreted with the following fixed assumptions:
453
+
`1 day = 24 hours`
454
+
`1 mo = 30 days`
455
+
`1 yr = 365 days`
456
+
457
+
Additional supported units include **currency codes** in 3-letter format as per ISO 4217:2015 (e.g., `EUR`, `USD`, `JPY`). These are not part of CommonUnitOfMeasure and must be specified as regular strings.
458
+
Units of measure can also be **composite**, using the {a}/{b} syntax, where both {a} and {b} are either units from CommonUnitOfMeasure or ISO 4217 currency codes.
459
+
460
+
### Conversion Logic
461
+
462
+
Unit conversion is based on the assumption that each unit of measure can be decomposed into a **"BaseDimension"**, which represents a polynomial of base SI units (`m`, `s`, `kg`, etc.) and currencies (`EUR`, `USD`, etc.).
463
+
A unit of measure is represented as a value in BaseDimension UnitOdMeasure.
464
+
Example:
465
+
10 `Wh` = 10 `kg·m²·s⁻³`
466
+
Conversion is allowed when the BaseDimensions **match exactly**, i.e., the same set of base units raised to the same exponents.
467
+
In Artesian, units that differ **only** in the **time dimension** are also potentially convertible, as the time dimension can be inferred from the data’s time interval.
### UnitOfMeasure Conversion and Aggregation Rule Override
501
+
502
+
In the QueryService, there are two supported methods related to unit of measure handling during extraction:
503
+
504
+
1. UnitOfMeasure Conversion
505
+
2. Aggregation Rule Override
506
+
507
+
### UnitOfMeasure Conversion
508
+
509
+
To convert a UnitOfMeasure during data extraction, use the `.inUnitOfMeasure()` method. This function converts the data from the unit defined at MarketData registration to the target unit you specify in the query.
510
+
511
+
```Python
512
+
qs = QueryService(cfg)
513
+
data = qs.createActual() \
514
+
.forMarketData([100011484]) \
515
+
.inAbsoluteDateRange("2024-01-01","2024-01-02") \
516
+
.inTimeZone("UTC") \
517
+
.inGranularity(Granularity.Day) \
518
+
.inUnitOfMeasure(CommonUnitOfMeasure.MW) \
519
+
.execute()
520
+
```
521
+
522
+
By default, the aggregation rule used during extraction is the one defined at registration. However, you can override it if needed. The conversion is always applied before aggregation.
523
+
524
+
### Aggregation Rule Override
525
+
526
+
AggregationRule can be overrided using the `.withAggregationRule()` method in QueryService.
Sometimes, especially when converting from a **consumption unit** (e.g., `MWh`) to a **power unit** (e.g., `MW`), the registered aggregation rule (e.g., `SumAndDivide`) may not make sense for the new unit.
540
+
541
+
If you **don’t override the aggregation rule**, the conversion may produce **invalid or misleading results**.
542
+
543
+
### Example: Convert power (`MW`) to energy (`MWh`):
0 commit comments