Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subset_data is broken #2527

Closed
wwieder opened this issue May 6, 2024 · 4 comments · Fixed by #2528
Closed

subset_data is broken #2527

wwieder opened this issue May 6, 2024 · 4 comments · Fixed by #2528
Assignees
Labels
bug something is working incorrectly

Comments

@wwieder
Copy link
Contributor

wwieder commented May 6, 2024

Brief summary of bug

subset_data fails for a point when cbh and cth are not given and a dominant pft is defined.
@samsrabin suggested a python fix is pretty straight forward, but we need to also add testing around subset_data.

General bug information

CTSM version you are using: [output of git describe]
CTSM5.2.001

Does this bug cause significantly incorrect results in the model's science? [Yes / No]
No

Configurations affected: [Fill this in if known.]
Subset data for single point cases

Details of bug

Subset data fails if cbh and cth are not given. This seems to have come in with the PLUMBER2 PR to b4bdev, which introduced information on canopy top and bottom heights.

Important details of your setup / configuration so we can reproduce the bug

  ./subset_data point --lat 38.9592 --lon 253.0102 --create-surface --outdir /glade/derecho/scratch/wwieder/nldas/gothic/ --site Gothic_evergreen --dompft 1
Traceback (most recent call last):
  File "./subset_data", line 37, in <module>
    main()
  File "/glade/u/home/wwieder/CTSM/tools/site_and_regional/../../python/ctsm/subset_data.py", line 713, in main
    subset_point(args, file_dict)
  File "/glade/u/home/wwieder/CTSM/tools/site_and_regional/../../python/ctsm/subset_data.py", line 604, in subset_point
    specify_fsurf_out=file_dict["fsurf_out"],
  File "/glade/u/home/wwieder/CTSM/tools/site_and_regional/../../python/ctsm/site_and_regional/single_point_case.py", line 503, in create_surfdata_at_point
    f_out = self.modify_surfdata_atpoint(f_tmp)
  File "/glade/u/home/wwieder/CTSM/tools/site_and_regional/../../python/ctsm/site_and_regional/single_point_case.py", line 418, in modify_surfdata_atpoint
    zip_pfts = zip(self.dom_pft, self.pct_pft, self.cth, self.cbh)
TypeError: zip argument #3 must support iteration

@wwieder wwieder added the bug something is working incorrectly label May 6, 2024
@wwieder wwieder self-assigned this May 6, 2024
@wwieder
Copy link
Contributor Author

wwieder commented May 6, 2024

@samsrabin do you want to open a PR to fix this, or should I? Regardless, I could use some help re. testing.

@samsrabin
Copy link
Collaborator

It's probably best to start a PR with just the testing (which will fail), then add the fix to make sure the test passes. So I'll add myself as assignee here.

@samsrabin samsrabin self-assigned this May 6, 2024
@samsrabin
Copy link
Collaborator

samsrabin commented May 6, 2024

And for my future reference: The solution is to replace

zip_pfts = zip(self.dom_pft, self.pct_pft, self.cth, self.cbh)

with

cth_to_zip = self.cth
if cth_to_zip is None:
    cth_to_zip = [None for x in self.dom_pft]
zip_pfts = zip(self.dom_pft, self.pct_pft, cth_to_zip, self.cbh)

and do the same thing for self.cbh.

@samsrabin
Copy link
Collaborator

samsrabin commented May 6, 2024

Revert changes in ba0a3c to ensure testing fails if scalar values provided (before implementing fix).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something is working incorrectly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants