npsphinx prolog… I dont know what to write here….

[1]:
import holoviews as hv
hv.extension('bokeh')
import geoviews as gv

import numpy as np
from glob import glob
from time import time

import os, sys
from slcl1butils.get_polygons_from_l1b import get_swath_tiles_polygons_from_l1bfiles
config path: /home/docs/checkouts/readthedocs.org/user_builds/slcl1butils/checkouts/latest/slcl1butils/config.yaml
[2]:
from slcl1butils.utils import get_test_file
one_safe_l1b = get_test_file('S1B_IW_XSP__1SDV_20211026T045709_20211026T045736_029302_037F35_1CD7.SAFE')
l1bncfile_pattern = os.path.join(one_safe_l1b,'*iw*vv*nc')
print(l1bncfile_pattern)
files = glob(l1bncfile_pattern)
len(files)
/home/docs/checkouts/readthedocs.org/user_builds/slcl1butils/checkouts/latest/assests/S1B_IW_XSP__1SDV_20211026T045709_20211026T045736_029302_037F35_1CD7.SAFE/*iw*vv*nc
[2]:
3

Load the polygons pts and corresponding variables from L1B

[3]:
polygons,coordinates,variables = get_swath_tiles_polygons_from_l1bfiles(files,variable_names=['sigma0'])

Define boundaries for each variable to adjust the colorbar

[4]:
#burst_type = 'intra'
burst_type = 'intra'
varis = [var for var in variables['intra'].keys()]
for var in varis:
    variables[burst_type][var+'_clim'] = (np.nanpercentile(np.array(variables[burst_type][var]), 1.), np.nanpercentile(np.array(variables[burst_type][var]),99.))

Example for plotting the NRCS (sigma0)

[5]:
vari = 'sigma0'
variable = variables[burst_type][vari]
clim = variables[burst_type][vari+'_clim']

Build the polygons and associated color for each tiles

[6]:
gsigvv = []
for cpt in np.arange(len(variable)):
    pts= [(i,j) for i,j in zip(polygons[burst_type]['tiles'][cpt].exterior.xy[0].tolist(),polygons[burst_type]['tiles'][cpt].exterior.xy[1].tolist())]
    gsigvv.append(gv.Polygons({('Longitude','Latitude'): pts, 'level':variable[cpt]},vdims='level',kdims=['Longitude','Latitude']).opts(color='NA',colorbar=True,cmap='Greys_r',clim=clim,alpha=0.75, muted_alpha=0))

Build the polygons for tile intra and tiles inter, swath and map background

[7]:
# Background cartography
gvvbckg = gv.tile_sources.EsriImagery
# Swath limits
gvvswath = gv.Polygons(polygons['intra']['swath'],label='swath').opts(fill_color='white',
                                                                      alpha=0.25,show_legend=True, muted_alpha=0,tools=['hover'])
# Intra and inter bursts polygons
gvvtile_intra = gv.Polygons(polygons['intra']['tiles'],label='intraburst tiles').opts(fill_color='blue',
                                                                    alpha=0.25, show_legend=True, muted_alpha=0,tools=['hover'])
gvvtile_inter = gv.Polygons(polygons['inter']['tiles'],label='interburst tiles').opts(fill_color='red',
                                                                                      alpha=0.25,show_legend=True, muted_alpha=0)

Simple direct plotting

[8]:
(gvvbckg*gvvswath*gvvtile_intra*gvvtile_inter*hv.Overlay(gsigvv)).opts(width=1000,height=1500,tools=['hover'], legend_position='top_right')
[8]: