Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Upgrade to QUDT 3.1.4
- Calculation of scalings and factor units now happens in QUDT (see PR [1129](https://github.com/qudt/qudt-public-repo/pull/1129))
However, a few things have changed:
- rename `qudt:isScalingOf` to `qudt:scalingOf`
- rename `qudt:factorUnit/qudt:unit` to `qudt:hasFactorUnit/qudt:hasUnit`
- Currency units have changed:
- they were moved back into the graph 'http://qudt.org/vocab/unit/'
- their localnames have received the prefix `CCY_`
- both changes are 'soft', ie, the old way is still available, but deprecated
- for example: `http://qudt.org/vocab/currency/EUR` is now `http://qudt.org/vocab/unit/CCY_EUR`.
- QUDTLib makes the change now instead of adopting the deprecation, as there are other breaking changes as well, so upgrading will require work anyway.
- for QUDTLib constants, this means that the pattern `${CurrencyName}_Currency` is dropped in favor of the QUDT style `CCY_${CurrencyName}`, e.g. `Qudt.Units.EUR_Currency` becomes `Qudt.Units.CCY_EUR`
- Many conversion multipliers were changed in QUDT. They now consistently have at most 34 significant digits (ie, BigDecimal's precision of 34). This fixes problems such as the one reported in [Conversion error from MilliSV__PER__HR to MicroSV__PER__HR](https://github.com/qudtlib/qudtlib-java/issues/109).
- scalings of `unit:GM` deserve special mention:
- in the upcoming QUDT release we have `unit:GM qudt:scalingOf unit:KiloGM`, making `qudt:scalingOf` and `qudt:conversionMultiplier` consistent in all cases
- QUDTLib makes the change as well, with the effect that unit factorization does not use `Units.GM` (which probably surprised a few people) for the mass dimension but `Units.KiloGM` (which is what one would expect)
- Sorting in `Qudt.derivedUnitListFromFactorUnits` now takes more aspects into account and ordering has changed in some cases.
- When creating a Unit instance, its factor units are checked for factors `x^N^M`, where x has no more factors.
Such factors are simplified as x^(N*M). The same is applied to newly instantiated `FactorUnits` objects.

### Fixed

- Fixed a sorting bug in `Qudt.derivedUnitListFromFactorUnits` that caused wrong sorting for some very similar units.

### Added

- `Unit.dependents` - the number of units that refer to that unit as one of its factor units or are scaled from that base unit.
this value is required to achieve better sorting in `Qudt.derivedUnitListFromFactorUnits`, allowing to prefer
more important units (those with more dependents)

## [6.8.1] - 2025-01-29

### Fixed
Expand Down Expand Up @@ -93,13 +125,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Simplified BEST_MATCH algorithm for obtaining a unit from a set of factor units. Recent additions to the data model (isScalingOf and factorUnit relationships) led to a larger set of candidates and the complexity of the previous algorithm led to very high computation time.
- Simplified BEST_MATCH algorithm for obtaining a unit from a set of factor units. Recent additions to the data model (scalingOf and factorUnit relationships) led to a larger set of candidates and the complexity of the previous algorithm led to very high computation time.
- Changed the behaviour of Unit.hasFactorUnits() such that for a FactorUnits object with only one top-level factor unit (such as [N^1]), the method returns false.

### Fixed

- `unit:MHO`, `unit:MicroMHO`: fix dimension vector and quantity kind
- `unit:F`: fix `unit:isScalingOf`
- `unit:F`: fix `unit:scalingOf`

## [6.1.0] - 2024-01-05

Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<qudt.release.version>2.1.47</qudt.release.version>
<qudt.release.version>3.1.4</qudt.release.version>
<spotless.format.version>1.25.0</spotless.format.version>
</properties>

Expand Down Expand Up @@ -331,6 +331,12 @@
</plugins>
</build>
</profile>
<profile>
<id>skip-test</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
</profiles>
<distributionManagement>
<snapshotRepository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class ConstantsGenerator {
// input data
private static final String DATA_UNITS = "qudtlib/qudt-units.ttl";
private static final String DATA_QUANTITYKINDS = "qudtlib/qudt-quantitykinds.ttl";
private static final String DATA_CURRENCY = "qudtlib/qudt-currency.ttl";
private static final String DATA_PREFIXES = "qudtlib/qudt-prefixes.ttl";
private static final String DATA_SYSTEMS_OF_UNITS = "qudtlib/qudt-systems-of-units.ttl";
private static final String DATA_PHYSICAL_CONSTANTS = "qudtlib/qudt-constants.ttl";
Expand Down Expand Up @@ -148,9 +147,6 @@ private Map<String, Object> getConstantNamesByQuery(String queryFile, String...
typeName.substring(0, 1).toLowerCase()
+ typeName.substring(1)
+ "FromLocalnameRequired";
if (typeName.equals("Unit") && constName.endsWith("_Currency")) {
valueFactory = "currencyFromLocalnameRequired";
}
Constant constant =
new Constant(
constName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,20 @@ public class DataGenerator {

// QUDT files
private static final String UNITS_FILE = "qudt/vocab/unit/VOCAB_QUDT-UNITS-ALL.ttl";
private static final String CURRENCIES_FILE =
"qudt/vocab/currency/VOCAB_QUDT-UNITS-CURRENCY.ttl";
private static final String PREFIXES_FILE = "qudt/vocab/prefixes/VOCAB_QUDT-PREFIXES.ttl";
private static final String QUANTITYKINDS_FILE =
"qudt/vocab/quantitykinds/VOCAB_QUDT-QUANTITY-KINDS-ALL.ttl";

private static final String CONSTANTS_FILE = "qudt/vocab/constants/VOCAB_QUDT-CONSTANTS.ttl";

// queries
private static final String FACTOR_UNITS_QUERY = "factorUnit.rq";
private static final String IS_SCALING_OF_QUERY = "isScalingOf.rq";
private static final String MISSING_UNITS_QUERY = "missing-units.rq";
private static final String DELETE_KILOGM_SCALINGS_QUERY = "delete-kiloGM-scalings.rq";
private static final String DELETE_UNITS_QUERY = "delete-units.rq";

private static final String DELETE_FROM_UNITS_BY_QUERY_PATTERN =
"delete-from-units-by-query[N].rq";
private static final String DELETE_FROM_QUANTITYKINDS_BY_QUERY_PATTERN =
"delete-from-quantitykinds-by-query[N].rq";
private static final String UPDATE_UNITS_BY_QUERY_PATTERN = "update-units-by-query[N].rq";
private static final String UPDATE_QUANTITYKINDS_BY_QUERY_PATTERN =
"update-quantitykinds-by-query[N].rq";
// additional data
private static final String SI_BASE_UNITS_DATA = "si-base-units.ttl";
private static final String ADD_TO_UNITS = "add-to-units.ttl";
private static final String ADD_TO_QUANTITYKINDS = "add-to-quantitykinds.ttl";
private static final String DELETE_FROM_UNITS = "delete-from-units.ttl";
Expand Down Expand Up @@ -137,11 +130,9 @@ private void processQuantityKinds() {
Repository outputRepo = new SailRepository(new MemoryStore());
try (RepositoryConnection outputCon = outputRepo.getConnection()) {
RdfOps.addStatementsFromFile(outputCon, QUANTITYKINDS_FILE);
RdfOps.addStatementsFromFile(outputCon, CURRENCIES_FILE);
RdfOps.updateDataUsingQuery(outputCon, DELETE_UNITS_QUERY);
// remove unwanted individual triples
RdfOps.updateDataUsingNQueries(
outputCon, DELETE_FROM_QUANTITYKINDS_BY_QUERY_PATTERN, 5);
RdfOps.updateDataUsingNQueries(outputCon, UPDATE_QUANTITYKINDS_BY_QUERY_PATTERN, 5);
RdfOps.removeStatementsFromFile(outputCon, DELETE_FROM_QUANTITYKINDS);
// add missing triples
RdfOps.addStatementsFromFile(outputCon, ADD_TO_QUANTITYKINDS);
Expand All @@ -157,30 +148,20 @@ void processUnits() {
try (RepositoryConnection outputCon = outputRepo.getConnection()) {
// start with the original units data in the INPUT repo
RdfOps.addStatementsFromFile(inputCon, UNITS_FILE);
RdfOps.addStatementsFromFile(inputCon, CURRENCIES_FILE);
// deal with kg
RdfOps.updateDataUsingQuery(inputCon, DELETE_KILOGM_SCALINGS_QUERY);
// if we have identified wrong data in this query, remove it
RdfOps.updateDataUsingNQueries(inputCon, DELETE_FROM_UNITS_BY_QUERY_PATTERN, 5);
RdfOps.updateDataUsingNQueries(inputCon, UPDATE_UNITS_BY_QUERY_PATTERN, 5);
// remove unwanted individual triples
RdfOps.removeStatementsFromFile(inputCon, DELETE_FROM_UNITS);
// add missing triples
RdfOps.addStatementsFromFile(inputCon, ADD_TO_UNITS);
// add SI base units
RdfOps.addStatementsFromFile(outputCon, SI_BASE_UNITS_DATA);
// put result in OUTPUT repo
RdfOps.copyData(inputCon, outputCon);
// add prefixes to INPUT repo (cannot be in output, but is required for queries!)
RdfOps.addStatementsFromFile(inputCon, PREFIXES_FILE);
// find isScalingOf where missing, write result in INPUT and OUTPUT repos
// find scalingOf where missing, write result in INPUT and OUTPUT repos
if (DEBUG) {
RdfOps.writeTurtleFile(inputCon, new File("/tmp/scaling-data.ttl").toPath());
}
RdfOps.addDataUsingQuery(inputCon, IS_SCALING_OF_QUERY, inputCon, outputCon);
// find factor units, write result in INPUT and OUTPUT repos
RdfOps.addDataUsingQuery(inputCon, FACTOR_UNITS_QUERY, inputCon, outputCon);
// we generate some units in the above, add basic unit info for those, write to
// INPUT and OUTPUT repos
RdfOps.addDataUsingQuery(inputCon, MISSING_UNITS_QUERY, inputCon, outputCon);
copyNamespaces(inputCon, outputCon);
// write units file from OUTPUT repo
Expand Down Expand Up @@ -215,7 +196,7 @@ private void compareWithExpected(RepositoryConnection outputCon) {
.collect(Collectors.toList()));
RdfOps.message(
"\n\nExpected data subset of generated: " + Models.isomorphic(actual, expected));
compareForProperty(expected, actual, QUDT.isScalingOf);
compareForProperty(expected, actual, QUDT.scalingOf);
compareForProperty(expected, actual, QUDTX.factorUnit);
}

Expand Down
51 changes: 0 additions & 51 deletions qudtlib-data-gen/src/main/resources/add-to-units.ttl
Original file line number Diff line number Diff line change
@@ -1,53 +1,2 @@
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
@prefix unit: <http://qudt.org/vocab/unit/> .

unit:DEG_C2
qudt:symbol "°C²" .

unit:GM-PER-M2-HR
qudt:symbol "g/m²·hr" .

unit:GM-PER-M2-YR
qudt:symbol "g/m²·yr" .

unit:GM-PER-M3-CentiPOISE
qudt:symbol "g/(m³·cP)" .

unit:GM-PER-M3-PA-SEC
qudt:symbol "g/(m³Pa·s)" .

unit:KiloGM-PER-M2-DAY
qudt:symbol "kg/(m²·d)" .

unit:KiloTONNE-PER-YR
qudt:symbol "kt/yr" .

unit:MegaGM-PER-HA-YR
qudt:symbol "Mg/(ha·yr)" .

unit:MegaJ-PER-M2-DAY
qudt:symbol "MJ/(m²·d)" .

unit:MicroGM-PER-GM-HR
qudt:symbol "μg/(g·h)" .

unit:MicroGM-PER-L-DAY
qudt:symbol "μg/(L·d)" .

unit:MicroMOL-PER-M2-SEC2
qudt:symbol "μmol/(m²·s²)" .

unit:MilliM-PER-M2
qudt:symbol "mm/m²" .

unit:MilliMOL-PER-M2-HR
qudt:symbol "mmol/(m²·h)" .

unit:NanoMOL-PER-GM-HR
qudt:symbol "nmol/(g.h)" .

unit:NanoMOL-PER-M2-SEC
qudt:symbol "nmol/(m²·s)" .


This file was deleted.

24 changes: 0 additions & 24 deletions qudtlib-data-gen/src/main/resources/delete-from-units-by-query1.rq

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions qudtlib-data-gen/src/main/resources/delete-kiloGM-scalings.rq

This file was deleted.

83 changes: 0 additions & 83 deletions qudtlib-data-gen/src/main/resources/factorUnit.rq

This file was deleted.

Loading