Travel times and TauP#
JPype is not used. Java calls execute in subprocesses; the default functions select ObsPy when the JAR or JDK tools are absent. taup_time_java explicitly requires Java. Importing the module detects availability without starting Java or compiling the bridge.
Java rayparameter is seconds/radian. Native SPGRN table slowness is seconds/metre; neither value can be used as seconds/degree without conversion.
pytaup#
- pygrnwang.pytaup.cal_first_p(event_depth_km, dist_km, receiver_depth_km=0.0, model_name='ak135')[source]#
Calculate the earliest arrival from the configured P phase set.
- Parameters:
event_depth_km (float) – Requested source depth in km, positive down.
dist_km (float) – Epicentral distance in km; query within the stored distance grid.
receiver_depth_km (float, optional) – Requested receiver depth in km, positive down. Default: 0.0.
model_name (str, optional) – TauP built-in model name or path to a custom model. Use a model consistent with the Green library. Default: ‘ak135’.
- Returns:
arrival (float) – Arrival time in seconds after origin; NaN when the selected phase set has no arrival.
- Raises:
RuntimeError – The model cannot be built or loaded, or the Java bridge fails.
OSError – A required file or executable cannot be accessed.
Notes
Uses Java subprocesses when the bundled JAR, java and javac are available; otherwise uses ObsPy. Importing this module does not start a JVM. Runtime Java failures are reported rather than silently switching backends. Distances use 111.19492664455874 km per degree. Phases: p, P, pP, Pg, Pn, Pdiff, PKP. The deeper endpoint is treated as source using reciprocity.
- pygrnwang.pytaup.cal_first_s(event_depth_km, dist_km, receiver_depth_km=0.0, model_name='ak135')[source]#
Calculate the earliest arrival from the configured S phase set.
- Parameters:
event_depth_km (float) – Requested source depth in km, positive down.
dist_km (float) – Epicentral distance in km; query within the stored distance grid.
receiver_depth_km (float, optional) – Requested receiver depth in km, positive down. Default: 0.0.
model_name (str, optional) – TauP built-in model name or path to a custom model. Use a model consistent with the Green library. Default: ‘ak135’.
- Returns:
arrival (float) – Arrival time in seconds after origin; NaN when the selected phase set has no arrival.
- Raises:
RuntimeError – The model cannot be built or loaded, or the Java bridge fails.
OSError – A required file or executable cannot be accessed.
Notes
Uses Java subprocesses when the bundled JAR, java and javac are available; otherwise uses ObsPy. Importing this module does not start a JVM. Runtime Java failures are reported rather than silently switching backends. Distances use 111.19492664455874 km per degree. Phases: s, S, sS, pS, Sg, Sn, Sdiff, SKS. The deeper endpoint is treated as source using reciprocity.
- pygrnwang.pytaup.cal_first_p_s(event_depth_km, dist_km, receiver_depth_km=0.0, model_name='ak135')[source]#
Calculate first P and S arrivals for one geometry.
- Parameters:
event_depth_km (float) – Requested source depth in km, positive down.
dist_km (float) – Epicentral distance in km; query within the stored distance grid.
receiver_depth_km (float, optional) – Requested receiver depth in km, positive down. Default: 0.0.
model_name (str, optional) – TauP built-in model name or path to a custom model. Use a model consistent with the Green library. Default: ‘ak135’.
- Returns:
first_p, first_s (float) – P and S arrival seconds after origin. Each can independently be NaN.
- Raises:
RuntimeError – The model cannot be built or loaded, or the Java bridge fails.
OSError – A required file or executable cannot be accessed.
Notes
Uses Java subprocesses when the bundled JAR, java and javac are available; otherwise uses ObsPy. Importing this module does not start a JVM. Runtime Java failures are reported rather than silently switching backends. Distances use 111.19492664455874 km per degree. Uses the same phase sets and endpoint reciprocity as cal_first_p and cal_first_s.
- pygrnwang.pytaup.taup_time_java(event_depth_km, dist_km, phases_list, receiver_depth_km=0, model_name='ak135')[source]#
Query all requested phase arrivals directly through Java TauP.
- Parameters:
event_depth_km (float) – Requested source depth in km, positive down.
dist_km (float) – Epicentral distance in km; query within the stored distance grid.
phases_list (list of str) – TauP phase names to request, for example [‘P’, ‘p’, ‘S’].
receiver_depth_km (float, optional) – Requested receiver depth in km, positive down. Default: 0.
model_name (str, optional) – TauP built-in model name or path to a custom model. Use a model consistent with the Green library. Default: ‘ak135’.
- Returns:
arrivals (dict) – Lists under phase, puristphase, time and rayparameter. Times are seconds and ray parameters are seconds/radian, not seconds/degree. Missing phases produce empty lists.
- Raises:
RuntimeError – The model cannot be built or loaded, or the Java bridge fails.
OSError – A required file or executable cannot be accessed.
Notes
Requires java and javac plus the bundled JAR. The bridge is compiled lazily. Built-in TauP names and .nd model paths are supported. This explicitly Java-only entry does not fall back to ObsPy.
- pygrnwang.pytaup.taup_create_npz_file(nd_file)[source]#
Prepare a custom velocity-model path for the selected TauP backend.
- Parameters:
nd_file (str) – Path to a named-discontinuity velocity model; the selected TauP backend reads or converts this file.
- Returns:
model_path (str) – Java returns nd_file unchanged; ObsPy builds and returns a sibling .npz path.
- Raises:
RuntimeError – The model cannot be built or loaded, or the Java bridge fails.
OSError – A required file or executable cannot be accessed.
Notes
Uses Java subprocesses when the bundled JAR, java and javac are available; otherwise uses ObsPy. Importing this module does not start a JVM. Runtime Java failures are reported rather than silently switching backends. Distances use 111.19492664455874 km per degree. The historical function name does not imply that every backend creates an NPZ file.
- pygrnwang.pytaup.create_tpts_table(path_green, event_depth_km, receiver_depth_km, dist_km_list, model_name='ak135', check_finished=False, max_workers=None)[source]#
Write first P/S arrival tables for a depth pair and distance sequence.
- Parameters:
path_green (str) – Absolute library root containing green_lib_info.json and backend subdirectories.
event_depth_km (float) – Requested source depth in km, positive down.
receiver_depth_km (float) – Requested receiver depth in km, positive down.
dist_km_list (sequence of float) – Epicentral distances in km; output order follows this sequence.
model_name (str, optional) – TauP built-in model name or path to a custom model. Use a model consistent with the Green library. Default: ‘ak135’.
check_finished (bool, optional) – Reuse outputs marked finished. Markers do not verify that inputs are unchanged. Default: False.
max_workers (int or None, optional) – ObsPy process limit; None uses CPU count. Fewer than 50 distances use one worker; Java always batches in one process. Default: None.
- Returns:
None – Writes tp_table.bin and ts_table.bin under source/receiver depth folders named with two decimal places. Each file is one float32 second value per input distance; NaN records a missing arrival.
- Raises:
RuntimeError – The model cannot be built or loaded, or the Java bridge fails.
OSError – A required file or executable cannot be accessed.
Notes
Uses Java subprocesses when the bundled JAR, java and javac are available; otherwise uses ObsPy. Importing this module does not start a JVM. Runtime Java failures are reported rather than silently switching backends. Distances use 111.19492664455874 km per degree. Java evaluates all distances in one subprocess; ObsPy may split them among workers. Model-cache files are built before workers start. Guard multiprocessing calls with if __name__ == “__main__”.