pyacs.vel_field
Velocity field package: read, manipulate and write GMT psvelo velocity fields.
- class pyacs.vel_field.Velocity_Field(file_name=None, name=None, lgmt_points=None, verbose=False)[source]
Bases:
objectRead a velocity field from a GMT psvelo file and manipulate it.
- name
Name of the velocity field.
- Type:
str, optional
- file_name
Path to the GMT psvelo file.
- Type:
str, optional
- sites
List of GMT_Point instances.
- Type:
list
- add_point(M)
Append a GMT_Point to the velocity field.
- Parameters:
M (GMT_Point) – Point to add.
- Returns:
self (for chaining).
- Return type:
- calc_pole(plates, method='WLS', verbose=False)
Perform Euler pole calculation for multiple plates.
- Parameters:
plates (dict) – Plate name -> list of site codes for each plate.
method (str, optional) – ‘WLS’ (weighted least-squares) or ‘L1’. Default is ‘WLS’.
verbose (bool, optional) – If True, print progress. Default is False.
Notes
For each plate, creates: euler_stat_<plate>.dat, <plate>.gmt, <plate>.shp, and euler_sum.dat with Euler pole summary.
- common(linGpoint, prefit=10.0, lexclude=[])
Return sites common to this velocity field and a list of GMT_Points.
- Parameters:
linGpoint (list) – List of GMT_Point instances (e.g. from SINEX).
prefit (float, optional) – Maximum coordinate difference (m) to consider a match. Default is 10.0.
lexclude (list, optional) – Site codes to exclude.
- Returns:
GMT_Point instances from this field that match by code (coordinates from this field).
- Return type:
list
- info(details=True)
Print basic information about the velocity field.
- Parameters:
details (bool, optional) – If True, list all site codes. Default is True.
- l_GMT_Point()
Return the velocity field as a list of GMT_Point objects.
- Returns:
List of GMT_Point instances.
- Return type:
list
- lcode()
Return a list of all point codes in the velocity field.
- Returns:
List of 4-character site codes.
- Return type:
list
- nsites()
Return the number of sites in the velocity field.
- Returns:
Number of sites.
- Return type:
int
- pole(lexclude=[], method='WLS', exp='pLate', log=None)
Compute Euler pole from the velocity field.
- Parameters:
lexclude (list, optional) – Site codes to exclude from the fit.
method (str, optional) – ‘WLS’ (weighted least squares), ‘LS’, or ‘Dikin’ (L1). Default is ‘WLS’.
exp (str, optional) – Experiment name prefix. Default is ‘pLate’.
log (str, optional) – Log file path. If None, uses exp + ‘.log’.
- Returns:
(X, VCV_POLE_X): rotation rate vector (3,) and variance-covariance (3, 3).
- Return type:
tuple
- print_info_site(code, verbose=False)
Print information for a site given its code.
- Parameters:
code (str) – 4-character site code.
verbose (bool, optional) – If True, print legend. Default is False.
- proj_profile(slon, slat, elon, elat, d, save=None, verbose=False)
Project velocity components along a great-circle profile.
- Parameters:
slon (float) – Longitude of profile start (decimal degrees).
slat (float) – Latitude of profile start (decimal degrees).
elon (float) – Longitude of profile end (decimal degrees).
elat (float) – Latitude of profile end (decimal degrees).
d (float) – Maximum distance (km) from profile for a point to be included.
save (str, optional) – If provided, write results to this file.
verbose (bool, optional) – If True, print progress. Default is False.
- Returns:
np_code, np_distance_along_profile, np_distance_to_profile, np_Ve, np_Vn, np_SVe, np_SVn, np_v_parallele, np_v_perpendicular, np_sigma_v_parallele, np_sigma_v_perpendicular, np_lazimuth.
- Return type:
tuple
- radial(center)
Return a velocity field with radial and tangential components about a center.
- Parameters:
center (array_like) – [longitude, latitude] of center in decimal degrees.
- Returns:
New velocity field with Ve = radial, Vn = tangential.
- Return type:
- classmethod read(file_name=None, lexclude=[], lonly=[], verbose=False)
Read a GMT psvelo file.
- Parameters:
file_name (str, optional) – Path to the GMT psvelo file.
lexclude (list, optional) – List of site codes to exclude.
lonly (list, optional) – If non-empty, only these site codes are included.
verbose (bool, optional) – If True, print progress. Default is False.
- Returns:
Populated velocity field instance.
- Return type:
- remove_point(code)
Remove a GMT_Point from the velocity field by code.
- Parameters:
code (str) – 4-character code of the point to remove.
- Returns:
New velocity field without the point (self replaced).
- Return type:
- site(code)
Return a site as a GMT_Point by code.
- Parameters:
code (str) – 4-character site code.
- Returns:
The site if found, else None.
- Return type:
GMT_Point or None
- strain(lcode, save=None, method='WLS', verbose=False)
Calculate strain rate from a list of sites.
- Parameters:
lcode (list) – List of site codes to use.
save (str, optional) – File path to save the result. If None, result is only printed.
method (str, optional) – ‘WLS’ (weighted least-squares) or ‘L1’. Default is ‘WLS’.
verbose (bool, optional) – If True, print progress. Default is False.
- Returns:
self.
- Return type:
- subset(lonly=None, lexclude=None)
Return a new Velocity_Field from a subset of sites.
- Parameters:
lonly (list, optional) – If provided, only these site codes are included.
lexclude (list, optional) – If provided, these site codes are excluded (ignored if lonly is set).
- Returns:
New velocity field with the subset of sites.
- Return type:
- substract_pole(W=None, type_euler='rot')
Subtract (or add) the prediction of an Euler pole from the velocity field.
- Parameters:
W (array_like, optional) – Euler pole: either [lon, lat, omega] in deg/Myr or [wx, wy, wz] in rad/yr.
type_euler (str, optional) – ‘rot’ for cartesian rotation rate (rad/yr), ‘euler’ for geographic. Default is ‘rot’.
- Returns:
New velocity field with pole removed.
- Return type:
- write(out_file=None, lexclude=[], verbose=True, comment='', up=False)
Write the velocity field to a GMT psvelo file.
- Parameters:
out_file (str, optional) – Output file path. Default is ‘tmp_vel.gmt’ if None.
lexclude (list, optional) – List of site codes to exclude from output.
verbose (bool, optional) – If True, print progress. Default is True.
comment (str, optional) – Comment line written at top of file.
up (bool, optional) – If True, write up component instead of east/north. Default is False.