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
Move emissions definitions to single csv #135
Conversation
Codecov Report
@@ Coverage Diff @@
## master #135 +/- ##
==========================================
+ Coverage 96.85% 96.87% +0.02%
==========================================
Files 4 4
Lines 889 895 +6
Branches 123 122 -1
==========================================
+ Hits 861 867 +6
Misses 16 16
Partials 12 12
Continue to review full report at Codecov.
|
Sorry, but i have trouble reviewing because i don't know what does this PR do/change? I still don't understand what the emms codes do. |
Sorry was being super lazy, try again now with a proper description
Not sure why that's that way, happy to change to whatever you'd like. |
Awesome, that makes sense now! What do you want me to do, create a file where this go into the documentation? |
haha ideally decide what the best system is Other options we could also do:
|
I like both proposals! Should I push right to this branch and you tweak as you see fit? |
Yep definitely |
Pushed an example of how this could look like using the Data Package format. One question though, are the definitions used elsewhere, potentially later? Why don't we just define pymagicc.definitions.scen_emms_code_1 = [
['CO2I',
'CO2B',
'CH4',
'N2O',
'SOX',
'NOX',
'CO',
'BC',
'OC',
'NMVOC',
'NH3',
'CF4',
'C2F6',
'C6F14',
'HFC23',
'HFC32',
'HFC4310',
'HFC125',
'HFC134A',
'HFC143A',
'HFC227EA',
'HFC245FA',
'SF6'] |
If we use the Data Package format we can do validation of the data quite easily, e.g. a mis-typed "TRU" for the boolean values would give
This could become part of the CI. Same could be done to define allowed numbers or ranges etc. |
I avoid this because I want to put the units right next to the emissions. I also want to have the emissions defined in only one place (rather than once next to the emissions, once for scen code 0, once for scen code 1 etc.). This makes it much easier to keep track of things (as they're only defined in one place) and also update should we ever decide to use a more sensible naming in
Super nice |
Good points, I understand now. I'll convert the rest of CSV reading to use the Data Package logic. |
Have just gone through this and updated. I didn't think about the fact that |
df68a3a
to
e02e45b
Compare
Alright @rgieseke the thing blocking this is how we get the information in |
While we're here, do you have a link which explains what the data package standard is/where people should look to find out more? |
Either a custom script to write out a .rst file or something with Sphinx templates I guess: http://www.sphinx-doc.org/en/master/templating.html What do you have in mind? A Table? |
e12e778
to
4c64da1
Compare
Ye or even just a series of dot points in the |
I'll write something now. |
@rgieseke that was harder than I thought it would be but I think it's ready to go |
That looks super nice, what is the magicc that makes the variables appear, just documenting wth a doc string? Only thing i would review is the naming of columns, it's a mix of lower, upper, spaces and underscores now. |
Ye as shown here https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html
Good point, to clarify: would we do "MAGICC Variable" or "MAGICC variable" or something else? |
After discussion with @znicholls let's go for all lower case, underscores scenfile_region_code part_of_scenfile_with_emissions_code_0 part_of_prnfile |
Add metadata for definitions Turns this into a Data Package. Fix and finish making `get_special_scen_code` public
[skip ci]
abce930
to
1c075d5
Compare
@rgieseke all yours |
I've changed the bools to look Pythonic otherwise thanks a lot! |
Move emissions definitions
This pull request moves all the definitions of MAGICC emissions species, their units and which files they belong in to a single csv.
The first column is the emissions species. These follow MAGICC7's internal conventions (and are mapped to MAGICC6 variables as necessary in other functions).
The second column is the units. They are written in a way which is pint compatible (although no tests have been added to show this yet, that is for the next pull request). This means that we have to put spaces between the mass, the time and the thing which is being emitted which looks a bit yuck but is the only way pint can parse the emissions.
The next three columns define where these species go when being written to MAGICC6 input files (note that in MAGICC7 you can simply put everything in a SCEN7 file so this extra layer of definition isn't required). For example, all the variables with
True
in the 'prn emms' column belong in '.prn' files. For SCEN files, MAGICC6 has an internal convention which means we have to do even more work. At the top of every MAGICC6 compatible.SCEN
file there is a two digit number (in the currentpymagicc/__init__.py
its calledregion_code
but it's actually more than that). The first digit tells MAGICC how many regions data is being provided for and hence isn't relevant to this PR. The second digit tells MAGICC which gases are in the SCEN file. This is referred to as the 'SCEN emms code'. Hence the column which has the header 'SCEN emms code 1' defines the gases which are expected when that 'SCEN emms code' is 1. Similarly, the column which has the header 'SCEN emms code 0' defines the gases which are expected when that 'SCEN emms code' is 0. Having these definitions allowspymagicc
to check that the right set of emissions has been provided before writing SCEN files.Please confirm that this pull request has done the following:
Adding to CHANGELOG.md
Please add a single line in the changelog notes similar to the following: