Example 1: Use of I2EM

1. Requirements

  • Installation of SenSE

2. I2EM for different incidence angles

[2]:
import sense
import sys
import os
import numpy as np
from sense.surface import I2EM
import matplotlib.pyplot as plt
import time
[3]:

def db(x):
    return 10.*np.log10(x)

theta_deg = np.linspace(0.,70., 71)
theta = np.deg2rad(theta_deg)

eps = 11.3-1.5j
f = 3.

s = 1./100.
l = 10./100.

hh1=[]
hh2=[]
vv1=[]
vv2=[]
hv1=[]
hv2=[]
xpol = True
auto=False
for t in theta:
    print(t)
    I1 = I2EM(f, eps, s, l, t, acf_type='gauss', xpol=xpol, auto=auto)
    I2 = I2EM(f, eps, s, l, t, acf_type='exp15', xpol=xpol, auto=auto)
    print(I1.ks, I1.kl)
    hh1.append(I1.hh)
    hh2.append(I2.hh)
    vv1.append(I1.vv)
    vv2.append(I2.vv)
    if xpol:
        hv1.append(I1.hv)
        hv2.append(I2.hv)

hh1 = np.array(hh1)
hh2 = np.array(hh2)
vv1 = np.array(vv1)
vv2 = np.array(vv2)
hv1 = np.array(hv1)
hv2 = np.array(hv2)
0.0
/media/wodan/data/Git/Github/mcwhity/sense/env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py:377: RuntimeWarning: divide by zero encountered in double_scalars
  ct = np.cos(self.theta)/np.sin(self.theta)
/media/wodan/data/Git/Github/mcwhity/sense/env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py:378: RuntimeWarning: divide by zero encountered in double_scalars
  cts = np.cos(self.thetas)/np.sin(self.thetas)
/media/wodan/data/Git/Github/mcwhity/sense/env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py:368: RuntimeWarning: divide by zero encountered in double_scalars
  ct = np.cos(self.theta)/np.sin(self.theta)
/media/wodan/data/Git/Github/mcwhity/sense/env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py:282: NumbaWarning: 
Compilation is falling back to object mode WITH looplifting enabled because Function "_xpol_integralfunc" failed type inference due to: non-precise type pyobject
During: typing of argument at /media/wodan/data/Git/Github/mcwhity/sense/env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py (291)

File "../../env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py", line 291:
    def _xpol_integralfunc(self, r, phi, *args):
        <source elided>

        rvh = args[0][0]
        ^

  @jit(cache=True)
/media/wodan/data/Git/Github/mcwhity/sense/env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py:282: NumbaWarning: 
Compilation is falling back to object mode WITHOUT looplifting enabled because Function "_xpol_integralfunc" failed type inference due to: Cannot determine Numba type of <class 'numba.core.dispatcher.LiftedLoop'>

File "../../env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py", line 335:
    def _xpol_integralfunc(self, r, phi, *args):
        <source elided>
        vhmnsum = 0.
        for i in xrange(nspec):
        ^

  @jit(cache=True)
/media/wodan/data/Git/Github/mcwhity/sense/env/lib/python3.10/site-packages/numba/core/object_mode_passes.py:151: NumbaWarning: Function "_xpol_integralfunc" was compiled in object mode without forceobj=True, but has lifted loops.

File "../../env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py", line 291:
    def _xpol_integralfunc(self, r, phi, *args):
        <source elided>

        rvh = args[0][0]
        ^

  warnings.warn(errors.NumbaWarning(warn_msg,
/media/wodan/data/Git/Github/mcwhity/sense/env/lib/python3.10/site-packages/numba/core/object_mode_passes.py:161: NumbaDeprecationWarning: 
Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour.

For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit

File "../../env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py", line 291:
    def _xpol_integralfunc(self, r, phi, *args):
        <source elided>

        rvh = args[0][0]
        ^

  warnings.warn(errors.NumbaDeprecationWarning(msg,
/media/wodan/data/Git/Github/mcwhity/sense/env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py:282: NumbaWarning: Cannot cache compiled function "_xpol_integralfunc" as it uses lifted code
  @jit(cache=True)
/media/wodan/data/Git/Github/mcwhity/sense/env/lib/python3.10/site-packages/numba/core/ir_utils.py:2147: NumbaPendingDeprecationWarning: 
Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'fac' of function 'I2EM._xpol_integralfunc'.

For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

File "../../env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py", line 335:
    def _xpol_integralfunc(self, r, phi, *args):
        <source elided>
        vhmnsum = 0.
        for i in xrange(nspec):
        ^

  warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc))
0.0007870779703274
/media/wodan/data/Git/Github/mcwhity/sense/env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py:377: RuntimeWarning: divide by zero encountered in double_scalars
  ct = np.cos(self.theta)/np.sin(self.theta)
/media/wodan/data/Git/Github/mcwhity/sense/env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py:378: RuntimeWarning: divide by zero encountered in double_scalars
  cts = np.cos(self.thetas)/np.sin(self.thetas)
/media/wodan/data/Git/Github/mcwhity/sense/env/lib/python3.10/site-packages/sense-0.1-py3.10.egg/sense/surface/i2em.py:368: RuntimeWarning: divide by zero encountered in double_scalars
  ct = np.cos(self.theta)/np.sin(self.theta)
0.001217568974107298
0.6287535065855046 6.287535065855046
0.017453292519943295
0.0007833912328427959
0.0012172347989278084
0.6287535065855046 6.287535065855046
0.03490658503988659
0.0007724472676413573
0.0012162267716881322
0.6287535065855046 6.287535065855046
0.05235987755982989
0.0007545881118301572
0.001214529526372035
0.6287535065855046 6.287535065855046
0.06981317007977318
0.0007303620486923845
0.0012121208734153857
0.6287535065855046 6.287535065855046
0.08726646259971647
0.0007004929128896699
0.0012089758043466103
0.6287535065855046 6.287535065855046
0.10471975511965978
0.0006658408050007181
0.0012050703982415306
0.6287535065855046 6.287535065855046
0.12217304763960307
0.0006273573948793676
0.001200384843099453
0.6287535065855046 6.287535065855046
0.13962634015954636
0.0005860392756843346
0.0011949052321223563
0.6287535065855046 6.287535065855046
0.15707963267948966
0.0005428826920074877
0.0011886241864850497
0.6287535065855046 6.287535065855046
0.17453292519943295
0.0004988426103502825
0.0011815405842379586
0.6287535065855046 6.287535065855046
0.19198621771937624
0.0004547984106345945
0.0011736587386531575
0.6287535065855046 6.287535065855046
0.20943951023931956
0.0004115276939570183
0.0011649873308396516
0.6287535065855046 6.287535065855046
0.22689280275926285
0.0003696888601976802
0.0011555383168453746
0.6287535065855046 6.287535065855046
0.24434609527920614
0.00032981232982490905
0.0011453259431630546
0.6287535065855046 6.287535065855046
0.2617993877991494
0.0002922995992110675
0.0011343659352043458
0.6287535065855046 6.287535065855046
0.2792526803190927
0.00025742891358188037
0.0011226748757403198
0.6287535065855046 6.287535065855046
0.29670597283903605
0.0002253659963137618
0.0011102697620355552
0.6287535065855046 6.287535065855046
0.3141592653589793
0.0001961781947318948
0.001097167715951632
0.6287535065855046 6.287535065855046
0.33161255787892263
0.0001698505134578716
0.0010833858196391808
0.6287535065855046 6.287535065855046
0.3490658503988659
0.00014630217887930718
0.0010689410446290857
0.6287535065855046 6.287535065855046
0.3665191429188092
0.00012540264020651176
0.001053850250613996
0.6287535065855046 6.287535065855046
0.3839724354387525
0.00010698622143712585
0.0010381302330911516
0.6287535065855046 6.287535065855046
0.4014257279586958
9.08649076661163e-05
0.001021797800825326
0.6287535065855046 6.287535065855046
0.4188790204786391
7.683907801347758e-05
0.0010048698719540643
0.6287535065855046 6.287535065855046
0.4363323129985824
6.47060088383194e-05
0.000987363578169959
0.6287535065855046 6.287535065855046
0.4537856055185257
5.426653191164206e-05
0.0009692963704122781
0.6287535065855046 6.287535065855046
0.47123889803846897
4.532972513738973e-05
0.0009506861213894736
0.6287535065855046 6.287535065855046
0.4886921905584123
3.7716171136690495e-05
0.0009315512220852859
0.6287535065855046 6.287535065855046
0.5061454830783556
3.125995923836093e-05
0.0009119106707282502
0.6287535065855046 6.287535065855046
0.5235987755982988
2.5809643512120262e-05
0.0008917841539695165
0.6287535065855046 6.287535065855046
0.5410520681182421
2.1228509680783093e-05
0.0008711921200975481
0.6287535065855046 6.287535065855046
0.5585053606381855
1.739439440907498e-05
0.0008501558460214563
0.6287535065855046 6.287535065855046
0.5759586531581288
1.4198967966629382e-05
0.00082869749860118
0.6287535065855046 6.287535065855046
0.5934119456780721
1.1546912405655916e-05
0.0008068401920696337
0.6287535065855046 6.287535065855046
0.6108652381980153
9.354909564715706e-06
0.0007846080439845066
0.6287535065855046 6.287535065855046
0.6283185307179586
7.550497840470289e-06
0.000762026230118149
0.6287535065855046 6.287535065855046
0.6457718232379019
6.071260526364211e-06
0.0007391210414130877
0.6287535065855046 6.287535065855046
0.6632251157578453
4.863511749804842e-06
0.0007159199440344537
0.6287535065855046 6.287535065855046
0.6806784082777885
3.881384545332372e-06
0.0006924516430656711
0.6287535065855046 6.287535065855046
0.6981317007977318
3.086045174187111e-06
0.0006687461528785964
0.6287535065855046 6.287535065855046
0.7155849933176751
2.4443915821997164e-06
0.0006448348722852194
0.6287535065855046 6.287535065855046
0.7330382858376184
1.9288780801218114e-06
0.0006207506673914341
0.6287535065855046 6.287535065855046
0.7504915783575618
1.516358430618686e-06
0.0005965279587456802
0.6287535065855046 6.287535065855046
0.767944870877505
1.1875669484556368e-06
0.0005722028145910166
0.6287535065855046 6.287535065855046
0.7853981633974483
9.265459572447714e-07
0.0005478130449529752
0.6287535065855046 6.287535065855046
0.8028514559173916
7.201426505168773e-07
0.0005233982965075161
0.6287535065855046 6.287535065855046
0.8203047484373349
5.575685009030334e-07
0.0004990001406306541
0.6287535065855046 6.287535065855046
0.8377580409572782
4.3002185362650245e-07
0.000474662151786069
0.6287535065855046 6.287535065855046
0.8552113334772214
3.303307094634452e-07
0.0004504299675672313
0.6287535065855046 6.287535065855046
0.8726646259971648
2.527601560583872e-07
0.00042635131979611564
0.6287535065855046 6.287535065855046
0.8901179185171081
1.9259400277359915e-07
0.00040247603076070987
0.6287535065855046 6.287535065855046
0.9075712110370514
1.461308982660359e-07
0.00037885595907687265
0.6287535065855046 6.287535065855046
0.9250245035569946
1.1041699084687379e-07
0.0003555448843663175
0.6287535065855046 6.287535065855046
0.9424777960769379
8.302792272512525e-08
0.00033259831761471554
0.6287535065855046 6.287535065855046
0.9599310885968813
6.213094503332646e-08
0.00031007322496553184
0.6287535065855046 6.287535065855046
0.9773843811168246
4.615174949469982e-08
0.00028802765423847253
0.6287535065855046 6.287535065855046
0.9948376736367679
3.426139822734052e-08
0.0002665202565423069
0.6287535065855046 6.287535065855046
1.0122909661567112
2.5311834376432677e-08
0.0002456096998640865
0.6287535065855046 6.287535065855046
1.0297442586766545
1.8606294346711813e-08
0.00022535397690892788
0.6287535065855046 6.287535065855046
1.0471975511965976
1.3605638829177466e-08
0.00020580961713832774
0.6287535065855046 6.287535065855046
1.064650843716541
9.8944931646004e-09
0.00018703081998928985
0.6287535065855046 6.287535065855046
1.0821041362364843
7.154229002248726e-09
0.00016906853363084692
0.6287535065855046 6.287535065855046
1.0995574287564276
5.1415091813315375e-09
0.00015196951465099243
0.6287535065855046 6.287535065855046
1.117010721276371
3.6713311782587867e-09
0.00013577539552523735
0.6287535065855046 6.287535065855046
1.1344640137963142
2.6036885221261765e-09
0.00012052181015805438
0.6287535065855046 6.287535065855046
1.1519173063162575
1.8331266950927074e-09
0.00010623760621810564
0.6287535065855046 6.287535065855046
1.1693705988362009
1.2806028943894302e-09
9.294418038433718e-05
0.6287535065855046 6.287535065855046
1.1868238913561442
8.871704176951327e-10
8.06549598981515e-05
0.6287535065855046 6.287535065855046
1.2042771838760873
6.091010720889855e-10
6.937504617069839e-05
0.6287535065855046 6.287535065855046
1.2217304763960306
4.1413548225238386e-10
5.910102462802539e-05
0.6287535065855046 6.287535065855046
[4]:
f = plt.figure()
ax = f.add_subplot(111)

# ax.plot(theta_deg, db(hh2), color='red', label='hh')
ax.plot(theta_deg, db(hh1), color='blue', label='hh')

# ax.plot(theta_deg, db(vv2), color='red', label='vv', linestyle='--')
ax.plot(theta_deg, db(vv1), color='blue', label='vv', linestyle='--')

# ax.plot(theta_deg, db(hv2), color='red', label='hv', linestyle='-.')
ax.plot(theta_deg, db(hv1), color='blue', label='hv', linestyle='-.')

ax.grid()
ax.set_xlim(0.,70.)
ax.set_ylim(-100.,15.)
ax.set_yticks(np.arange(-90, 20, 10))
plt.ylabel('Backscatter [dB]')
plt.xlabel('incidence angle [°]')
plt.legend()
plt.show()
../_images/notebooks_I2EM_5_0.png
[ ]: