-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backwards-compatibility of variable names #46
Comments
My suggestion:
A minimal working example (MWE) using SDMX:import sdmx
import sdmx.model.v21 as m
# Create a Code whose ID is a current variable name
c = m.Code(id="Final Energy|Foo|Bar")
# Create an annotation containing old/superseded variable names
ann = m.Annotation(
id="iamc-variable-old",
text="\n".join(
["Final Energy|Bar|Foo", "Final Energy|Foo Bar"],
)
)
c.annotations.append(ann)
# Write to file
cl = m.Codelist(id="VARIABLE", name="IAMC variable name")
cl.append(c)
msg = sdmx.message.StructureMessage()
msg.add(cl)
with open("example.xml", "wb") as f:
f.write(sdmx.to_xml(msg, pretty_print=True)) This gives output like: …
<str:Code id="Final Energy|Foo|Bar">
<com:Annotations>
<com:Annotation id="iamc-variable-old">
<com:AnnotationText xml:lang="en">Final Energy|Bar|Foo
Final Energy|Foo Bar</com:AnnotationText>
</com:Annotation>
</com:Annotations>
</str:Code> And can be read and used like: # Read the file, retrieve the codelist
>>> msg = sdmx.read_sdmx("example.xml")
>>> cl = msg.codelist["VARIABLE"]
# Retrieve a specific variable name
>>> c = cl["Final Energy|Foo|Bar"]
>>> c
<Code Final Energy|Foo|Bar>
# Retrieve the list of old names from the annotation
>>> c.eval_annotation("iamc-variable-old").split("\n")
['Final Energy|Bar|Foo', 'Final Energy|Foo Bar'] |
Do I understand it right that you say we can in principle add as many entries as we want? The old examples of the ENGAGE and NAVIGATE template only seem to have the entries "description" and "unit", but you say we could also add extra entries for storing the 'old' name. |
@christophbertram I say we should agree on as many common annotations as we need, and that doing so is a feature of the SDMX standard (and supported by tools that implement it). What I don't know is whether the Per full-resolution keys: yes, exactly. I hope we can provide a proof-of-concept when linking the iTEM structure info to this repo. Per "minimum and maximum allowed values per capita"—I think that is actually data, not structure. You can imagine an IAMC-structured table (or with fewer or more dimensions, e.g. possibly without YEAR or REGION) in which the numbers are not "actual observed historical values" nor "model-projection values" but "expected {minimum,maximum} per capita values". One could imagine having different sets of such values for different purposes, even when the same variable names are used. |
Thanks for raising this issue, see a few comments below. Let's please try to keep issues and discussions narrow and start new issues where possible. Cross-reference to legacy variables/regions or other standards: this is already implemented in a simple example here, see
and the value can be accessed from the nomenclature.DataStructureDefinition as dsd.variable["Final Energy|Carbon Removal|Direct Air Capture|Electricity"].navigate If you have specific suggestions for feature-support in nomenclature, e.g. as a "known" attribute with dedicated documentation, please start an issue there. Validation of values should indeed be handled as a separate use-case and will be implemented similar to the required-data feature in nomenclature, see here. This PR IAMconsortium/pyam#804 is a step towards support for that feature. |
I think this is partly fixed by yesterday's Daniel commit |
At the SWG meeting on 2023-12-06, Masa Sugiyama and others raised the idea of how to support backward-compatibility if it becomes necessary to change a variable name.
This issue is to discuss/collect ideas.
The text was updated successfully, but these errors were encountered: