Skip to content

Commit

Permalink
Merge pull request #511 from gerald-scharitzer/fair-1.6.4
Browse files Browse the repository at this point in the history
Fix of FaIR Deprecation Warning
  • Loading branch information
denised authored Nov 16, 2021
2 parents 75fe33d + c7d185a commit 7e8cdb4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ dependencies:
- pytest
- pip
- pip:
- fair
- fair>=1.6.4
- numpy-financial
- openpyxl
34 changes: 17 additions & 17 deletions model/co2calcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from io import StringIO

import fair
from fair.RCPs import rcp3pd, rcp45, rcp6, rcp85
from fair.RCPs import rcp26, rcp45, rcp60, rcp85
import numpy as np
import pandas as pd
import model.advanced_controls
Expand Down Expand Up @@ -707,7 +707,7 @@ def FaIR_CFT_baseline_RCP3(self):
3: Change in temperature since pre-industrial time in Celsius
4: RCP emissions (39 individual gases)
"""
emissions = rcp3pd.Emissions.emissions
emissions = rcp26.Emissions.emissions
rcpemissions = pd.DataFrame(emissions, index = range(1765,2501),
columns=['Year', 'FossilCO2 (Gt-C)', 'OtherCO2 (Gt-C)', 'CH4 (Mt-CH4)',
'N2O (Mt-N2O)', 'SOx (Mt-S)', 'CO (Mt-CO)', 'NMVOC (Mt)',
Expand All @@ -723,13 +723,13 @@ def FaIR_CFT_baseline_RCP3(self):
rcpemissions.name = 'FaIR_CFT_baseline_emis_rcp3'

(C,F,T) = fair.forward.fair_scm(emissions=emissions)
result1 = pd.DataFrame({'CO2(ppm)': C[:,0,], 'CH4(ppb)': C[:,1,], 'N2O(ppb)': C[:,2,]}, index=rcp3pd.Emissions.year)
result1 = pd.DataFrame({'CO2(ppm)': C[:,0,], 'CH4(ppb)': C[:,1,], 'N2O(ppb)': C[:,2,]}, index=rcp26.Emissions.year)
result1.index.name="Year"
result1.name = 'FaIR_CFT_baseline_conc_rcp3'
result2 = pd.DataFrame({'CO2(Wm-2)': F[:,0,], 'CH4(Wm-2)': F[:,1,], 'N2O(Wm-2)': F[:,2,], 'others(Wm-2)': np.sum(F, axis=1)-F[:,0,]-F[:,1,]-F[:,2,], 'total(Wm-2)': np.sum(F, axis=1)}, index=rcp3pd.Emissions.year)
result2 = pd.DataFrame({'CO2(Wm-2)': F[:,0,], 'CH4(Wm-2)': F[:,1,], 'N2O(Wm-2)': F[:,2,], 'others(Wm-2)': np.sum(F, axis=1)-F[:,0,]-F[:,1,]-F[:,2,], 'total(Wm-2)': np.sum(F, axis=1)}, index=rcp26.Emissions.year)
result2.index.name="Year"
result2.name = 'FaIR_CFT_baseline_forc_rcp3'
result3 = pd.DataFrame({'TempAnomaly(C)': T}, index=rcp3pd.Emissions.year)
result3 = pd.DataFrame({'TempAnomaly(C)': T}, index=rcp26.Emissions.year)
result3.index.name="Year"
result3.name = 'FaIR_CFT_baseline_temp_rcp3'
return result1, result2, result3, rcpemissions
Expand Down Expand Up @@ -793,7 +793,7 @@ def FaIR_CFT_baseline_RCP6(self):
3: Change in temperature since pre-industrial time in Celsius
4: RCP emissions (39 individual gases)
"""
emissions = rcp6.Emissions.emissions
emissions = rcp60.Emissions.emissions
rcpemissions = pd.DataFrame(emissions, index = range(1765,2501),
columns=['Year', 'FossilCO2 (Gt-C)', 'OtherCO2 (Gt-C)', 'CH4 (Mt-CH4)',
'N2O (Mt-N2O)', 'SOx (Mt-S)', 'CO (Mt-CO)', 'NMVOC (Mt)',
Expand All @@ -809,13 +809,13 @@ def FaIR_CFT_baseline_RCP6(self):
rcpemissions.name = 'FaIR_CFT_baseline_emis_rcp6'

(C,F,T) = fair.forward.fair_scm(emissions=emissions)
result1 = pd.DataFrame({'CO2(ppm)': C[:,0,], 'CH4(ppb)': C[:,1,], 'N2O(ppb)': C[:,2,]}, index=rcp6.Emissions.year)
result1 = pd.DataFrame({'CO2(ppm)': C[:,0,], 'CH4(ppb)': C[:,1,], 'N2O(ppb)': C[:,2,]}, index=rcp60.Emissions.year)
result1.index.name="Year"
result1.name = 'FaIR_CFT_baseline_conc_rcp6'
result2 = pd.DataFrame({'CO2(Wm-2)': F[:,0,], 'CH4(Wm-2)': F[:,1,], 'N2O(Wm-2)': F[:,2,], 'others(Wm-2)': np.sum(F, axis=1)-F[:,0,]-F[:,1,]-F[:,2,], 'total(Wm-2)': np.sum(F, axis=1)}, index=rcp6.Emissions.year)
result2 = pd.DataFrame({'CO2(Wm-2)': F[:,0,], 'CH4(Wm-2)': F[:,1,], 'N2O(Wm-2)': F[:,2,], 'others(Wm-2)': np.sum(F, axis=1)-F[:,0,]-F[:,1,]-F[:,2,], 'total(Wm-2)': np.sum(F, axis=1)}, index=rcp60.Emissions.year)
result2.index.name="Year"
result2.name = 'FaIR_CFT_baseline_forc_rcp6'
result3 = pd.DataFrame({'TempAnomaly(C)': T}, index=rcp6.Emissions.year)
result3 = pd.DataFrame({'TempAnomaly(C)': T}, index=rcp60.Emissions.year)
result3.index.name="Year"
result3.name = 'FaIR_CFT_baseline_temp_rcp6'
return result1, result2, result3, rcpemissions
Expand Down Expand Up @@ -928,7 +928,7 @@ def FaIR_CFT_Drawdown_RCP3(self):
# Call on the solution emission reductions
annual_reductions = self.ghg_emissions_reductions_global_annual()
# Call on the RCP scenario
rcpemissions = rcp3pd.Emissions.emissions
rcpemissions = rcp26.Emissions.emissions
rcpemissionsnew = pd.DataFrame(rcpemissions, index = range(1765,2501),
columns=['Year','FossilCO2 (Gt-C)', 'OtherCO2 (Gt-C)', 'CH4 (Mt-CH4)',
'N2O (Mt-N2O)', 'SOx (Mt-S)', 'CO (Mt-CO)', 'NMVOC (Mt)',
Expand Down Expand Up @@ -956,13 +956,13 @@ def FaIR_CFT_Drawdown_RCP3(self):

emissionsnew = rcpemissionsnew.to_numpy()
(C,F,T) = fair.forward.fair_scm(emissions=emissionsnew)
result1 = pd.DataFrame({'CO2(ppm)': C[:,0,], 'CH4(ppb)': C[:,1,], 'N2O(ppb)': C[:,2,]}, index=rcp3pd.Emissions.year)
result1 = pd.DataFrame({'CO2(ppm)': C[:,0,], 'CH4(ppb)': C[:,1,], 'N2O(ppb)': C[:,2,]}, index=rcp26.Emissions.year)
result1.index.name="Year"
result1.name = 'FaIR_CFT_Drawdown_conc_rcp3'
result2 = pd.DataFrame({'CO2(Wm-2)': F[:,0,], 'CH4(Wm-2)': F[:,1,], 'N2O(Wm-2)': F[:,2,], 'others(Wm-2)': np.sum(F, axis=1)-F[:,0,]-F[:,1,]-F[:,2,], 'total(Wm-2)': np.sum(F, axis=1)}, index=rcp3pd.Emissions.year)
result2 = pd.DataFrame({'CO2(Wm-2)': F[:,0,], 'CH4(Wm-2)': F[:,1,], 'N2O(Wm-2)': F[:,2,], 'others(Wm-2)': np.sum(F, axis=1)-F[:,0,]-F[:,1,]-F[:,2,], 'total(Wm-2)': np.sum(F, axis=1)}, index=rcp26.Emissions.year)
result2.index.name="Year"
result2.name = 'FaIR_CFT_Drawdown_forc_rcp3'
result3 = pd.DataFrame({'TempAnomaly(C)': T}, index=rcp3pd.Emissions.year)
result3 = pd.DataFrame({'TempAnomaly(C)': T}, index=rcp26.Emissions.year)
result3.index.name="Year"
result3.name = 'FaIR_CFT_Drawdown_temp_rcp3'
return result1, result2, result3, rcpemissionsnew
Expand Down Expand Up @@ -1044,7 +1044,7 @@ def FaIR_CFT_Drawdown_RCP6(self):
# Call on the solution emission reductions
annual_reductions = self.ghg_emissions_reductions_global_annual()
# Call on the RCP scenario
rcpemissions = rcp6.Emissions.emissions
rcpemissions = rcp60.Emissions.emissions
rcpemissionsnew = pd.DataFrame(rcpemissions, index = range(1765,2501),
columns=['Year','FossilCO2 (Gt-C)', 'OtherCO2 (Gt-C)', 'CH4 (Mt-CH4)',
'N2O (Mt-N2O)', 'SOx (Mt-S)', 'CO (Mt-CO)', 'NMVOC (Mt)',
Expand Down Expand Up @@ -1072,13 +1072,13 @@ def FaIR_CFT_Drawdown_RCP6(self):

emissionsnew = rcpemissionsnew.to_numpy()
(C,F,T) = fair.forward.fair_scm(emissions=emissionsnew)
result1 = pd.DataFrame({'CO2(ppm)': C[:,0,], 'CH4(ppb)': C[:,1,], 'N2O(ppb)': C[:,2,]}, index=rcp6.Emissions.year)
result1 = pd.DataFrame({'CO2(ppm)': C[:,0,], 'CH4(ppb)': C[:,1,], 'N2O(ppb)': C[:,2,]}, index=rcp60.Emissions.year)
result1.index.name="Year"
result1.name = 'FaIR_CFT_Drawdown_conc_rcp6'
result2 = pd.DataFrame({'CO2(Wm-2)': F[:,0,], 'CH4(Wm-2)': F[:,1,], 'N2O(Wm-2)': F[:,2,], 'others(Wm-2)': np.sum(F, axis=1)-F[:,0,]-F[:,1,]-F[:,2,], 'total(Wm-2)': np.sum(F, axis=1)}, index=rcp6.Emissions.year)
result2 = pd.DataFrame({'CO2(Wm-2)': F[:,0,], 'CH4(Wm-2)': F[:,1,], 'N2O(Wm-2)': F[:,2,], 'others(Wm-2)': np.sum(F, axis=1)-F[:,0,]-F[:,1,]-F[:,2,], 'total(Wm-2)': np.sum(F, axis=1)}, index=rcp60.Emissions.year)
result2.index.name="Year"
result2.name = 'FaIR_CFT_Drawdown_forc_rcp6'
result3 = pd.DataFrame({'TempAnomaly(C)': T}, index=rcp6.Emissions.year)
result3 = pd.DataFrame({'TempAnomaly(C)': T}, index=rcp60.Emissions.year)
result3.index.name="Year"
result3.name = 'FaIR_CFT_Drawdown_temp_rcp6'
return result1, result2, result3, rcpemissionsnew
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fair
fair>=1.6.4
numpy-financial
pandas==1.2.4
openpyxl
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ addopts = --strict-markers --ignore limbo --ignore tools
filterwarnings =
ignore:.*wmf image format is not supported.*:UserWarning
ignore:.*extension is not supported and will be removed.*:UserWarning
ignore:.*will be deprecated in FaIR 2.0.*:DeprecationWarning
markers =
slow: mark a test as taking a long time.
deep: mark a test as "whitebox" testing
Expand Down

0 comments on commit 7e8cdb4

Please sign in to comment.