Skip to content

view: bugfix for DEM masking#673

Merged
yunjunz merged 4 commits intoinsarlab:mainfrom
sssangha:sss_shadebug
Oct 2, 2021
Merged

view: bugfix for DEM masking#673
yunjunz merged 4 commits intoinsarlab:mainfrom
sssangha:sss_shadebug

Conversation

@sssangha
Copy link
Contributor

@sssangha sssangha commented Sep 27, 2021

Description of proposed changes

When I attempted to use the --mask-dem option, here is the error I got:

reading DEM: geometryGeo.h5 ...
display data in transparency: 0.8
plot in geo-coordinate
plotting DEM background ...
show shaded relief DEM
Traceback (most recent call last):
  File "/u/leffe-data/ssangha/conda_installation/stable_july30_2020/MintPy/mintpy/view.py", line 1659, in <module>
    main(sys.argv[1:])
  File "/u/leffe-data/ssangha/conda_installation/stable_july30_2020/MintPy/mintpy/view.py", line 1653, in main
    obj.plot()
  File "/u/leffe-data/ssangha/conda_installation/stable_july30_2020/MintPy/mintpy/view.py", line 1605, in plot
    ax, self, im, cbar = plot_slice(ax, data, self.atr, self)
  File "/u/leffe-data/ssangha/conda_installation/stable_july30_2020/MintPy/mintpy/view.py", line 526, in plot_slice
    pp.plot_dem_background(ax=ax, geo_box=inps.geo_box,
  File "/u/leffe-data/ssangha/conda_installation/stable_july30_2020/MintPy/mintpy/utils/plot.py", line 1055, in plot_dem_background
    dem_contour_seq) = prepare_dem_background(dem, inps=inps, print_msg=print_msg)
  File "/u/leffe-data/ssangha/conda_installation/stable_july30_2020/MintPy/mintpy/utils/plot.py", line 1015, in prepare_dem_background
    if inps.msk.shape == dem_contour.shape:
AttributeError: 'NoneType' object has no attribute 'shape'

This problem arose because when attempting to mask the dem shade and contours, the code expects the dem_contour object to exist at all times, which cannot be the case if the user wishes to suppress the contours or if this condition is meet in view.py:

    # DEM contour display
    if max(inps.pix_box[3] - inps.pix_box[1],
           inps.pix_box[2] - inps.pix_box[0]) > 2e3:
        inps.disp_dem_contour = False

This was check was updated, but then I noticed that dem shade masking still failed:

WARNING: DEM has different size than mask, ignore --mask-dem and continue.

After printing out the two arrays and referring to the documentation for the LightSource module of matplotlib, I realized this was because the dem_shade array is generated as an array with 4 layers. I thus updated the code with this in mind.

However after this I noticed that even when I specify the --mask-dem and --zero-mask option, the masked pixels in the InSAR field are not masked in the dem:
OG_velocity_TECTscale_noGPSjustDEM

I thus introduced a more simplified update such that the msk array in memory reflects these nodata values:
velocity_TECTscale_noGPSjustDEM

Reminders

  • Fix #xxxx
  • Pass Codacy code review (green)
  • Pass Circle CI test (green)
  • Make sure that your code follows our style. Use the other functions/files as a basis.
  • If modifying functionality, describe changes to function behavior and arguments in a comment below the function declaration.
  • If adding new functionality, add a detailed description to the documentation and/or an example.

@sssangha sssangha requested a review from yunjunz September 27, 2021 07:01
@sssangha sssangha marked this pull request as draft September 27, 2021 07:01
@sssangha sssangha marked this pull request as ready for review September 27, 2021 07:02
Copy link
Member

@yunjunz yunjunz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @sssangha.

@yunjunz
Copy link
Member

yunjunz commented Sep 27, 2021

I was aware of the multi-dimension matrix of dem_shade but forgot the potential None among the two. Thank you. I updated the PR. @sssangha Could you check again if it works as you expected before we squash and merge?

@yunjunz yunjunz changed the title Address DEM masking bug view: bugfix for DEM masking Sep 27, 2021
@yunjunz yunjunz merged commit 65c856b into insarlab:main Oct 2, 2021
@sssangha
Copy link
Contributor Author

sssangha commented Oct 2, 2021

@yunjunz apologies for the delay, but I can confirm this works now! Looks like right when I was typing this you squashed and merged, so thanks!

@yunjunz
Copy link
Member

yunjunz commented Oct 2, 2021

Great, thanks for the bug fix and confirmation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants