# 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()
# 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
---------------------------------------------------------------------------
gaierror Traceback (most recent call last)
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiohttp/connector.py:1155, in TCPConnector._create_direct_connection(self, req, traces, timeout, client_error)
1151 try:
1152 # Cancelling this lookup should not cancel the underlying lookup
1153 # or else the cancel event will get broadcast to all the waiters
1154 # across all connections.
-> 1155 hosts = await asyncio.shield(host_resolved)
1156 except asyncio.CancelledError:
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiohttp/connector.py:874, in TCPConnector._resolve_host(self, host, port, traces)
872 await trace.send_dns_resolvehost_start(host)
--> 874 addrs = await self._resolver.resolve(host, port, family=self._family)
875 if traces:
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiohttp/resolver.py:33, in ThreadedResolver.resolve(self, hostname, port, family)
30 async def resolve(
31 self, hostname: str, port: int = 0, family: int = socket.AF_INET
32 ) -> List[Dict[str, Any]]:
---> 33 infos = await self._loop.getaddrinfo(
34 hostname,
35 port,
36 type=socket.SOCK_STREAM,
37 family=family,
38 flags=socket.AI_ADDRCONFIG,
39 )
41 hosts = []
File ~/miniconda3/envs/p39m/lib/python3.9/asyncio/base_events.py:861, in BaseEventLoop.getaddrinfo(self, host, port, family, type, proto, flags)
859 getaddr_func = socket.getaddrinfo
--> 861 return await self.run_in_executor(
862 None, getaddr_func, host, port, family, type, proto, flags)
File ~/miniconda3/envs/p39m/lib/python3.9/concurrent/futures/thread.py:58, in _WorkItem.run(self)
57 try:
---> 58 result = self.fn(*self.args, **self.kwargs)
59 except BaseException as exc:
File ~/miniconda3/envs/p39m/lib/python3.9/socket.py:954, in getaddrinfo(host, port, family, type, proto, flags)
953 addrlist = []
--> 954 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
955 af, socktype, proto, canonname, sa = res
gaierror: [Errno 8] nodename nor servname provided, or not known
The above exception was the direct cause of the following exception:
ClientConnectorError Traceback (most recent call last)
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/httpsession.py:208, in AIOHTTPSession.send(self, request)
207 url = URL(url, encoded=True)
--> 208 response = await self._session.request(
209 request.method,
210 url=url,
211 chunked=chunked,
212 headers=headers_,
213 data=data,
214 proxy=proxy_url,
215 proxy_headers=proxy_headers,
216 )
218 http_response = aiobotocore.awsrequest.AioAWSResponse(
219 str(response.url), response.status, response.headers, response
220 )
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiohttp/client.py:562, in ClientSession._request(self, method, str_or_url, params, data, json, cookies, headers, skip_auto_headers, auth, allow_redirects, max_redirects, compress, chunked, expect100, raise_for_status, read_until_eof, proxy, proxy_auth, timeout, verify_ssl, fingerprint, ssl_context, ssl, proxy_headers, trace_request_ctx, read_bufsize)
561 assert self._connector is not None
--> 562 conn = await self._connector.connect(
563 req, traces=traces, timeout=real_timeout
564 )
565 except asyncio.TimeoutError as exc:
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiohttp/connector.py:540, in BaseConnector.connect(self, req, traces, timeout)
539 try:
--> 540 proto = await self._create_connection(req, traces, timeout)
541 if self._closed:
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiohttp/connector.py:901, in TCPConnector._create_connection(self, req, traces, timeout)
900 else:
--> 901 _, proto = await self._create_direct_connection(req, traces, timeout)
903 return proto
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiohttp/connector.py:1169, in TCPConnector._create_direct_connection(self, req, traces, timeout, client_error)
1167 # in case of proxy it is not ClientProxyConnectionError
1168 # it is problem of resolving proxy ip itself
-> 1169 raise ClientConnectorError(req.connection_key, exc) from exc
1171 last_exc: Optional[Exception] = None
ClientConnectorError: Cannot connect to host icesat-2-sea-ice-us-west-2.s3.us-west-2.amazonaws.com:443 ssl:default [nodename nor servname provided, or not known]
During handling of the above exception, another exception occurred:
EndpointConnectionError Traceback (most recent call last)
Cell In[2], line 2
1 # Load the winter IS-2 thickness data from zarr/s3
----> 2 IS2SITMOGR4_v3 = read_IS2SITMOGR4(data_type='zarr-s3', persist=True)
3 #IS2SITMOGR4_v3
File ~/GitHub/icesat2-book/content/utils/read_data_utils.py:122, in read_IS2SITMOGR4(data_type, version, local_data_path, zarr_path, netcdf_s3_path, persist)
119 is2_ds = is2_ds.assign_coords(latitude=(["y","x"], is2_ds.latitude.values))
121 if persist==True:
--> 122 is2_ds = is2_ds.persist()
124 return is2_ds
126 if data_type=='netcdf-s3':
127 # Download data from S3 to local bucket
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/xarray/core/dataset.py:1037, in Dataset.persist(self, **kwargs)
1019 """Trigger computation, keeping data as dask arrays
1020
1021 This operation can be used to trigger computation on underlying dask
(...)
1034 dask.persist
1035 """
1036 new = self.copy(deep=False)
-> 1037 return new._persist_inplace(**kwargs)
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/xarray/core/dataset.py:1011, in Dataset._persist_inplace(self, **kwargs)
1008 import dask
1010 # evaluate all the dask arrays simultaneously
-> 1011 evaluated_data = dask.persist(*lazy_data.values(), **kwargs)
1013 for k, data in zip(lazy_data, evaluated_data):
1014 self.variables[k].data = data
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/dask/base.py:931, in persist(traverse, optimize_graph, scheduler, *args, **kwargs)
928 postpersists.append((rebuild, a_keys, state))
930 with shorten_traceback():
--> 931 results = schedule(dsk, keys, **kwargs)
933 d = dict(zip(keys, results))
934 results2 = [r({k: d[k] for k in ks}, *s) for r, ks, s in postpersists]
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/xarray/core/indexing.py:487, in ImplicitToExplicitIndexingAdapter.__array__(self, dtype)
486 def __array__(self, dtype: np.typing.DTypeLike = None) -> np.ndarray:
--> 487 return np.asarray(self.get_duck_array(), dtype=dtype)
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/xarray/core/indexing.py:490, in ImplicitToExplicitIndexingAdapter.get_duck_array(self)
489 def get_duck_array(self):
--> 490 return self.array.get_duck_array()
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/xarray/core/indexing.py:667, in CopyOnWriteArray.get_duck_array(self)
666 def get_duck_array(self):
--> 667 return self.array.get_duck_array()
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/xarray/core/indexing.py:560, in LazilyIndexedArray.get_duck_array(self)
555 # self.array[self.key] is now a numpy array when
556 # self.array is a BackendArray subclass
557 # and self.key is BasicIndexer((slice(None, None, None),))
558 # so we need the explicit check for ExplicitlyIndexed
559 if isinstance(array, ExplicitlyIndexed):
--> 560 array = array.get_duck_array()
561 return _wrap_numpy_scalars(array)
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/xarray/coding/variables.py:74, in _ElementwiseFunctionArray.get_duck_array(self)
73 def get_duck_array(self):
---> 74 return self.func(self.array.get_duck_array())
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/xarray/core/indexing.py:554, in LazilyIndexedArray.get_duck_array(self)
553 def get_duck_array(self):
--> 554 array = self.array[self.key]
555 # self.array[self.key] is now a numpy array when
556 # self.array is a BackendArray subclass
557 # and self.key is BasicIndexer((slice(None, None, None),))
558 # so we need the explicit check for ExplicitlyIndexed
559 if isinstance(array, ExplicitlyIndexed):
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/xarray/backends/zarr.py:92, in ZarrArrayWrapper.__getitem__(self, key)
90 array = self.get_array()
91 if isinstance(key, indexing.BasicIndexer):
---> 92 return array[key.tuple]
93 elif isinstance(key, indexing.VectorizedIndexer):
94 return array.vindex[
95 indexing._arrayize_vectorized_indexer(key, self.shape).tuple
96 ]
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/zarr/core.py:798, in Array.__getitem__(self, selection)
796 result = self.vindex[selection]
797 elif is_pure_orthogonal_indexing(pure_selection, self.ndim):
--> 798 result = self.get_orthogonal_selection(pure_selection, fields=fields)
799 else:
800 result = self.get_basic_selection(pure_selection, fields=fields)
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/zarr/core.py:1080, in Array.get_orthogonal_selection(self, selection, out, fields)
1077 # setup indexer
1078 indexer = OrthogonalIndexer(selection, self)
-> 1080 return self._get_selection(indexer=indexer, out=out, fields=fields)
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/zarr/core.py:1343, in Array._get_selection(self, indexer, out, fields)
1340 if math.prod(out_shape) > 0:
1341 # allow storage to get multiple items at once
1342 lchunk_coords, lchunk_selection, lout_selection = zip(*indexer)
-> 1343 self._chunk_getitems(
1344 lchunk_coords,
1345 lchunk_selection,
1346 out,
1347 lout_selection,
1348 drop_axes=indexer.drop_axes,
1349 fields=fields,
1350 )
1351 if out.shape:
1352 return out
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/zarr/core.py:2179, in Array._chunk_getitems(self, lchunk_coords, lchunk_selection, out, lout_selection, drop_axes, fields)
2177 if not isinstance(self._meta_array, np.ndarray):
2178 contexts = ConstantMap(ckeys, constant=Context(meta_array=self._meta_array))
-> 2179 cdatas = self.chunk_store.getitems(ckeys, contexts=contexts)
2181 for ckey, chunk_select, out_select in zip(ckeys, lchunk_selection, lout_selection):
2182 if ckey in cdatas:
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/zarr/storage.py:1435, in FSStore.getitems(self, keys, contexts)
1432 continue
1433 elif isinstance(v, Exception):
1434 # Raise any other exception
-> 1435 raise v
1436 else:
1437 # The function calling this method may not recognize the transformed
1438 # keys, so we send the values returned by self.map.getitems back into
1439 # the original key space.
1440 results[keys_transformed[k]] = v
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/fsspec/asyn.py:245, in _run_coros_in_chunks.<locals>._run_coro(coro, i)
243 async def _run_coro(coro, i):
244 try:
--> 245 return await asyncio.wait_for(coro, timeout=timeout), i
246 except Exception as e:
247 if not return_exceptions:
File ~/miniconda3/envs/p39m/lib/python3.9/asyncio/tasks.py:442, in wait_for(fut, timeout, loop)
437 warnings.warn("The loop argument is deprecated since Python 3.8, "
438 "and scheduled for removal in Python 3.10.",
439 DeprecationWarning, stacklevel=2)
441 if timeout is None:
--> 442 return await fut
444 if timeout <= 0:
445 fut = ensure_future(fut, loop=loop)
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/s3fs/core.py:1128, in S3FileSystem._cat_file(self, path, version_id, start, end)
1125 finally:
1126 resp["Body"].close()
-> 1128 return await _error_wrapper(_call_and_read, retries=self.retries)
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/s3fs/core.py:145, in _error_wrapper(func, args, kwargs, retries)
143 err = e
144 err = translate_boto_error(err)
--> 145 raise err
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/s3fs/core.py:113, in _error_wrapper(func, args, kwargs, retries)
111 for i in range(retries):
112 try:
--> 113 return await func(*args, **kwargs)
114 except S3_RETRYABLE_ERRORS as e:
115 err = e
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/s3fs/core.py:1115, in S3FileSystem._cat_file.<locals>._call_and_read()
1114 async def _call_and_read():
-> 1115 resp = await self._call_s3(
1116 "get_object",
1117 Bucket=bucket,
1118 Key=key,
1119 **version_id_kw(version_id or vers),
1120 **head,
1121 **self.req_kw,
1122 )
1123 try:
1124 return await resp["Body"].read()
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/s3fs/core.py:365, in S3FileSystem._call_s3(self, method, *akwarglist, **kwargs)
363 logger.debug("CALL: %s - %s - %s", method.__name__, akwarglist, kw2)
364 additional_kwargs = self._get_s3_method_kwargs(method, *akwarglist, **kwargs)
--> 365 return await _error_wrapper(
366 method, kwargs=additional_kwargs, retries=self.retries
367 )
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/s3fs/core.py:145, in _error_wrapper(func, args, kwargs, retries)
143 err = e
144 err = translate_boto_error(err)
--> 145 raise err
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/s3fs/core.py:113, in _error_wrapper(func, args, kwargs, retries)
111 for i in range(retries):
112 try:
--> 113 return await func(*args, **kwargs)
114 except S3_RETRYABLE_ERRORS as e:
115 err = e
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/client.py:366, in AioBaseClient._make_api_call(self, operation_name, api_params)
362 maybe_compress_request(
363 self.meta.config, request_dict, operation_model
364 )
365 apply_request_checksum(request_dict)
--> 366 http, parsed_response = await self._make_request(
367 operation_model, request_dict, request_context
368 )
370 await self.meta.events.emit(
371 'after-call.{service_id}.{operation_name}'.format(
372 service_id=service_id, operation_name=operation_name
(...)
377 context=request_context,
378 )
380 if http.status_code >= 300:
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/client.py:391, in AioBaseClient._make_request(self, operation_model, request_dict, request_context)
387 async def _make_request(
388 self, operation_model, request_dict, request_context
389 ):
390 try:
--> 391 return await self._endpoint.make_request(
392 operation_model, request_dict
393 )
394 except Exception as e:
395 await self.meta.events.emit(
396 'after-call-error.{service_id}.{operation_name}'.format(
397 service_id=self._service_model.service_id.hyphenize(),
(...)
401 context=request_context,
402 )
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/endpoint.py:100, in AioEndpoint._send_request(self, request_dict, operation_model)
96 request = await self.create_request(request_dict, operation_model)
97 success_response, exception = await self._get_response(
98 request, operation_model, context
99 )
--> 100 while await self._needs_retry(
101 attempts,
102 operation_model,
103 request_dict,
104 success_response,
105 exception,
106 ):
107 attempts += 1
108 self._update_retries_context(context, attempts, success_response)
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/endpoint.py:262, in AioEndpoint._needs_retry(self, attempts, operation_model, request_dict, response, caught_exception)
260 service_id = operation_model.service_model.service_id.hyphenize()
261 event_name = f"needs-retry.{service_id}.{operation_model.name}"
--> 262 responses = await self._event_emitter.emit(
263 event_name,
264 response=response,
265 endpoint=self,
266 operation=operation_model,
267 attempts=attempts,
268 caught_exception=caught_exception,
269 request_dict=request_dict,
270 )
271 handler_response = first_non_none_response(responses)
272 if handler_response is None:
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/hooks.py:66, in AioHierarchicalEmitter._emit(self, event_name, kwargs, stop_on_response)
63 logger.debug('Event %s: calling handler %s', event_name, handler)
65 # Await the handler if its a coroutine.
---> 66 response = await resolve_awaitable(handler(**kwargs))
67 responses.append((handler, response))
68 if stop_on_response and response is not None:
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/_helpers.py:15, in resolve_awaitable(obj)
13 async def resolve_awaitable(obj):
14 if inspect.isawaitable(obj):
---> 15 return await obj
17 return obj
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/retryhandler.py:107, in AioRetryHandler._call(self, attempts, response, caught_exception, **kwargs)
104 retries_context = kwargs['request_dict']['context'].get('retries')
105 checker_kwargs.update({'retries_context': retries_context})
--> 107 if await resolve_awaitable(self._checker(**checker_kwargs)):
108 result = self._action(attempts=attempts)
109 logger.debug("Retry needed, action of: %s", result)
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/_helpers.py:15, in resolve_awaitable(obj)
13 async def resolve_awaitable(obj):
14 if inspect.isawaitable(obj):
---> 15 return await obj
17 return obj
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/retryhandler.py:126, in AioMaxAttemptsDecorator._call(self, attempt_number, response, caught_exception, retries_context)
121 if retries_context:
122 retries_context['max'] = max(
123 retries_context.get('max', 0), self._max_attempts
124 )
--> 126 should_retry = await self._should_retry(
127 attempt_number, response, caught_exception
128 )
129 if should_retry:
130 if attempt_number >= self._max_attempts:
131 # explicitly set MaxAttemptsReached
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/retryhandler.py:165, in AioMaxAttemptsDecorator._should_retry(self, attempt_number, response, caught_exception)
161 return True
162 else:
163 # If we've exceeded the max attempts we just let the exception
164 # propagate if one has occurred.
--> 165 return await resolve_awaitable(
166 self._checker(attempt_number, response, caught_exception)
167 )
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/_helpers.py:15, in resolve_awaitable(obj)
13 async def resolve_awaitable(obj):
14 if inspect.isawaitable(obj):
---> 15 return await obj
17 return obj
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/retryhandler.py:174, in AioMultiChecker._call(self, attempt_number, response, caught_exception)
171 async def _call(self, attempt_number, response, caught_exception):
172 for checker in self._checkers:
173 checker_response = await resolve_awaitable(
--> 174 checker(attempt_number, response, caught_exception)
175 )
176 if checker_response:
177 return checker_response
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/botocore/retryhandler.py:247, in BaseChecker.__call__(self, attempt_number, response, caught_exception)
245 return self._check_response(attempt_number, response)
246 elif caught_exception is not None:
--> 247 return self._check_caught_exception(
248 attempt_number, caught_exception
249 )
250 else:
251 raise ValueError("Both response and caught_exception are None.")
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/botocore/retryhandler.py:416, in ExceptionRaiser._check_caught_exception(self, attempt_number, caught_exception)
408 def _check_caught_exception(self, attempt_number, caught_exception):
409 # This is implementation specific, but this class is useful by
410 # coordinating with the MaxAttemptsDecorator.
(...)
414 # the MaxAttemptsDecorator is not interested in retrying the exception
415 # then this exception just propogates out past the retry code.
--> 416 raise caught_exception
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/endpoint.py:181, in AioEndpoint._do_get_response(self, request, operation_model, context)
179 http_response = first_non_none_response(responses)
180 if http_response is None:
--> 181 http_response = await self._send(request)
182 except HTTPClientError as e:
183 return (None, e)
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/endpoint.py:285, in AioEndpoint._send(self, request)
284 async def _send(self, request):
--> 285 return await self.http_session.send(request)
File ~/miniconda3/envs/p39m/lib/python3.9/site-packages/aiobotocore/httpsession.py:253, in AIOHTTPSession.send(self, request)
247 raise ReadTimeoutError(endpoint_url=request.url, error=e)
248 except (
249 ClientConnectorError,
250 ClientConnectionError,
251 socket.gaierror,
252 ) as e:
--> 253 raise EndpointConnectionError(endpoint_url=request.url, error=e)
254 except asyncio.TimeoutError as e:
255 raise ReadTimeoutError(endpoint_url=request.url, error=e)
EndpointConnectionError: Could not connect to the endpoint URL: "https://icesat-2-sea-ice-us-west-2.s3.us-west-2.amazonaws.com/IS2SITMOGR4_V3/IS2SITMOGR4_V3_201811-202404.zarr/ice_density_j22/20.0.0"
# 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