Closed gusbacos closed 3 years ago
In SUEWS_AnthropogenicHeat.txt, there is a reference to Järvi. When changing ä to a the problem disappeared.
here is the error message from using command-line suews-convert. Same UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 298: invalid continuation byte appear from using SUEWSConverter through UMEP in QGIS 3.16
2021-02-22 13:08:30,476 - SuPy - INFO - chained list: ['2020a', '2019b', '2019a', '2018c', '2018b', '2018a', '2017a']
C:\Script\SaraSUEWSTG\Input\SUEWS_AnthropogenicHeat.txt
C:\Script\SaraSUEWSTG\Input\SUEWS_Conductance.txt
C:\Script\SaraSUEWSTG\Input\SUEWS_ESTMCoefficients.txt
C:\Script\SaraSUEWSTG\Input\SUEWS_Irrigation.txt
C:\Script\SaraSUEWSTG\Input\SUEWS_NonVeg.txt
C:\Script\SaraSUEWSTG\Input\SUEWS_OHMCoefficients.txt
C:\Script\SaraSUEWSTG\Input\SUEWS_Profiles.txt
C:\Script\SaraSUEWSTG\Input\SUEWS_SiteSelect.txt
C:\Script\SaraSUEWSTG\Input\SUEWS_Snow.txt
C:\Script\SaraSUEWSTG\Input\SUEWS_Soil.txt
C:\Script\SaraSUEWSTG\Input\SUEWS_Veg.txt
C:\Script\SaraSUEWSTG\Input\SUEWS_Water.txt
C:\Script\SaraSUEWSTG\Input\SUEWS_WithinGridWaterDist.txt
C:\Script\SaraSUEWSTG\Input\InitialConditionsMast1_2004.nml
C:\Script\SaraSUEWSTG\Input\InitialConditionsMast1_2004_EndofRun.nml
C:\Script\SaraSUEWSTG\Input\InitialConditionsMast_2003.nml
C:\Script\SaraSUEWSTG\RunControl.nml
2021-02-22 13:08:30,551 - SuPy - INFO - **
2021-02-22 13:08:30,554 - SuPy - INFO - working on: 2017a --> 2018a
2021-02-22 13:08:30,557 - SuPy - INFO - filesToConvert: ['SUEWS_AnthropogenicHeat.txt', 'SUEWS_SiteSelect.txt', 'SUEWS_BiogenCO2.txt', 'SUEWS_Veg.txt', 'RunControl.nml']
2021-02-22 13:08:30,557 - SuPy - INFO - working on file: SUEWS_AnthropogenicHeat.txt
2021-02-22 13:08:30,569 - SuPy - INFO - working on C:\Users\xbacos\AppData\Local\Temp\tmpndsulepa\temp1\SUEWS_AnthropogenicHeat.txt in ISO-8859-1
2021-02-22 13:08:30,569 - SuPy - INFO - Rename, C:\Users\xbacos\AppData\Local\Temp\tmpndsulepa\temp1\SUEWS_AnthropogenicHeat.txt, QF_A_Weekday, -999, QF_A_WD
Traceback (most recent call last):
File "C:\OSGEO4~1\apps\Python37\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\OSGEO4~1\apps\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\OSGEO4~1\apps\Python37\Scripts\suews-convert.exe__main.py", line 7, in
Using command-line suews-convert took less than 1 second to complete the conversion 2017a-->2020a But when using SUEWSConvert through UMEP the process took about 40min. See below excerpt from supy.log
I tried using following line in the OSGeo4W-shell, which worked fine as well.
from supy.util._converter import convert_table
convert_table("C:\Script\SaraSUEWSTG", "C:\Script\SaraSUEWSTG\output_new", "2017a", "2020a")
When using the converted SUEWS-output from all three above mentioned methods, the same error message appear
2021-02-22 16:51:49,871 - SuPy - INFO - All cache cleared.
2021-02-22 16:51:49,999 - SuPy - ERROR - Entries missing from SUEWS_Profiles.txt
Traceback (most recent call last):
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py", line 843, in build_code_df
df_code = df_code0.loc[list_code, list_keys]
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 889, in __getitem__
return self._getitem_tuple(key)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1060, in _getitem_tuple
return self._getitem_lowerdim(tup)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 791, in _getitem_lowerdim
return self._getitem_nested_tuple(tup)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 865, in _getitem_nested_tuple
obj = getattr(obj, self.name)._getitem_axis(key, axis=axis)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1113, in _getitem_axis
return self._getitem_iterable(key, axis=axis)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1053, in _getitem_iterable
keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1266, in _get_listlike_indexer
self._validate_read_indexer(keyarr, indexer, axis, raise_missing=raise_missing)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1308, in _validate_read_indexer
raise KeyError(f"None of [{key}] are in the [{axis_name}]")
KeyError: "None of [Int64Index([801, 801], dtype='int64', name='Code')] are in the [index]"
2021-02-22 16:51:50,000 - SuPy - ERROR - missing code:
[801, 801]
Traceback (most recent call last):
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py", line 843, in build_code_df
df_code = df_code0.loc[list_code, list_keys]
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 889, in __getitem__
return self._getitem_tuple(key)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1060, in _getitem_tuple
return self._getitem_lowerdim(tup)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 791, in _getitem_lowerdim
return self._getitem_nested_tuple(tup)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 865, in _getitem_nested_tuple
obj = getattr(obj, self.name)._getitem_axis(key, axis=axis)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1113, in _getitem_axis
return self._getitem_iterable(key, axis=axis)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1053, in _getitem_iterable
keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1266, in _get_listlike_indexer
self._validate_read_indexer(keyarr, indexer, axis, raise_missing=raise_missing)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1308, in _validate_read_indexer
raise KeyError(f"None of [{key}] are in the [{axis_name}]")
KeyError: "None of [Int64Index([801, 801], dtype='int64', name='Code')] are in the [index]"
2021-02-22 16:51:50,001 - SuPy - ERROR - missing key:
['P', 'o', 'p', 'P', 'r', 'o', 'f', 'W', 'D']
Traceback (most recent call last):
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py", line 843, in build_code_df
df_code = df_code0.loc[list_code, list_keys]
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 889, in __getitem__
return self._getitem_tuple(key)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1060, in _getitem_tuple
return self._getitem_lowerdim(tup)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 791, in _getitem_lowerdim
return self._getitem_nested_tuple(tup)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 865, in _getitem_nested_tuple
obj = getattr(obj, self.name)._getitem_axis(key, axis=axis)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1113, in _getitem_axis
return self._getitem_iterable(key, axis=axis)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1053, in _getitem_iterable
keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1266, in _get_listlike_indexer
self._validate_read_indexer(keyarr, indexer, axis, raise_missing=raise_missing)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1308, in _validate_read_indexer
raise KeyError(f"None of [{key}] are in the [{axis_name}]")
KeyError: "None of [Int64Index([801, 801], dtype='int64', name='Code')] are in the [index]"
2021-02-22 16:51:50,003 - SuPy - ERROR - `df_code0` has been dumped into C:\Script\SaraSUEWSTG\df_code0.pkl for debugging!
Traceback (most recent call last):
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py", line 843, in build_code_df
df_code = df_code0.loc[list_code, list_keys]
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 889, in __getitem__
return self._getitem_tuple(key)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1060, in _getitem_tuple
return self._getitem_lowerdim(tup)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 791, in _getitem_lowerdim
return self._getitem_nested_tuple(tup)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 865, in _getitem_nested_tuple
obj = getattr(obj, self.name)._getitem_axis(key, axis=axis)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1113, in _getitem_axis
return self._getitem_iterable(key, axis=axis)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1053, in _getitem_iterable
keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1266, in _get_listlike_indexer
self._validate_read_indexer(keyarr, indexer, axis, raise_missing=raise_missing)
File "C:\Users\xbacos\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py", line 1308, in _validate_read_indexer
raise KeyError(f"None of [{key}] are in the [{axis_name}]")
KeyError: "None of [Int64Index([801, 801], dtype='int64', name='Code')] are in the [index]"
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-25-973e41b826d6> in <module>
3 path_runcontrol_umepcmd = "C:\Script\SaraSUEWSTG\output_new\RunControl.nml"
4 path_runcontrol = 'C:\Script\SuPy\src\supy\sample_run\RunControl.nml'
----> 5 df_state_init = sp.init_supy(path_runcontrol_umep)
6
~\Anaconda3\envs\supy_env\lib\site-packages\supy\_supy_module.py in init_supy(path_init, force_reload, check_input)
101 if path_init_x.suffix == ".nml":
102 # SUEWS `RunControl.nml`:
--> 103 df_state_init = load_InitialCond_grid_df(
104 path_init_x, force_reload=force_reload
105 )
~\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py in load_InitialCond_grid_df(path_runcontrol, force_reload)
1589 # load base df of InitialCond
1590 logger_supy.debug("loading base df_init...")
-> 1591 df_init = load_SUEWS_InitialCond_df(path_runcontrol)
1592
1593 # add Initial Condition variables from namelist file
~\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py in load_SUEWS_InitialCond_df(path_runcontrol)
1325 path_input = path_runcontrol.parent / dict_ModConfig["fileinputpath"]
1326 logger_supy.debug("loading df_gridSurfaceChar")
-> 1327 df_gridSurfaceChar = load_SUEWS_SurfaceChar_df(path_input)
1328 # df_gridSurfaceChar.to_pickle("df_gridSurfaceChar.pkl")
1329 # only use the first year of each grid as base for initial conditions
~\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py in load_SUEWS_SurfaceChar_df(path_input)
1098 @functools.lru_cache(maxsize=16)
1099 def load_SUEWS_SurfaceChar_df(path_input):
-> 1100 df_gridSurfaceChar_exp = gen_df_gridSurfaceChar_exp(path_input)
1101 dict_var_ndim = {
1102 "ahprof_24hr": (24, 2),
~\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py in gen_df_gridSurfaceChar_exp(path_input)
1082 @functools.lru_cache(maxsize=16)
1083 def gen_df_gridSurfaceChar_exp(path_input):
-> 1084 df_siteselect_exp = gen_df_siteselect_exp(path_input)
1085 dict_var_tuple = exp_dict_full(dict_var2SiteSelect)
1086 df_gridSurfaceChar_exp = pd.concat(
~\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py in gen_df_siteselect_exp(path_input)
986 # nested code: code -> code -> value
987 df_code_exp_nest = pd.concat(
--> 988 [build_code_exp_df(path_input, code) for code in list(dict_code_var_nest)],
989 axis=1,
990 )
~\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py in <listcomp>(.0)
986 # nested code: code -> code -> value
987 df_code_exp_nest = pd.concat(
--> 988 [build_code_exp_df(path_input, code) for code in list(dict_code_var_nest)],
989 axis=1,
990 )
~\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py in build_code_exp_df(path_input, code_x)
935 # print(list_code_x)
936 df_all_code_x = pd.concat(
--> 937 [build_code_df(code, path_input, df_base_x) for code in list_code_x], axis=1
938 )
939 df_all_code_x = pd.concat([df_all_code_x], axis=1, keys=[code_x])
~\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py in <listcomp>(.0)
935 # print(list_code_x)
936 df_all_code_x = pd.concat(
--> 937 [build_code_df(code, path_input, df_base_x) for code in list_code_x], axis=1
938 )
939 df_all_code_x = pd.concat([df_all_code_x], axis=1, keys=[code_x])
~\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py in build_code_df(code, path_input, df_base)
858 )
859
--> 860 raise e
861
862 df_code.index = df_base.index
~\Anaconda3\envs\supy_env\lib\site-packages\supy\_load.py in build_code_df(code, path_input, df_base)
841
842 try:
--> 843 df_code = df_code0.loc[list_code, list_keys]
844 except Exception as e:
845 logger_supy.exception(f"Entries missing from {lib_code}")
~\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py in __getitem__(self, key)
887 # AttributeError for IntervalTree get_value
888 return self.obj._get_value(*key, takeable=self._takeable)
--> 889 return self._getitem_tuple(key)
890 else:
891 # we by definition only have the 0th axis
~\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py in _getitem_tuple(self, tup)
1058 def _getitem_tuple(self, tup: Tuple):
1059 with suppress(IndexingError):
-> 1060 return self._getitem_lowerdim(tup)
1061
1062 # no multi-index, so validate all of the indexers
~\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py in _getitem_lowerdim(self, tup)
789 # we may have a nested tuples indexer here
790 if self._is_nested_tuple_indexer(tup):
--> 791 return self._getitem_nested_tuple(tup)
792
793 # we maybe be using a tuple to represent multiple dimensions here
~\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py in _getitem_nested_tuple(self, tup)
863
864 current_ndim = obj.ndim
--> 865 obj = getattr(obj, self.name)._getitem_axis(key, axis=axis)
866 axis += 1
867
~\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py in _getitem_axis(self, key, axis)
1111 raise ValueError("Cannot index with multidimensional key")
1112
-> 1113 return self._getitem_iterable(key, axis=axis)
1114
1115 # nested tuple slicing
~\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py in _getitem_iterable(self, key, axis)
1051
1052 # A collection of keys
-> 1053 keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False)
1054 return self.obj._reindex_with_indexers(
1055 {axis: [keyarr, indexer]}, copy=True, allow_dups=True
~\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py in _get_listlike_indexer(self, key, axis, raise_missing)
1264 keyarr, indexer, new_indexer = ax._reindex_non_unique(keyarr)
1265
-> 1266 self._validate_read_indexer(keyarr, indexer, axis, raise_missing=raise_missing)
1267 return keyarr, indexer
1268
~\Anaconda3\envs\supy_env\lib\site-packages\pandas\core\indexing.py in _validate_read_indexer(self, key, indexer, axis, raise_missing)
1306 if missing == len(indexer):
1307 axis_name = self.obj._get_axis_name(axis)
-> 1308 raise KeyError(f"None of [{key}] are in the [{axis_name}]")
1309
1310 ax = self.obj._get_axis(axis)
KeyError: "None of [Int64Index([801, 801], dtype='int64', name='Code')] are in the [index]"
I did try to replace SUEWS_Profiles.txt with a SUEWS_Profiles.txt from the sample data, but then a similar error message- SuPy - ERROR - Entries missing from SUEWS_BiogenCO2.txt appeared. I looked in BiogenCO2.txt and found that it only had columns
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|---|---|---|---|---|---|---|---|
800 | alpha | beta | theta | alpha_enh | beta_enh | resp_a | resp_b | min_respi |
I have not checked any other .txt files
the issue is the SUEWS_BiogenCO2
table: your siteselect is looking for an entry 801
which however is missing in this table.
so, just add an entry 801
to SUEWS_BiogenCO2
with proper values (most likely you just need to duplicate the row 800
and change the code to 801
to get it working).
On 2). I tried again and now it take only a couple of seconds... Hm what could this be about?
1) # reading special symbols ' ä ' in Järvi
In SUEWS_AnthropogenicHeat.txt, there is a reference to Järvi. When changing ä to a the problem disappeared.
I noticed this issue while was developing this converter and didn't find a proper solution as computer encoding systems vary; so my solution was the same as yours: replacing those accented characters with common latin ones.
On 2). I tried again and now it take only a couple of seconds... Hm what could this be about?
I'm curious about this as well: since it is supposed and indeed very fast based on my experience.
@gusbacos , tomorrow, could you just try the Converter via UMEP and see if it still is slow?
2) Yes very strange, I did a rerun after restarting my computer and now the result came immediately.
good to know a restart helps 😉
how about 3) now?
Not really. I think that it might be more to it than only BiogenCO2. Despite what I do with BiogenCO2.txt, SUEWS_Profile does not work properly, and still gives me the same error message.
to examine the issue in BiogenCO2 i I did replace the failing SUEWS_Profiles.txt with a SUEWS_Profiles.txt from the sample data
As the table imply above, there is not rows in the SUEWSBiogenCO2.txt. only those two header rows, where I was expecting to find the word "code" instead of "800". Furthermore, the used vegetation is calling for code 32 (or 31) in BiogenCO2.txt, so i copied those lines from the SUEWS.txt files from the sample data and it worked.
As BiogenCO2 does not exist in the 2017a, perhaps it it reasonable to provide the codes in the .txt files when converting? Since the column in SUEWS_veg.txt gets a column that is filled, is it not also reasonable to provide lines in BiogenCO2 that correspond to these codes?
that sounds like a bug in the converter. Let me examine your dataset later on.
fixed in UMEP-dev/SuPy#26. please update supy to its latest version.
I tried converting SUEWS-data from version 2017a to 2020 a using both UMEP SUEWSConvert as well as command line version suews-convert, but I have run into some problems.
For sake of simplicity I will divide them into three sections:
Here is the data used SUEWSConvert_data.zip