Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

sarsim.py

Andrew Player edited this page Aug 17, 2022 · 1 revision

module src.sarsim

Created By: Andrew Player
File Name: sarsim.py
Date Created: 07-2022
Description: Functions for simulated-deformation interferogram generation for R&D purposes.
Credits: Functions taken from https://github.com/matthew-gaddes/SyInterferoPy


function I1

I1(xi, eta, q, delta, nu, R, X, d_tild)

Compute the component I1 of the model (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return I1


function I2

I2(xi, eta, q, delta, nu, R, y_tild, d_tild)

Compute the component I2 of the model (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return I2


function I3

I3(xi, eta, q, delta, nu, R, y_tild, d_tild)

Compute the component I3 of the model (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return I3


function I4

I4(xi, eta, q, delta, nu, R, d_tild)

Compute the component I4 of the model (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return I4


function I5

I5(xi, eta, q, delta, nu, R, X, d_tild)

Compute the component I5 of the model (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return I5


function f_x_strike

f_x_strike(xi, eta, q, delta, nu)

Fault strike component along the x axis (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return The associated component


function f_x_dip

f_x_dip(xi, eta, q, delta, nu)

Fault dip component along the x axis (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return The associated component


function f_x_tensile

f_x_tensile(xi, eta, q, delta, nu)

Fault tensile component along the x axis (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return The associated component


function f_y_strike

f_y_strike(xi, eta, q, delta, nu)

Fault strike component along the y axis (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return The associated component


function f_y_dip

f_y_dip(xi, eta, q, delta, nu)

Fault dip component along the y axis (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return The associated component


function f_y_tensile

f_y_tensile(xi, eta, q, delta, nu)

Fault tensile component along the y axis (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return The associated component


function f_z_strike

f_z_strike(xi, eta, q, delta, nu)

Fault strike component along the z axis (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return The associated component


function f_z_dip

f_z_dip(xi, eta, q, delta, nu)

Fault dip component along the z axis (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return The associated component


function f_z_tensile

f_z_tensile(xi, eta, q, delta, nu)

Fault tensile component along the z axis (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return The associated component


function chinnerys_notation

chinnerys_notation(f, x, p, q, L, W, delta, nu)

Formula to add the different fault components (for more information, see Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154)

@return The combined components


function compute_okada_displacement

compute_okada_displacement(
    fault_centroid_x,
    fault_centroid_y,
    fault_centroid_depth,
    fault_strike,
    fault_dip,
    fault_length,
    fault_width,
    fault_rake,
    fault_slip,
    fault_open,
    poisson_ratio,
    x_array,
    y_array
)

Compute the surface displacements for a rectangular fault, based on Okada's model. For more information, see: Okada, Surface deformation due to shear and tensile faults in a half-space, Bulletin of the Seismological Society of America (1985) 75 (4): 1135-1154

@param fault_centroid_x: x cooordinate for the fault's centroid @param fault_centroid_y: y cooordinate for the fault's centroid @param fault_centroid_depth: depth of the fault's centroid @param fault_strike: strike of the fault ([0 - 2pi], in radian) @param fault_dip: dip of the fault ([0 - pi/2], in radian) @param fault_length: length of the fault (same unit as x and y) @param fault_width: width of the fault (same unit as x and y) @param fault_rake: rake of the fault ([-pi - pi], in radian) @param fault_slip: slipe of the fault (same unit as x and y) @param fault_open: opening of the fault (same unit as x and y) @param poisson_ratio: Poisson's ratio @param x_array: x cooordinate for the domain within a NumPy array @param y_array: y cooordinate for the domain within a NumPy array

@return The surface displacement field


function deformation_eq_dyke_sill

deformation_eq_dyke_sill(source, source_xy_m, xyz_m, **kwargs)

A function to create deformation patterns for either an earthquake, dyke or sill. Uses the Okada function from PyInSAR: https://github.com/MITeaps/pyinsar To aid in readability, different sources take different parameters (e.g. slip for a quake, opening for a dyke) are passed separately as kwargs, even if they ultimately go into the same field in the model parameters.

A quick recap on definitions: strike - measured clockwise from 0 at north, 180 at south. fault dips to the right of this. hanging adn fo dip - measured from horizontal, 0 for horizontal, 90 for vertical. rake - direction the hanging wall moves during rupture, measured relative to strike, anticlockwise is positive, so: 0 for left lateral ss 180 (or -180) for right lateral ss -90 for normal 90 for thrust

Inputs: source | string | quake or dyke or sill source_xy_m | tuple | x and y location of centre of source, in metres. xyz_m | rank2 array | x and y locations of all points in metres. 0,0 is top left?

examples of kwargs:

quake_normal = {'strike' : 0, 'dip' : 70, 'length' : 5000, 'rake' : -90, 'slip' : 1, 'top_depth' : 4000, 'bottom_depth' : 8000}

quake_thrust = {'strike' : 0, 'dip' : 30, 'length' : 5000, 'rake' : 90, 'slip' : 1, 'top_depth' : 4000, 'bottom_depth' : 8000}

quake_ss = {'strike' : 0, 'dip' : 80, 'length' : 5000, 'rake' : 0, 'slip' : 1, 'top_depth' : 4000, 'bottom_depth' : 8000}

dyke = {'strike' : 0, 'top_depth' : 1000, 'bottom_depth' : 3000, 'length' : 5000, 'dip' : 80, 'opening' : 0.5}

sill = {'strike' : 0, 'depth' : 3000, 'width' : 5000, 'length' : 5000, 'dip' : 1, 'opening' : 0.5}

Returns: x_grid | rank 2 array | displacment in x direction for each point (pixel on Earth's surface) y_grid | rank 2 array | displacment in y direction for each point (pixel on Earth's surface) z_grid | rank 2 array | displacment in z direction for each point (pixel on Earth's surface) los_grid | rank 2 array | change in satellite - ground distance, in satellite look angle direction. Need to confirm if +ve is up or down.

History: 2020/08/05 | MEG | Written 2020/08/21 | MEG | Switch from disloc3d.m function to compute_okada_displacement.py functions.


function atmosphere_turb

atmosphere_turb(
    n_atms,
    lons_mg,
    lats_mg,
    method='fft',
    mean_m=0.02,
    water_mask=None,
    difference=False,
    verbose=False,
    cov_interpolate_threshold=10000.0,
    cov_Lc=2000
)

A function to create synthetic turbulent atmospheres based on the methods in Lohman Simons 2005, or using Andy Hooper and Lin Shen's fft method. Note that due to memory issues, when using the covariance (Lohman) method, largers ones are made by interpolateing smaller ones. Can return atmsopheres for an individual acquisition, or as the difference of two (as per an interferogram). Units are in metres.

Inputs: n_atms | int | number of atmospheres to generate lons_mg | rank 2 array | longitudes of the bottom left corner of each pixel. lats_mg | rank 2 array | latitudes of the bottom left corner of each pixel. method | string | 'fft' or 'cov'. Cov for the Lohmans Simons (sp?) method, fft for Andy Hooper/Lin Shen's fft method (which is much faster). Currently no way to set length scale using fft method. mean_m | float | average max or min value of atmospheres that are created. e.g. if 3 atmospheres have max values of 0.02m, 0.03m, and 0.04m, their mean would be 0.03cm. water_mask | rank 2 array | If supplied, this is applied to the atmospheres generated, convering them to masked arrays. difference | boolean | If difference, two atmospheres are generated and subtracted from each other to make a single atmosphere. verbose | boolean | Controls info printed to screen when running. cov_Lc | float | length scale of correlation, in metres. If smaller, noise is patchier, and if larger, smoother. cov_interpolate_threshold | int | if n_pixs is greater than this, images will be generated at size so that the total number of pixels doesn't exceed this. e.g. if set to 1e4 (10000, the default) and images are 120120, they will be generated at 100100 then upsampled to 120*120.

Outputs: ph_turbs | r3 array | n_atms x n_pixs x n_pixs, UNITS ARE M. Note that if a water_mask is provided, this is applied and a masked array is returned.

2019/09/13 | MEG | adapted extensively from a simple script 2020/10/02 | MEG | Change so that a water mask is optional. 2020/10/05 | MEG | Change so that meshgrids of the longitudes and latitudes of each pixel are used to set resolution. Also fix a bug in how cov_Lc is handled, so this is now in meters. 2020/10/06 | MEG | Add support for rectangular atmospheres, fix some bugs. 2020_03_01 | MEG | Add option to use Lin Shen/Andy Hooper's fft method which is quicker than the covariance method.


function gen_fake_topo

gen_fake_topo(size: int = 512, alt_scale_min: int = 0, alt_scale_max: int = 500)

Generate fake topography (a dem in meters) for generating simulated atmospheric topographic error.

Parameters:

  • size : int
    The size n for the (n, n) dimension array that is returned.
  • alt_scale_min : int
    The minimum altitude scaling value for the generated perlin noise.
  • alt_scale_max : int
    The maximum altitude scaling value for the generated perlin noise.

Returns:

  • dem : np.ndarray
    The array that is meant to be used as a simulated dem with values in meters.

function atm_topo_simulate

atm_topo_simulate(
    dem_m: ndarray,
    strength_mean: float = 56.0,
    strength_var: float = 2.0,
    difference: bool = True
)

Generate simulated topographic atmospheric error.

Parameters:

  • dem_m : np.ndarray
    An array containing either real dem values (in meters) or simulated ones.
  • strength_mean : float
    The mean strength/magnitude of the error.
  • strength_var : float
    The maximum variation from strength_mean of the magnitude of the error.
  • difference : bool
    Whether the error should come from the difference of 2 aquisitions or just 1.

Returns:

  • ph_turb : np.ndarray
    The array containing the turbulent atmospheric error.

function aps_simulate

aps_simulate()

Generate simulated turbulent atmospheric error.

Parameters:

None

Returns:

  • ph_turb : np.ndarray
    The array containing the turbulent atmospheric error.

function coherence_mask_simulate

coherence_mask_simulate(threshold: float = 0.3)

Generate simulated incoherence to be masked out.

Parameters:

  • threshold : float
    The maximum value of coherence to be masked to zeros.

Returns:

  • mask_coh : np.ndarray
    The masked coherence array.

function gen_simulated_deformation

gen_simulated_deformation(
    seed: int = 0,
    tile_size: int = 512,
    log: bool = False
)

Generate a wrapped interferogram along with an event-mask from simulated deformation

Parameters:

  • seed : int, Optional
    A seed for the random functions. For the same seed, with all other values the same as well, the interferogram generation will have the same results. If left at 0, the results will be different every time.
  • tile_size : int, Optional
    The desired dimensional size of the interferogram pairs. This should match the input shape of the model.
  • log : bool, Optional
    If true, the function will log various relevant values in the console.

Returns:

  • masked_grid : np.ndarray(shape=(tile_size, tile_size))
    An array representing a mask over the simulated deformation which simulates masking an event.
  • wrapped_grid : np.ndarray(shape=(tile_size, tile_size)
    The wrapped interferogram.

This file was automatically generated via andrewplayer3's fork of lazydocs.