calc_crust_corr.html 0100644 0002000 0001751 00000004254 07636626363 0015417 0 ustar 00richard dev 0000270 0000002
calc_crust_corr
calc_crust_corr
Called by: correct_ttime for each phase if crust_corr_on =1.
Includes: iscloc.h, jb_model.h, crust_type.h, crust_type_key.h.
Input arguments:
Character indicating whether the phase is P or S.
Latitude of either source or station.
Longitude of either source or station.
Depth of source. 0 for station.
Elevation of station if elev_corr_on =1. NULLVAL otherwise and for source.
dt/dd for the phase.
Structure members updated: None.
Return: Travel time correction in seconds.
Gabi Laski has made available on the REM web site a global crustal
model on a 2 x 2 degree grid. (http://mahi.ucsd.edu/Gabi/rem.html or
Bassin, C., Laske, G. and Masters, G., The Current Limits of Resolution
for Surface Wave Tomography in North America, EOS Trans AGU, 81, F897, 2000.)
Each 2x2 degree 'tile' of the Earth's surface is assigned one of 360 crustal
structures each made up of 7 layers. Each layer has a P velocity, an S velocity
and a density.
Here, the crust types are stored in crust_type.h in a two dimensional
array which has indexes corresponding to latitude and longitude. The velocity
profiles for each crust type are stored in crust_type_key.h in an array of
suitable structures. For each phase the time to traverse the crust of the
homogenious earth model in use is subtracted from the travel time and the
time taken to traverse the crust from this model is added on. This is done
for both the source and the station, taking the depth of the former into
account and allowing for non-radial take off angle.
calc_delaz.html 0100644 0002000 0001751 00000002556 07636626363 0014334 0 ustar 00richard dev 0000270 0000002 calc_delaz
calc_delaz
Called by: main each iteration.
Includes: iscloc.h
Input arguments:
Pointer to solution structure.
Array of phase structures.
Calls:
calc_delta from utils
calc_esaz from utils
print_pha if diagnostic is on.
Structure members updated: delta and esaz in each phase structure.
Return: 0/1 for success/failure.
Loops over all the phases contributing to an event and for each initial phase calculates delta and esaz for that reading. The values are stored in every phase structure but not recalculated for secondary phases.
calc_depdp.html 0100644 0002000 0001751 00000002605 07636626363 0014324 0 ustar 00richard dev 0000270 0000002 calc_depdp
calc_depdp
Called by: main
Includes: iscloc.h
Input arguments:
Pointer to solution structure.
Array of phase structures.
Calls: Functions find_pP, pP_duplicates, calc_pP_resid, and solve_depdp.
Structure members updated: none.
Return: 0/1 for success/failure.
This function calls a sequence of other functions to identify
depth phases, calculate pP - P residuals for them and then use the residuals
to calculate a depth phase depth. This function needs to be called
after id_pha
so that pP phases reported with other names (e.g. AP) have been identified.
If this function is run each iteration, as when the fix_on_depdp flag is set, then id_pha
must also be run afterwards as the depth will have changed and the previous identifications are now out of date.
calc_elev_corr.html 0100644 0002000 0001751 00000002151 07636626363 0015204 0 ustar 00richard dev 0000270 0000002
calc_elev_corr
calc_elev_corr
Called by: correct_ttime for each phase if elev_corr_on=1 and crust_corr_on=0.
Includes: iscloc.h, jb_model.h
Input arguments: Pointer to a phase structure.
Structure members updated: None.
Return: Travel time correction in seconds for elevation of station.
Calculates the extra time spent by a phase to traverse the crust
between the geoid and the surface. Does so by dividing the station elevation
by the upper crust velocity for the model in use and by a factor that accounts
for non vertical incidence.
calc_error.html 0100644 0002000 0001751 00000006671 07636626364 0014371 0 ustar 00richard dev 0000270 0000002 calc_error
calc_error
Called by: main
Includes: iscloc.h
Input arguments:
Pointer to solution structure.
Pointer to array of phase structures.
Calls: Functions get_fact and get_fact2 from this file.
Structure members updated: nass, ndef, nsta, ndefsta, sdobs, mindist, maxdist, azimgap, error[], majax, minax, and theta
Return: 0/1 for success/failure.
This function calculates the standard errors and error ellipse
for a final solution using the covariance matrix stored by function solve. It also calculates the final azimuthal gap and the number of stations and phases that were used in the solution.
There are 12 members of the solution structure used to store errors and other information for the final solution.
- error - array of standard errors for solution. Set in function calc_error.
- majax - major axis of error ellipse (km). Set in function calc_error.
- minax - minor axis of error ellipse (km). Set in function calc_error.
- theta - azimuth of error ellipse (degrees). Set in function calc_error.
- sdobs - measure of standard deviation of weighted residuals. Set in function calc_error.
- mindist - distance to closest station (degrees). Set in function calc_error.
- maxdist - distance to furthest station (degrees). Set in function calc_error.
- azimgap - maximum azimuthal gap between stations (degrees). Set in function calc_error.
- nsta - number of stations with associated phases. Set in function calc_error.
- ndefsta - number of stations with defining phases. Set in function calc_error.
- nass - number of associated phases. Set in function calc_error.
- ndef - number of defining phases. Set in function calc_error.
calc_gap.html 0100644 0002000 0001751 00000005037 07636626364 0014002 0 ustar 00richard dev 0000270 0000002 calc_gap
calc_gap
Called by: rank_hyp once for each event.
Includes: iscloc.h
Input arguments:
Pointer to event structure.
Array of hypocentre structures.
Array of phase structures.
Calls: calc_delta
, calc_esaz, dsort from utils
Structure members updated: nsta, azimgap, and mindist in hypocentre structure.
Return: 0/1 for success/failure.
The 3 parameters nsta, azimgap, and mindist
are used to order hypocentres in the sequence that they will be used as
starting points for the solution process. These parameters may or may
not be provided by the reporting agency, depending on the format that they
use and the completeness of their reports. If any of the parameters
are not provided then they are calculated from the phases that the reporting
agency associated with their hypocentre. (This may not result in the same
values as the agency would have given, as some agencies use more phases in
their solution than they send to the ISC but is the best that can be done.)
This function loops over all the hypocentre structures for an event and checks whether nsta, azimgap, and mindist
are present for each. If any value is missing for a hypocentre then
this function loops over the phases, if any, associated by the agency that
reported this hypocentre. For each phase nsta is incremented and delta and esaz are calculated. When all the phases have been counted the azimuthal gap is calculated from the esaz values.
calc_geoid_corr.html 0100644 0002000 0001751 00000003516 07636626364 0015347 0 ustar 00richard dev 0000270 0000002
calc_geoid_corr
calc_geoid_corr
Called by: correct_ttime for each phase.
Includes: iscloc.h
External: Array of deltas at which the correction is incremented delta_step[].
Input arguments:
Latitude of the current solution.
Pointer to a phase structure
Calls: height_above_mean_sphere from this file.
Structure members updated: None.
Return: Travel time correction in seconds for height of geoid above mean sphere.
Corrects for the difference in distance travelled between a ray
in a spherical Earth, as assumed by the tables, and in a more accurately
shaped Earth. Multiplies the height above the mean sphere of both the station
and the source by an average velocity that depends on the distance between
the two. This velocity is stored at 10 delta intervals in the array delta_step[],
declared at the top of this file.
height_above_mean_sphere
Called by: calc_geoid_corr for station and source.
Input arguments: Latitude in radians.
Structure members updated: None.
Return: Height above mean sphere in km.
calc_netmag.html 0100644 0002000 0001751 00000003526 07636626364 0014507 0 ustar 00richard dev 0000270 0000002 calc_netmag
calc_netmag
Called by: main
Includes: iscloc.h
External: mag_range_warn_thresh set in read_config.
Input arguments:
Pointer to solution structure.
Pointer to array of phase structures.
Calls: Functions calc_sta_mb and calc_sta_ms.
Structure members updated:
bodymag, surfmag, nsta_mb, nsta_ms in the solution structure.
Return: 0/1 for success/failure.
This function loops over all associated phases calling calc_sta_mb for each phase and calc_sta_ms
for each reading. Any station magnitudes found are averaged to give
two network magnitudes, one for body waves and the other for surface waves.
These two averages are stored, along with the number of stations that
contribute to them, in the solution structure for output to file or database.
If the difference between the two magnitudes is greater than the number
entered in the configuration file as mag_range_warn_thresh then a warning is written to the logfile output stream.
calc_pP_resid.html 0100644 0002000 0001751 00000002747 07636626364 0015005 0 ustar 00richard dev 0000270 0000002 calc_pP_resid
calc_pP_resid
Called by: calc_depdp
Includes: iscloc.h
Input arguments:
Pointer to solution structure.
Array of phase structures.
Calls:
Function read_pP_P
add_to_error and handle_error from utils
Structure members updated: pP_resid in phase structure.
Return: 0/1 for success/failure.
This function calculates a pP - P residual for each arrival with a phase
of pP that was reported in a reading with a P phase. It does this
by calculating the difference in arrival times for the two phases and subtracting
the theoretical difference returned by function read_pP_P, which looks it up in tables. The resulting residual is stored in the phase structure as member pP_resid.
calc_resid.html 0100644 0002000 0001751 00000006574 07636626364 0014350 0 ustar 00richard dev 0000270 0000002
calc_resid
calc_resid
Called by: main each iteration and after convergence.
Includes: iscloc.h
External: max_depth set in read_ttime
Input arguments:
Pointer to solution structure.
Array of phase structures.
A string, mode, set to "all" if require residuals for all phases, "use" if only want residuals that will be used in solution.
Calls:
function read_ttime
functions add_to_error and handle_error from utils
Structure members updated: resid in phase structure.
Return: 0/1 for success/failure.
First this function checks the depth of the current solution against max_depth, a value passed as an external variable by function read_ttime for the earth model in use. If the source depth is greater than the maximum depth allowed for by the model then no residuals can be calculated and the function returns early.
Next it loops over all associated phases and calculates residuals for those applicable. Each iteration this function is called with mode="use" and only calculates residuals for those phases with weight_factor > 0 , i.e. those that will be used in the solution. After convergence this function is called one last time with mode="all" and calculates residuals with respect to the final solution for all recognised phases. For each applicable phase the observed travel time is calculated and then the model travel time and derivatives are added to the phase structure by calling function read_ttime. The residual is calculated by subtracting the model time from the observed time and is also added to the structure.
Note: The ultimate calculation of residuals with respect to the final solution can be confusing. It is possible for the solution to alter sufficiently in the final iteration that it is impossible to calculate residuals for phases that were used in that final iteration. For example, if the depth of the solution changed form above the Conrad discontinuity to below it then Pg and Sg phases that contributed to the hypocentre can not have residuals with respect to it. In such cases a warning is written to logfile , weight_factor for the phase is set to 0 and phase to "". The effect is that ndef will be less than it should be and the phases concerned will not be included in the calculation of sdobs or mindist .
calc_sta_mb.html 0100644 0002000 0001751 00000002556 07636626364 0014503 0 ustar 00richard dev 0000270 0000002
calc_sta_mb
calc_sta_mb
Called by: calc_netmag
Includes: iscloc.h, bodymag_cor.h
External:
body_mag_min_dist , body_mag_max_dist , body_mag_min_per , body_mag_max_per set in read_config .
Input arguments:
Pointer to solution structure.
Pointer to phase structure.
Structure members updated: bodymag in the phase structure.
Return: 0/1 for success/failure.
This function calculates a body wave magnitude for P phases recorded at a suitable distance with an amplitude at a suitable period. The magnitude is calculated using a table of corrections included as bodymag_cor.h.
calc_sta_ms.html 0100644 0002000 0001751 00000005502 07636626364 0014516 0 ustar 00richard dev 0000270 0000002 calc_sta_ms
calc_sta_ms
Called by: calc_netmag
Includes: iscloc.h
External:
surf_mag_min_dist, surf_mag_max_dist, surf_mag_min_per, surf_mag_max_per set in read_config.
Input arguments:
Array of phase structures.
Array of indexes of the phase structure array making up one reading.
Number of entries in the reading array.
Structure members updated: surfmag in the phases that contributed to it.
Return: MS for the reading or 0 if there is none.
Note: ISF bulletin format does not include component information so MS can not be calculated for data read in from ISF file.
This function goes through the phases of one reading and looks for
amplitudes recorded at a suitable distance and with suitable periods for
surface wave magnitude calculation. If a vertical amplitude is given
then MSZ is calculated and if amplitudes on both horizontal components are
given at a similar period to each other then MSH is calculated. MS
for the reading is set to either MSZ or MSH or the average of the two if
both are available.
Any phase with phase ="" is considered, as surface wave codes do not get mapped in id_pha
. Multiple amplitudes for one reading can either be on separate phases
or attached to one phase as rows in the amplitude array a. In either case the surfmag
written to the phase structure needs to be that calculated using amplitude(s)
from that phase. Therefore if there are 3 orthogonal amplitudes for
a reading then either two phases with horizontal amplitudes could have surfmag=MSH
and a phase with a vertical amplitude have surfmag=MSZ or a single phase
with 3 amplitudes could have surfmag=MS. Because some phases in the
reading may not have a surfmag while others do and because the MS for the
reading may not be stored with any of the phases the value of MS is returned
back to the calling function so that it can be used in network magnitude
calculation.
calc_weight.html 0100644 0002000 0001751 00000004152 07636626364 0014517 0 ustar 00richard dev 0000270 0000002
calc_weight
calc_weight
Called by: main each iteration.
Includes: iscloc.h
Input arguments:
Pointer to solution structure.
Array of phase structures.
Calls:
Weighting function that depends on weighting_type in the solution structure.
print_pha if diagnostic is on.
Structure members updated:
prev_alpha, prev_sigma, and sigma in solution structure.
Return: 0/1 for success/failure.
Calls the weighting function corresponding to the current value of weighting_type in the solution structure. After weighting has been done this function calculates sigma - a weighted measure of standard deviation of residuals that is used in iteration control in function decide_iter. This function also records the values of alpha (which is calculated in the weighting function itself) and sigma from the previous iteration as prev_alpha and prev_sigma. These are compared with the current values in function decide_iter to tell if the solution is converged or diverging.
change_weighting.html 0100644 0002000 0001751 00000004713 07636626364 0015543 0 ustar 00richard dev 0000270 0000002
change_weighting
change_weighting
Called by: main after convergence has been reached.
Includes: iscloc.h
External:
weighting1 set in read_config
weighting2 set in read_config
Input arguments:
Pointer to solution structure.
Structure members updated:
weighting_type in solution structure.
converged in solution structure.
Return: 0/1 for success/failure.
If a parameter weighting2 is present in config.txt then an external variable weighting2 will have been initialised in read_config. If this is the case and weighting_type in the solution structure is currently set to the value of weighting1 (i.e. this function has not been called before) then this function sets weighting_type to weighting2 and converged to 0. This has the effect of restarting the iteration process with the most recent solution as a starting point and using a different weighting function.
Note that the iteration process may be restarted after the first convergence even if no change is made to the weighting function because phases may have been purged in function purge_pha, which also updates converged in the solution structure if it does anything.
changing_model.html 0100644 0002000 0001751 00000007374 07636626364 0015215 0 ustar 00richard dev 0000270 0000002
changing_model.html
Changing the Earth Model in Use
The iscloc program is designed to make it as simple as possible to change the method employed to calculate the travel times that are compared with observed travel times to get the residuals used in solution of hypocentre locations. Travel times themselves are returned by the function read_ttime, which calls a model specific function read_jb. This separates residual calculation from the method used to estimate travel times and it is possible to alter read_ttime to call a different function that calculates travel times in a different way. Any part of the program that needs to know travel times (e.g. functions calc_resid , mark_duplicates) can call read_ttime and so remain unchanged. It would be possible to use read_ttime to check that phases are identified consistently with the model in use, but in practice it is much more efficient to use a set of simple rules to check the majority of phase identifications. These rules are, of course, specific to the model in use and so an alternative function would have to be called to do this job if a different travel time method was required. A similar method to that for travel times has been used to buffer the calculation of pP - P differential travel times from from the calculation of pP - P residuals and the solution of depth phase depth.
There are three functions that need to be replaced if a different earth model is used to replace Jeffreys - Bullen. These are:
- The re-identification of phases which have a reporter's ID inconsistent with the current model. [id_jb]
- The calculation of travel times used to calculate residuals and locate the earthquake. [read_jb]
- The calculation of P-pP differential travel times used to calculate the depth phase depth. [jb_pP_P]
The functions that call these functions will then need to be edited to call the new functions instead. The calling functions are
In function id_pha it will also probably be necessary to alter the phase_map structure to reflect the phase names used in the model being used. In the same way it may be necessary to change the phase_weight structure in function get_weight_factor.
In function calc_resid the maximum depth allowed by the model is required and read in from an external variable . This variable is set in function read_ttime so read_ttime must include the relevant definition. This is conveniently done for JB by including the header file, jb_model.h, used by the model specific functions. Other functions that need to know some details of the model in use also include this header file.
If the model were changed then the include statements in these functions would need to be updated:
correct_ttime.html 0100644 0002000 0001751 00000005376 07636626364 0015122 0 ustar 00richard dev 0000270 0000002
correct_ttime
correct_ttime
Called by: read_ttime for each phase after getting travel time.
Includes: iscloc.h
External:
Threshold for applying crustal correction CRUST_CORR_MIN_DELTA.
crust_corr_on
and elev_corr_on
set in read_config
Input arguments:
Pointer to solution structure.
Pointer to phase structure.
Calls:
calc_geoid_corr
calc_elev_corr
if elev_corr_on = 1 and crust_corr_on = 0
calc_crust_corr
if crust_corr_on = 1
Structure members updated: None.
Return: Travel time correction in seconds.
Calls functions to make corrections to the travel time for a particular
phase. In all cases will make a correction for the true shape of the Earth
by calling calc_geoid_corr. Whether any other correction is made depends on the value of two configuration values read from config.txt
by read_config.
If crust_corr_on is set then
function calc_crust_corr
is called which replaces the effect of a constant
crust from the earth model with the effect of a laterally varying crust.
calc_crust_corr
will also make a correction for station elevation using the
appropriate crustal velocity if it is provided with an elevation value and
so this function only sends such an elevation if elev_corr_on is also set.
If crust_corr_on is not set but elev_corr_on
is set then function calc_elev_corr
is called to correct for the elevation
of the station using the upper crustal velocity from the earth model in use.
data_input.html 0100644 0002000 0001751 00000005341 07636626364 0014377 0 ustar 00richard dev 0000270 0000002
data_input
Data Input
Each event structure has 5 members related to inputting data:
- evid - numerical ID of event. If database in use then set in read_instruction and used to select data. Otherwise input with other data in read_isf_event.
- prime - hypid of prime hypocentre for this event in the database. Only used if database being used.
- isc_hypid - hypid of the ISC hypocentre for this event in the database. Only used if database being used.
- numhyps - number of hypocentres in this event. Set in either get_event or read_isf_event.
- numphas - number of phases associated with hypocentres in this event. Set in either get_event or read_isf_event.
The iscloc program is designed to input data in one of two ways, either from an ORACLE database with the same schema as used at the ISC or form text files with events in ISF bulletin format. The mode of input depends on the instruction line:
- If the instruction line contains an evid that can be used to select an event from the database then function get_data is used. A connection is made to the database the first time such an instruction is read and not broken until the program ends.
- If the instruction line contains the name of a file containing ISF data then function read_isf_event is used. The first time that a particular ISF file is requested it is opened in main and left open in case subsequent instruction lines request the same file. That way the events in the file are read in order, rather than going back to the first one every time.
Because a new instruction line is read in for each event it is possible to mix database and file input as well as to read from more than one file.
The data input functions are responsible for dynamically allocating memory for the arrays of hypocentre and phase structures that they insert data into.
>contents
Data Input
Each event structure has 5 members related to inputting data:
- evid - numerical ID of event. If database in use then set decide_iter.html 0100644 0002000 0001751 00000005374 07636626364 0014515 0 ustar 00richard dev 0000270 0000002
decide_iter
decide_iter
Called by: main each iteration.
Includes: iscloc.h
External:
avg_weight_thresh set in read_config
alpha_thresh set in read_config
dalpha_thresh set in read_config
dsigma_low set in read_config
dsigma_high set in read_config
Input arguments:
Pointer to solution structure.
Array of phase structures.
Structure members updated:
converged or diverging in the solution structure.
Return: 0/1 for success/failure.
Each iteration, after a solution has been calculated, this function decides whether it has changed little enough from the previous solution to be considered to have converged. It does this by calculating the change in sigma , the standard deviation of the weighted residuals, between this iteration and the previous one and comparing this change to thresholds imported from config.txt . The absolute value of alpha , the average weighted residual, must also be below a certain threshold for convergence to decided.
A decision is also made as to whether the solution is drifting so badly that it can be considered to be diverging. Divergence is implied if the average weight of the defining phases is above a certain threshold or if alpha has changed more than a given amount while sigma has decreased more than a given amount.
If this function decides that either of the above cases are true it sets the corresponding flag in the solution structure.
depth_phase_depth.html 0100644 0002000 0001751 00000005624 07636626364 0015723 0 ustar 00richard dev 0000270 0000002 depth_phase_depth
Depth Phase Depth Calculation
Once a solution has converged for
a given event an attempt is made to calculate a depth phase depth for that
event using the differences in arrival time between pairs of P and pP phases
at the same station (calc_depdp). It is also possible for the operator to give the fix_on_depdp
instruction and do this calculation at the start of each iteration, using
the resulting depth as a fixed depth for that iteration. In this case
the depth and depth phase depth for a solution will be the same unless the
depth phase depth is changed by the final calculation done for all events
- very unlikely as the solution and depth phase depth have already been through
several iterations together.
Each phase structure has 4 members related to depth phase depth calculation:
- pP_weight - number between 0 and 1. Set in function solve_depdp
depending on pP_resid.
- pP_resid - difference between observed P time minus pP time and corresponding value from tables. Set in function calc_pP_resid.
- pP_dtdh - derivative of time with respect to distance in seconds per degree. Set in function jb_pP_P.
- pP_P_time - theoretical difference between P arrival time and pP arrival time. Set in function jb_pP_P.
The solution structure has 2 members related to depth phase depth calculation:
- depdp - depth calculated from P minus pP times. Set in function solve_depdp.
- depdp_error - standard error in depth phase depth. Set in function solve_depdp.
The event structure has 1 member related to depth phase depth calculation:
- fix_on_depdp - either 0 or 1. Set in function read_instruction. Will be 0 unless fix_on_depdp is included on the instruction line for this event by the operator.
error_handling.html 0100644 0002000 0001751 00000002174 07636626365 0015246 0 ustar 00richard dev 0000270 0000002 error_handling
Error Handling
Whenever an error occurs in one of the functions
making up the iscloc program a message is written to the global string
variable errstr, which is declared in iscloc.h. The function then
returns with non zero status so that the calling function knows that there
is a problem. In most cases it will call function handle_error , printing the message to output stream errfile , which is assigned in config.txt
. In other cases it passes the status back another level to the function
that it was called by after possibly using function add_to_error to concatenate further information to errstr. The final error message will still be displayed using function handle_error , usually called by main.
find_pP.html 0100644 0002000 0001751 00000003455 07636626365 0013633 0 ustar 00richard dev 0000270 0000002 find_pP
find_pP
Called by: calc_depdp
Includes: iscloc.h
External:
Definition of structure pP_max_reisd_rec.
Array of pP_max_reisd_rec structures, pP_max_reisd.
Number of rows in that array, NUM_MAX_RESID.
Input arguments:
Pointer to solution
structure.
Array of
phase
structures.
Calls: Function read_pP_P
and function add_to_error
from utils
Structure members updated: phase
in phase
structure.
Return: 0/1 for success/failure.
This function loops through all associated phases finding those that could
be pP for use in the depth phase depth calculation. Phases with a rep_phase
of pP will already have phase
pP and this will remain unless such a phase is not possible at the current delta and source depth. Phases with null phase
will be named pP if their pP - P residual when compared with the table value calculated in read_pP_P
is small enough. The threshold used to decide whether a residual is
small enough depends on source depth and the different values are held in
a structure at the top of the file.
get_data.html 0100644 0002000 0001751 00000003041 07636626365 0014013 0 ustar 00richard dev 0000270 0000002 get_data
get_data
Called by: main for each event that is requested with an
evid
on the instruction
line.
Includes: iscloc.h
Input arguments:
Pointer to event
structure.
Pointer to the address of the hypocentre structure array.
Pointer to the address of the phase structure array.
Calls: get_event, get_hyp, and get_pha
Structure members updated: none.
Return: 0/1 for success/failure.
This function calls get_event
to find out how many hypocentres and phases are present in the database
for this event and the hypid of the hypocentre that
all ISC associations will have been made with (prime). It then allocates an
appropriate amount of memory for arrays of hypocentre
and phase
structures and calls get_hyp
and get_pha
to select the data from the database into these arrays
get_event.html 0100644 0002000 0001751 00000004351 07636626365 0014230 0 ustar 00richard dev 0000270 0000002
get_event
get_event
Called by: get_data
Includes: iscloc.h
Input arguments: Pointer to event structure.
Calls: sql_error in oracle_funcs
Structure members updated:
numhyps, numphas, prime, and isc_hypid in event structure.
Return: 0/1 for success/failure.
Written in ORACLE Pro*C this function needs to be precompiled to get C code.
This function uses the value of evid stored in the event structure by read_instruction to select data from the ISC database. It loops over all rows in the HYPOCENTER table with this evid to get the hypid of the ISC hypocentre for this event, if there is one. If there is then this hypid is stored both as isc_hypid and prime. Otherwise prime is selected from the appropriate row of the EVENT table, prime is not taken from the EVENT table if there is an ISC hypocentre because there are rare cases where the ISC hypocentre will not be prime but will still have all the ISC associations made with it.
This function then counts the number of rows in the HYPOCENTER table that have the required evid to set numhyps and the number of phases in the ASSOCIATION table that have hypid = prime to set numphas
get_hyp.html 0100644 0002000 0001751 00000003237 07636626365 0013711 0 ustar 00richard dev 0000270 0000002 get_hyp
get_hyp
Called by: get_data
Includes: iscloc.h
Input arguments:
Pointer to event
structure.
Array of hypocentre
structures.
Calls: sql_error
in oracle_funcs
Structure members updated:
time, lat, lon, depth, depfix, epifix, timfix, nsta, ndefsta, nass, ndef, mindist, maxdist, azimgap, etype, agency, minax, majax, theta, stime, sdepth, sdobs in hypocentre
structures.
Return: 0/1 for success/failure.
Written in ORACLE Pro*C this function needs to be precompiled to get C code.
This function selects data from the HYPOCENTER and HYPOC_ERR tables in the ISC database using the evid
stored in the event
structure and assigns values to members of the hypocentre
structure.
get_pha.html 0100644 0002000 0001751 00000003166 07636626365 0013662 0 ustar 00richard dev 0000270 0000002 get_pha
get_pha
Called by: get_data
Includes: iscloc.h
Input arguments:
Pointer to event
structure.
Array of phase
structures.
Calls: sql_error
in oracle_funcs
Structure members updated:
hypid, phid, rdid, pref_rd, time, init, rep_phase, net, sta, slow, azim, comp, sp_fm, detchar, sta_lat, sta_lon, sta_elev, dircos, numamps
and a
in phase
structures.
Return: 0/1 for success/failure.
Written in ORACLE Pro*C this function needs to be precompiled to get C code.
This function selects data from the PHASE, ASSOCIATION and AMPLITUDE tables of the ISC database using the prime
hypid stored in the event
structure and assigns values to members of the phase
get_weight_factor.html 0100644 0002000 0001751 00000004477 07636626365 0015745 0 ustar 00richard dev 0000270 0000002
calc_weight
get_weighting_factor
Called by: main each iteration.
Includes: iscloc.h
External:
Definition of structure phase_weight_rec.
Array of phase_weight_rec structures, phase_weight.
Number of rows in that array, NUM_PHASE_WEIGHTS.
Input arguments:
Array of
phase
structures.
Number of phases in that array.
Calls: print_pha
from utils.c
if diagnostic is on.
Structure members updated: weight_factor
in phase structure.
Return: 0/1 for success/failure.
Assigns a value of weight_factor
to each arrival based on the phase code,
phase, and the distance between the station where the arrival was recorded
and the source, delta. Phases with null time
or phase
= "" will have weight_factor
set to 0, as will any phase with purged
= 1. Otherwise the value of
weight_factor
assigned will depend on whether phase
is present in the phase_weight array and if it is on the corrsponding values
of delta1, delta2 and weight_factor.
struct phase_weight_rec phase_weight[2] = {
{ "P", 0, 20, 1 },
{ "P", 20, 100, 0.5 },
}
Would weight local P arrivals fully while weighting down teleseismic P.
A P arrival from a source more than 100 degrees away would not get a weight
and neither would any other type of arrival.
huber_weight.html 0100644 0002000 0001751 00000010306 07636626365 0014721 0 ustar 00richard dev 0000270 0000002
huber_weight
huber_weight
Called by:
calc_weight
each iteration that weighting_type
is set to huber.
Includes: iscloc.h
External:
Threshold for difference between residual and alpha, CUT_OFF [0.8275].
min_phases
set in read_config
init_max_resid
set in read_config
max_resid
set in read_config
Input arguments:
Pointer to
solution
structure.
Array of
phase
structures.
Structure members updated:
weight
in
phase
structure.
alpha
in
solution
structure.
prev_alpha
in
solution
structure first iteration only.
Return: 0/1 for success/failure.
Huber-t weighting designed to get a basic solution before using more
complex but less stable uniform reduction weighting (implemented here
in buland_weight) to get a final solution. First the average weighted residual, alpha,
is calculated then each phase is given a weight depending on the difference
between its residual and alpha. If the difference is greater than CUT_OFF,
a constant defined as a macro in this file, then the weight is set to CUT_OFF
divided by the difference. Otherwise the weight is set to 1.
No weight is given to a phase if its residual is greater than
max_resid
and before a weight is assigned it is multiplied by
weight_factor
for this phase, which will be 0 unless this type of
phase
is wanted at this particular delta. Once all phases have been weighted the number with non-zero weights
is counted and if the total is less than
min_phases
then the solution is aborted and restarted with the next option or seed.
The first time that this function is called it can not calculate alpha in
the normal way because the phases do not have weights yet. Instead
provisional weights are calculated with alpha as the unweighted average of
all residuals less than init_max_resid. Then alpha is recalculated from these provisional weights and used
in the calculation of the weights that will be used in the solution. The
initial, unweighted alpha is stored as
prev_alpha
in the
solution
structure for comparison with alpha
in the function decide_iter.
This weighting scheme was first programmed at the ISC by R. Buland in 1987.
Here is his comment from that code:
The cutoff, s, between least squares behavior and one-norm behavior
has been determined empirically to optimize efficiency against the distribution
of teleseismic travel-time residuals. For this case, the efficiency
is about .905 which is quite close to the optimal efficiency achievable with
a non-decreasing influence function. Except for the non-linearity inherent
in the earthquake location problem, this weighting would always produce unique
results.
align="Right">
contents
huber_weight
Called by:
calc_weight
each iteration that weighting_type
is set to huber.
Includes: iscloc.h
Exterid_jb.html 0100644 0002000 0001751 00000005445 07636626365 0013324 0 ustar 00richard dev 0000270 0000002
id_jb
id_jb
Called by:
id_pha
each iteration unless no_reid_phase set.
Includes: iscloc.h, jb_model.h
External: max_resid
set in read_config
Input arguments:
Pointer to
solution
structure.
Pointer to
phase
structure.
Calls:
read_ttime
handle_error
and add_to_error
from utils
Structure members updated: phase
in phase structure.
Return: 0/1 for success/failure.
If the phase code given to an arrival is based purely on the reporters code
for that arrival then it is likely that it will not be possible to calculate
a residual for it using the required earth model. This could either
be because the reporter misidentified it or that they are using a different
naming convention. As the solution moves from iteration to iteration
it is necessary to retest that the value of phase
given to an arrival in id_pha
is still consistent with delta, source depth and the earth model in use.
The distance limits of the JB tables for each type of phase are stored as
macros in jb_model.h. For non-crustal P type arrivals
phase
is chosen from P, Pdiff, and PKP depending on the value of
delta
and an S phase can be renamed SKS or vice versa. If
delta
and source depth show that a phase is crustal then it can be more complicated.
If phase
is already a possible crustal phase (i.e.
rep_phase
is a possible crustal phase) then it will be left unchanged but if
phase
is P or S or an impossible crustal phase then
read_ttime
is called to find the travel times for all possible phases and the first
arriving phase is assumed to be the correct one.
id_pha.html 0100644 0002000 0001751 00000006131 07636626365 0013472 0 ustar 00richard dev 0000270 0000002 id_pha
id_pha
Called by: main
each iteration.
Includes: iscloc.h
External:
Definition of structure phase_map_rec.
Array of phase_map_rec structures, phase_map.
Number of rows in that array, NUM_PHASE_MAP.
Input arguments:
Pointer to
solution
structure.
Array of
phase
structures.
reid_phase
- a flag from the
event
structure.
Calls:
Function to reidentify phases e.g. id_jb
handle_error
from utils.c
Structure members updated:
phase
in
phase
structure.
Return: 0/1 for success/failure.
This function assigns a standard phase code to
phase
for each arrival that will be recognised by all subsequent functions.
This is initially done by looking up the value of
rep_phase
in the array of structures, phase_map, at the top of the file.
struct phase_map_rec phase_map[2] = {
{"p" , "P" },
{"P" , "P" },
}
With the phase_map above, for example, phase
would be set to "P" if rep_phase
for an arrival were either "p" or "P". Arrivals with all other
phase codes would have
phase
set to "". In addition unidentified initial phases (rep_phase
= "", init
= 1) have phase
set to "P" and secondary phases with
rep_phase
= "P" have
phase
set to "". Phases with no arrival time have
phase
set to "" as they are of no use in location.
Unless the no_reid_phase instruction has been given by the operator
the
reid_phase
flag will be set to 1. In this case each arrival that has been assigned
a non null value of
phase
will have that value checked to see if it is consistent with the distance
between the station and the source, and the source depth. This is carried
out by a function specific to the earth model in use, the function given is id_jb.
index.html 0100644 0002000 0001751 00000007111 07636626365 0013354 0 ustar 00richard dev 0000270 0000002 iscloc
Documentation for iscloc Hypocentre Location Program
Contents
Alphabetical Listing of Functions
calc_crust_corr
calc_delaz
calc_depdp
calc_elev_corr
calc_error
calc_gap
calc_geoid_corr
calc_netmag
calc_pP_resid
calc_resid
calc_sta_mb
calc_sta_ms
calc_weight
change_weighting
correct_ttime
decide_iter
find_pP
get_data
get_event
get_hyp
get_pha
get_weight_factor
huber_weight
id_jb
id_pha
init_event
init_sol
magnitudes
mark_duplicates
no_weight
oracle_funcs
pP_duplicates
print_hyp
purge_pha
put_hyp
rank_hyp
read_config
read_instruction
read_isf_event
read_jb
read_pP_P
read_stafile
read_ttime
solve
solve_depdp
utils
write_isf_event
init_event.html 0100644 0002000 0001751 00000007602 07636626366 0014417 0 ustar 00richard dev 0000270 0000002 init_event
init_event
Called by: main once for each event.
Includes: iscloc.h
External:
default_depth
set in read_config
min_phases
set in read_config
Input arguments:
Pointer to event
structure.
Array of hypocentre
structures.
FIelds updated:
Can reset fixed_depth, fixed_lat, fixed_lon, fixed_time, seed_agency
in event
structure.
etype
in event
structure.
Return: 0/1 for success/failure.
This function has two main roles:
First it checks and implements the combination of event
structure members set in read_instruction
and which concern fixing solution parameters. Thus, for example, if
depth_agency
has been set this function sets fixed_depth
to the depth from
the corresponding hypocentre. This can not be done by read_instruction
because the hypocentres have not been read in at that stage. If location_agency
is set and no separate depth fixing instructions have been given then the same hypocentre is used to set fixed_depth. If the location is set explicitly using lat=value and lon=value and no separate depth fixing instructions have been given then the depth is fixed to the value of default_depth
set in read_config. A similar procedure is followed if the time is fixed by agency, if
it is set explicitly then it is an error not to give a location fixing instruction
as there is no default location. Examples of combinations of operator instructions are given in the operator_control
chapter.
Second it sets the event type in the event
structure - a descriptive value not used except when printing or writing to database:
-
etype - a 2 character string indicating whether the event is certainly
or probably a tectonic earthquake, an explosion or a mining related event.
Set in function init_event
based on the reported event types of the hypocentres grouped in an event.
In addition this function checks that there are enough associated phases
to start a solution by comparing the total number of phases against min_phases, an external variable assigned in read_config. There is a test
every iteration in the weighting function to ensure that the number of useful
phases is greater than min_phases, but also testing at this stage saves time and a lot of error messages if there are no associated phases at all.
init_sol.html 0100644 0002000 0001751 00000006474 07636626366 0014101 0 ustar 00richard dev 0000270 0000002 init_sol
init_sol
Called by: main for each new seed/option.
Includes: iscloc.h
External:
sigma_start
set in read_config
weighting1
set in read_config
default_depth
set in read_config
Input arguments:
Pointer to solution
structure.
Pointer to event
structure.
Pointer to hypocentre
structure.
Calls: Function calc_dircos
from utils
.
Structure members updated:
time, lat, lon, dircos, and depth
in the
solution
structure.
converged, diverging, and phases_purged
in the
solution
structure.
numphas, weighting_type, and sigma
in the
solution
structure.
error
, sdobs
, mindist
, maxdist
, minax
, majax
, and theta
in the
solution
structure.
depdp
in the solution
structure.
Return: 0/1 for success/failure
This function sets up the solution for the first iteration using the hypocentre
passed to it as an argument. It also initialises the flags converged, diverging, and phases_purged
for a new solution and sets weighting_type
and sigma
to those given in config.txt
. For the sake of diagnostic messages that might be printed midway
through an iteration errors are set to 0 here and the value of depdp
is initialised
to NULLVAL in case none is calculated for this solution.
ter to solution
structure.
Pointer to event
structure.
Pointer to