Main Page Class Hierarchy Compound List File List Compound Members File Members

# sacputaway.c File Reference

`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <errno.h>`
`#include <earthworm.h>`
`#include <time.h>`
`#include <trace_buf.h>`
`#include <swap.h>`
`#include <ws_clientII.h>`
`#include <chron3.h>`
`#include <sacputaway.h>`
`#include <pa_subs.h>`
`#include <time_ew.h>`

Go to the source code of this file.

## Defines
#define | NQUICKLOOK 10
#define | INIT_FNAME "init"
#define | QUICKLOOK_FNAME "quicklook"
#define | REPICK_FNAME "repick"
#define | SACLIST_FNAME "saclist"
## Functions
void | sacinit (struct SAChead *)
void | swapsac (struct SAChead *)
int | SAC_Compare (const void *, const void *)
int | CreateSACSupportFiles (char *, SACFileListStruct *, int)
int | SACmac_init (void)
int | SACmac_quicklook (SACFileListStruct *, int)
int | SACmac_repick (SACFileListStruct *, int)
int | SAC_filelist (SACFileListStruct *, int, char *)
int | SAC_SwapDouble (double *pValue, char cDataType)
int | SAC_SwapLong (long *pValue, char cDataType)
int | SAC_SwapShort (short *pValue, char cDataType)
int | SACPA_init (long OutBufferLen, char *OutDir, char *OutputFormat, int debug)
int | SACPA_next_ev (char *EventID, TRACE_REQ *ptrReq, int nReq, char *OutDir, char *EventDate, char *EventTime, int debug)
int | SACPA_next (TRACE_REQ *getThis, double GapThresh, long OutBufferLen, int debug)
int | SACPA_end_ev (int debug)
int | SACPA_close (int debug)
int | SACPABase_Debug (int bDebug)
int | SACPABase_SetOutputFormat (char *szOutputFormat)
int | SACPABase_init (int OutBufferLen, char *szOutDir, int CreateNewDir, char *szOutputFormat)
int | SACPABase_next_ev (char *szEventID, double dEventStartTime, SAC_OriginStruct *pOrigin)
int | SACPABase_next_ev_review (char *EventDir, int EventID, SAC_OriginStruct *pSacOrigin)
int | SACPABase_next_scn (char *szSta, char *szChan, char *szNet)
int | SACPABase_write_trace (TRACE_REQ *pTrace, double dGapThresh)
int | SACPABase_write_parametric (SAC_ArrivalStruct *pArrival, int WaveType)
int | SACPABase_write_amppicks (SAC_AmpPickStruct *pAmpPick)
int | SACPABase_write_stainfo (SAC_StationStruct *pStation)
int | SACPABase_end_scn (void)
int | SACPABase_end_scn_gm (void)
int | SACPABase_end_ev (void)
int | SACPABase_close (void)
int | SACPABase_write_extinfo (SAC_ExtChanStruct *pExtChan)
## Variables
SACFileListStruct | FileList [DB_MAX_PHS_PER_EQ]
int | FileIndex
char | szCurEventID [EVENTID_SIZE+1]
int | SACPAB_Debug = 0
char | SAC_szOutDir [MAXTXT]
char | SAC_szOutputFormat [20]
double | SAC_starttime
SAC_OriginStruct | SAC_Origin
char | default_sachead [SACHEADERSIZE]
char | sachead [SACHEADERSIZE]
SAChead * | sacheadp = (struct SAChead *) sachead
SAChead * | default_sacheadp = (struct SAChead *) default_sachead
char | SacDir [2 *MAXTXT+4]
char * | SacBuffer
char | SAC_szSta [10]
char | SAC_szChan [10]
char | SAC_szNet [10]
int | BufferLen
int | bSACPABase_init = FALSE
int | bSACPABase_scn_open = FALSE

## Define Documentation

#define INIT_FNAME "init"

| Definition at line 1416 of file sacputaway.c.

#define NQUICKLOOK 10

| Definition at line 1413 of file sacputaway.c. Referenced by CreateSACSupportFiles().

#define QUICKLOOK_FNAME "quicklook"

| Definition at line 1417 of file sacputaway.c.

#define REPICK_FNAME "repick"

| Definition at line 1418 of file sacputaway.c.

#define SACLIST_FNAME "saclist"

| Definition at line 1419 of file sacputaway.c.

## Function Documentation

int CreateSACSupportFiles | ( | char * | ,
|  | SACFileListStruct * | ,
|  | int |
| ) |

| Definition at line 1425 of file sacputaway.c. References EW_FAILURE, EW_SUCCESS, logit(), NQUICKLOOK, SAC_filelist(), SACmac_init(), SACmac_quicklook(), and SACmac_repick(). Referenced by SACPABase_end_ev().

int SAC_Compare | ( | const void * | ,
|  | const void * |
| ) |

| Definition at line 1385 of file sacputaway.c. References _SACFileList::sort_param.

int SAC_filelist | ( | SACFileListStruct * | ,
|  | int | ,
|  | char * |
| ) |

| Definition at line 1568 of file sacputaway.c. References logit(). Referenced by CreateSACSupportFiles().

int SAC_SwapDouble | ( | double * | pValue,
|  | char | cDataType
| ) |

| Definition at line 1629 of file sacputaway.c. References logit(), and SwapDouble().

int SAC_SwapLong | ( | long * | pValue,
|  | char | cDataType
| ) |

| Definition at line 1595 of file sacputaway.c. References logit(), and SwapLong().

int SAC_SwapShort | ( | short * | pValue,
|  | char | cDataType
| ) |

| Definition at line 1612 of file sacputaway.c. References logit(), and SwapShort().

void sacinit | ( | struct SAChead * |  | ) |

| FUNCTION PROTOTYPES * Definition at line 1331 of file sacputaway.c. References MAXINT, MAXSTRING, NUM_FLOAT, SAC_I_D, SAChead2::SACfloat, SACUNDEF, and SACVERSION. Referenced by SACPABase_init().

int SACmac_init | ( | void |  | ) |

| Definition at line 1464 of file sacputaway.c. References logit(). Referenced by CreateSACSupportFiles().

int SACmac_quicklook | ( | SACFileListStruct * | ,
|  | int |
| ) |

| Definition at line 1493 of file sacputaway.c. References logit(). Referenced by CreateSACSupportFiles().

int SACmac_repick | ( | SACFileListStruct * | ,
|  | int |
| ) |

| Definition at line 1528 of file sacputaway.c. References logit(). Referenced by CreateSACSupportFiles().

int SACPA_close | ( | int | debug | ) |

| Definition at line 402 of file sacputaway.c. References EW_SUCCESS, logit(), SACPABase_close(), and SACPABase_Debug(). Referenced by PA_close().

int SACPA_end_ev | ( | int | debug | ) |

| Definition at line 374 of file sacputaway.c. References EW_SUCCESS, logit(), SACPABase_Debug(), and SACPABase_end_ev(). Referenced by PA_end_ev().

int SACPA_init | ( | long | OutBufferLen,
|  | char * | OutDir,
|  | char * | OutputFormat,
|  | int | debug
| ) |

| Definition at line 253 of file sacputaway.c. References EW_SUCCESS, logit(), SACPABase_Debug(), and SACPABase_init(). Referenced by PA_init().

int SACPA_next | ( | TRACE_REQ * | getThis,
|  | double | GapThresh,
|  | long | OutBufferLen,
|  | int | debug
| ) |

| Definition at line 323 of file sacputaway.c. References TRACE_REQ::chan, EW_SUCCESS, logit(), TRACE_REQ::net, SACPABase_Debug(), SACPABase_end_scn(), SACPABase_next_scn(), SACPABase_write_trace(), and TRACE_REQ::sta. Referenced by PA_next().

int SACPA_next_ev | ( | char * | EventID,
|  | TRACE_REQ * | ptrReq,
|  | int | nReq,
|  | char * | OutDir,
|  | char * | EventDate,
|  | char * | EventTime,
|  | int | debug
| ) |

| Definition at line 281 of file sacputaway.c. References epochsec17(), EW_SUCCESS, logit(), SACPABase_Debug(), and SACPABase_next_ev(). Referenced by PA_next_ev().

int SACPABase_close | ( | void |  | ) |

| Definition at line 1317 of file sacputaway.c. References bSACPABase_init, EW_SUCCESS, FALSE, and logit(). Referenced by SACPA_close(), and WriteSAC_shutdown().

int SACPABase_Debug | ( | int |  | ) |

| FUNCTION PROTOTYPES * Definition at line 450 of file sacputaway.c. References SACPAB_Debug. Referenced by SACPA_close(), SACPA_end_ev(), SACPA_init(), SACPA_next(), SACPA_next_ev(), and WriteSAC_init().

int SACPABase_end_ev | ( | void |  | ) |

| Definition at line 1285 of file sacputaway.c. References CreateSACSupportFiles(), EW_FAILURE, EW_SUCCESS, logit(), and SACPAB_Debug. Referenced by SACPA_end_ev(), and WriteSAC_EndEvent().

int SACPABase_end_scn | ( | void |  | ) |

| Definition at line 1157 of file sacputaway.c. References bSACPABase_scn_open, DB_MAX_PHS_PER_EQ, EW_FAILURE, FALSE, FileIndex, FileList, logit(), MAXTXT, SAChead::npts, SAC_starttime, SacBuffer, SACHEADERSIZE, sacheadp, SwapFloat(), and swapsac(). Referenced by SACPA_next(), and WriteSAC_NextStationForEvent().

int SACPABase_end_scn_gm | ( | void |  | ) |

| Definition at line 1225 of file sacputaway.c. References bSACPABase_scn_open, EW_FAILURE, FALSE, logit(), MAXTXT, SAChead::npts, SacBuffer, SACHEADERSIZE, sacheadp, SwapFloat(), and swapsac().

int SACPABase_init | ( | int | OutBufferLen,
|  | char * | szOutDir,
|  | int | CreateNewDir,
|  | char * | szOutputFormat
| ) |

| Definition at line 504 of file sacputaway.c. References SAChead::b, bSACPABase_init, BufferLen, CreateDir(), default_sacheadp, EW_FAILURE, EW_SUCCESS, SAChead::idep, SAChead::iftype, SAChead::iztype, SAChead::ko, SAChead::leven, logit(), MIN_OUTBUFFER_LEN, SAC_IBEGINTIME, SAC_ITIME, SAC_IUNKN, SacBuffer, sacinit(), and TRUE. Referenced by SACPA_init(), and WriteSAC_init().

int SACPABase_next_ev | ( | char * | szEventID,
|  | double | dEventStartTime,
|  | SAC_OriginStruct * | pOrigin
| ) |

| Definition at line 587 of file sacputaway.c. References CreateDir(), default_sacheadp, _SAC_OriginStruct::dElev, _SAC_OriginStruct::dLat, _SAC_OriginStruct::dLon, SAChead::evdp, SAChead::evel, EVENTID_SIZE, SAChead::evla, SAChead::evlo, EW_FAILURE, EW_SUCCESS, FileIndex, gmtime_ew(), logit(), SAC_Origin, szCurEventID, and _SAC_OriginStruct::tOrigin. Referenced by SACPA_next_ev(), and WriteSAC_StartEvent().

int SACPABase_next_ev_review | ( | char * | EventDir,
|  | int | EventID,
|  | SAC_OriginStruct * | pSacOrigin
| ) |

| Definition at line 662 of file sacputaway.c. References default_sacheadp, _SAC_OriginStruct::dElev, _SAC_OriginStruct::dLat, _SAC_OriginStruct::dLon, SAChead::evdp, SAChead::evel, EVENTID_SIZE, SAChead::evla, SAChead::evlo, EW_FAILURE, EW_SUCCESS, logit(), and szCurEventID.

int SACPABase_next_scn | ( | char * | szSta,
|  | char * | szChan,
|  | char * | szNet
| ) |

| Definition at line 700 of file sacputaway.c. References bSACPABase_scn_open, SAChead::cmpaz, SAChead::cmpinc, K_LEN, SAChead::kcmpnm, SAChead::knetwk, SAChead::kstnm, logit(), SAC_szChan, SAC_szSta, sacheadp, SACUNDEF, and TRUE. Referenced by ProduceSAC_NextStationForEvent(), and SACPA_next().

int SACPABase_SetOutputFormat | ( | char * | szOutputFormat | ) |

| Definition at line 471 of file sacputaway.c. References logit().

int SACPABase_write_amppicks | ( | SAC_AmpPickStruct * | pAmpPick | ) |

| Definition at line 1016 of file sacputaway.c. References EW_FAILURE, EW_SUCCESS, SAChead::kinst, SAChead::kt0, SAChead::kt1, SAChead::kt2, SAChead::kuser0, SAChead::kuser1, logit(), _SAC_AmpPickStruct::PickType, _SAC_AmpPickStruct::PP_amp, _SAC_AmpPickStruct::PPmax_time, _SAC_AmpPickStruct::PPmin_time, SAC_starttime, sacheadp, SAChead::t0, SAChead::t1, SAChead::t2, SAChead::user0, SAChead::user1, _SAC_AmpPickStruct::ZP_amp, and _SAC_AmpPickStruct::ZP_time.

int SACPABase_write_extinfo | ( | SAC_ExtChanStruct * | pExtChan | ) |

| Definition at line 1648 of file sacputaway.c. References SAChead::cmpaz, SAChead::cmpinc, _SAC_ExtChanStruct::dAzm, _SAC_ExtChanStruct::dDamping, _SAC_ExtChanStruct::dDip, _SAC_ExtChanStruct::dFullscale, _SAC_ExtChanStruct::dNaturalFrequency, _SAC_ExtChanStruct::dSensitivity, _SAC_ExtChanStruct::iGain, _SAC_ExtChanStruct::iSensorType, logit(), sacheadp, SAChead::user0, SAChead::user1, SAChead::user2, SAChead::user3, SAChead::user4, and SAChead::user5.

int SACPABase_write_parametric | ( | SAC_ArrivalStruct * | pArrival,
|  | int | WaveType
| ) |

| Definition at line 968 of file sacputaway.c. References SAChead::a, SAChead::az, _SAC_ArrivalStruct::cFMotion, _SAC_ArrivalStruct::cOnset, _SAC_ArrivalStruct::dAzm, _SAC_ArrivalStruct::dCodaLen, _SAC_ArrivalStruct::dDist, SAChead::dist, EW_FAILURE, SAChead::f, _SAC_ArrivalStruct::iPhaseWt, K_LEN, SAChead::ka, SAChead::kt0, logit(), PWAVE, SAC_starttime, sacheadp, SWAVE, SAChead::t0, and _SAC_ArrivalStruct::tPhase. Referenced by ProduceSAC_NextStationForEvent().

int SACPABase_write_stainfo | ( | SAC_StationStruct * | pStation | ) |

| Definition at line 1063 of file sacputaway.c. References SAChead::az, _SAC_StationStruct::bResponseIsValid, _SAC_StationStruct::dElev, _SAC_ResponseStruct::dGain, _SAC_PZNum::dImag, dist, SAChead::dist, _SAC_StationStruct::dLat, _SAC_StationStruct::dLon, _SAC_PZNum::dReal, SAChead::evla, SAChead::evlo, geo_to_km(), _SAC_ResponseStruct::iNumPoles, _SAC_ResponseStruct::iNumZeroes, logit(), _SAC_ResponseStruct::Poles, _SAC_StationStruct::pResponse, sacheadp, SACUNDEF, SAChead::stel, SAChead::stla, SAChead::stlo, and _SAC_ResponseStruct::Zeroes. Referenced by ProduceSAC_NextStationForEvent().

int SACPABase_write_trace | ( | TRACE_REQ * | pTrace,
|  | double | dGapThresh
| ) |

| Definition at line 779 of file sacputaway.c. References TRACE_REQ::actLen, BufferLen, TRACE_HEADER::datatype, SAChead::delta, SAChead::e, TRACE_HEADER::endtime, EW_FAILURE, logit(), SAChead::npts, TRACE_HEADER::nsamp, SAChead::nzhour, SAChead::nzjday, SAChead::nzmin, SAChead::nzmsec, SAChead::nzsec, SAChead::nzyear, SAChead::o, TRACE_REQ::pBuf, SAC_Origin, SAC_starttime, SacBuffer, SACHEADERSIZE, sacheadp, SACPAB_Debug, SACUNDEF, TRACE_HEADER::samprate, TRACE_HEADER::starttime, _SAC_OriginStruct::tOrigin, and WaveMsgMakeLocal(). Referenced by ProduceSAC_NextStationForEvent(), and SACPA_next().

void swapsac | ( | struct SAChead * |  | ) |

| Definition at line 1361 of file sacputaway.c. References MAXINT, NUM_FLOAT, SwapFloat(), and SwapLong(). Referenced by SACPABase_end_scn(), and SACPABase_end_scn_gm().

## Variable Documentation

int bSACPABase_init = FALSE`[static]`

| Definition at line 218 of file sacputaway.c. Referenced by SACPABase_close(), and SACPABase_init().

int bSACPABase_scn_open = FALSE`[static]`

| Definition at line 219 of file sacputaway.c. Referenced by SACPABase_end_scn(), SACPABase_end_scn_gm(), and SACPABase_next_scn().

int BufferLen`[static]`

| Definition at line 217 of file sacputaway.c. Referenced by SACPABase_init(), and SACPABase_write_trace().

char default_sachead[SACHEADERSIZE]`[static]`

| Definition at line 200 of file sacputaway.c.

struct SAChead* default_sacheadp = (struct SAChead *) default_sachead`[static]`

| Definition at line 212 of file sacputaway.c. Referenced by SACPABase_init(), SACPABase_next_ev(), and SACPABase_next_ev_review().

int FileIndex`[static]`

| Definition at line 187 of file sacputaway.c. Referenced by SACPABase_end_scn(), and SACPABase_next_ev().

SACFileListStruct FileList[DB_MAX_PHS_PER_EQ]`[static]`

| GLOBAL VARIABLES (global to this file )* Definition at line 186 of file sacputaway.c. Referenced by SACPABase_end_scn().

SAC_OriginStruct SAC_Origin`[static]`

| Definition at line 193 of file sacputaway.c. Referenced by SACPABase_next_ev(), and SACPABase_write_trace().

double SAC_starttime`[static]`

| Definition at line 192 of file sacputaway.c. Referenced by SACPABase_end_scn(), SACPABase_write_amppicks(), SACPABase_write_parametric(), and SACPABase_write_trace().

char SAC_szChan[10]`[static]`

| Definition at line 216 of file sacputaway.c. Referenced by SACPABase_next_scn().

char SAC_szNet[10]`[static]`

| Definition at line 216 of file sacputaway.c.

char SAC_szOutDir[MAXTXT]`[static]`

| Definition at line 190 of file sacputaway.c.

char SAC_szOutputFormat[20]`[static]`

| Definition at line 191 of file sacputaway.c.

char SAC_szSta[10]`[static]`

| Definition at line 216 of file sacputaway.c. Referenced by SACPABase_next_scn().

char* SacBuffer`[static]`

| Definition at line 215 of file sacputaway.c. Referenced by SACPABase_end_scn(), SACPABase_end_scn_gm(), SACPABase_init(), and SACPABase_write_trace().

char SacDir[2*MAXTXT + 4]`[static]`

| Definition at line 214 of file sacputaway.c.

char sachead[SACHEADERSIZE]`[static]`

| Definition at line 201 of file sacputaway.c.

struct SAChead* sacheadp = (struct SAChead *) sachead`[static]`

| Definition at line 206 of file sacputaway.c. Referenced by SACPABase_end_scn(), SACPABase_end_scn_gm(), SACPABase_next_scn(), SACPABase_write_amppicks(), SACPABase_write_extinfo(), SACPABase_write_parametric(), SACPABase_write_stainfo(), and SACPABase_write_trace().

int SACPAB_Debug = 0`[static]`

| Definition at line 189 of file sacputaway.c. Referenced by SACPABase_Debug(), SACPABase_end_ev(), and SACPABase_write_trace().

char szCurEventID[EVENTID_SIZE+1]`[static]`

| Definition at line 188 of file sacputaway.c. Referenced by SACPABase_next_ev(), and SACPABase_next_ev_review().