# Why would I use UAVSAR for snow?¶

L-band SAR penetrates through the snowpack. However when it crosses into the snowpack from the air it refracts at an angle, similar to light entering water. This refraction leads to a phase shift relative to an image with no or less snow. Using this difference in phase between two images we can calculate the change in snow height between flights using:

$\Delta d = - \frac{\Delta \phi \lambda}{4 \pi} \frac{1}{\cos^{ } \alpha - \sqrt{\epsilon_{s} - \sin^{2} \alpha}}$

Where $$\Delta$$ d is the change in snow height, $$\Delta \phi$$ is the phase shift between two SAR images, $$\lambda$$ is the radar wavelength, $$\alpha$$ is the incidence angle, and $$\epsilon_{s}$$ is the dielectric constant of snow which is dependent on the density and liquid water content. Fig. 5 Conceptual diagram of radar refraction across the air-snow interface.

import os
# clone tifs to tmp directory
os.chdir('/tmp/')
if not os.path.exists('/tmp/uavsar-tutorial-data'):
!git clone --quiet https://github.com/SnowEx/uavsar-tutorial-data.git

data_dir = '/tmp/uavsar-tutorial-data/'
os.chdir(data_dir)
# ! ls -l


### Import Libraries¶

# Database imports
from snowexsql.db import get_db
from snowexsql.data import PointData, ImageData, LayerData, SiteData
from snowexsql.conversions import query_to_geopandas

# Uavsar_pytools imports
from uavsar_pytools.snow_depth_inversion import depth_from_phase, phase_from_depth

# Other imports
from os.path import join
from datetime import date
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from shapely.geometry import box
import rasterio as rio
import rioxarray as rxa
import contextily as cx
import holoviews as hv
import rioxarray as rxa
from bokeh.plotting import show