{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Converting NetCDF into COGs\n", "Copying the data from the network drive using a wildcard to get SWE maps. \\\n", "Then using a function defined in utils.py to convert the NetCDF files into COGs. " ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import warnings\n", "import xarray as xr\n", "from rasterio.errors import NotGeoreferencedWarning\n", "from utils import copy_netcdf_data, netcdf_to_cog\n", "\n", "warnings.filterwarnings(\"ignore\", category=NotGeoreferencedWarning)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Find and copy the SWE data to the data folder\n", "netcdf_path = '/mnt/CEPH_PROJECTS/PROSNOW/SENTINEL-2/Daily_SCA/Venosta/*_swe.nc'\n", "output = './data'\n", "\n", "copy_netcdf_data(netcdf_path, output)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/jzvolensky/eurac/projects/swe-maps-stac/swe_maps_stac/utils.py:30: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.\n", " transform = rasterio.transform.from_bounds(dataset.x[0], dataset.y[-1], dataset.x[-1], dataset.y[0], dataset.dims['x'], dataset.dims['y'])\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "COG creation time: 10.03 seconds\n" ] } ], "source": [ "cogs= netcdf_to_cog(netcdf_path = './data/venosta_hy1718_swe.nc',\n", " cog_dir = './output_cog/venosta_1718_cog/',\n", " swe_name_year = 'venosta_1718_swe'\n", " )" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 2 }