# Regular Python library imports 
import xarray as xr 
import numpy as np
import pandas as pd
import pyproj
import scipy.interpolate
import matplotlib.pyplot as plt
import glob
from datetime import datetime
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import os

# Helper functions for reading the data from the bucket and plotting
from utils.read_data_utils import read_IS2SITMOGR4, read_book_data
from utils.plotting_utils import static_winter_comparison_lineplot, staticArcticMaps, interactiveArcticMaps, compute_gridcell_winter_means, interactive_winter_comparison_lineplot # Plotting utils 
from extra_funcs import read_IS2SITMOGR4S, regrid_ubris_to_is2, get_cs2is2_snow, apply_interpolation_time
# Plotting dependencies
#%config InlineBackend.figure_format = 'retina'
import matplotlib as mpl

# Remove warnings to improve display
import warnings 
warnings.filterwarnings('ignore') 

# Get the current working directory
current_directory = os.getcwd()
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 17
     15 from utils.read_data_utils import read_IS2SITMOGR4, read_book_data
     16 from utils.plotting_utils import static_winter_comparison_lineplot, staticArcticMaps, interactiveArcticMaps, compute_gridcell_winter_means, interactive_winter_comparison_lineplot # Plotting utils 
---> 17 from extra_funcs import read_IS2SITMOGR4S, regrid_ubris_to_is2, get_cs2is2_snow, apply_interpolation_time
     18 # Plotting dependencies
     19 #%config InlineBackend.figure_format = 'retina'
     20 import matplotlib as mpl

ModuleNotFoundError: No module named 'extra_funcs'
# Load the winter IS-2 thickness data from zarr/s3
IS2SITMOGR4_v3 = read_IS2SITMOGR4(data_type='zarr-s3', persist=True) 
#IS2SITMOGR4_v3
load zarr from S3 bucket
zarr_path: s3://icesat-2-sea-ice-us-west-2/IS2SITMOGR4_V3/IS2SITMOGR4_V3_201811-202404.zarr
# Get some IS2 map projection/domain info needed for later functions
out_proj = 'EPSG:3411'
mapProj = pyproj.Proj("+init=" + out_proj)

xIS2 = IS2SITMOGR4_v3.x.values
yIS2 = IS2SITMOGR4_v3.y.values
xptsIS2, yptsIS2 = np.meshgrid(xIS2, yIS2)
out_lons = IS2SITMOGR4_v3.longitude.values
out_lats = IS2SITMOGR4_v3.latitude.values
IS2SITMOGR4_v3 = apply_interpolation_time(IS2SITMOGR4_v3, xptsIS2, yptsIS2, ['snow_depth_sm', 'ice_thickness_sm'])
Creating/forcing new variable snow_depth_sm_int
snow_depth_sm 0
Interpolated.
snow_depth_sm 1
Interpolated.
snow_depth_sm 2
Interpolated.
snow_depth_sm 3
Interpolated.
snow_depth_sm 4
Interpolated.
snow_depth_sm 5
Interpolated.
snow_depth_sm 6
Interpolated.
snow_depth_sm 7
Interpolated.
snow_depth_sm 8
Interpolated.
snow_depth_sm 9
Interpolated.
snow_depth_sm 10
Interpolated.
snow_depth_sm 11
Interpolated.
snow_depth_sm 12
Interpolated.
snow_depth_sm 13
Interpolated.
snow_depth_sm 14
Interpolated.
snow_depth_sm 15
Interpolated.
snow_depth_sm 16
Interpolated.
snow_depth_sm 17
Interpolated.
snow_depth_sm 18
Interpolated.
snow_depth_sm 19
Interpolated.
snow_depth_sm 20
Interpolated.
snow_depth_sm 21
Interpolated.
snow_depth_sm 22
no data or issue with gridding, so skipping...
snow_depth_sm 23
no data or issue with gridding, so skipping...
snow_depth_sm 24
no data or issue with gridding, so skipping...
snow_depth_sm 25
no data or issue with gridding, so skipping...
snow_depth_sm 26
no data or issue with gridding, so skipping...
snow_depth_sm 27
no data or issue with gridding, so skipping...
snow_depth_sm 28
no data or issue with gridding, so skipping...
snow_depth_sm 29
no data or issue with gridding, so skipping...
snow_depth_sm 30
no data or issue with gridding, so skipping...
snow_depth_sm 31
no data or issue with gridding, so skipping...
snow_depth_sm 32
no data or issue with gridding, so skipping...
snow_depth_sm 33
no data or issue with gridding, so skipping...
snow_depth_sm 34
no data or issue with gridding, so skipping...
snow_depth_sm 35
no data or issue with gridding, so skipping...
snow_depth_sm 36
no data or issue with gridding, so skipping...
snow_depth_sm 37
no data or issue with gridding, so skipping...
snow_depth_sm 38
no data or issue with gridding, so skipping...
snow_depth_sm 39
no data or issue with gridding, so skipping...
snow_depth_sm 40
no data or issue with gridding, so skipping...
snow_depth_sm 41
no data or issue with gridding, so skipping...
snow_depth_sm 42
no data or issue with gridding, so skipping...
snow_depth_sm 43
no data or issue with gridding, so skipping...
snow_depth_sm 44
no data or issue with gridding, so skipping...
snow_depth_sm 45
no data or issue with gridding, so skipping...
Creating/forcing new variable ice_thickness_sm_int
ice_thickness_sm 0
Interpolated.
ice_thickness_sm 1
Interpolated.
ice_thickness_sm 2
Interpolated.
ice_thickness_sm 3
Interpolated.
ice_thickness_sm 4
Interpolated.
ice_thickness_sm 5
Interpolated.
ice_thickness_sm 6
Interpolated.
ice_thickness_sm 7
Interpolated.
ice_thickness_sm 8
Interpolated.
ice_thickness_sm 9
Interpolated.
ice_thickness_sm 10
Interpolated.
ice_thickness_sm 11
Interpolated.
ice_thickness_sm 12
Interpolated.
ice_thickness_sm 13
Interpolated.
ice_thickness_sm 14
Interpolated.
ice_thickness_sm 15
Interpolated.
ice_thickness_sm 16
Interpolated.
ice_thickness_sm 17
Interpolated.
ice_thickness_sm 18
Interpolated.
ice_thickness_sm 19
Interpolated.
ice_thickness_sm 20
Interpolated.
ice_thickness_sm 21
Interpolated.
ice_thickness_sm 22
no data or issue with gridding, so skipping...
ice_thickness_sm 23
no data or issue with gridding, so skipping...
ice_thickness_sm 24
no data or issue with gridding, so skipping...
ice_thickness_sm 25
no data or issue with gridding, so skipping...
ice_thickness_sm 26
no data or issue with gridding, so skipping...
ice_thickness_sm 27
no data or issue with gridding, so skipping...
ice_thickness_sm 28
no data or issue with gridding, so skipping...
ice_thickness_sm 29
no data or issue with gridding, so skipping...
ice_thickness_sm 30
no data or issue with gridding, so skipping...
ice_thickness_sm 31
no data or issue with gridding, so skipping...
ice_thickness_sm 32
no data or issue with gridding, so skipping...
ice_thickness_sm 33
no data or issue with gridding, so skipping...
ice_thickness_sm 34
no data or issue with gridding, so skipping...
ice_thickness_sm 35
no data or issue with gridding, so skipping...
ice_thickness_sm 36
no data or issue with gridding, so skipping...
ice_thickness_sm 37
no data or issue with gridding, so skipping...
ice_thickness_sm 38
no data or issue with gridding, so skipping...
ice_thickness_sm 39
no data or issue with gridding, so skipping...
ice_thickness_sm 40
no data or issue with gridding, so skipping...
ice_thickness_sm 41
no data or issue with gridding, so skipping...
ice_thickness_sm 42
no data or issue with gridding, so skipping...
ice_thickness_sm 43
no data or issue with gridding, so skipping...
ice_thickness_sm 44
no data or issue with gridding, so skipping...
ice_thickness_sm 45
no data or issue with gridding, so skipping...
done, returning new dataset
# Read in the new summer IS-2 thickness data locally (not on s3 yet)
IS2SITMOGR4_summer_v0 = read_IS2SITMOGR4S(local_data_path="./data/IS2SITMOGR4_SUMMER/")
./data/IS2SITMOGR4_SUMMER/V0/*.nc
# Quick check it looks interpolated..!
# IS2SITMOGR4_v3.ice_thickness_sm_int.isel(time=0).plot()
# Merge winter and summer IS-2 thickness data into one dataset
IS2SITMOGR4_allseason = IS2SITMOGR4_summer_v0.merge(IS2SITMOGR4_v3)
interp_vars=[
 'snow_density',
 'snow_density_sm',
 'snow_depth_mw99',
 'snow_density_w99',
 'ice_thickness_mw99',
 'ice_density_j22',
 'ice_thickness_j22']

IS2SITMOGR4_allseason = apply_interpolation_time(IS2SITMOGR4_allseason, xptsIS2, yptsIS2, interp_vars)
Creating/forcing new variable snow_density_int
snow_density 0
Interpolated.
snow_density 1
Interpolated.
snow_density 2
Interpolated.
snow_density 3
Interpolated.
snow_density 4
Interpolated.
snow_density 5
Interpolated.
snow_density 6
no data or issue with gridding, so skipping...
snow_density 7
no data or issue with gridding, so skipping...
snow_density 8
no data or issue with gridding, so skipping...
snow_density 9
Interpolated.
snow_density 10
Interpolated.
snow_density 11
Interpolated.
snow_density 12
Interpolated.
snow_density 13
Interpolated.
snow_density 14
Interpolated.
snow_density 15
Interpolated.
snow_density 16
Interpolated.
snow_density 17
no data or issue with gridding, so skipping...
snow_density 18
no data or issue with gridding, so skipping...
snow_density 19
no data or issue with gridding, so skipping...
snow_density 20
no data or issue with gridding, so skipping...
snow_density 21
Interpolated.
snow_density 22
Interpolated.
snow_density 23
Interpolated.
snow_density 24
Interpolated.
snow_density 25
Interpolated.
snow_density 26
Interpolated.
snow_density 27
Interpolated.
snow_density 28
Interpolated.
snow_density 29
no data or issue with gridding, so skipping...
snow_density 30
no data or issue with gridding, so skipping...
snow_density 31
no data or issue with gridding, so skipping...
snow_density 32
Interpolated.
snow_density 33
Interpolated.
snow_density 34
Interpolated.
snow_density 35
Interpolated.
snow_density 36
Interpolated.
snow_density 37
Interpolated.
snow_density 38
Interpolated.
snow_density 39
Interpolated.
snow_density 40
Interpolated.
snow_density 41
Interpolated.
snow_density 42
Interpolated.
snow_density 43
Interpolated.
snow_density 44
Interpolated.
snow_density 45
Interpolated.
snow_density 46
Interpolated.
snow_density 47
Interpolated.
snow_density 48
Interpolated.
snow_density 49
Interpolated.
snow_density 50
Interpolated.
snow_density 51
Interpolated.
snow_density 52
Interpolated.
snow_density 53
Interpolated.
snow_density 54
Interpolated.
snow_density 55
Interpolated.
Creating/forcing new variable snow_density_sm_int
snow_density_sm 0
Interpolated.
snow_density_sm 1
Interpolated.
snow_density_sm 2
Interpolated.
snow_density_sm 3
Interpolated.
snow_density_sm 4
Interpolated.
snow_density_sm 5
Interpolated.
snow_density_sm 6
Interpolated.
snow_density_sm 7
Interpolated.
snow_density_sm 8
Interpolated.
snow_density_sm 9
Interpolated.
snow_density_sm 10
Interpolated.
snow_density_sm 11
Interpolated.
snow_density_sm 12
Interpolated.
snow_density_sm 13
Interpolated.
snow_density_sm 14
Interpolated.
snow_density_sm 15
Interpolated.
snow_density_sm 16
Interpolated.
snow_density_sm 17
Interpolated.
snow_density_sm 18
Interpolated.
snow_density_sm 19
Interpolated.
snow_density_sm 20
Interpolated.
snow_density_sm 21
Interpolated.
snow_density_sm 22
Interpolated.
snow_density_sm 23
Interpolated.
snow_density_sm 24
Interpolated.
snow_density_sm 25
Interpolated.
snow_density_sm 26
Interpolated.
snow_density_sm 27
Interpolated.
snow_density_sm 28
Interpolated.
snow_density_sm 29
Interpolated.
snow_density_sm 30
Interpolated.
snow_density_sm 31
Interpolated.
snow_density_sm 32
no data or issue with gridding, so skipping...
snow_density_sm 33
no data or issue with gridding, so skipping...
snow_density_sm 34
no data or issue with gridding, so skipping...
snow_density_sm 35
no data or issue with gridding, so skipping...
snow_density_sm 36
no data or issue with gridding, so skipping...
snow_density_sm 37
no data or issue with gridding, so skipping...
snow_density_sm 38
no data or issue with gridding, so skipping...
snow_density_sm 39
no data or issue with gridding, so skipping...
snow_density_sm 40
no data or issue with gridding, so skipping...
snow_density_sm 41
no data or issue with gridding, so skipping...
snow_density_sm 42
no data or issue with gridding, so skipping...
snow_density_sm 43
no data or issue with gridding, so skipping...
snow_density_sm 44
no data or issue with gridding, so skipping...
snow_density_sm 45
no data or issue with gridding, so skipping...
snow_density_sm 46
no data or issue with gridding, so skipping...
snow_density_sm 47
no data or issue with gridding, so skipping...
snow_density_sm 48
no data or issue with gridding, so skipping...
snow_density_sm 49
no data or issue with gridding, so skipping...
snow_density_sm 50
no data or issue with gridding, so skipping...
snow_density_sm 51
no data or issue with gridding, so skipping...
snow_density_sm 52
no data or issue with gridding, so skipping...
snow_density_sm 53
no data or issue with gridding, so skipping...
snow_density_sm 54
no data or issue with gridding, so skipping...
snow_density_sm 55
no data or issue with gridding, so skipping...
Creating/forcing new variable snow_depth_mw99_int
snow_depth_mw99 0
Interpolated.
snow_depth_mw99 1
Interpolated.
snow_depth_mw99 2
Interpolated.
snow_depth_mw99 3
Interpolated.
snow_depth_mw99 4
Interpolated.
snow_depth_mw99 5
Interpolated.
snow_depth_mw99 6
no data or issue with gridding, so skipping...
snow_depth_mw99 7
no data or issue with gridding, so skipping...
snow_depth_mw99 8
no data or issue with gridding, so skipping...
snow_depth_mw99 9
Interpolated.
snow_depth_mw99 10
Interpolated.
snow_depth_mw99 11
Interpolated.
snow_depth_mw99 12
Interpolated.
snow_depth_mw99 13
Interpolated.
snow_depth_mw99 14
Interpolated.
snow_depth_mw99 15
Interpolated.
snow_depth_mw99 16
Interpolated.
snow_depth_mw99 17
no data or issue with gridding, so skipping...
snow_depth_mw99 18
no data or issue with gridding, so skipping...
snow_depth_mw99 19
no data or issue with gridding, so skipping...
snow_depth_mw99 20
no data or issue with gridding, so skipping...
snow_depth_mw99 21
Interpolated.
snow_depth_mw99 22
Interpolated.
snow_depth_mw99 23
Interpolated.
snow_depth_mw99 24
Interpolated.
snow_depth_mw99 25
Interpolated.
snow_depth_mw99 26
Interpolated.
snow_depth_mw99 27
Interpolated.
snow_depth_mw99 28
Interpolated.
snow_depth_mw99 29
no data or issue with gridding, so skipping...
snow_depth_mw99 30
no data or issue with gridding, so skipping...
snow_depth_mw99 31
no data or issue with gridding, so skipping...
snow_depth_mw99 32
Interpolated.
snow_depth_mw99 33
Interpolated.
snow_depth_mw99 34
Interpolated.
snow_depth_mw99 35
Interpolated.
snow_depth_mw99 36
Interpolated.
snow_depth_mw99 37
Interpolated.
snow_depth_mw99 38
Interpolated.
snow_depth_mw99 39
Interpolated.
snow_depth_mw99 40
Interpolated.
snow_depth_mw99 41
Interpolated.
snow_depth_mw99 42
Interpolated.
snow_depth_mw99 43
Interpolated.
snow_depth_mw99 44
Interpolated.
snow_depth_mw99 45
Interpolated.
snow_depth_mw99 46
Interpolated.
snow_depth_mw99 47
Interpolated.
snow_depth_mw99 48
Interpolated.
snow_depth_mw99 49
Interpolated.
snow_depth_mw99 50
Interpolated.
snow_depth_mw99 51
Interpolated.
snow_depth_mw99 52
Interpolated.
snow_depth_mw99 53
Interpolated.
snow_depth_mw99 54
Interpolated.
snow_depth_mw99 55
Interpolated.
Creating/forcing new variable snow_density_w99_int
snow_density_w99 0
Interpolated.
snow_density_w99 1
Interpolated.
snow_density_w99 2
Interpolated.
snow_density_w99 3
Interpolated.
snow_density_w99 4
Interpolated.
snow_density_w99 5
Interpolated.
snow_density_w99 6
no data or issue with gridding, so skipping...
snow_density_w99 7
no data or issue with gridding, so skipping...
snow_density_w99 8
no data or issue with gridding, so skipping...
snow_density_w99 9
Interpolated.
snow_density_w99 10
Interpolated.
snow_density_w99 11
Interpolated.
snow_density_w99 12
Interpolated.
snow_density_w99 13
Interpolated.
snow_density_w99 14
Interpolated.
snow_density_w99 15
Interpolated.
snow_density_w99 16
Interpolated.
snow_density_w99 17
no data or issue with gridding, so skipping...
snow_density_w99 18
no data or issue with gridding, so skipping...
snow_density_w99 19
no data or issue with gridding, so skipping...
snow_density_w99 20
no data or issue with gridding, so skipping...
snow_density_w99 21
Interpolated.
snow_density_w99 22
Interpolated.
snow_density_w99 23
Interpolated.
snow_density_w99 24
Interpolated.
snow_density_w99 25
Interpolated.
snow_density_w99 26
Interpolated.
snow_density_w99 27
Interpolated.
snow_density_w99 28
Interpolated.
snow_density_w99 29
no data or issue with gridding, so skipping...
snow_density_w99 30
no data or issue with gridding, so skipping...
snow_density_w99 31
no data or issue with gridding, so skipping...
snow_density_w99 32
Interpolated.
snow_density_w99 33
Interpolated.
snow_density_w99 34
Interpolated.
snow_density_w99 35
Interpolated.
snow_density_w99 36
Interpolated.
snow_density_w99 37
Interpolated.
snow_density_w99 38
Interpolated.
snow_density_w99 39
Interpolated.
snow_density_w99 40
Interpolated.
snow_density_w99 41
Interpolated.
snow_density_w99 42
Interpolated.
snow_density_w99 43
Interpolated.
snow_density_w99 44
Interpolated.
snow_density_w99 45
Interpolated.
snow_density_w99 46
Interpolated.
snow_density_w99 47
Interpolated.
snow_density_w99 48
Interpolated.
snow_density_w99 49
Interpolated.
snow_density_w99 50
Interpolated.
snow_density_w99 51
Interpolated.
snow_density_w99 52
Interpolated.
snow_density_w99 53
Interpolated.
snow_density_w99 54
Interpolated.
snow_density_w99 55
Interpolated.
Creating/forcing new variable ice_thickness_mw99_int
ice_thickness_mw99 0
Interpolated.
ice_thickness_mw99 1
Interpolated.
ice_thickness_mw99 2
Interpolated.
ice_thickness_mw99 3
Interpolated.
ice_thickness_mw99 4
Interpolated.
ice_thickness_mw99 5
Interpolated.
ice_thickness_mw99 6
no data or issue with gridding, so skipping...
ice_thickness_mw99 7
no data or issue with gridding, so skipping...
ice_thickness_mw99 8
no data or issue with gridding, so skipping...
ice_thickness_mw99 9
Interpolated.
ice_thickness_mw99 10
Interpolated.
ice_thickness_mw99 11
Interpolated.
ice_thickness_mw99 12
Interpolated.
ice_thickness_mw99 13
Interpolated.
ice_thickness_mw99 14
Interpolated.
ice_thickness_mw99 15
Interpolated.
ice_thickness_mw99 16
Interpolated.
ice_thickness_mw99 17
no data or issue with gridding, so skipping...
ice_thickness_mw99 18
no data or issue with gridding, so skipping...
ice_thickness_mw99 19
no data or issue with gridding, so skipping...
ice_thickness_mw99 20
no data or issue with gridding, so skipping...
ice_thickness_mw99 21
Interpolated.
ice_thickness_mw99 22
Interpolated.
ice_thickness_mw99 23
Interpolated.
ice_thickness_mw99 24
Interpolated.
ice_thickness_mw99 25
Interpolated.
ice_thickness_mw99 26
Interpolated.
ice_thickness_mw99 27
Interpolated.
ice_thickness_mw99 28
Interpolated.
ice_thickness_mw99 29
no data or issue with gridding, so skipping...
ice_thickness_mw99 30
no data or issue with gridding, so skipping...
ice_thickness_mw99 31
no data or issue with gridding, so skipping...
ice_thickness_mw99 32
Interpolated.
ice_thickness_mw99 33
Interpolated.
ice_thickness_mw99 34
Interpolated.
ice_thickness_mw99 35
Interpolated.
ice_thickness_mw99 36
Interpolated.
ice_thickness_mw99 37
Interpolated.
ice_thickness_mw99 38
Interpolated.
ice_thickness_mw99 39
Interpolated.
ice_thickness_mw99 40
Interpolated.
ice_thickness_mw99 41
Interpolated.
ice_thickness_mw99 42
Interpolated.
ice_thickness_mw99 43
Interpolated.
ice_thickness_mw99 44
Interpolated.
ice_thickness_mw99 45
Interpolated.
ice_thickness_mw99 46
Interpolated.
ice_thickness_mw99 47
Interpolated.
ice_thickness_mw99 48
Interpolated.
ice_thickness_mw99 49
Interpolated.
ice_thickness_mw99 50
Interpolated.
ice_thickness_mw99 51
Interpolated.
ice_thickness_mw99 52
Interpolated.
ice_thickness_mw99 53
Interpolated.
ice_thickness_mw99 54
Interpolated.
ice_thickness_mw99 55
Interpolated.
Creating/forcing new variable ice_density_j22_int
ice_density_j22 0
Interpolated.
ice_density_j22 1
Interpolated.
ice_density_j22 2
Interpolated.
ice_density_j22 3
Interpolated.
ice_density_j22 4
Interpolated.
ice_density_j22 5
Interpolated.
ice_density_j22 6
Interpolated.
ice_density_j22 7
Interpolated.
ice_density_j22 8
Interpolated.
ice_density_j22 9
Interpolated.
ice_density_j22 10
Interpolated.
ice_density_j22 11
Interpolated.
ice_density_j22 12
Interpolated.
ice_density_j22 13
Interpolated.
ice_density_j22 14
Interpolated.
ice_density_j22 15
Interpolated.
ice_density_j22 16
Interpolated.
ice_density_j22 17
Interpolated.
ice_density_j22 18
Interpolated.
ice_density_j22 19
Interpolated.
ice_density_j22 20
Interpolated.
ice_density_j22 21
Interpolated.
ice_density_j22 22
Interpolated.
ice_density_j22 23
Interpolated.
ice_density_j22 24
Interpolated.
ice_density_j22 25
Interpolated.
ice_density_j22 26
Interpolated.
ice_density_j22 27
Interpolated.
ice_density_j22 28
Interpolated.
ice_density_j22 29
Interpolated.
ice_density_j22 30
Interpolated.
ice_density_j22 31
Interpolated.
ice_density_j22 32
Interpolated.
ice_density_j22 33
Interpolated.
ice_density_j22 34
Interpolated.
ice_density_j22 35
Interpolated.
ice_density_j22 36
Interpolated.
ice_density_j22 37
Interpolated.
ice_density_j22 38
Interpolated.
ice_density_j22 39
Interpolated.
ice_density_j22 40
Interpolated.
ice_density_j22 41
Interpolated.
ice_density_j22 42
Interpolated.
ice_density_j22 43
Interpolated.
ice_density_j22 44
Interpolated.
ice_density_j22 45
Interpolated.
ice_density_j22 46
Interpolated.
ice_density_j22 47
Interpolated.
ice_density_j22 48
Interpolated.
ice_density_j22 49
Interpolated.
ice_density_j22 50
Interpolated.
ice_density_j22 51
Interpolated.
ice_density_j22 52
Interpolated.
ice_density_j22 53
Interpolated.
ice_density_j22 54
Interpolated.
ice_density_j22 55
Interpolated.
Creating/forcing new variable ice_thickness_j22_int
ice_thickness_j22 0
Interpolated.
ice_thickness_j22 1
Interpolated.
ice_thickness_j22 2
Interpolated.
ice_thickness_j22 3
Interpolated.
ice_thickness_j22 4
Interpolated.
ice_thickness_j22 5
Interpolated.
ice_thickness_j22 6
no data or issue with gridding, so skipping...
ice_thickness_j22 7
no data or issue with gridding, so skipping...
ice_thickness_j22 8
no data or issue with gridding, so skipping...
ice_thickness_j22 9
Interpolated.
ice_thickness_j22 10
Interpolated.
ice_thickness_j22 11
Interpolated.
ice_thickness_j22 12
Interpolated.
ice_thickness_j22 13
Interpolated.
ice_thickness_j22 14
Interpolated.
ice_thickness_j22 15
Interpolated.
ice_thickness_j22 16
Interpolated.
ice_thickness_j22 17
no data or issue with gridding, so skipping...
ice_thickness_j22 18
no data or issue with gridding, so skipping...
ice_thickness_j22 19
no data or issue with gridding, so skipping...
ice_thickness_j22 20
no data or issue with gridding, so skipping...
ice_thickness_j22 21
Interpolated.
ice_thickness_j22 22
Interpolated.
ice_thickness_j22 23
Interpolated.
ice_thickness_j22 24
Interpolated.
ice_thickness_j22 25
Interpolated.
ice_thickness_j22 26
Interpolated.
ice_thickness_j22 27
Interpolated.
ice_thickness_j22 28
Interpolated.
ice_thickness_j22 29
no data or issue with gridding, so skipping...
ice_thickness_j22 30
no data or issue with gridding, so skipping...
ice_thickness_j22 31
no data or issue with gridding, so skipping...
ice_thickness_j22 32
Interpolated.
ice_thickness_j22 33
Interpolated.
ice_thickness_j22 34
Interpolated.
ice_thickness_j22 35
Interpolated.
ice_thickness_j22 36
Interpolated.
ice_thickness_j22 37
Interpolated.
ice_thickness_j22 38
Interpolated.
ice_thickness_j22 39
Interpolated.
ice_thickness_j22 40
Interpolated.
ice_thickness_j22 41
Interpolated.
ice_thickness_j22 42
Interpolated.
ice_thickness_j22 43
Interpolated.
ice_thickness_j22 44
Interpolated.
ice_thickness_j22 45
Interpolated.
ice_thickness_j22 46
Interpolated.
ice_thickness_j22 47
Interpolated.
ice_thickness_j22 48
Interpolated.
ice_thickness_j22 49
Interpolated.
ice_thickness_j22 50
Interpolated.
ice_thickness_j22 51
Interpolated.
ice_thickness_j22 52
Interpolated.
ice_thickness_j22 53
Interpolated.
ice_thickness_j22 54
Interpolated.
ice_thickness_j22 55
Interpolated.
done, returning new dataset
# Get UBRIS/UIT CS-2 data
start_date_cs2 = "Oct 2018"
end_date_cs2 = "July 2021"
# NB: MS indicates a time frequency of start of the month
date_range_cs2 = pd.date_range(start=start_date_cs2, end=end_date_cs2, freq='MS') 

# Re-grid the UBRIS/UIT CS-2 data to the IS-2 grid.
# Includes monthly resampling of the biweekly data
cs2_ubris = regrid_ubris_to_is2(mapProj, xIS2, yIS2, out_lons, out_lats, date_range_cs2,
                             dataPathCS2=current_directory+'/data/', dataset='uit_cryosat2_seaicethickness_nh_80km_v1p7.nc')

# Relabel the cs2_sea_ice_thickness_UBRIS variable to ice_thickness_cs2_ubris
cs2_ubris = cs2_ubris.rename({'cs2_sea_ice_thickness_UBRIS': 'ice_thickness_cs2_ubris'})
# Get the preliminary IS-2/CS-2 winter snow depths, downlaoded from Zenodo
cs2is2_snow_regridded_da = get_cs2is2_snow(mapProj, xIS2, yIS2, dataPathCS2=current_directory+'/data/uit_cs2-is2-ak_snow_depth_25km_v3.nc')
# Merge with other CS-2 data
cs2_ubris = cs2_ubris.merge({'cs2is2_snow_depth': cs2is2_snow_regridded_da})
# Merge all season IS-2 data and CS-2 datasets
IS2_CS2_allseason = IS2SITMOGR4_allseason.merge(cs2_ubris)

# Adjust all times to the middle (15th) of the month for plotting purposes
# (generally time defaults to the start of the month, with the MS function)
IS2_CS2_allseason['time'] = IS2_CS2_allseason['time'] + pd.Timedelta(days=14)
# Remove data outside of the period coincident with the SM-LG/IS-2 data
IS2_CS2_allseason = IS2_CS2_allseason.where(IS2_CS2_allseason['time'] <= pd.Timestamp('2021-07-20'), drop=True)
IS2_CS2_allseason = IS2_CS2_allseason.where(IS2_CS2_allseason['time'] >= pd.Timestamp('2018-11-01'), drop=True)
#IS2_CS2_allseason
# Only need the region mask for the first time step (missing from time=0 for some reason...)
IS2_CS2_allseason['region_mask'] = IS2_CS2_allseason['region_mask'].isel(time=1, drop=True)
# Save the dataset to netCDF file
output_path = './data/book_data_allseason.nc'
IS2_CS2_allseason.to_netcdf(output_path)

print(f"Dataset saved to {output_path}")
Dataset saved to ./data/book_data_allseason.nc
# Test loading the saved file
test_load = xr.open_dataset('./data/book_data_allseason.nc')
print("Successfully loaded saved dataset")
Successfully loaded saved dataset