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

Bug in Hemis_seaice_visual_compare_obs_lens.ipynb #199

Open
mnlevy1981 opened this issue Mar 7, 2025 · 2 comments
Open

Bug in Hemis_seaice_visual_compare_obs_lens.ipynb #199

mnlevy1981 opened this issue Mar 7, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@mnlevy1981
Copy link
Collaborator

Describe the bug
If climo_nyears is larger than the total number of years in the output set (but total number of years in the output set is not 1), the Ice Area and Ice Volume plots don't look right

To Reproduce
Run a case for two or three years, but keep climo_nyears = 35 when you run the sea ice notebooks in key_metrics; test_cupid_30a06b.10 was only run for 3 years so the red line should not span the entire time axis:

Image

Expected behavior
The red line above should connect years 1,2, and 3; the Lab Sea section handles it correctly:

Image

@mnlevy1981
Copy link
Collaborator Author

mnlevy1981 commented Mar 7, 2025

i'm pretty sure the issue is in

# Set up axes
if first_year > 1:
    model_start_year1 = end_year - len(ds1_mar_nh.time)
    model_end_year1 = end_year
    model_start_year2 = base_end_year - len(ds2_mar_nh.time)
    model_end_year2 = base_end_year
    lens1_start_year = ds_cesm1_aicetot_nh.year[60]
    lens1_end_year = ds_cesm1_aicetot_nh.year[95]
    lens2_start_year = ds_cesm2_aicetot_nh.year[110]
    lens2_end_year = ds_cesm2_aicetot_nh.year[145]
else:
    model_start_year1 = 1
    model_end_year1 = climo_nyears
    model_start_year2 = 1
    model_end_year2 = climo_nyears
    lens1_start_year = 1
    lens1_end_year = 36
    lens2_start_year = 1
    lens2_end_year = 36

specifically in the else block, we probably want

model_end_year1 = len(ds1_mar_nh.time)
model_end_year2 = len(ds2_mar_nh.time)

[edit: remove min() because climo_nyears is already accounted for in the creation of these datasets]

Also, the first block may have off-by-one issues that can be fixed by adding one to the two start_year variables:

model_start_year1 = end_year - len(ds1_mar_nh.time) + 1
model_start_year2 = base_end_year - len(ds2_mar_nh.time) + 1

@dabail10
Copy link
Collaborator

dabail10 commented Mar 7, 2025

I think there needs to be a more general fix here. In several places I do the following. In other words, I should reset climo_nyears earlier to the actual number of years on the files.

.isel(time=slice(-climo_nyears * 12, None))

@TeaganKing TeaganKing added the bug Something isn't working label Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants