Skip to content
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

Merge all emission files into a SCEN7 format #237

Open
lewisjared opened this issue Apr 18, 2019 · 5 comments
Open

Merge all emission files into a SCEN7 format #237

lewisjared opened this issue Apr 18, 2019 · 5 comments

Comments

@lewisjared
Copy link
Collaborator

lewisjared commented Apr 18, 2019

Describe the bug

When reading a SCEN7 file with a region mode of other than World, all World region data is ignored. This makes it impossible to merge World-only emissions with emissions disaggregated by region.

Possible options to resolve this:

  1. Relax config check to raise a DeprecationWarning (Implemented in Allow multiple emisscen #238)
  2. Update the Fortran code to only discard world data if no other region data is added 🙈
  3. Disaggregate World emissions explicitly into regions in pymagicc. Effectively multiplication using the GEN_SRESREGIONS2NH variable.

For now, 1. is the simplest, with that warning eventually being replaced with a ValueError again

@lewisjared
Copy link
Collaborator Author

@rgieseke Thoughts? Flattening all emissions wasn't as simple as we would have liked...

@lewisjared lewisjared mentioned this issue Apr 18, 2019
3 tasks
@znicholls
Copy link
Collaborator

I think there's a step 1a) update pymagicc to write multiple input scenario files, splitting things by their region code. Errors would be thrown if the region code can't be determined for a given variable and if there is both world and disaggregated region data for a given variable (forcing the user to choose what to use before passing it into .run(). @lewisjared we could either do this step 1a in #238 or I can do it as another PR, what would you prefer?

@lewisjared
Copy link
Collaborator Author

That's more like an additional bullet than 1a.

In that case, does it make sense to raise a warning at all for MAGICC7 as that seems like a logical way of handling the multiple emisscen values. My hesitation would be that it adds more complexity than blindly passing through the emissscen_x params?

I'll add in a func to process multiple emisscen's which for now is effectively a noop, but in future could reduce the emissions files if needed.

@lewisjared
Copy link
Collaborator Author

lewisjared commented Apr 18, 2019

Ohh actually the current setup should work - the check_config only checks if the MAGCFG_USER.CFG file is correct and valid. So any additional config passed to run() isn't checked by check_config so maybe #238 is actually invalid.

The following script uses multiple emisscen files as confirmed by the log messages:

from pymagicc import MAGICC7

cfg = {
    "file_emisscen": "WMO_MHALO.SCEN7",
    "file_emisscen_2": "Velders_HFC_Kigali.SCEN7",
    "file_emisscen_3": "NONE",
    "file_emisscen_4": "NONE",
    "file_emisscen_5": "RCP85.SCEN7"
}
with MAGICC7() as magicc:
    magicc.run(out_forcing=1, **cfg)

@znicholls
Copy link
Collaborator

znicholls commented Apr 18, 2019

I think whilst MAGICC7 is still private, let's just do whatever works for us.

When it goes public, if it has the ability to run with multiple file_emisscen then I think we need to support two things:

  1. The user passes in an emissions dataframe with emissions which have different regional breakdowns. In this case, pymagicc should split the dataframe into the appropriate SCEN7 files and set the flags appropriately.
    • Whilst setting flags, if it finds any file_emisscen flags are being set by passing a keyword argument then it should scream and force the user to choose either only pre-written files or only an input dataframe. Building the logic to make sure we write at the right level of file_emisscen_x and getting the overwrites correct etc. would be a nightmare and we shouldn't support it.
    • Whilst splitting emissions, if it finds any ambiguities (i.e. world and regional data provided for a given variable), it should throw an error too
  2. The user writes all the files themselves and then sets the file_emisscen_x flags themselves.
    • If the user passes a scenario dataframe too, pymagicc should explode and force the user to decide whether they want to pre-write everything and deal with MAGICC's internal overwrites or whether they want us to do it (again avoid mixing those two for reasons of sanity).

There might be one major gotcha with this (I need to double check when we actually start implementing...), users might have to supply emissions for a number of minor species that they wouldn't normally think about. The reason is that without supplied emissions, MAGICC7 assumes emissions are zero and hence the concentrations of these species can plummet, blowing up the whole run. In that case, we might have to automatically supply emissions of these species if they're not there, throwing a warning in the process to let people know we've done this. The better solution would be to fix MAGICC so this doesn't happen but that might not be possible on the timelines we need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants