amply
amply copied to clipboard
[Bug] Mixed inputformat error
Error in sys.excepthook:
Traceback (most recent call last):
File "c:\nobackup\anaconda3\envs\snakemake\lib\site-packages\otoole\cli.py", line 282, in exception_handler
print("{}: {}".format(exception_type.__name__, exception.message))
AttributeError: 'AmplyError' object has no attribute 'message'
Original exception was:
Traceback (most recent call last):
File "c:\nobackup\anaconda3\envs\snakemake\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\nobackup\anaconda3\envs\snakemake\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Nobackup\Anaconda3\envs\snakemake\Scripts\otoole.exe\__main__.py", line 7, in <module>
File "c:\nobackup\anaconda3\envs\snakemake\lib\site-packages\otoole\cli.py", line 287, in main
args.func(args)
File "c:\nobackup\anaconda3\envs\snakemake\lib\site-packages\otoole\cli.py", line 112, in result_matrix
input_data, _ = ReadDatafile().read(args.input_datafile)
File "c:\nobackup\anaconda3\envs\snakemake\lib\site-packages\otoole\read_strategies.py", line 212, in read
amply_datafile = self.read_in_datafile(filepath, config)
File "c:\nobackup\anaconda3\envs\snakemake\lib\site-packages\otoole\read_strategies.py", line 229, in read_in_datafile
datafile_parser.load_file(datafile)
File "c:\nobackup\anaconda3\envs\snakemake\lib\site-packages\amply\amply.py", line 817, in load_file
self.load_string(f.read())
File "c:\nobackup\anaconda3\envs\snakemake\lib\site-packages\amply\amply.py", line 806, in load_string
obj.eval(self)
File "c:\nobackup\anaconda3\envs\snakemake\lib\site-packages\amply\amply.py", line 305, in eval
self.name, self.tokens
amply.amply.AmplyError: Error in number of records of Peakdemand when reading ['param', 'Peakdemand', 'default', 1.0, [<SliceRecord: ('Kenya', '*', '*')>, <TabularRecord: {'TRLV_1_0': {2016.0: 0.0, 2017.0: 0.0, 2018.0: 0.0, 2019.0: 0.035503748, 2020.0: 0.073847796, 2021.0: 0.115202562, 2022.0: 0.159747552, 2023.0: 0.207671818, 2024.0: 0.259174428, 2025.0: 0.314464973, 2026.0: 0.373764082, 2027.0: 0.437303976, 2028.0: 0.437303976, 2029.0: 0.437303976, 2030.0: 0.437303976, 2031.0: 0.437303976, 2032.0: 0.437303976, 2033.0: 0.437303976, 2034.0: 0.437303976, 2035.0: 0.437303976, 2036.0: 0.437303976, 2037.0: 0.437303976, 2038.0: 0.437303976, 2039.0: 0.437303976, 2040.0: 0.437303976}, 'TRLV_2_0': {2016.0: 0.0, 2017.0: 0.0, 2018.0: 0.0, 2019.0: 0.031715426, 2020.0: 0.065968085, 2021.0: 0.102910213, 2022.0: 0.142702162, 2023.0: 0.18551281, 2024.0: 0.231519987, 2025.0: 0.280910918, 2026.0: 0.333882691, 2027.0: 0.390642748, 2028.0: 0.390642748, 2029.0: 0.390642748, 2030.0: 0.390642748, 2031.0: 0.390642748, 2032.0: 0.390642748, 2033.0: 0.390642748, 2034.0: 0.390642748, 2035.0: 0.390642748, 2036.0: 0.390642748, 2037.0: 0.390642748, 2038.0: 0.390642748, 2039.0: 0.390642748, 2040.0: 0.390642748}, 'TRLV_3_0': {2016.0: 0.0, 2017.0: 0.0, 2018.0: 0.0, 2019.0: 0.03760931, 2020.0: 0.078227364, 2021.0: 0.122034688, 2022.0: 0.169221434, 2023.0: 0.219987865, 2024.0: 0.274544855, 2025.0: 0.333114424, 2026.0: 0.395930287, 2027.0: 0.463238436, 2028.0: 0.463238436, 2029.0: 0.463238436, 2030.0: 0.463238436, 2031.0: 0.463238436, 2032.0: 0.463238436, 2033.0: 0.463238436, 2034.0: 0.463238436, 2035.0: 0.463238436, 2036.0: 0.463238436, 2037.0: 0.463238436, 2038.0: 0.463238436, 2039.0: 0.463238436, 2040.0: 0.463238436}, 'TRLV_4_0': {2016.0: 0.0, 2017.0: 0.0, 2018.0: 0.0, 2019.0: 0.052990896, 2020.0: 0.110221063, 2021.0: 0.171944858, 2022.0: 0.238430203, 2023.0: 0.309959264, 2024.0: 0.386829161, 2025.0: 0.469352715, 2026.0: 0.557859227, 2027.0: 0.652695296, 2028.0: 0.652695296, 2029.0: 0.652695296, 2030.0: 0.652695296, 2031.0: 0.652695296, 2032.0: 0.652695296, 2033.0: 0.652695296, 2034.0: 0.652695296, 2035.0: 0.652695296, 2036.0: 0.652695296, 2037.0: 0.652695296, 2038.0: 0.652695296, 2039.0: 0.652695296, 2040.0: 0.652695296}, 'TRLV_5_0': {2016.0: 0.0, 2017.0: 0.0, 2018.0: 0.0, 2019.0: 0.034974676, 2020.0: 0.072747325, 2021.0: 0.113485828, 2022.0: 0.157367014, 2023.0: 0.204577119, 2024.0: 0.255312244, 2025.0: 0.309778856, 2026.0: 0.368194298, 2027.0: 0.430787328, 2028.0: 0.430787328, 2029.0: 0.430787328, 2030.0: 0.430787328, 2031.0: 0.430787328, 2032.0: 0.430787328, 2033.0: 0.430787328, 2034.0: 0.430787328, 2035.0: 0.430787328, 2036.0: 0.430787328, 2037.0: 0.430787328, 2038.0: 0.430787328, 2039.0: 0.430787328, 2040.0: 0.430787328}, 'TRLV_6_0': {2016.0: 0.0, 2017.0: 0.0, 2018.0: 0.0, 2019.0: 0.037202401, 2020.0: 0.077380994, 2021.0: 0.12071435, 2022.0: 0.167390565, 2023.0: 0.217607735, 2024.0: 0.271574453, 2025.0: 0.329510336, 2026.0: 0.391646571, 2027.0: 0.458226488, 2028.0: 0.458226488, 2029.0: 0.458226488, 2030.0: 0.458226488, 2031.0: 0.458226488, 2032.0: 0.458226488, 2033.0: 0.458226488, 2034.0: 0.458226488, 2035.0: 0.458226488, 2036.0: 0.458226488, 2037.0: 0.458226488, 2038.0: 0.458226488, 2039.0: 0.458226488, 2040.0: 0.458226488}, 'TRLV_7_0': {2016.0: 0.0, 2017.0: 0.0, 2018.0: 0.0, 2019.0: 0.023055127, 2020.0: 0.047954664, 2021.0: 0.074809276, 2022.0: 0.103735529, 2023.0: 0.134856188, 2024.0: 0.168300522, 2025.0: 0.204204634, 2026.0: 0.242711793, 2027.0: 0.283972798, 2028.0: 0.283972798, 2029.0: 0.283972798, 2030.0: 0.283972798, 2031.0: 0.283972798, 2032.0: 0.283972798, 2033.0: 0.283972798, 2034.0: 0.283972798, 2035.0: 0.283972798, 2036.0: 0.283972798, 2037.0: 0.283972798, 2038.0: 0.283972798, 2039.0: 0.283972798, 2040.0: 0.283972798}, 'TRLV_8_0': {2016.0: 0.0, 2017.0: 0.0, 2018.0: 0.0, 2019.0: 0.029656132, 2020.0: 0.061684755, 2021.0: 0.096228218, 2022.0: 0.133436462, 2023.0: 0.1734674, 2024.0: 0.216487316, 2025.0: 0.262671276, 2026.0: 0.312203574, 2027.0: 0.365278182, 2028.0: 0.365278182, 2029.0: 0.365278182, 2030.0: 0.365278182, 2031.0: 0.365278182, 2032.0: 0.365278182, 2033.0: 0.365278182, 2034.0: 0.365278182, 2035.0: 0.365278182, 2036.0: 0.365278182, 2037.0: 0.365278182, 2038.0: 0.365278182, 2039.0: 0.365278182, 2040.0: 0.365278182}, 'TRLV_9_0': {2016.0: 0.0, 2017.0: 0.0, 2018.0: 0.0, 2019.0: 0.040579304, 2020.0: 0.084404952, 2021.0: 0.131671725, 2022.0: 0.182584792, 2023.0: 0.23736023, 2024.0: 0.296225567, 2025.0: 0.359420354, 2026.0: 0.427196764, 2027.0: 0.499820214, 2028.0: 0.499820214, 2029.0: 0.499820214, 2030.0: 0.499820214, 2031.0: 0.499820214, 2032.0: 0.499820214, 2033.0: 0.499820214, 2034.0: 0.499820214, 2035.0: 0.499820214, 2036.0: 0.499820214, 2037.0: 0.499820214, 2038.0: 0.499820214, 2039.0: 0.499820214, 2040.0: 0.499820214}}>]]
I have mixed input formats in my datafile for parameters. Some inputs are in matrix form and some are in "long" format.
I get the following Error message:
amply.amply.AmplyError: Error in number of records of Peakdemand
when reading the first parameter which is in matrix format.
@NMoksnes - thanks for the bug report! Please could you provide a copy of the data which causes this error? Also, if possible, could you paste in the text of the error from the console rather than the screen shot?
Here is the first datalines that I get an error from.
###############
# Sets #
###############
#
set REGION := Kenya ;
set YEAR := 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 ;
set EMISSION := CO2 NOX ;
set FUEL := KEHF KEUR KENG KECO KEDS KEBM KEEL1 KEEL2 EL2_9 EL2_8 EL2_7 EL2_6 EL2_5 EL2_4 EL2_3 EL2_2 EL2_1 EL3_9_1 EL3_8_1 EL3_7_1 EL3_6_1 EL3_5_1 EL3_4_1 EL3_3_1 EL3_2_1 EL3_1_1 EL3_9_0 EL3_8_0 EL3_7_0 EL3_6_0 EL3_5_0 EL3_4_0 EL3_3_0 EL3_2_0 EL3_1_0;
set TIMESLICE := 1D 1E 1N 2D 2E 2N 3D 3E 3N 4D 4E 4N 5D 5E 5N 6D 6E 6N 7D 7E 7N 8D 8E 8N 9D 9E 9N 10D 10E 10N 11D 11E 11N 12D 12E 12N;
set MODE_OF_OPERATION := 1 ;
set TECHNOLOGY := KEIMPETH KEEL00t00 KENG00i00 KEHF00i00 KECO00x00 KECO00i00 KEDS00i00 KEBMCHx00 KEUR00i00 KEWI31ph KEHFCCph KEHYRRph1 KEHYDMph2 KEHYDMph3 KEGOBIph KESOU1ph KEBMCHph KEDSCCph KENGCCpn KECOSCpn KENULWpn KESOC3pn KECOBSpn KEGOFSph KEHYDMph3MA KEHYDMph3KA KEHYDMph3GI KEHYDMph3KIN KEHYDMph3KIA KEHYDMpn3MU KEHYDMpn3LGF KEHYDMpn3HGF KEDSGEN_9 WI4c_9 WI_9 SOMG8c_9 SOMG_9 KEDSGEN_8 WI4c_8 WI_8 SOMG8c_8 SOMG_8 KEDSGEN_7 WI4c_7 WI_7 SOMG8c_7 SOMG_7 KEDSGEN_6 WI4c_6 WI_6 SOMG8c_6 SOMG_6 KEDSGEN_5 WI4c_5 WI_5 SOMG8c_5 SOMG_5 KEDSGEN_4 WI4c_4 WI_4 SOMG8c_4 SOMG_4 KEDSGEN_3 WI4c_3 WI_3 SOMG8c_3 SOMG_3 KEDSGEN_2 WI4c_2 WI_2 SOMG8c_2 SOMG_2 KEDSGEN_1 WI4c_1 WI_1 SOMG8c_1 SOMG_1 KEEL00d_9 KEEL00d_8 KEEL00d_7 KEEL00d_6 KEEL00d_5 KEEL00d_4 KEEL00d_3 KEEL00d_2 KEEL00d_1 SOPV_9_0 SOPV_9_1 SOPV8r_9_0 SOPV8r_9_1 BACKSTOP TRLV_9_0 TRLV_9_1 SOPV_8_0 SOPV_8_1 SOPV8r_8_0 SOPV8r_8_1 TRLV_8_0 TRLV_8_1 SOPV_7_0 SOPV_7_1 SOPV8r_7_0 SOPV8r_7_1 TRLV_7_0 TRLV_7_1 SOPV_6_0 SOPV_6_1 SOPV8r_6_0 SOPV8r_6_1 TRLV_6_0 TRLV_6_1 SOPV_5_0 SOPV_5_1 SOPV8r_5_0 SOPV8r_5_1 TRLV_5_0 TRLV_5_1 SOPV_4_0 SOPV_4_1 SOPV8r_4_0 SOPV8r_4_1 TRLV_4_0 TRLV_4_1 SOPV_3_0 SOPV_3_1 SOPV8r_3_0 SOPV8r_3_1 TRLV_3_0 TRLV_3_1 SOPV_2_0 SOPV_2_1 SOPV8r_2_0 SOPV8r_2_1 TRLV_2_0 TRLV_2_1 SOPV_1_0 SOPV_1_1 SOPV8r_1_0 SOPV8r_1_1 TRLV_1_0 TRLV_1_1;
set SEASON:=;
set DAYTYPE:=;
set DAILYTIMEBRACKET:=;
set STORAGE:=;
#####################
# Parameters #
#####################
#
# Units are GJ, kW and USD
param Peakdemand default 1 :=
[Kenya,*,*]:
2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040:=
TRLV_1_0 0 0 0 0.035503748 0.073847796 0.115202562 0.159747552 0.207671818 0.259174428 0.314464973 0.373764082 0.437303976 0.437303976 0.437303976 0.437303976 0.437303976 0.437303976 0.437303976 0.437303976 0.437303976 0.437303976 0.437303976 0.437303976 0.437303976 0.437303976
TRLV_2_0 0 0 0 0.031715426 0.065968085 0.102910213 0.142702162 0.18551281 0.231519987 0.280910918 0.333882691 0.390642748 0.390642748 0.390642748 0.390642748 0.390642748 0.390642748 0.390642748 0.390642748 0.390642748 0.390642748 0.390642748 0.390642748 0.390642748 0.390642748
TRLV_3_0 0 0 0 0.03760931 0.078227364 0.122034688 0.169221434 0.219987865 0.274544855 0.333114424 0.395930287 0.463238436 0.463238436 0.463238436 0.463238436 0.463238436 0.463238436 0.463238436 0.463238436 0.463238436 0.463238436 0.463238436 0.463238436 0.463238436 0.463238436
TRLV_4_0 0 0 0 0.052990896 0.110221063 0.171944858 0.238430203 0.309959264 0.386829161 0.469352715 0.557859227 0.652695296 0.652695296 0.652695296 0.652695296 0.652695296 0.652695296 0.652695296 0.652695296 0.652695296 0.652695296 0.652695296 0.652695296 0.652695296 0.652695296
TRLV_5_0 0 0 0 0.034974676 0.072747325 0.113485828 0.157367014 0.204577119 0.255312244 0.309778856 0.368194298 0.430787328 0.430787328 0.430787328 0.430787328 0.430787328 0.430787328 0.430787328 0.430787328 0.430787328 0.430787328 0.430787328 0.430787328 0.430787328 0.430787328
TRLV_6_0 0 0 0 0.037202401 0.077380994 0.12071435 0.167390565 0.217607735 0.271574453 0.329510336 0.391646571 0.458226488 0.458226488 0.458226488 0.458226488 0.458226488 0.458226488 0.458226488 0.458226488 0.458226488 0.458226488 0.458226488 0.458226488 0.458226488 0.458226488
TRLV_7_0 0 0 0 0.023055127 0.047954664 0.074809276 0.103735529 0.134856188 0.168300522 0.204204634 0.242711793 0.283972798 0.283972798 0.283972798 0.283972798 0.283972798 0.283972798 0.283972798 0.283972798 0.283972798 0.283972798 0.283972798 0.283972798 0.283972798 0.283972798
TRLV_8_0 0 0 0 0.029656132 0.061684755 0.096228218 0.133436462 0.1734674 0.216487316 0.262671276 0.312203574 0.365278182 0.365278182 0.365278182 0.365278182 0.365278182 0.365278182 0.365278182 0.365278182 0.365278182 0.365278182 0.365278182 0.365278182 0.365278182 0.365278182
TRLV_9_0 0 0 0 0.040579304 0.084404952 0.131671725 0.182584792 0.23736023 0.296225567 0.359420354 0.427196764 0.499820214 0.499820214 0.499820214 0.499820214 0.499820214 0.499820214 0.499820214 0.499820214 0.499820214 0.499820214 0.499820214 0.499820214 0.499820214 0.499820214
;
end;