Skip to content

Commit

Permalink
fix issues with ipft and ivar in labels
Browse files Browse the repository at this point in the history
  • Loading branch information
tztsai committed Oct 16, 2024
1 parent c229433 commit 85be85f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 9 additions & 6 deletions Tools/ML.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,15 @@ def MLmap_multidim(

if (PFT_mask[ipft - 1] > 0).any():
res = MLeval.evaluation_map(Global_Predicted_Y_map, pool_map, ipft, PFT_mask)
if varname.startswith("carbon"):
ipft = int(varname.split("_")[1])
ivar = ind[0]
else:
if varname.startswith("biomass"):
ipft = ind[0]
ivar = int(varname.split("_")[1])
else:
ipft = int(varname.split("_")[1])
ivar = ind[0]
if varname.startswith("litter"):
j = ["ab", "be"].index(varname.split("_")[2])
ivar = ivar * 2 + j - 1
if type(model).__name__ == "Pipeline":
alg = type(model.named_steps["estimator"]).__name__
else:
Expand All @@ -180,8 +183,8 @@ def MLmap_multidim(
"C4G",
"C3C",
"C4C",
"C3S",
"C4S",
"_",
"_",
][ipft - 1]
res["ivar"] = ivar
res["var"] = varlist["resp"][f"pool_name_{ipool}"][ivar - 1]
Expand Down
1 change: 0 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@
subpool_name = varlist["resp"]["pool_name_" + ipool]
npfts = varlist["resp"]["npfts"]
subLabel = varlist["resp"]["sub_item"]
print(subLabel)
pp = varlist["resp"]["dim"][ipool]
sect_n = varlist["resp"]["sect_n"][ipool]
if pp[0] == "pft":
Expand Down

2 comments on commit 85be85f

@Mandresy-code
Copy link
Collaborator

@Mandresy-code Mandresy-code commented on 85be85f Oct 23, 2024

Choose a reason for hiding this comment

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

@tztsai , I tried to launch the NN branch for CNP2 and I get the error below in task 4. It seems like this modification prevent now task 4 to complete and get MLacc_results.csv.

Here is the error :

Traceback (most recent call last):
File "/home/surface10/mrasolon/SPINacc_index/main.py", line 217, in
res_df = ML.MLloop(
File "/home/surface10/mrasolon/SPINacc_index/Tools/ML.py", line 353, in MLloop
result = list(filter(None, pool.map(MLmap_multidim, *zip(*result))))
File "/usr/local/install/python-3.9/lib/python3.9/concurrent/futures/_base.py", line 609, in result_iterator
yield fs.pop().result()
File "/usr/local/install/python-3.9/lib/python3.9/concurrent/futures/_base.py", line 446, in result
return self.__get_result()
File "/usr/local/install/python-3.9/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
raise self.exception
File "/usr/local/install/python-3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/surface10/mrasolon/SPINacc_index/Tools/ML.py", line 161, in MLmap_multidim
ipft = int(varname.split("
")[1])
ValueError: invalid literal for int() with base 10: 'longterm'

@tztsai
Copy link
Collaborator Author

@tztsai tztsai commented on 85be85f Oct 23, 2024

Choose a reason for hiding this comment

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

It seems due to the different varnames in the CNP2 data. Can you provide the varnames there?

Please sign in to comment.