Skip to content

Instantly share code, notes, and snippets.

@sixy6e
Last active June 18, 2021 01:51
Show Gist options
  • Save sixy6e/9a6cc669b0471000c01f0726fcae140c to your computer and use it in GitHub Desktop.
Save sixy6e/9a6cc669b0471000c01f0726fcae140c to your computer and use it in GitHub Desktop.
Sample InSAR test
In the attached data table, you have a set of 12 differential InSAR observations ("obs" in units of millimetres)
for a single pixel observed over a patch of ground undergoing a periodic surface movement signal.
The InSAR observations are formed from 11 SAR images collected by the Sentinel-1A satellite at regular 12 day intervals.
First and second epochs for each InSAR observation are given in the attached table ("epoch1" and "epoch2").
Write and submit some code (in the language of your choice) to re-construct the periodic ground surface movement signal
from the InSAR observations.
Answer the following questions:
1) What is your estimate of the absolute amplitude of the ground surface movement signal?
2) What is your estimate of the period of the ground surface movement signal?
obs epoch1 epoch2
10.3921 1 2
9.6647 1 6
-8.1724 2 3
-13.6400 2 5
-10.0686 3 4
-3.6267 3 5
1.5047 4 8
5.1846 5 7
4.8141 7 10
5.1083 8 9
11.7095 9 11
-2.6498 10 11
"""
A sample test from the InSAR team.
You have a set of 12 differential InSAR observations ("obs" in units of millimetres)
for a single pixel observed over a patch of ground undergoing a periodic surface
movement signal.
The InSAR observations are formed from 11 SAR images collected by the Sentinel-1A
satellite at regular 12 day intervals.
First and second epochs for each InSAR observation are given in the attached table
("epoch1" and "epoch2").
Write and submit some code (in the language of your choice) to re-construct the
periodic ground surface movement signal from the InSAR observations.
Answer the following questions:
1) What is your estimate of the absolute amplitude of the ground surface movement signal?
2) What is your estimate of the period of the ground surface movement signal?
"""
import numpy
import pandas
import structlog
PATHNAME = "data.csv"
SAMPLE_SPACING = 12 # we've been told the sample spacing is 12 days
_LOG = structlog.get_logger()
def main():
"""
Sample script that attempts to answer Matt's test.
Keywords I picked up on are:
periodic/period
signal
amplitude
regular
intervals
"""
# loading the data; TABLE schema: obs epoch1 epoch2
dataframe = pandas.read_csv(PATHNAME)
frequencies = numpy.fft.fftfreq(dataframe.shape[0], SAMPLE_SPACING)
# need to estimate the period of the signal and will do so using Fourier
# need to normalise the transformation to get the correct amplitudes
fwd_transform = numpy.fft.fft(dataframe.obs) / numpy.sqrt(dataframe.shape[0])
# only interested in the positive frequencies above the fundamental frequency
offset = 1
pos_freq = frequencies > 0
magnitude = numpy.abs(fwd_transform[pos_freq]) # amplitudes
second_harmonic = numpy.max(magnitude[offset:]) # max amplitude
harmonic_idx = numpy.argmax(magnitude[offset:])
signal_period = 1 / frequencies[pos_freq][offset:][harmonic_idx]
_LOG.info("my answers", signal_period=signal_period, max_amplitude=second_harmonic)
if __name__ == "__main__":
main()
@sixy6e
Copy link
Author

sixy6e commented Jun 18, 2021

My (unconfident) answer:

2021-06-18 11:45.23 my answers                     max_amplitude=8.411596348840888 signal_period=72.0

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