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

Multiple fixes and improvements on MAGICC for damages #1736

Merged
merged 5 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions modules/51_internalizeDamages/KWlikeItr/postsolve.gms
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ p51_marginalDamageCumul(tall,tall2,regi2)$((tall2.val ge tall.val) and (tall.val
;

p51_sccLastItr(tall) = p51_scc(tall);

* Add an epsilon to pm_consPC to avoid division by zero in case of INFES in the reference data
p51_sccParts(tall,tall2,regi2)$((tall.val ge 2010) and (tall.val le 2150) and (tall2.val ge tall.val) and (tall2.val le 2250)) =
(1 + pm_prtp(regi2) )**(-(tall2.val - tall.val))
* pm_consPC(tall,regi2)/pm_consPC(tall2,regi2)
* pm_consPC(tall,regi2)/(pm_consPC(tall2,regi2) + 0.0000001)
* pm_damage(tall2,regi2) * pm_GDPGross(tall2,regi2)
* p51_marginalDamageCumul(tall,tall2,regi2)
* pm_sccIneq(tall2,regi2)
Expand Down
11 changes: 2 additions & 9 deletions scripts/input/climate_assessment_openscm_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

# TONN REMOVE start
# If these are already set, it shouldn't override it. We actually may not want to have a default but just throw an error if not set
Copy link
Contributor

@tonnrueter tonnrueter Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the code in the following lines actually overwrites the environment variables MAGICC_EXECUTABLE_7 & MAGICC_WORKER_ROOT_DIR. If you want to achieve the behavior described in this comment, change it to

class EnvironmentError(Exception):
    pass

for env_var in ["MAGICC_EXECUTABLE_7", "MAGICC_WORKER_ROOT_DIR"]:
    if os.environ.get(env_var, '') == '':
        # If clause covers both cases in which the env var is not set at all 
        # as well as the case in which it is set to an empty string
        raise EnvironmentError(f"{env_var} does not exist")
    # Optional debug prints
    print(f"Found '{env_var}' = '{os.environ.get(env_var)}' ")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

os.environ["MAGICC_EXECUTABLE_7"] = "/p/projects/piam/abrahao/scratch/module_climate_tests/climate-assessment-files/magicc-v7.5.3/bin/magicc"
os.environ["MAGICC_WORKER_ROOT_DIR"] = "/p/projects/piam/abrahao/scratch/methane/methane_scm/workers"
os.environ["MAGICC_EXECUTABLE_7"] = "/p/projects/rd3mod/climate-assessment-files/magicc-v7.5.3/bin/magicc"
os.environ["MAGICC_WORKER_ROOT_DIR"] = os.environ["PTMP"] + "/"

LOGGER = logging.getLogger(__name__) # We don't need this
# TONN REMOVE end
Expand Down Expand Up @@ -189,10 +189,3 @@ def fix_hfc_unit(variable):
).to_excel(
outfilename
)

# # # %%
# # # Show basic results
# # runresults.filter(
# # variable = "Surface Air Temperature Change",
# # region = "World"
# # ).lineplot()
Loading