BPMF.NLLoc_utils
- BPMF.NLLoc_utils.load_pykonal_tts(filename, path)[source]
Load the travel-time grid computed with Pykonal.
Load the travel times previously computed with Pykonal and reformat the axes to follow NLLoc’s convention.
- Parameters:
filename (string) – Name of the travel-time file. Example: ‘tts.h5’.
path (string, default to BPMF.cfg.MOVEOUTS_PATH) – Name of the directory where the travel-time file is located.
- Returns:
longitude ((n_longitude, n_latitude, n_depth) numpy.ndarray) – longitudes of the grid points, in decimals.
latitude ((n_longitude, n_latitude, n_depth) numpy.ndarray) – latitudes of the grid points, in decimals.
depth ((n_longitude, n_latitude, n_depth) numpy.ndarray) – depths of the grid points, in km.
tts (dictionary) – dictionary with one entry per phase, e.g. tts[‘p’]. each phase is itself made of sub-dictionaries, one for each station: e.g. tts[‘p’][‘station1’]. tts[‘p’][‘stationxx’] is an (n_longitude, n_latitude, n_depth) numpy.ndarray of travel times.
- BPMF.NLLoc_utils.read_NLLoc_outputs(filename, path)[source]
Read the NLLoc output hyp file.
- Parameters:
filename (string) – Name of the NLLoc output file.
path (string) – Name of the NLLoc output directory.
- Returns:
hypocenter (dictionary) – Dictionary with four fields: origin_time, latitude, longitude, depth.
predicted_times (pandas.DataFrame) – pandas.DataFrame with the predicted arrival times and the residuals.
- BPMF.NLLoc_utils.write_NLLoc_control(ctrl_filename, out_filename, obs_filename, TRANS='GLOBAL', NLLoc_input_path='', NLLoc_output_path='', NLLoc_basename='', method='EDT_OT_WT_ML', angle_grid='ANGLES_NO', grid='MISFIT', locsearch='OCT', phases=['P', 'S'], excluded_obs={}, n_depth_points=None, **kwargs)[source]
Write the NLLoc control file.
All input and output files created here for NLLoc will be deleted. Note that all additional key-word arguments to NLLoc, using the same parameter names as in NLLoc (http://alomax.free.fr/nlloc/).
- Parameters:
ctrl_filename (str) – Name of the control file.
out_filename (str) – Name of NLLoc’s output file.
obs_filename (str) – Name of the input observation file.
TRANS (str, optional) – Geographic transformation. See NLLoc’s documentation. Defaults to ‘GLOBAL’.
NLLoc_input_path (str, optional) – Path to NLLoc’s input files, that is, travel-time tables. Defaults to ‘cfg.NLLOC_INPUT_PATH’.
NLLoc_output_path (str, optional) – Path to NLLoc’s output files, that is, the results of location. Defaults to ‘cfg.NLLOC_OUTPUT_PATH’.
NLLoc_basename (str, optional) – Basename of the travel-time files. If you have multiple travel-time grids at the same NLLoc_input_path directory, use this argument to use one or the other. Defaults to ‘cfg.NLLOC_BASENAME’.
method (str, optional) – Name of the loss function. See NLLoc’s documentation. Defaults to ‘EDT_OT_WT_ML’.
angle_grid (str, optional) – Alias for the ‘angleMode’ parameter of the ‘LOCANGLES’ command in the NLLoc control file. See NLLoc’s documentation. Defaults to ‘ANGLES_NO’.
grid (str, optional) – Either of ‘MISFIT’ (default) or ‘PROB_DENSITY’. Alias for the ‘gridType’ parameter of the ‘LOCGRID’ command in the NLLoc control file. See NLLoc’s documentation.
locsearch (str, optional) –
Either of ‘GRID’, ‘MET’ or ‘OCT’ (default). This parameter goes to the LOCSEARCH command in the NLLoc control file. It determines how the loss function is minimizes: - GRID: Grid search (very computationally expensive). - MET: Metropolis algorithm (MCMC). Efficient but may be stuck in a
local minimum.
- OCT: Oct tree importance sampling algorithm. This is a mix of sampling
and grid search that allows the efficient search for the global minimum. See ‘http://alomax.free.fr/nlloc/octtree/OctTree.html’ for more details. This is the default option.
phases (list of str, optional) – List of phases used by NonLinLoc. This list includes either “P”, “S” or both. Defaults to [“P”, “S”].
excluded_obs (dict, optional) –
- Excluded observations using NLLoc’s LOCEXCLUDE command:
LOCEXCLUDE sta ph
and excluded_obs[sta] = ph. Defaults to an empty dictionary.
n_depth_points (int or None, optional) – If not None, only the first n_depth_points points are kept along the depth axis in the grid.
- BPMF.NLLoc_utils.write_NLLoc_inputs(longitude, latitude, depth, tts, net, output_path='', basename='')[source]
Write the hdr and buf travel-time files for NLLoc.
Write the hdr and buf NLLoc files assuming the GLOBAL mode. In this mode, coordinates are given in geographic coordinates: longitude, latitude and depth. The origin of the grid is taken as the southwest corner. More information at: http://alomax.free.fr/nlloc/soft7.00/formats.html#_grid_
- Parameters:
longitude ((n_longitude, n_latitude, n_depth) numpy.ndarray) – longitudes of the grid points, in decimals.
latitude ((n_longitude, n_latitude, n_depth) numpy.ndarray) – latitudes of the grid points, in decimals.
depth ((n_longitude, n_latitude, n_depth) numpy.ndarray) – depths of the grid points, in km.
tts (dictionary) – dictionary with one entry per phase, e.g. tts[‘p’]. each phase is itself made of sub-dictionaries, one for each station: e.g. tts[‘p’][‘station1’]. tts[‘p’][‘stationxx’] is an (n_longitude, n_latitude, n_depth) numpy.ndarray of travel times.
net (dataset.Network class) – The dataset.Network instance with the station names and coordinates.
output_path (string, default to 'cfg.NLLOC_INPUT_PATH') – Path to the directory where NLLoc grid files are stored.
basename (string, default to 'cfg.NLLOC_BASENAME') – Basename of all NLLoc input files.
- BPMF.NLLoc_utils.write_NLLoc_obs(origin_time, picks, stations, filename, path='', err_min=0.04)[source]
Write the .obs file for NLLoc.
- Parameters:
origin_time (string or datetime) – Origin, or reference, time of the picks.
picks (pandas.DataFrame) – Attribute of an dataset.Event instance, produced by dataset.Event.pick_PS_phases.
stations (List of strings) – List of the station names to use for the relocation.
filename (string) – Name of the .obs file.
path (string, default to cfg.NLLOC_INPUT_PATH) – Name of the directory where to save the .obs file.
err_min (scalar float, default to 0.04) – Minimum error, in seconds, on phase picks.