Skip to content

bulk_plate_motion.py#769

Merged
yuankailiu merged 14 commits intoinsarlab:mainfrom
yuankailiu:dev.bulkmotion
Jun 29, 2022
Merged

bulk_plate_motion.py#769
yuankailiu merged 14 commits intoinsarlab:mainfrom
yuankailiu:dev.bulkmotion

Conversation

@yuankailiu
Copy link
Contributor

@yuankailiu yuankailiu commented May 6, 2022

Commits

  • add a code for bulk plate motion estimation/correction

  • reference_point.py: use FILE_TYPE for velocity datasetName

Major change

Collaborators: @olliestephenson, @yunjunz

Short intro:

This update adds functionality to account for the bulk motion of tectonic plates in the reference frame of the satellite. Plate motion at centimeters per year. combined with the variable satellite line of sight, can introduce velocity ramps in InSAR-derived velocity fields (Stephenson et al, 2022, submitted to GRL). This module combines a user-input plate velocity field with the LOS geometry file (e.g. geometryGeo.h5) to remove the impact of plate motion from secular velocities derived from Mintpy time series.

User inputs:

Users can estimate predicted bulk motion by either:

  1. assuming a constant single-vector translation in local ENU space:
    manually input ve, vn, vu based on your prior knowledge e.g., GNSS ENU velocities.
  2. using a plate rotation model on a spherical Earth:
    manually input Euler Pole rotation lat, lon, omega or omega_x, omega_y, omega_z based on e.g., ITRF2014 plate motion model.

For more details, please see the usage: bulk_plate_motion.py -h:

Expected outputs:

Input scenario 1: Assume you run the code with specified -v velocity.h5, then the output files are:

FILE_1: velocity_bmModelRaw.h5
(the absolute bulk motion model velocity, and its' east, north, and up components, without any reference pixel)

HDF5 dataset "/east               ": shape (LENGTH, WIDTH)         , dtype <float64>    (east component)
HDF5 dataset "/north              ": shape (LENGTH, WIDTH)         , dtype <float64>    (north component)
HDF5 dataset "/up                 ": shape (LENGTH, WIDTH)         , dtype <float64>    (up component)
HDF5 dataset "/velocity           ": shape (LENGTH, WIDTH)         , dtype <float64>    (LOS velocity)

FILE_2: velocity_bmModel.h5
(the bulk motion model LOS velocity referenced to the same reference pixel as your input velocity.h5)

HDF5 dataset "/velocity          ": shape (LENGTH, WIDTH)         , dtype <float64>    (referenced LOS velocity)

FILE_3: velocity_bmCorr.h5
(the corrected velocity file; Convention: FILE_3 = velocity.h5 - FILE_2)

HDF5 dataset "/velocity          ": shape (LENGTH, WIDTH)         , dtype <float32>    (corrected LOS velocity)

Input scenario 2: If you run the code without specifying -v, there is not uncorrected velocity as input. The output file is only the predicted bulk motion velocity:

FILE_1: velocity_bmModelRaw.h5
(the absolute bulk motion model velocity, and its' east, north, and up components, without any reference pixel)

HDF5 dataset "/east               ": shape (LENGTH, WIDTH)         , dtype <float64>    (east component)
HDF5 dataset "/north              ": shape (LENGTH, WIDTH)         , dtype <float64>    (north component)
HDF5 dataset "/up                 ": shape (LENGTH, WIDTH)         , dtype <float64>    (up component)
HDF5 dataset "/velocity           ": shape (LENGTH, WIDTH)         , dtype <float64>    (LOS velocity)

Dependencies:

This new script relyies on platemotion package (https://github.com/lcx366/PlateTectonic) to calculate the ENU velocity from a given Euler Pole at lat/lon. One could run pip install platemotion to install this package.

Some expected improvements are commented on in the code.

Minor change

  • reference_point.py: use FILE_TYPE for velocity datasetName

Reason for this proposal:

Currently, if you run reference_point.py on the velocity file, it will only reference the first dataset in the velocity file. In MintPy, we used to have only “velocity” and “velocityStd” in the velocity.h5. But when you have fitted seasonal functions, for example, you may have the first dataset as e.g., “annualAmplitude”. Or in the case of plate motion correction file (proposed above in this PR), the first dataset within velocity_bmModelRaw.h5 is “east” component. So now I suggest to add a datasetName in reference_point.py for reading the velocity file. Without having to specify datasetName, if you are dealing with atr[' FILE_TYPE']=velocity, then the default dataset is “velocity”.

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.
  • If adding new functionality, add a detailed description to the documentation and/or an example.

@yuankailiu yuankailiu requested a review from yunjunz May 6, 2022 15:21
@yuankailiu yuankailiu force-pushed the dev.bulkmotion branch 2 times, most recently from 8d3cc2e to d8b72e8 Compare May 8, 2022 00:41
@yunjunz
Copy link
Member

yunjunz commented May 19, 2022

Thank you @yuankailiu for this very cool PR!

For the output plate motion file, how about saving them into 2 files:

  • inputs/BulkPlateMotion3D.h5 for the calculated plate motion in east/north/up direction.
  • inputs/BulkPlateMotion.h5 for the LOS bulk motion file.

Both of them are spatially absolute. This will give us two benefits:

  1. The BulkPlateMotion3D.h5 could be sharable between asc/desc tracks in the same region.
  2. The diff.py operation will be simpler, and we could easily leverage the "spatial referencing on the fly".

I think I suggested you merge the 4 datasets into one file in our offline discussion, sorry for the back and forth!

For the corrected velocity file, how about adding a suffix of _BPM to it, e.g. velocity_BPM.h5?

I will go through the rest of the PR at another time.

yuankailiu added a commit to yuankailiu/MintPy that referenced this pull request Jun 2, 2022
(insarlab#769 (comment))

For the output plate motion file, saving them into 2 files:
+ inputs/BulkPlateMotion3D.h5: for the calculated plate motion in east/north/up direction.
+ inputs/BulkPlateMotion.h5:   for the LOS bulk motion file.
Both of them are spatially absolute.

The diff.py operation will easily leverage the "spatial referencing on the fly" when apply on a input velocity file.

For the corrected velocity file, use a universal suffix of _BPM, e.g. velocity_BPM.h5
yuankailiu added a commit to yuankailiu/MintPy that referenced this pull request Jun 2, 2022
(insarlab#769 (comment))

For the output plate motion file, saving them into 2 files:
+ inputs/BulkPlateMotion3D.h5: for the calculated plate motion in east/north/up direction.
+ inputs/BulkPlateMotion.h5:   for the LOS bulk motion file.
Both of them are spatially absolute.

The diff.py operation will easily leverage the "spatial referencing on the fly" when apply on a input velocity file.

For the corrected velocity file, use a universal suffix of _BPM, e.g. velocity_BPM.h5
yuankailiu added a commit to yuankailiu/MintPy that referenced this pull request Jun 2, 2022
(insarlab#769 (comment))

For the output plate motion file, saving them into 2 files:
+ inputs/BulkPlateMotion3D.h5: for the calculated plate motion in east/north/up direction.
+ inputs/BulkPlateMotion.h5:   for the LOS bulk motion file.
Both of them are spatially absolute.

The diff.py operation will easily leverage the "spatial referencing on the fly" when apply on a input velocity file.

For the corrected velocity file, use a universal suffix of _BPM, e.g. velocity_BPM.h5
yuankailiu added a commit to yuankailiu/MintPy that referenced this pull request Jun 2, 2022
(insarlab#769 (comment))

For the output plate motion file, saving them into 2 files:
+ inputs/BulkPlateMotion3D.h5: for the calculated plate motion in east/north/up direction.
+ inputs/BulkPlateMotion.h5:   for the LOS bulk motion file.
Both of them are spatially absolute.

The diff.py operation will easily leverage the "spatial referencing on the fly" when apply on a input velocity file.

For the corrected velocity file, use a universal suffix of _BPM, e.g. velocity_BPM.h5
yuankailiu added a commit to yuankailiu/MintPy that referenced this pull request Jun 2, 2022
(insarlab#769 (comment))

For the output plate motion file, saving them into 2 files:
+ inputs/BulkPlateMotion3D.h5: for the calculated plate motion in east/north/up direction.
+ inputs/BulkPlateMotion.h5:   for the LOS bulk motion file.
Both of them are spatially absolute.

The diff.py operation will easily leverage the "spatial referencing on the fly" when apply on a input velocity file.

For the corrected velocity file, use a universal suffix of _BPM, e.g. velocity_BPM.h5
@yuankailiu
Copy link
Contributor Author

Updates

Addressed PR comments

(#769 (comment))

For the output plate motion file, save them into 2 files:

  • inputs/BulkPlateMotion3D.h5: for the calculated plate motion in east/north/up direction.
  • inputs/BulkPlateMotion.h5: for the LOS bulk motion file.
    Both of them are spatially absolute.

The diff.py operation will easily leverage the "spatial referencing on the fly" when apply to an input velocity file.

For the corrected velocity file, use a universal suffix of _BPM, e.g. velocity_BPM.h5

diff.py: reference point (mintpy/diff.py)

Check and apply the reference point for the velocity files

@yunjunz
Copy link
Member

yunjunz commented Jun 12, 2022

It seems that part of the changes in reference_point.py in this PR is duplicated in #780, which is now merged. @yuankailiu Could you rebase this PR against the latest main branch?

@yuankailiu
Copy link
Contributor Author

It seems that part of the changes in reference_point.py in this PR is duplicated in #780, which is now merged. @yuankailiu Could you rebase this PR against the latest main branch?

Yes, I will do it now.

yuankailiu added a commit to yuankailiu/MintPy that referenced this pull request Jun 13, 2022
(insarlab#769 (comment))

For the output plate motion file, saving them into 2 files:
+ inputs/BulkPlateMotion3D.h5: for the calculated plate motion in east/north/up direction.
+ inputs/BulkPlateMotion.h5:   for the LOS bulk motion file.
Both of them are spatially absolute.

The diff.py operation will easily leverage the "spatial referencing on the fly" when apply on a input velocity file.

For the corrected velocity file, use a universal suffix of _BPM, e.g. velocity_BPM.h5
yuankailiu and others added 4 commits June 13, 2022 09:29
+ add a code for bulk plate motion estimation/correction

+ reference_point.py: use FILE_TYPE for velocity datasetName
+ setup.py: add entry_points for bulk_plate_motion.py

+ bulk_plate_motion.py:
   - add REFERENCE to part of the argparse msg
   - try/except checking for platemotion import
(insarlab#769 (comment))

For the output plate motion file, saving them into 2 files:
+ inputs/BulkPlateMotion3D.h5: for the calculated plate motion in east/north/up direction.
+ inputs/BulkPlateMotion.h5:   for the LOS bulk motion file.
Both of them are spatially absolute.

The diff.py operation will easily leverage the "spatial referencing on the fly" when apply on a input velocity file.

For the corrected velocity file, use a universal suffix of _BPM, e.g. velocity_BPM.h5
Check and apply the reference point for the velocitty files
yuankailiu added a commit to yuankailiu/MintPy that referenced this pull request Jun 13, 2022
yuankailiu added a commit to yuankailiu/MintPy that referenced this pull request Jun 13, 2022
Address the PR comments in insarlab#769 (comment)

typo fixed
Address the PR comments in insarlab#769 (comment)

typo fixed
olliestephenson pushed a commit to olliestephenson/MintPy that referenced this pull request Jun 15, 2022
(insarlab#769 (comment))

For the output plate motion file, saving them into 2 files:
+ inputs/BulkPlateMotion3D.h5: for the calculated plate motion in east/north/up direction.
+ inputs/BulkPlateMotion.h5:   for the LOS bulk motion file.
Both of them are spatially absolute.

The diff.py operation will easily leverage the "spatial referencing on the fly" when apply on a input velocity file.

For the corrected velocity file, use a universal suffix of _BPM, e.g. velocity_BPM.h5
olliestephenson pushed a commit to olliestephenson/MintPy that referenced this pull request Jun 15, 2022
@olliestephenson olliestephenson requested a review from yunjunz June 15, 2022 06:08
yuankailiu and others added 4 commits June 14, 2022 23:13
+ update usage comments
+ add mutually exclusive argument group for the 3 PMM input methods
+ use snake_case style for variable and function names
+ remove --mask option, as it's not really needed for the BPM calculation and projection, which only needs the native mask from the input geometry file.

+ add -o option to specify the output corrected velocity file.

+ update comments under functions() for style consistency

+ estimate_bulk_motion():
   - remove the masking part
   - simplify the atr reading part
   - update the HDF5 file writing
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.

I have finished my part of the refactoring. The PR looks good to me, pending the minor comment above.

Thank you @yuankailiu for this very cool and useful PR!

+ Added complete references for the plate motion models papers (NNR-NUVEL1A, NNR-MORVEL56, NNR-ITRF14).

+ Added a brief description about each of the PMMs, including the number of plates, and the technique that used to constrained the plate motions.
@yuankailiu yuankailiu merged commit b13e409 into insarlab:main Jun 29, 2022
@yuankailiu yuankailiu deleted the dev.bulkmotion branch July 1, 2022 21:21
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