Closed yuankailiu closed 11 months ago
This is great @yuankailiu!! I have a few comments below:
Regarding the to-do list:
Implement this in the multiple subplots function, such as plotting all the geometries (height, longitude, latitude, incidencAngle, etc. with DEM shaded effects):
We don't need to worry about that at this PR. For a maintainable future, let's just add advanced features to the single subplot (I have been doing that for many years now). For multi-subplots, simplicity and efficiency are more important. People can run the command multiple times if they want nice figures, which is easy to do. Thus, I would suggest keeping this PR to the single plot only.
The current fancy version of the colorbar.
If I understand it correctly, we could not really interpret the color in the shaded version to a super-accurate level, because the shading of different slopes will give different colors, thus, it might be not doable/useful to have a shaded colorbar?
From my limited use of GMT, I don't remember seeing a shaded colorbar, so it's totally fine with me to use the regular colorbar in this case. Maybe I am wrong.
I like the utils.plot.plot_image4view()
function, which simplifies the view.plot_slice()
. But I find the modified prep/plot_dem_background()
functions less clear, as they are not really pure DEM anymore. How about the following re-orgnization, so that the this PR is completely independent of existing sub-functions in utils.plot.py
?
shaded_image()
-> prep_blend_image()
prep/plot_dem_background()
into plot_blend_image()
prep/plot_blend_image()
in plot_image4view()
Another reason for the independent prep/plot_blend_image()
is that we could add the resampling capability there in the future. Let me know what you think please.
Know what was going on for
hsv
showing that color jump.
Yes, this is strange in the apparent solid Earth tides velocity.
Testing on the FernandinaSenDT128 example dataset, I actually finds the overlay
mode more appealing. Shall we add an option for the blend mode, and switch to overlay
as default?
Similarly for the 2023 Turkey EQ from an ALOS-2 interferogram as well:
Ok, overlay looks more realistic, hsv looks much more striking topography. I think we can use overlay
as default and allow a --blend-mode
input option.
Ok, overlay looks more realistic, hsv looks much more striking topography. I think we can use
overlay
as default and allow a--blend-mode
input option.
Great, I am done with changes on my side for now.
Thanks, I agree and will work on the suggestions above regarding functions inside utils.plot.
Yes, we can just allow for single plotting for now. Keep it simple.
Yes, GMT does have a shaded color bar if your image is shaded with illumination. But I don't know what they do exactly.
Hi @yunjunz, I am done with the changes.
Awesome! This looks great! Do you mind if I use this as well in BEAT?
Hello Hannes, it's great to connect here! Of course not, you are very welcome to use it in BEAT.
The major functions are:
elev = np.ones_like(arr) * np.cos(0.6*x)
, I used an arbitrary cosine function as a fake elevation profile across the colorbar width to reflect the illumination effects. I don't know if it is the right way to do it, but it looks okay. Try to mimic this GMT plot or like in Sjonni's paper
Description of proposed changes
Hi @yunjunz,
Here is what MintPy has long been awaiting for :star2:!!! To be like GMT :satisfied:
Rather than plotting DEM in the background and overlaying the data with transparency, I attempt to view data with color adjusted by the shaded relief DEM when provided. Just like
gmt grdimage -I
feature. Hereafter, I call this way of showing data as "DEM-blended data".This can be done via
matplotlib.colors.LightSource.shade_rgb()
module (as opposed to what has been used in MintPy, i.e., theLightSource.shade()
module, which only produces the shaded relief of the DEM itself).Thus, I added two major functions in
plot.py
to handle this functionality of displaying DEM-blended data.Changes in MintPy code are as follows.
arg_utils.py
: allow the user to specify--dem-blend
,--shade-frac
, and--base-color
arguments to activate and tune the DEM-blended data plotting.--dem-blend
: to activate the way of plotting the DEM-blended data--shade-frac
: tune the fraction or the contrast in shade_rgb()--base-color
: set the grayish color of the DEM backgroundplot.py
:shaded_image()
: add illumination to the RGB data array based on a DEM file.shaded_colorbar()
: to plot a shaded illuminated colorbar. The shading is just schematic, not reflecting the real shades in the data (see future To-dos at the end of this PR).plot_image4view()
: handle the top layer plotting, this will call several other functions in plot.py, including the above two new functions.view.py
: adjust the current code to call new functions in plot.py. For a single plot, the DEM-blended data is shown well. We need to have some further tweaks for multiple subplots.Calling view.py examples:
Results:
Compare between the original view.py figure (left) and this PR (right).
Shading parameters (shown in both figure titles) are intentionally adjusted so that the two plots have a similar color tone. The only difference is the style in which the DEM is displayed.
Compare different
blend_mode
There are three blend modes in
matplotlib.colors.LightSource.shade_rgb()
, {hsv
,overlay
,soft
}. The default ishsv
. Although matplotlib documentation saysoverlay
orsoft
may be more realistic in showing elevation,hsv
somehow looks better from my not-thoroughly tests (upper right panel in the below plot).However,
hsv
seems to have some artificial color jumps (upper right panel in the below plot) when plotting these Solid Earth tides apparent velocity with a tiny data range.Future To-do
Know what was going on for
hsv
showing that color jump.Implement this in the multiple subplots function, such as plotting all the geometries (height, longitude, latitude, incidencAngle, etc. with DEM shaded effects):
I try to adapt the code and implement this in plotting multiple subplots. But it still looks like it is plotting as the original MintPy way. The DEM-blended data does not seem to show up.
The current fancy version of the colorbar with the illumination effects is not indicating the real shading in the data image. It is now serve only as a schematic. Although maybe it is hard to tell from our eyes. I did this by creating a fake color data from vmin & vmax in the colorbar axis, and adding yet another fake cosine-function elevation profile (hardcoded values) with shaded relief across the colorbar axis to micmic the illumination effects. Here, I have to use
soft
blend_mode for better performance. I know now it sounds pretty hacky, but it works. Check (plot.py shaded_colorbar() function).Perhaps some refactoring is needed.
Reminders