@@ -19,10 +19,10 @@ def test_main_input():
1919
2020 data = pd .DataFrame (
2121 [
22- ["AUSTRIA " , "Price|Primary Energy|Biomass" , 2015 , 3.15 ],
23- ["AUSTRIA " , "Price|Primary Energy|Biomass" , 2016 , 4.2 ],
24- ["BELGIUM " , "Price|Primary Energy|Biomass" , 2015 , 1.785 ],
25- ["BELGIUM " , "Price|Primary Energy|Biomass" , 2016 , 1.890 ],
22+ ["Austria " , "Price|Primary Energy|Biomass" , 2015 , 3.15 ],
23+ ["Austria " , "Price|Primary Energy|Biomass" , 2016 , 4.2 ],
24+ ["Belgium " , "Price|Primary Energy|Biomass" , 2015 , 1.785 ],
25+ ["Belgium " , "Price|Primary Energy|Biomass" , 2016 , 1.890 ],
2626 ],
2727 columns = ["region" , "variable" , "year" , "value" ],
2828 )
@@ -50,18 +50,18 @@ def test_main_result():
5050
5151 data = pd .DataFrame (
5252 [
53- ["AUSTRIA " , "Capacity|Electricity" , 2015 , 0.446776 ],
54- ["BELGIUM " , "Capacity|Electricity" , 2016 , 0.184866 ],
55- ["BULGARIA " , "Capacity|Electricity" , 2015 , 4.141 ],
56- ["CYPRUS " , "Capacity|Electricity" , 2015 , 0.3904880555817921 ],
57- ["CZECHIA " , "Capacity|Electricity" , 2015 , 0.299709 ],
58- ["DENMARK " , "Capacity|Electricity" , 2015 , 0.0005 ],
59- ["ESTONIA " , "Capacity|Electricity" , 2015 , 0.006 ],
60- ["FINLAND " , "Capacity|Electricity" , 2015 , 0.0263 ],
61- ["FRANCE " , "Capacity|Electricity" , 2015 , 0.47835 ],
62- ["GERMANY " , "Capacity|Electricity" , 2015 , 9.62143 ],
63- ["SPAIN " , "Capacity|Electricity" , 2015 , 7.7308 ],
64- ["SWITZERLAND " , "Capacity|Electricity" , 2026 , 0.004563975391582646 ],
53+ ["Austria " , "Capacity|Electricity" , 2015 , 0.446776 ],
54+ ["Belgium " , "Capacity|Electricity" , 2016 , 0.184866 ],
55+ ["Bulgaria " , "Capacity|Electricity" , 2015 , 4.141 ],
56+ ["Cyprus " , "Capacity|Electricity" , 2015 , 0.3904880555817921 ],
57+ ["Czechia " , "Capacity|Electricity" , 2015 , 0.299709 ],
58+ ["Denmark " , "Capacity|Electricity" , 2015 , 0.0005 ],
59+ ["Estonia " , "Capacity|Electricity" , 2015 , 0.006 ],
60+ ["Finland " , "Capacity|Electricity" , 2015 , 0.0263 ],
61+ ["France " , "Capacity|Electricity" , 2015 , 0.47835 ],
62+ ["Germany " , "Capacity|Electricity" , 2015 , 9.62143 ],
63+ ["Spain " , "Capacity|Electricity" , 2015 , 7.7308 ],
64+ ["Switzerland " , "Capacity|Electricity" , 2026 , 0.004563975391582646 ],
6565 ],
6666 columns = ["region" , "variable" , "year" , "value" ],
6767 )
@@ -92,10 +92,10 @@ def test_main_result_capture():
9292
9393 data = pd .DataFrame (
9494 [
95- ["AUSTRIA " , "Carbon Capture|Biomass" , 2026 , 7.573069442598169 ],
96- ["AUSTRIA " , "Carbon Capture|Biomass" , 2027 , 7.766777427515737 ],
97- ["BELGIUM " , "Carbon Capture|Biomass" , 2026 , 2.24498280006968 ],
98- ["BELGIUM " , "Carbon Capture|Biomass" , 2027 , 6.746886436926597 ],
95+ ["Austria " , "Carbon Capture|Biomass" , 2026 , 7.573069442598169 ],
96+ ["Austria " , "Carbon Capture|Biomass" , 2027 , 7.766777427515737 ],
97+ ["Belgium " , "Carbon Capture|Biomass" , 2026 , 2.24498280006968 ],
98+ ["Belgium " , "Carbon Capture|Biomass" , 2027 , 6.746886436926597 ],
9999 ],
100100 columns = ["region" , "variable" , "year" , "value" ],
101101 )
@@ -108,3 +108,46 @@ def test_main_result_capture():
108108 )
109109
110110 assert_iamframe_equal (actual , expected )
111+
112+
113+ def test_main_trade ():
114+ """Test operation of trade filter
115+
116+ Config
117+ ------
118+ - iamc_variable: Trade|Secondary Energy|Electricity|Volume
119+ osemosys_param:
120+ - UseByTechnology
121+ - ProductionByTechnologyAnnual
122+ trade_tech:
123+ - (?=^.{2}(EL))^((?!00).)*$
124+ unit: PJ/yr
125+
126+ """
127+
128+ config_path = os .path .join ("tests" , "fixtures" , "trade" , "config_trade.yaml" )
129+ inputs_path = os .path .join ("tests" , "fixtures" , "trade" )
130+ results_path = os .path .join ("tests" , "fixtures" , "trade" )
131+
132+ with open (config_path , "r" ) as config_file :
133+ config = load (config_file , Loader = SafeLoader )
134+
135+ actual = main (config , inputs_path , results_path )
136+
137+ data = pd .DataFrame (
138+ [
139+ ["Austria" , "Trade|Secondary Energy|Electricity|Volume" , 2010 , - 0.024824 ],
140+ ["Austria" , "Trade|Secondary Energy|Electricity|Volume" , 2011 , - 0.024924 ],
141+ ["Austria" , "Trade|Secondary Energy|Electricity|Volume" , 2012 , - 0.025024 ],
142+ ],
143+ columns = ["region" , "variable" , "year" , "value" ],
144+ )
145+
146+ expected = IamDataFrame (
147+ data ,
148+ model = "OSeMBE v1.0.0" ,
149+ scenario = "DIAG-C400-lin-ResidualFossil" ,
150+ unit = "EJ/yr" ,
151+ )
152+
153+ assert_iamframe_equal (actual , expected )
0 commit comments