Skip to content

plot_network: color-code network/matrix plot based on temp/perp baselines#693

Merged
yunjunz merged 5 commits intoinsarlab:mainfrom
yuankailiu:dev
Jan 21, 2022
Merged

plot_network: color-code network/matrix plot based on temp/perp baselines#693
yunjunz merged 5 commits intoinsarlab:mainfrom
yuankailiu:dev

Conversation

@yuankailiu
Copy link
Contributor

@yuankailiu yuankailiu commented Nov 10, 2021

Description of proposed changes

Here are two proposed changes:

1). The displacement map in tsview.py needs to be projected onto a specific Cartopy projection (e.g., ccrs.PlateCarree()) to properly overlay the coastline. This is added. But I am not sure whether there should be tunable projections. For small regions (for most of the cases), I think it is fine.

2). In 'plot_network.py', Other than coherence, I personally think it would be good to also allow the lines (connecting acquisitions) to be colored based on their temporal or spatial baselines. This is just for network design displaying purposes. You can reject that as well.

Reminders

  • 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.

@yunjunz yunjunz self-requested a review November 11, 2021 03:43
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.

Thank you @yuankailiu, the two features sound fine to me.

Here are my suggestions:

  1. For the plot_network.py, I tried to run plot_network.py inputs/ifgramStack.h5 --tb and it does seem to work. Could you double-check, and add an example usage as well?

  2. For the tsview.py, it's more complicated, as the script needs to support files in radar coordinates as well. Below is how view.py handles this, which eventually translated into the inps.map_proj_obj variable. I would recommend: packing this checking into a sub-function in view.py or utils/plot.py, and call it from tsview.py. If you want to go for this, please consider submitting it in another PR, as it requires much more changes.

MintPy/mintpy/view.py

Lines 310 to 345 in 92e00ad

# Map Projection via cartopy
# cartopy requires that:
# 1. file is geocoded AND
# 2. file coordinates are in the unit of degrees / meters AND
# 3. set to display in geo-coordinates
# use cartopy (by initiating inps.map_proj_obj) ONLY IF:
# 1. show fancy lat/lon label via --lalo-label OR
# 2. show coastline via --coastline
inps.map_proj_obj = None
inps.coord_unit = metadata.get('Y_UNIT', 'degrees').lower()
if (inps.geo_box
and inps.coord_unit.startswith(('deg', 'meter'))
and inps.fig_coord == 'geo'
and (inps.lalo_label or inps.coastline)):
# get projection name from the data coord unit
# https://scitools.org.uk/cartopy/docs/latest/crs/projections.html
msg = 'initiate cartopy map projection: '
if inps.coord_unit.startswith('deg'):
inps.map_proj_obj = ccrs.PlateCarree()
vprint(msg + 'PlateCarree')
elif inps.coord_unit.startswith('meter'):
if 'UTM_ZONE' in metadata.keys():
utm_zone = metadata['UTM_ZONE']
inps.map_proj_obj = ccrs.UTM(utm_zone)
vprint(msg + f'UTM zone {utm_zone}')
# check --lalo-label (works for PlateCarree only)
if inps.lalo_label:
raise ValueError('--lalo-label is NOT supported for projection: UTM')
else:
print('WARNING: Un-recognized coordinate unit: {}'.format(inps.coord_unit))
print(' Switch to the native Y/X and continue to plot')
inps.fig_coord = 'radar'

@yuankailiu yuankailiu force-pushed the dev branch 3 times, most recently from a17b51c to d0cd424 Compare January 6, 2022 23:37
@yuankailiu yuankailiu changed the title Map projection in tsview.py + Network plot line coloring based on baselines plot_network: Network plot lines coloring based on baselines Jan 6, 2022
@yuankailiu
Copy link
Contributor Author

Hi Yunjun, thanks for reviewing this.

plot_network.py and plot.py have been updated, with an example added in plot_network.py -h. Now it is working after my testing.

I have also changed the utils1.py a bit in the get_residual_std() function. I make it to return the std_file as the get_residual_rms() function.

As for tsview.py, I will do it later in another PR. Thanks!

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.

Thank you @yuankailiu for the updates. Could you check the few minor suggestions I listed above?

After that, the code is clean enough and I could work on the idea below (unless you are willing to work that, in that case let me know), which requires quite some refactoring:

Your implementation makes me think that we could use a more generic/flexible --dset dsName option: if dsName is a 3D matrix, then use maskFIle to calculate the spatial average (which is what currently do); if dsName is a 1D matrix, e.g. bperp, treat it as the calculated spatial average directly, and all the following code should be the same.

    + Can color the network lines with tbase (days) using --tbase option

    + Can color the network lines with pbase (days) using --pbase option

    (use plot_network.py -h to see the explanations and an example)

utils1:

    + get_residual_std(): also return `std_file` variable
@yunjunz yunjunz changed the title plot_network: Network plot lines coloring based on baselines plot_network: color-code network/matrix plot based on temp/perp baselines Jan 21, 2022
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.

Looks all good to me.

@yunjunz yunjunz merged commit 1727c7d into insarlab:main Jan 21, 2022
@yuankailiu yuankailiu deleted the dev branch January 21, 2022 03:47
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