Created
May 3, 2024 19:06
-
-
Save cmutel/a16d3434d77d655e154cd9613a3eef82 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flowmapper.transformation_mapping import prepare_transformations | |
from flowmapper import Flow | |
from flowmapper.utils import load_standard_transformations | |
our_transform = [{ | |
"update": [{ | |
"source": | |
{ | |
"name": "2,4-D", | |
"context": "Emissions to air/" | |
}, | |
"target": | |
{ | |
"name": "2,4-D amines", | |
}, | |
"author": "Marwa", | |
"comment": "Equivalent chemicals with different name forms" | |
}] | |
}] | |
transformations = prepare_transformations(load_standard_transformations() + our_transform) | |
source = Flow({ | |
"name": "2,4-D", | |
"unit": "kg", | |
"context": "Emissions to air/" | |
}, transformations) | |
target = Flow({ | |
"identifier": "4f777e05-70f9-4a18-a406-d8232325073f", | |
"unit": "kg", | |
"context": [ | |
"air", | |
"non-urban air or from high stacks" | |
], | |
"name": "2,4-D amines", | |
"synonyms": [ | |
"2,4-D dimethylamine salt", | |
"2-(2,4-dichlorophenoxy)acetic acid", | |
"N-methylmethanamine" | |
], | |
"CAS number": "002008-39-1" | |
}, transformations) | |
source.name == target.name | |
>>> True | |
source.context == target.context | |
>>> False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flowmapper.transformation_mapping import prepare_transformations | |
from flowmapper import Flow | |
from flowmapper.utils import load_standard_transformations | |
fixed_transform = [{ | |
"update": [{ | |
"source": { | |
"name": "2,4-D", | |
"context": "Emissions to air/" | |
}, | |
"target": { | |
"name": "2,4-D amines", | |
"context": ["air", "non-urban air or from high stacks"] | |
}, | |
"author": "Marwa", | |
"comment": "Equivalent chemicals with different name forms" | |
}] | |
}] | |
transformations = prepare_transformations(load_standard_transformations() + fixed_transform) | |
source = Flow({ | |
"name": "2,4-D", | |
"unit": "kg", | |
"context": "Emissions to air/" | |
}, transformations) | |
target = Flow({ | |
"identifier": "4f777e05-70f9-4a18-a406-d8232325073f", | |
"unit": "kg", | |
"context": [ | |
"air", | |
"non-urban air or from high stacks" | |
], | |
"name": "2,4-D amines", | |
"synonyms": [ | |
"2,4-D dimethylamine salt", | |
"2-(2,4-dichlorophenoxy)acetic acid", | |
"N-methylmethanamine" | |
], | |
"CAS number": "002008-39-1" | |
}, transformations) | |
source.name == target.name | |
>>> True | |
source.context == target.context | |
>>> True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment