Morphing: apply a local deformation of fieldΒΆ
[1]:
%matplotlib inline
# for figures in notebook
# import & initialize epygram
import epygram
epygram.init_env()
import os
INPUTS_DIR = os.path.join('..', 'inputs')
[2]:
r = epygram.formats.resource(os.path.join(INPUTS_DIR, 'ICMSHAROM+0022'), 'r')
f = r.readfield('SURFTEMPERATURE')
[3]:
fig, ax = f.cartoplot(subzone='CI')
[4]:
# make 2 PointFields by extracting them from the field
p1 = f.extract_point(8,45)
p2 = f.extract_point(8.5, 45.5)
print(p1.getdata(), p2.getdata())
279.10697361419653 276.7998386410072
[5]:
# set arbitrary different values
p1.setdata(270)
p2.setdata(285)
[6]:
f.morph_with_points([p1, p2], morphing='gaussian', sigma=10000) # gaussian blending weight with 10km sigma
[7]:
fig, ax = f.cartoplot(subzone='CI')
[8]:
# or as increment (less brutal):
p = f.extract_point(7,46)
p.setdata(+10) # +10K increment
f.morph_with_points([p], morphing='gaussian', sigma=10000, increment=True)
[9]:
fig, ax = f.cartoplot(subzone='CI')
[ ]: