CUPiD icon indicating copy to clipboard operation
CUPiD copied to clipboard

Bug in Hemis_seaice_visual_compare_obs_lens.ipynb

Open mnlevy1981 opened this issue 10 months ago • 2 comments

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 avatar Mar 07 '25 15:03 mnlevy1981

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

mnlevy1981 avatar Mar 07 '25 16:03 mnlevy1981

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))

dabail10 avatar Mar 07 '25 16:03 dabail10

I think this was fixed in #202

TeaganKing avatar Jul 07 '25 13:07 TeaganKing