suds: seismic unified data system - usgs · suds: seismic unified data system peter l. ward ... to...

124
UNITED STATES DEPARTMENT OF INTERIOR GEOLOGICAL SURVEY SUDS: Seismic Unified Data System Peter L. Ward U. S. Geological Survey 345 Middlefield Road Menlo Park, CA. 94025 March 29, 1989 Open-File Report 89-188 This report is preliminary and has not been reviewed for conformity with U.S. Geological Survey editorial standards. Any use of trade names is for descriptive purposes only and does not imply endorse- ment by the USGS.

Upload: lamcong

Post on 14-Apr-2018

226 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

UNITED STATES DEPARTMENT OF INTERIOR GEOLOGICAL SURVEY

SUDS: Seismic Unified Data System

Peter L. Ward

U. S. Geological Survey345 Middlefield Road

Menlo Park, CA. 94025

March 29, 1989

Open-File Report 89-188

This report is preliminary and has not been reviewed for conformity with U.S. Geological Survey editorial standards. Any use of trade names is for descriptive purposes only and does not imply endorse­ ment by the USGS.

Page 2: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

Contents

1. Description 2

2. File listing 13

3. Manual pages 15

4. Connection of A/D to computer 44

5. Include files 46

6. Libsuds computer code 61

7. Commands computer code 74

8. Eqdetect computer code 90

9. AtoD computer code 113

Page 3: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

-2-

SUDS: Seismic Unified Data System

Peter L. Ward

U.S. Geological Survey, MS 977345 Middlefield Road

Menlo Park, Ca. 94025415/329-4736

1. NoteThis open-file report is a collection of documents written about SUDS at many different times.

They are collected here as a formality to provide public release of this information.

2. OverviewThe Seismic Unified Data System (SUDS) is a system for storing, accessing, and processing all

types of seismic data efficiently. The goals of SUDS are:

1). To promote widespread exchange of data.

2). To promote widespread exchange of programs for analyzing and displaying data.3). To make it easier for most seismologists to get their work done.

4). To reduce the effort required to write new programs.5). To provide a transparent way of dealing with the proliferation of computer architectures now

often being networked together.SUDS is a bus. In the figurative sense it provides a vehicle for many people traveling together.

Like a computer bus, SUDS provides a standardized way to plug together a wide variety of devices or modules so that they can communicate with each other efficiently. SUDS is also a workshop, a friendly place containing many of the specific tools needed to complete a project quickly and easily. While SUDS is based on standardization, it also provides numerous channels for growth and adaptation to fit the needs of an independent-minded research community. SUDS is developed around seismic data, but its methods and major tools apply equally well to any type of data in any field.

Overcoming the coefficient of static friction to learn about a new concept, language, or piece of hardware or software can appear difficult. It seems easier to stick with the familiar. There are many intricate details to SUDS, but most people will be able to derive the benefits of SUDS without having to learn these details. It is simply necessary to understand the overall concepts and then proceed to use the tools. You can fill in the details later when needed.

The building blocks of SUDS are natural, logical groups of data. These data groups are arranged end to end in a stream of information that can be stored and accessed sequentially, for example in a file or on a tape, and can be loaded sequentially into a database system where they can be accessed more randomly. Streams can be directed between different processes running on the same computer or over networks between processes running on different computers.

3. Introduction

The need for easy exchange of seismic data and data-analysis programs is increasing rapidly as digital recording systems are added to existing seismograph stations and networks and as we plan and build major global, national, topical, and portable networks. The advent of relatively inexpensive but powerful desktop workstations makes it feasible for most seismologists to do sophisticated waveform processing that we barely dreamed of a decade ago. In the last decade, major amounts of resources, especially in terms of trained scientific personnel, have been diverted to computer programming. This trend is likely to increase significantly as the data sources increase by orders of magnitude and our pro­ cessing goals increase in complexity. In theory it is a relatively trivial programming job to convert from one data format to another and to create analysis programs that input or output (I/O) several optional data formats. In practice, however, input and output becomes onerous, and some popular programs con­ tain little scientific code but major amounts of I/O code. Furthermore many scientists now wish to use

Page 4: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

-3-

database management systems to provide rapid indexed access to large collections of data. Thus a whole new layer of software is becoming necessary.

A major step forward in seismic data organization was made at Lamont-Doherty Geological Observatory with the creation of the ah or ad hoc data format Their approach was to group related information into C language structures and then to group structures into a header that is added to waveform data. This grouping leads to a data and file format that interfaces cleanly with dozens of pro­ grams or filters that they have developed.

The purpose of this document is to suggest an extension to Lament's approach that is applicable to a wide variety of seismic data and seismic data processing. The primary concern is to define a com­ mon but succinct set of data that would typically be archived for seismic stations and networks and to group these data in a manner that will be efficient in terms of storage space, processing time, and pro­ gramming time. The secondary concern is to make sure that this core format is readily extensible to meet the developing needs of research pursued by independent thinkers spread around the globe. If a common ground can be defined, we will all be able to exchange easily data and, even more important, data analysis programs. Such exchange would provide the most rapid route to accomplishing our individual and collective scientific goals.

4. ScopeMy interest in a data system relates primarily to local seismograph networks and the flavor of this

document reflects this interest. Most other users of earthquake related seismic data have similar needs, however. We all use waveforms, descriptors of waveforms, features picked from waveforms, and events calculated from these features. There are many areas where these interests overlap with people doing seismic refraction and reflection processing, strong ground motion analysis, etc. Thus I wish to encourage readers who have quite different interests not to be put off by the emphasis on local earth­ quakes and to provide advice on how their interests can be represented.

I have tried to take into account other major interests such as the database designed for the Center for Seismic Studies (Berger, J., North, R.G., Goff, R.C., and Tiberio, M.A., 1984, A seismological data base management system: Bull. Seism. Soc., v. 74, no. 5, p. 1849-1862)and the Proposed Seismic Data Distribution and Interchange Format developed at Albuquerque for world-wide data. I have also reviewed the typical PDE tape formats, ISC formats, and formats being used or developed for CALNET, the Southern Alaska Net, and SAC (Seismic Analysis Code). Some details from these representations will need to be added later to the structures discussed here.

The goal of this document is not to present THE ultimate data organization for seismology but to suggest and illustrate an approach to see if others would think it valuable to march to the same drummer. We could then work together to develop Version 1.

5. Levels of AgreementThere are four primary levels for agreement:

1.) Agree that a common, widely used, and extensible data format is desirable.2.) Agree on the groups of data that are most important.3.) Agree on the specific variables that most people need for present or anticipated routine and

research processing.4.) Agree on the actual bit representation of each variable, the manner in which variables will be

grouped, and the manner in which groups will be combined to form files, archive tapes or disks, and databases.In this document these levels are intermixed in order to organize the topics logically. Readers

may wish to focus their attention at specific levels depending on their degree of interest

3

Page 5: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

-4-

6. Groupings of Seismic DataComputing typically consists of grabbing groups of data, processing these data, and creating new

groups of data or images of data. Thinking involves much the same process. Just as our thinking is typically clearer when we can quickly and easily grab a small group of coherent ideas often represented by a precise scientific term, computer programs tend to be more efficient and shorter when we can easily grab related pieces of data.

Seismic data have certain natural groupings. For example:1). Information about the station and component on which data was collected: Name, location, gain

settings, component orientation, instrument type, etc.2). Information about a station component, such as calibration information, that typically involves

interpretation and calculation and may not be available at the time a waveform is recorded.3). The digital waveform data for an event often expressed in digital samples or volts.4). Descriptive information about a waveform such as maximum and minimum amplitude, average

noise, signal to noise ratio, number of clipped samples, etc. Such information is not only useful for scaling and plotting waveforms but also for searching for waveforms with certain characteris­ tics.

5). Information derived from a waveform such as phase arrival time, phase first motion, phase period, amplitude, coda length, etc.

6). Event information resulting from analysis of a group of phases, etc. As research processing continues more derivative forms of data arise:7). The waveform data expressed as ground velocity or displacement or as spectra or in other numer­

ically filtered forms such as rotated or summed components.8). "Phase" type data derived by advanced processing techniques.

These groups of data are created at different times. Thus before an event is detected by an online computer, only group 1 exists. After the event is detected groups 1 and 3 exist. After a small amount of automatic processing groups 1, 3, and 4 exist. The other groups might be generated automatically but generally will only be believed after human interaction.

A general data format should recognize these natural groupings and should allow for the fact that not all groups exist or are utilized at the same time.

7. OverviewA suggested data model is summarized in Figure 1 that reflects the general flow of research which

typically involves installation of instruments at many stations, observation of waveforms, interpretation of many features from each waveform, and processing these features to derive results. The topics in this figure are organized from those we create and thus know well at the top to those that involve the most interpretation and calculation at the bottom. Each box represents a topic or subject that has numerous attributes and each box will ultimately be represented by a data structure. The arrows with double stems designate the one-to-many relationships that are typical in these data. For one earthquake there may be many calculated origins. For one origin there are many arrival times. For one station there are many waveforms. For one waveform there may be many phase arrivals. Most database systems are built around these one-to-many relationships. A simple example is a table that presents data on a given topic or subject. The columns represent features of the subject and the rows represent instances of these features. In relational database terminology, the table is a relation, the columns are attributes, and the rows are tuples. The fundamental reason for establishing a new topic is to be able to represent suc­ cinctly these one-to-many relationships. The selection of topics is relatively straight-forward at the top and bottom of Figure 1 but becomes less clear in the middle. For example, most researchers group information on stations and events in different tables or files. On the other hand should information on moment be grouped with magnitude or even contained within the origin? Several principles appear to apply:

Page 6: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

-5-

Logic: In many cases the data fall into natural groupings as discussed above.History: Some features do not exist for much of the available data perhaps due to tradition or the development of new features such as moment. Thus while logically moment might be grouped with magnitude, it is typically not available for small earthquakes nor for most older earthquakes.Extensibility: Uncertainties for earthquake locations logically should be included with the origin information, but there are a variety of ways to calculate and represent the precision. Thus it seems reasonable to include a simple measure of precision with the origin especially for uniform search­ ing of the data but to assume that different researchers may need different ways to represent the precise errors such as by ellipsoids, by the covariance matrix, etc. Similarly there are many ways to represent the calibration of an instrument. While such extensibility will be needed to travel into the future, we should still strive where possible to find single, compact representations for com­ mon parameters from which a variety of traditional representations can be readily derived.Storage Efficiency: Most computer efficient database and file formats involve allocation of a fixed record size for each instance. Inclusion of many attributes that exist rarely will typically waste significant storage space. If these same attributes are relegated to a new topic, then they need only be stored when they existHalf of the topics in Figure 1 can be readily defined to meet common needs either because the

nature of these topics is closely related to experimental design or, as in the case of events, these topics have been traditionally tabulated for example by the ISC or NEIS. These topics represent the vast majority of the data and these are the topics that are most typically searched. Thus development of a unified data system for most of the data is not particularly difficult. Probably the greatest difficulty and disagreement regarding common formats will center on the rows marked Interpretation and Calculation. This is the area where there is the greatest diversity and where there will be the greatest need for expandability in the future. My approach here is to define groups commonly used making sure these groups can be indexed from the one side of the one-to-many relationships. New groups can then be defined as needed.

The box marked Association in Figure 1 represents the many ways we may chose to relate obser­ vations to calculations. Association is implementation dependent. In a database there might be a separate topic or relation that does this association. In the file system or on tape, this association is nor­ mally done by grouping the information in contiguous logical areas. Thus a disk or tape file might con­ tain all data applicable to a single event.

8. Data RepresentationThe groups of data will exist in different forms with different goals:

A). Off-line archival storage that ideally should include all relevant information about a given event and its data in contiguous storage space.

B). On-line storage in a format that is indexed for rapid retrieval probably contained within a data­ base management system. Typically for lack of sufficient storage devices, only waveforms of events being analyzed would be stored on line, but descriptive information of all events should be available.

C). On-line storage in files using the file system to specify groupings.D). In-core storage as represented in analysis programs.E). In some cases the original events as output by the online detector might be archived.

Choice of data storage format involves tradeoffs. Using ascii files for storage enhances readabil­ ity, allows use of existing editors and filters, and makes portability among machines easy, but reduces efficiency in reading, writing, storing and retrieving data. Efficiency has become an issue on the larger networks and will be an increasing problem as we expect to collect increasing amounts of data and to process these data with increasingly sophisticated tools. Since waveform data are most naturally and normally stored in binary format, I believe it is not much more of a problem if all the data are stored in binary format. I like Lament's approach to using a group of data structures, each of which groups related data. Furthermore the database that we are presently evaluating as most promising for seismic

b

Page 7: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

-6-

purposes, db_vista, uses data structures as the primary mode of data storage and retrieval. One of db_vista's major attributes, is speed. We can assure maximum machine efficiency with data structures. These structures also provide for excellent programming efficiency in C, Pascal, Modula2, PL/1 and VMS Fortran. It is rumored that the new Fortran standard expected this year will include structures.

Thus from my point of view, chosing data formats means first agreeing on what data needs to be stored and then designing a set of data structures that can be used as modules in storage, retrieval, and processing of seismic data. The rest of this document concerns my suggestions for these structures. It is assumed that while these structures are being adopted, utilities will be written to readily convert these structures into and out of ascii format. A good example of such a filter is the Lament command ah2asc. Similarly it is anticipated that a common library of low-level routines will be made available for identi­ fying and utilizing these structures. The structures are listed with a description of the data to be stored in the comment field on the right side of the page and the actual allocation of memory space on the left side of the page. Many readers may wish to focus only on the right side of the pages to be sure the appropriate information is stored.

9. Some principles:a). The structures should be self identifying so that in a general case such as a tape archive, the read­

ing program could determine what structures exist, in which order they exist, and whether the program knows how to deal with them.

b). The structures should define common groupings of interest, but new structures should be definable in the future. The structures discussed below might form a core set that is very extensible. The programs using these structures must be able to identify each structure and to decide whether or not they can be interpreted by that particular program.

c). There is typically a conflict between storage efficiency and generality. These structures are an attempt to ride the middle ground. I encourage you to consider other variables that should be added but to temper your first urge with realism.

d). To enhance portability among machines, some effort should be made to align appropriate byte boundaries.

10. A Short Primer on C StructuresThe appendix is written in C syntax although the ideas presented here do not depend on adoption

of C. A C structure is a grouping of variables of mixed types in a contiguous section of memory so that the whole structure can be passed between subroutines as a unit or by a pointer. In its simplest form a C structure is similar to a Fortran common block. In fact on many compilers Fortran common blocks are referenced in C as structures and C structures can be made available to Fortran programmers either as common blocks or, when more complex, as a small library of subroutines. Passing structures between routines and on and off of disk or tape is highly efficient

In C new variable types can be defined using typedef. typedef x y means henceforth define all variables of type y to be type x. Thus typedef int phase; phase x; means x is of type phase which is of type int. Typedefs are used to make the code more modular, readable, and portable and to isolate custom definitions. Use of typedefs will allow us in the future to take advantage of new languages such as C++ that allow complete specification of new variable types so that the compiler can check for improper usage. The following basic typedefs are used throughout this document:

typedef char CHAR A single ascii character typedef char STRING A character string, null byte terminated

STRING c[10] means a character string with a maximum length of 10. The active length may to 0 to 9 characters terminated by a null byte. Thus note that if a station name is, for example, defined as STRING name[6], it can contain only 5 characters.

typedef char BITS8 An 8 bit field, used for on-off flagstypedef short SH_INT A 16 bit signed integertypedef long LG_INT A 32 bit signed integertypedef float FLOAT A 32 bit floating point number, IEEE

Page 8: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

-7-

typedef double DOUBLE A 64 bit double precision number, IEEE

11. Special Types of VariablesTIME: A single number representation of time provides the most efficient form for storage,

search, and computation. Such a number is typically defined in terms of seconds from some standard time. One possible standard is that used by the UNIX operating system, which is now widely used in seismology. In UNIX time is kept in terms of the number of seconds since 00:00 GMT on January 1, 1970. The newest releases of UNIX also provide for a structure with two long integers, the number of seconds and the number of milliseconds. A double precision number takes the same storage as 2 longs and can provide time resolution finer than microseconds from the birth of Christ to a long time in the future. This precision is more accurate than needed in seismology. Thus I adopt the standard:

typedef DOUBLE ms_time;The value of ms_time variables can then be easily defined from the system clock and ms_time vari­ ables can be easily converted to ascii strings and other representations using UNIX utility subroutines.

A common use of time is to identify when an instrument was changed or calibrated, when a loca­ tion was calculated, etc. In this case accuracy to 1 second is more than adequate. Given the number of cases where such a timestamp is desirable, the use of only 4 bytes of storage becomes valuable. Thus I adopt a second type of time:

typedef LGJNT st_timeLONGITUDE-LATITUDE: A single number representation for degrees is also desirable for

storage, searching, and computation. By definingtypedef LG_INT lonlat;

and counting in units of millionths of degrees, we obtain a variable that uses only 4 bytes, is easily derived from true degrees, and is accurate to about 0.1 meters. This same type could be used for all angles, but in most cases a FLOAT seems adequate.

IDENTIFIER: Each phase, waveform pick, etc. needs to be associated with a given station, instrument type, and component. It is useful to adopt a structure of this information:

typedef struct {STRING network[4]; STRING name[5]; CHAR component; CHAR type; CHAR recorder;

} ident;Component would typically be v, n, e, r, t but could be any other character. A list of common types of components and instruments would need to be developed and a subroutine written that returns a charac­ ter string describing each code represented by a character or short integer.

12. Structures and Their UseThe structures are listed in the Appendix in a manner that is compilable. Before getting lost in the

details of each structure, it is important to understand how these structures might be used. The reason for defining structures is to group related variables in a manner that they can be readily accessed as a unit The bit representation of this unit would be identical whether the unit exists on disk or in memory, it should be identical on magnetic tape for the most commonly used computers, and probably would be identical when the unit exists in a database depending on the database design. User programs would read or write these units and would access individual variables by addressing them as components of these units. In Fortran a subroutine would be called to read the next unit, load the values into a com­ mon block, and return the number of the common block loaded. Of course the values could also be passed as subroutine arguments when desired. A fundamental feature of this design is that structures are identifiable, so that they can be combined in any order deemed appropriate and any subset of struc­ ture types could be used. Let's look at specific examples.

In some seismic networks the data are collected on a computer with a detector algorithm and written to tape for transport to another computer for processing. Each file on this tape might be

1

Page 9: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

-8-

formated as follows:For each station in order data are multiplexed:

structtag; stationtrace; structtag; muxdata; structtag; data;

In a different application the multiplexed data might be transmitted to a central recording center via satellite. Since the station information is known to the receive site, the data format might simply be:

structtag; muxdata; structtag; data;

Many seismic networks do automatic processing online. The data would be demultiplexed and might be stored in a disk or tape file as:

For each station:structtag; trace; structtag; data;

We might wish to integrate the same data into a database. In this case the trace and and loctrace struc­ tures would be loaded into the database and the preceding file either kept as is or the trace structures could be removed.A useful format for processing might be labeled by origin and contain:

structtag; event; structtag origin; For each station:

structtag; trace; structag; data; For each marker:

structtag; marker;An archive tape on the other hand might contain most of the structures as follows:

structag model; For each layer:

structtag; layers; For each event:

structtag; event; For each station:

structtag; trace; structag; data; For each origin:

structtag; origin; structtag; error; For each station marker:

structtag; marker; structtag eventread;The point is that the groupings can be set to meet local needs and to reflect the order and degree

of processing. Programs would typically ask for the next structure and proceed according to what that structure is. A program could skip unknown structures or complain about them as desired.

The simplest way to link relevant structures is to group them together within a file. Another way is to include header information for example about each event within each marker. This is essentially how a relational database is usually set up. A network database, on the other hand, stores these links invisibly for the user. Putting the links within the structures creates less ambiguity but increase the complexity of implementation details and the storage space required. I have designed these structures to minimize redundancy and to use physical grouping in files to define logical grouping. Thus all arrivals pertain to the previous mentioned solution. All features refer to the previously described waveform, and so forth.

13. Physical Tape FormatThe unified data system does not require any particular physical tape format. The data are treated

as a stream of information and can be blocked onto tape in any number of ways. I think the easiest is to use physical block sizes of 20 times 512 or 10,240 bytes or less and to truncate the last block in a record. This upper limit is the largest block some systems will read. Unix tar tapes provide a nice way to label and manage multiple files but other standards such as an ANSI Labeled tape format might work. A standard byte order will need to be adopted and filters provided to swab bytes and change

Page 10: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

-9-

data types as necessary. It would be most efficient to adopt the bit formats of the most heavily used computers in Seismology. Another more general approach would be to use the external Data Represen­ tation language developed for networking.

14. ExamplesAn example of a structure viewed using st2asc follows:

% Is -I stsample-rw-r r~ 1 ward 76 May 20 13:41 sLsample

% st2asc stsample5 64 0 "kat" "ksv" V 1 0 0 60.130000 -154.230000 675.000000 'b' 0 Y

V 115 'g' V V 'd' V 4 1000000.000000 1024.000000 55.669998 581100999

st2asc -v stsampleSTRUCTURE: stationcomp station/component :

STRUCTURE: stationnetworkstation namecomponentinstrument type

component azimuth component incidence lati tude longi tude elevation, meters enclosure annotated comment recorder type rock class rock type site condition sensor type data type data units polari ty statusmaximum gain clipping value convert factor effective date

(length=64+0=64 bytes)

ident"kat""ksv"'v'

1 {sp usgs)0060.130000-154.230000675.000000'b'

0 {no comment}

115 {this code undefined}

'v' s''d''n'

4 {filtered}1000000.0000001024.00000055.669998May 31, 1988 16:56 39 GMT

An example of a data file viewed with stdescribe follows:

% stdescribe st.871005040607

File st.871005040607: 0 5 stationcomp length1 7 descriptrace length2 5 stationcomp length

64+ 0 bytes kat.ksv.v.152+ 4312 bytes kat.ksv.v.164 + 0 bytes katkbte.e.l

Page 11: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

- 10-

3456789

10111213141516171819202122232425262728293031

75757575757575757575757575757

descriptracestationcompdescriptracestationcompdescriptracestationcompdescriptracestationcompdescriptracestationcompdescriptracestationcompdescriptracestationcompdescriptracestationcompdescriptracestationcompdescriptracestationcompdescriptracestationcompdescriptracestationcompdescriptracestationcompdescriptracestationcompdescriptrace

lengthlength

lengthlength

lengthlength

lengthlength

lengthlength

lengthlength

lengthlength

lengthlength

lengthlength

lengthlength

lengthlength

lengthlength

lengthlength

lengthlength

length

52 +64 +

52 +64 +

52 +64 +

52 +64 +

52 +64 +

52 +64 +

52 +64 +

52 +64 +

52 +64 +

52 +64 +

52 +64 +

52 +64 +

52 +64 +

52 +64 +

52 +

43120

43120

43120

43120

43120

4312

bytesbytesbytesbytesbytesbytesbytesbytesbytesbytesbytes

0 bytes4312

04312

04312

04312

04312

04312

04312

04312

04312

bytesbytesbytesbytesbytesbytesbytesbytesbytesbytesbytesbytesbytesbytesbytesbytesbytes

katkbte.e.lkat.kbtn.n.lkat.kbtn.n.lkatJcbtv.v.lkatJcbtv.v.lkat.krbe.e.1kat.krbe.e.1kat.krbn.n.lkatkrbn.n.lkatJcrbv.v.lkaLkrbv.v.lkat.ksm.v.14katksm.v.14katJctp.v.lkatktp.v.lkat.kkcn.n.1katkkcn.n.lkat.pub.v.14kat.pub.v.14kat.blm.v.14kat.blm.v.14kat.kkce.e.1kaLkkce.e.lkatJckcv.v.lkatkkcv.v.lkat.www.v.14kat.www.v.14kat.kkr.v.lkat.kkr.v.1

An example of a data files viewed with st2asc follows:

% st2asc -v st.871005040607

STRUCTURE: stationcomp (length=64+0=64 bytes) station/component :

STRUCTURE: station identnetworkstation namecomponentinstrument type

component azimuth component incidence lati tude longi tude elevation, meters enclosure annotated comment recorder type rock class rock type site condition sensor type

"kat""ksv"'v'

10058.591702-155.320007488.000000

{sp usgs)

0 {no comment)

{none given)

Page 12: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

data type data units polarity s tatusmaximum gain clipping value convert factor channel spare

STRUCTURE: descriptrace station/component :

STRUCTURE: stationnetworkstation namecomponentinstrument type

beginning time local time diff data type data descriptor digi t ized by processed by number of samples samples per second minimum data value maximum data value average noise num clipped samples Waveform Data:

- 11 -

's'» »

» 5

0 {none}NODATA0.000000NODATA-3276811648

(length=52+4312=4364 bytes)

ident : "kat" : "ksv" : 'v'

: 1 {sp usgs}

263234190190102205161161190234351263

13117516117573

13158102263234175249

:

dee

es

Oct 5,NODATA's'

0~

02156

1987 0

{not{not

4:06 07

given}given}

100.000000-14.00000073.000000212.949997

-14 146146 161190 146146 131-14 10214 20573 7329 146

161 131190 146161 322175 263

0

17523421914620511716173

205234307351

219234249249146190175263307336366234

1751751615873

20558

131307263234263

1429 14643 -1414

102 102 190 117 205 263

205 219 190 14658

117 -1443 117 234 380 307

234190292131117131161117190380424351

An example of reading structure in a C program:stream = st_open(input_file, "r");while ( st_get ( &st__ptr, &st_type, &st_len, stream)!=EOF) {

switch ( st_type ) { case STATIONCOMP:

load station list; break;

case FEATURE:load feature list;

(I

Page 13: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

- 12-

break; case DESCRIPTRACE:

plot trace;break;

default st_firee ( st_j>tr );

st_close(stream);

Page 14: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

file

.list

/um

r/m

udm

total

10-rw-r r

1 ward

drwxr-«r-x

3 ward

drwxr-«r-x

2 ward

drwxr-«r-x

2 ward

-rw-r r

1 ward

drwxr-ar-x

2 ward

drwxr-«r-x

3 ward

drwxr-«r-x

2 ward

drwxr-tr-x

4 ward

drwxr-«r-x

4 ward

./bin

total

888

-rwxr-xr-x

1 ward

-rwxr-xr-x

1 ward

-rwxr-xr-x

1 ward

-rwxr-xr-x

1 ward

-rwxr-xr-x

1 ward

-rwxr-xr-x

1 ward

-rwxr-xr-x

1 ward

./doc

total

72-rw-r r

1 ward

-rw-r r

1 ward

. /in

clud

*total

78-rw-r r

1 ward

-rw-r r

1 ward

drw

xr-«

r-x

2 ward

^-rw

-r r

1 ward

-rw-r r

1 ward

-r r r

1 ward

-rw-r r

1 ward

-rw-

r r

1 ward

-r r r

1 ward

-r r r

1 ward

. /inoltuU/SCCS

total

56-r r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-r r r

1 ward

-r r r

1 ward

-r r r

1 ward

-r r r

1 ward

-r r r

1 ward

./lib

total

0./ an

tota

l 3

-rwxrwxr-x

1 ward

drwxr-*r x

2 ward

drwxr-«r-x

2 ward

. /na

n/na

nltotal

31-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

927 Mar 29

10:25

README

512

Jan

24 17:05

SYS/

512 Mar 2

3 11:23

bin/

512 Mar 1

7 16:12

doc/

12 Mar 2

9 11:28

fila

.lic

t51

2 Jan

26 16:01

fila

s/512 Mar 2

3 11:40

includ*/

512 NOT

1 10:54

lib/

512 D*c 2

8 11

:46 nan/

512

Nor

1 10:54

arc/

131072 Nor

18 08:35

ah2*

t*114688 Nor 1

8 08

:36

a«c2

*t*

122880 Nor

14 09:41

d*mu

x*114688 Mar 2

3 11:23

*t2a

h*114688 Nor 1

8 08

:36

*t2a«o*

90112

Nor 1

8 08

:36

ctde

scri

ba*

172032 Nor

18 08

:36

*t*d

it*

36158 Mar 29

10:2

2 ud».op*n.fil*

36158 Mar 2

9 10:22

ud».op*n.fil*%

98 NOT 1

7 16:17 Ma

k*£i

l*98

Nor

17 16:17 Mak*£il*%

512 Mar 22

15:54

SCCS/

2906 Mar 2

2 15:51

ahh*ad*r.h

2895 Mar 2

2 15:51

ahh*ad*r.h%

828

NOT 1

7 16:18

mt *rror.h

20704 Mar 2

2 15:55 mda.h

20703 Mar 2

2 15:55

ud».h%

5954

Nor

17 16:16

mudm

cod*«.h

19586 Nor 1

7 16:16

ud»_d*«cr.h

0 Nor

17 15

:59

2036

.595

814378

31 Mar 22

15:5

0 p.ahh*ad*r.h

31 Mar 22 15:54

p. mud

m. h

3177 Nor

17 16:10

.ahh*ad*r.h

1090 Nor

17 16:10

m.mt

*rror.h

20981

Nor

17 16:11

a.auda.h

6216

Nor

17 16:11

m.mu

dm co

das. h

19850

Nor 17

16

:11

m.mudm daicr.h

539 Nor 17 11:19 MAKELZNKS*

512 Mar 29

11:00 nanl/

512

Nor

17 11:14

nan3/

1213 Nor

1 10:54

ah2«t.l

1651 Nor

1 10:54

a*c2*t.l

882

Nor

1 10:54

cdd.l

1784 Nor

1 10:54

plot

atod. 1

13956 Nor

1 10:54

rsx.

l28

45 Nor

9 09:22

«cmn»«i«.l

794 Mar 23

12

:29

*t2ah.l

1984 Nor

1 10:54

«t2a«c.l

-rw-

r r

1 ward

-rw-r r

1 wa

rd. /man/man3

total

31-rw-r r

1 wa

rd-rw-r r

1 wa

rd-rw-r r

1 ward

-rw-

r r

1 ward

-rw-

r r

1 ward

-rw-

r r

1 wa

rd-rw-r r

1 wa

rd-r

w-r r

1 ward

-rw-r r

1 ward

-rw- r

1 ward

-rw-

r

1 ward

-rw-

r

1 wa

rd-rw- r

1 ward

-rw- r

1 ward

./ re

tota

l 2

drwxr-«r-x

ward

drwxr-«r-x

3 ward

. / re/end

total

1000

-rw-

r r

1 ward

-r r r

1 ward

drwxr-«r-x

2 wa

rd-rwxr-xr-x

1 ward

-r r r

1 wa

rd-rwxr-xr-x

1 wa

rd-r r r

1 ward

drwxr-«r-x

2 ward

drwx

r-ft

x x

2 ward

drwx

r-ft

x x

3 ward

-rw-r r

1 wa

rd-r

wxr-

xr-x

1 ward

-rw-r r

1 ward

-rw-r r

1 wa

rd-rwxr-xr-x

1 wa

rd-r r r

1 wa

rd-rwxr-xr-x

1 wa

rd-r

r r

1 ward

-rwxr-xr-x

1 ward

-r r r

1 ward

. /src/cmd/atod

total

765

-rw-r r

1 wa

rd-rw-r r

1 wa

rd-rw-r r

1 wa

rd-rwxr-xr-x

1 ward

-rw-

r r

1 ward

-rw-

r r

1 ward

-rwxr-xr-x

1 ward

-rw-r r

1 ward

-rwxr-xr-x

1 wa

rd-r

w-r r

1 ward

. / rc/cmd/«<id«t*ct

total

788

-rw-

r r

1 ward

-rw-r r

1 ward

-rw-

r r

1 wa

rd-rwxr-xr-x

1 wa

rd-rw-r r

1 wa

rd-rw-r r

1 wa

rd-rw-r r

1 wa

rd

712 No

r 1

10:54

*tde

*cri

be.l

2403

NO

T 1

10:54

ct*d

it.l

911 No

r 1

10:54

a«c2

fi«l

d.3

3456

Nor

1 10:54

atod.3

1024 Nor

1 10:54 de.cr tra

e«.3

907 No

r 1

10:54

find cod*. 3

926 No

r 1

10:54

mt eloM.3

2698

No

r 1

10:54

mt nor. 3

1511 No

r 1

10:54

*t_0«t.3

875 Nor

1 10:54

mt in

lt.3

7940

No

r 1

10:54

mt intro.3

2033

Nor

1 10:54

mt op*n.3

787 Nor

1 10:54

«t_put.3

1715 No

r 1

10:54

mt sa

ck. 3

2378

NO

T 1

10:54

mt tiM.3

896 Nor

1 10:54

*t_u

ng«t

.3

1024 Mar 29

10:30

end/

512 Nor

1 10:54

lib/

815 NO

T 18

08

:26

,Mak

«fil

«89

1 Mar 22

09:45 Makafil*

512 Mar 22 09:44

SCCS/

1310

72 Nor 18

08:27

ah2«t*

8628 No

r 17

15:55

ah2«t.c

114688 No

r 18 08:27

a*c2

*t*

5699

Nor 17

16

:18

a*c2

*t.o

512 Mar 17

14

:56

atod

/512 Mar 29 10:44

dMnux/

1024 Mar 23

11:30

qdetcct/

154368 Mar 23

08:34

oldah

1146

88 Mar 23

11:08

*t2a

h*55

91 Mar 23 12:31

*t2ah.c

20776 Mar 23

11:08

*t2a

h.o

114688 No

r 18 08:27

*t2a

«c*

10375 No

r 17

16:18

*t2a*c.o

9011

2 No

r 18 08:27

ctdc

scri

ba*

1704

Nor 17

16

:18

*td**crib«.o

1720

32 No

r 18

08:28

ctadit*

19324 NO

T 17

16

:19

ct*dit.o

3154

No

r 1

10:55

CDDatod.e

372 Nor

1 10

:55 Makafil*

6756 Nor

1

10:5

6 atod . in

stal

lati

on98304

Nor

1 10

:56

odd*

5412 No

r 1 10:56

cdd.e

2110 No

r 1 10:56 parkfi«ld.*tat*

638976 Nor

1 10:56 pl

otat

od*

12582 No

r 1

10:5

6 plotatod. e

71 NOT

1 10

:55

show

atod

*12

80 Nor

1

10:55

«t.«

c. parkfiald

895 D«e 28

12:1

8 Makafil*

343

Jan

18 14:51

README

1076

NOT

1 10:56

T«*t

n«t.

c32768

Nor

1 10:56

a. out

*5622 Nor

1 10

:56

args

.c5922 NOT

1 10

:56

cach

a.c

4304

No

r 1 10:56 di

ag.c

Page 15: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

file

.list

-rw-r r

1 ward

-rw-r r

1 ward

-rwxr-xr-at

1 wa

rd-r

wxx-xr-x

1 wa

rd-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 wa

rd-rw-r r

1 ward

-rw-r r

1 ward

-rw-

r r

1 ward

-rwx

r-xr

-at

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-

r r

1 ward

-rw-

r r

1 ward

-rw-r r

1 wa

rd-r

w-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

drwxr- «r-

x 2 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

. / rc/cnd/*q

d«t*

ct/r

tptotal

61-rw-r r

1 ward

JJ -rw-r r

1 ward

-- X^-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rwxr-xr-at

1 ward

-rw-r r

1 ward

-rw-

rw-r

1 ward

. / rc/cnd/dwMuc

total

144

-rw-r r

1 ward

-rwxr-xr-at

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

. /arc/ cnd/SCCS

total

50-r r r

1 ward

-r r r

1 ward

-r r r

1 ward

-r r r

1 ward

-r r r

1 ward

-r r r

1 ward

./ rc/lib

total

1dn

ncrwcxwx

3 ward

. / r

c/li

b/cu

dctotal

167

-r r r

1 ward

drwxr-«r-at

2 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

-rw-r r

1 ward

2762

HOT

1 10

:56

dynflag.c

286720 NOT

1 10

:56

q.t

«*t

99 D*c 2

8 12

:10

qd.

park

*18

0224

NOT

1 10:56

qd«

t«ct

or*

3481 NOT

1 10:56

<jd«t«ctor.l*

9821

HOT

1 10

:56

<jd

«t«c

tor.

c8217 Nor

1 10

:56

od«t«ctor.h

1738 D*c 2

8 12

:14 qd«t«ctor.optiom

6947

F«b

1 13:35

g«tmf<Mp.c

449

Oet

25 14

:44

g«ttim .c

2054

Nor

1 10

:56

h*ad«r.h

32768

Nor

1 10

:56

in*p

*ct*

94 Nor

1 10:56

kata

ai . ubnwt*

284 Nor

1 10:56 k«y.h

2127

HOT

1 10:56

Ipa.h

1924

Nor

1 10

:56

Ipaopan.c

74 Nor

1 10

:56

onli

n*.r

un12

3 D*c 28

12:26

onli

ne. ru

n. vpi

174

Nor

1 10:56

onlioa.cta

366 Nor

1 10:56

onli

ne. «ta. chi

na71

77 Nor

1 10:56

out.c

103 Nor

1 10

:56 pa

rk£i

«ld.

*ubn«t*

512 Mar 17

15:59

rtp/

229 Nor

1 10:56

rtp.«

1415

28 Nor

1 10:56

mt .88

0805

2219

42890 Nor

1 10

:56

t**ttin*.c

16004

Nor

1 10

:56

trigger*

1289 NOT

1 10:56 Ma

k.fi

!

47 Mar 17

15:59

READ

ME

2716

Nor

1 10

:56

qdacmon.c

1713

Nor

1 10:56

qd«t*ctor.c

1872

Nor

1 10:56

qap

ool.

c3941 Nor

1 10:56 ppch«ck.c

13112

HOT

1 10

:56 pp

ick.

c32768 Nor

1 10

:56

*igt

«*t*

631 Nor

1 10:56

igt«*t.c

861

Nor

1 10:56

touc

h. c

233 Mar 22

08:08 Mak.fi !

114688 Mar 22

08:11

d*ou

x*6083 Mar 23

11

:35

d*»ux.c

16886 Mar 22

08:11

dmuu

t.o

1096 Mar 22

09:44

.M»k

*fil

«88

78 NOT 17

15

:54

.ah2

*t.c

5948

Nor 17

15:54

.a*c2*t.c

10624 Nor 17

15:54

.*t2a*c.c

1949 Nor 17

15

:54

.*td**crib*.c

1957

3 HOT 17

15:54

.«t«dit.c

1024

Nor 18

08

:24

*uda/

826 Nor 18

08

:24 Mak.fi !

512 Nor 18

08

:23

SCCS

/32

25 Nor 17

12:29

a*c2fi«ld.c

2180

Nor 17 12

:29

d«*c

r trac*.c

867 Nor 17

12:29

find cod«.c

1217

00 Nor 18 08:19

liba

ud«.

a18

35 NOT 17 12

:30

»t «r

ror.

c

-rw

-r z

1

war

d rw

-r r

1

war

d-r

w-r

r

1 w

ard

/

rc/1

ib/*

ud

*/S

CC

S

ota

l 2

-r r

r

1 w

ard

/fil

M

ota

l 23

1 r

w-r

r

1 w

ard

rw

-r r

1

war

d

1 w

ard

/SYS

otal 10

drwxrwxrwx

3 ward

rw

-r z

1

war

d r

w-r

r

1 w

ard

rw

-r r

1

war

d /S

YS

/Tw

ipla

tM

:ota

l 3

rw

-r r

1

war

d dr

wxr

wcr

wx

2 w

ard

/SY

S/T

«ip

latM

/root

tota

l 0

2091

NO

T 17

12

:30

*t_

init

.c63

27

NOT

17

12:3

1 «t_

tim

«.c

1653

2 NO

T 17

12

:31

cud

* io

.c

1030

»O

T 18

08

:23

«.M

ak

«fi

154368 »OT

1 10:54 ah.871005040607

71232 NOT

1 10:54 *t.871005040607

76 HOT

1 10:54 *t.*aapl«

512 Jan 24 17:04 T*nplat«*/

249 Jan 24 17:05 ho«t«

2580 Jan 24 17:05 re.boot

4753 Jan 24 17:05 re.local

1229 Jan 24 17:04 README

512 Jan 24 17:04 root/

Page 16: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

AH2ST(IS ) UNIX Programmer's Manual AH2ST(IS )

NAMEah2st - convert an ah stream into a suds stream

SYNOPSISah2st [ -c clip value ] [ -n netname ] [ -ofile ] [ -s factor ] [files]

DESCRIPTIONah2st converts a stream of ah or ad hoc structures in the Lamont-Doherty format into suds structures. For each waveform the suds structures stationcomp, origin, and descripttrace followed by the waveform are created. If calibration information is included in the ah structure, a suds structure cali­ bration is created. If the ah fields ecomment and rcomment include information, suds comment struc­ tures are also created.

OPTIONS-c Make the next argument the plus and minus value where clipping of the waveform begins.

-n Make the next argument the network name.

-o Put the output in the following file instead of stdout.

-s Convert the waveform to short integers multiplying each point by factor.

SEE ALSOst_intro(3s), asc2st(ls)

BUGSThe ah variable rmin is not translated into the suds structures.

AUTHORPeter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

4 May 1988 USGS

Page 17: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

ASC2ST(IS) UNIX Programmer's Manual ASC2ST(IS)

NAMEasc2st - convert an ascii stream to a stream of suds structures

SYNOPSISasc2st [ -ofile ] [file... ]

DESCRIPTIONasc2st converts a stream of ascii data into suds structures. Each input line is assumed to begin with the integer number of the structure type and to contain one data field for each variable within the structure in order. The data fields may be separated by blank spaces, tab characters, or commas. Presently this routine simply reads the non-verbose output of s&asc.

OPTIONS-c The following file contains a control file similar to /usr/include/suds/suds_descr.h. The input

format and order can be changed from this control file. NOT IMPLEMENTED YET.

-o Put the output in the following file instead of stdout.

-s Field separators may only be one of the characters in the following string. NOT IMPLE­ MENTED YET.

-v Ascii data are in verbose format output by st2asc. The input routines will assume any charac­ ters on a line before an unquoted colon are pan of the field label. The label is matched to the standard list to determine which field follows. Thus lines for fields may be in any order within a structure and may be left out NOT IMPLEMENTED YET.

-V List input as read. If asclst fails, this option can show on what field it fails.

SEE ALSOst_intro(3s), st2asc(ls)

DIAGNOSTICS BUGS

This routine is presently bare bones and should be expanded to cover a variety of input styles.EXAMPLES AUTHOR

Peter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

27 April 1988 USGS

Page 18: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

CDD(IS) UNIX Programmer's Manual CDD (IS)

NAMEcdd - contol CDD analog-to-digital converter

SYNOPSIS cdd

DESCRIPTIONcdd is an interactive program for controlling the Cutler Digital Design analog-to-digital converter. It provides a menu:

o open(type msec/sample and number of channels)r rezero atodg get datah get headerss send control information to atodt set time (Type day hour min sec)T set time to computer's cIock(GMT)c change time(type milliseconds)q quit

A typical sequence of commands to run the atod at 100 samples per second for 16 channels might be: 01016 t 145 22 12 0 r h g

SEE ALSOplotatod(ls), atod(3s)

AUTHORPeter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

19 July 1988 USGS

Page 19: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

PLOTATOD(IS ) UNIX Programmer's Manual PLOTATOD (IS )

NAMEplotatod - plot output of analog-to-digital converter in a window

SYNOPSISplotatod options stations device

DESCRIPTIONplotatod collects data from the analog-to-digital converter and plots it in a window on the SUN works­ tation. The program reads 1000 samples of data and calculates the average noise and DC voltage offset for each channel and scales the plot automatically so that the average noise fits within the pan of the window in the vertical direction assigned to the station. The channel number and station name are plot­ ted at the left together with the scale factor over the millivolts of DC offset. The scale factor is the number of millivolts from the bar above the name to the bar below the name.

stations is the name of a file containing STATIONCOMP structures (See st_intro.3s). The fields used that must be set are sc _name.st_name, con_mvolts, and channel.

device is the pathname of the atod, normally /dev/rstlBy pushing the right mouse button a menu is displayed to allow changing the vertical and horizontal scales by factors of 2, to begin autoscaling again, and to exit

OPTIONS-d n plot every nth point. Default is 2.-f number of first station to be plotted counting from one.

-g value Fix scale factor (gain) for all stations at this value in millivolts.

-I number of last station to be plotted counting from one.

-m value of milliseconds per sample atod is to be set for.-n number of stations atod is to be set for.

-p print average noise and DC offset of the stations.SEE ALSO

cdd(ls), atod(3s)

BUGS AUTHOR

Peter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

21 July 1988 USGS

Page 20: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

SCANSEIS ( SEIS ) UNIX Programmer's Manual SCANSEIS ( SEIS )

NAMEscanseis - scan digital seismic waveform files on a SUNS workstation

SYNOPSISscanseis [ -t tapename ] [filenames ]

DESCRIPTIONscanseis looks in the current directory, or on a tar(l) tape mounted on /dev/rstO if the -t option is specified, for files beginning with eq. or ah. or ending with D that are assumed to contain seismic waveform data in the USGS online format, Lamont adhoc format, or University of Washington format respectively. The seismic data in each file are displayed and the user may choose descriptors for the file using the right mouse button and may then decide to save, delete, or compact the file. If compaction is chosen, the user may specify the beginning and end of the record to be saved and which stations are to be deleted, compactseis is then executed in a spawned, asynchronous process. A log of all transac­ tions is appended to the file scanseis.log in the current directory.

Many aspects of the plotting and the contents of the descriptive menu can be specified in a file .scan­ seis in the current directory or if not there then in the user's home directory. The default for each item is used unless a different value is specified in a .scanseis file. The format for each line of .scanseis is label, number, and comment if desired. A label menu may be followed by a list of up to 50 menu items separated by commas. These may be clustered into as many as 5 groups separated by a slash character, /. Multiple lines may be used separated by . Only one item in each group may be selected from the menu by the user. This item is displayed in a different manner in the menu when selected. All selected items are appended to the line in scanseis.log describing the processing of the event A complete sample of .scanseis including all default options is given below.

maxfiles 4 /* Maximum number of files to process at once */decimation 4 /* Decimation factor */labelx 1000 /* Pixels in X to first station name */eachlabel 1000 /* Pixels in X between station names */labely 6 /* Pixels in Y from center of strip to base of name */overlap 100 /* percent overlap of traces in Y direction */height 47 /* Pixels per trace window in Y direction */second 50 /* Pixels per second in X direction */tickmark 25 /* Length of time tics in pixels on Y */xdelete 920 /* Pixels in X to first delete message for compacting */menu EVENT TYPE, Local event, Regional event, Teleseism,\

Seismic noise, Telemetry noise, Calibration/SIGNAL LEVEL,\Weak signal, Clear signal, Clipped signal

EXAMPLESFILESSEE ALSODIAGNOSTICSBUGSAUTHOR

Peter Ward, US Geological Survey, Menlo Park, Ca.

3 December 1987 USGS

Page 21: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

ST2AH (IS) UNIX Programmer's Manual ST2AH (IS)

NAMEst2ah - convert a suds stream into an ah stream

SYNOPSISst2ah [files]

DESCRIPTIONst2ah converts a stream of suds structures into ah or ad hoc structures in the Lamont-Doherty format. The only structures processed are ORIGIN, STATIONCOMP and DESCRIPTRACE. The ORIGIN structure, if it exists, must preceed the STATIONCOMP and DESCRIPTRACE structures and the STA­ TIONCOMP structure must preceed the DESCRIPTRACE structure. Data types allowed for waveforms are short, long, and float.

SEE ALSOst_intro(3s), ah2st(ls)

BUGSThis is a quick hack for moving local network data into sunpick and needs to be made more general.

AUTHORPeter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

22 March 1989 USGS

yo

Page 22: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

ST2ASC (IS ) UNIX Programmer's Manual ST2ASC (IS)

NAMEst2asc - convert a stream of suds structures to ascii

SYNOPSISst2asc [ -cfile ] [ -h string ] [ -i string ] [ -1 number ] [ -ofile ] [ -s string ] [ -v ] [file... ]

DESCRIPTIONst2asc converts a stream of suds structures from binary to ascii. One structure is output per line. The number of the structure is ouput followed by the length in bytes of the structure, the length in bytes of any ensuing data, and then by the value of each field in the structure in order. The values are separated by a space, characters are included within single quotes, and character strings are included within dou­ ble quotes.

OPTIONS-c The following file contains a control file similar to /usr/include/suds/suds_descr.h. The out­

put format and order can be changed from this control file as well as the content of label strings used in the verbose option. NOT IMPLEMENTED YET.

-h Place the next argument as a header at the beginning of the line for each new primary struc­ ture.

-4 Make the next argument the string by which lines are indented.

-1 When the output line is greater than the following number, it will be output and the next line will be indented by the indent string.

-n Do not list waveform data, simply list headers.

-o Put the output in the following file instead of stdout.

-s Separate the fields in the non verbose option by the following string.

-v Verbose option. Output each field on one line preceded by the field title. Structures nested within a structure are indented three spaces. Numeric codes defined in suds_codes.h are fol­ lowed by the appropriate explanatory string within brackets.

SEE ALSOst_intro(3s), asc2st(ls)

DIAGNOSTICSBUGSEXAMPLE

Separate the fields by commas:st2asc -s "," myfile

AUTHORPeter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

27 April 1988 USGS

Page 23: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

STDESCRIBE (IS ) UNIX Programmer's Manual STDESCRIBE (IS )

NAMEstdescribe - describe the suds structures in a file

SYNOPSISstdescribe [ -ofile ] [file... ]

DESCRIPTIONstdescribe lists the file name followed by a list of structures within the file. The number of the structure from the beginning of the file is given followed by the structure number, name, the length of the struc­ ture, and the length of any ensuing data. If the first field in the structure is STATIDENT, this sub­ structure is listed.

OPTIONS-o Put the output in the following file instead of stdout.

SEE ALSOst_intro(3s), st2asc(ls)

AUTHORPeter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

12 May 1988 USGS

Page 24: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

STEDIT (IS) UNIX Programmer's Manual STEDIT (IS)

NAMEstedit - edit the suds structures in a file

SYNOPSISstedit file...

DESCRIPTIONstedit displays one structure in a stream at a time and allows changes to be made to the values. Certain characters and values are not allowed for some fields where appropriate. The next structure is displayed by pushing the key F7. The editor may be exited without change by pressing the key F2. You change fields by pressing Tab, Return or the arrow keys. If any character is typed or changed in a field and Return is pressed, all characters after the last one typed or changed are deleted. Tab is equivalent to a Return except that all characters after the last one typed or changed are saved. Note that you may only type within certain parts of the screen.

stedit writes its output into a temporary file with a name of the form steditXXXXX. After completion of the input file, the editor asks whether to save the changes. If the answer is yes the temporary file is moved to be the input file.

The editor uses stform in suds_descr.h to get field labels, lengths, types, etc. The codes are listed in suds_codes.h

EDITORIALThis editor is a quick hack of some other code I had in order to demonstrate some of the features that might be nice in a real structure editor. It uses curses and is thus terminal independent on output but the input from cursor keys and function keys is not device independent and thus may not work on some terminals. UNIX System V curses might improve this, stedit may not start properly in a SUN-CMD window. Use Shelltool.

This editor should be integrated with the Lament waveform editor to allow display and editing of waveforms in sequence. Waveforms are presently passed through but not noted. It should allow global changes, that is changes of a specific field for all instances of the given structure. It should allow input of code fields as numbers or strings.

This general type of editor could improve the quality control of data in seismology immensely and would help enforce a standardization that will allow computer processing of even the ancillary fields. It also provides a way for unskilled operators to get work done reliably.

BUGSMany. Be patient

AUTHORPeter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

19 May 1988 USGS

Page 25: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

STJNTRO ( 3S ) UNIX Programmer's Manual STJNTRO ( 3S)

NAMEst_intro, suds - standard buffered input/output package for suds structures

SYNOPSIS^include <suds/suds.h>

DESCRIPTIONsuds or the Seismic Unified Data System consists of an extensible set of structures that associate related variables into logical groups. The initial structures relate to information about earthquakes, seismic waveforms, crustal structures, etc., but the methods and programs used apply equally well to any group­ ing of related variables pertaining to any subject Data typically have natural logical groupings. The basic concept of suds is to simplify programming, data exchange, and program exchange by taking advantage of these logical groupings. The programmer can then simply say: "I want to deal with infor­ mation pertaining to hypocenters, stations, or waveforms", for example, and not have to worry about the messy details of input, output, and data storage. Many general purpose utilities can be written to display, edit, store, filter, and massage these structures. The structures are designed to be extensible in order to allow them to grow and change with the whims of a wide variety of independent researchers. They also allow for a variety of styles of implementation so that individual institutions can decide on the best mode of use to meet their needs.suds is built around streams of data where a stream is simply a sequence of structures contained in a file, in a pipe, on a tape, as output from an indexed database, etc. The basic input and output routines for reading and writing the strucures are:

st_close: close an st_stream.

st_flush: flush an stjstream.

st_free: free memory associated with a structure pointer allocated by st_get.st_get: get the next structure in an st_stream.

st_open: open an st_stream.

st_peek: return the identification of the next structure in an st_stream.

st_put: put a structure into an stjstream.

stjrewind: rewind an st_stream.

st_seek: find the nth structure in an st_stream.

st_tell: return the number of the current structure's position in the st_stream.

st_unget: back up only 1 structure in an stjstream.

These routines are designed to look like standard, buffered I/O except that errors are handled using st_error. Fatal errors are reported and then call a user supplied subroutine die which may simply call exit or may also clear buffers, reset terminal characteristics, etc. stjerror provides an easy to use, gen­ eral error handling capability.

Programs using the stjroutines should be compiled with the -Isuds flag.

WARNING: Do not mix these routines with stdio(3s) or rawio(2) routines for the same file at the same time. Follow st_open and other routines with st_close before using open or fopen, and so forth.

Many utility commands or filters are available to operate on suds streams. Basic conversion routines include:

st2asc: Convert suds streams to ascii streams.

17 April 1988 USGS

Page 26: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

STJNTRO ( 3S ) UNIX Programmer's Manual STJNTRO ( 3S)

asc2st: Convert ascii streams to suds streams.

ah2st: Convert Lament ah streams to suds streams.

st2ah: Convert suds streams to Lament ah streams.ping2st: Convert ping (Carl Johnson andUniversity of Washington) streams to suds streams.

st2ping: Convert suds streams to ping streams.

segy2st: Convert SEG-Y format streams to suds streams.

st2segy: Convert suds streams to SEG-Y format streams.st2xdr: Convert suds streams to external Data Representation streams (A machine independent binary standard used in the Network File System).

xdr2st: Convert external Data Representation streams to suds streams.

st2db: Load suds streams into the dbjvista database.

db2st: Extract structures from the db_vista database into a suds stream.

General commands for handling suds streams include:

stdescribe: List the names and sizes of structures in a suds stream.

stedit: Edit a suds stream,

stsubset Extract a subset of structures from a suds stream.

Subroutines for use with suds structures include

st_create create a new suds structure and initialize it

st_init initialize a suds structure.

makejnstime convert years through seconds to a suds time variable.

decode_mstime decode a suds time variable into years through seconds.

list_mstime convert a suds time variable to an ascii string.

get_mstime get the present time-of-day as a suds time variable.

find_code find number representing an ascii string.

list_code find ascii string explaining a suds code.

descr_trace calulate many fields in a DESCRIPTRACE structure from a waveform.

asc2field convert an ascii string to a suds structure field.

field2asc convert a suds structure field to an ascii string.

suds is designed to take advantage of the flexibility of the UNIX shell command language and the speed of C language I/O. Commands and subroutines that extend these advantages to FORTRAN pro­ grammers and other operating systems include:

The seismic structures and related constants are defined in suds.h The core structures include:

TAG: A label to identify structures and provide a basis to check for errors.

17 April 1988 USGS

Page 27: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

STJNTRO (3S) UNIX Programmer's Manual STJNTRO (3S)

TERMINATOR: A marker to identify the logical end of a group of structures.

EQUIPMENT: Equipment making up a station/component.

STATIONCOMP: Station component information available before a waveform is recorded.

MUXDATA: Header for multiplexed data.

DESCRIPTRACE: Descriptive information about a seismic trace.

LOCTRACE: Location of a seismic trace within the filesystem.

CALIBRATION: Calibration information for a station component

FEATURE: Observed phase arrival time, amplitude, and period.

RESIDUAL: Calculated residuals for arrival times, magnitudes, etc.

EVENTREADINGS: Relation of features to a specific event

EVENT: General information about an event

EV_DESCRIPT: Descriptive information about an event.

ORIGIN: Information about a specific solution for a given event.ERROR: Errors related to a specific ORIGIN.

FOCALMECH: Focal mechanism solution.

MOMENT: Information on the seismic moment.

VELMODEL: Crustal velocity model.

LAYERS: Velocity characteristics of individual layers.

COMMENT: Free form comment that can be related to any field of any structure.SHOTGATHER: Grouping of waveforms related to a given source.PROFILE: Grouping of SHOTGATHERS into lines.

Extension of suds structures can be done by adding fields to the end of existing structures or adding new structures. Some care and close coordination with other institutions need to be exercised so that the wide portability can be maintained and so that old and new programs using these structures can co-exist harmoniously. Programs that use newly extended structures must check the length of structures on input and handle the older versions appropriately or give error messages. We strongly urge that you propose changes to these structures only after you are completely convinced that the existing structures can not meet your needs. In this way we can all work together to keep future confusion and complexity to a minimum.

SEE ALSOah2st(ls), asc2field(3s), asc2st(ls), descr_trace(3s), find_code(3s), st2asc(ls), st_describe(ls), st_edit(ls), st_close(3s), st_error(3s), st_flush(3s), st_get(3s), st_init(3s), st_open(3s), st_put(3s), st_rewind(3s), st_seek(3s), st_tell(3s), st_time(3s), st_unget(3s)

FILES/usr/lib/libsuds.a

/usr/include/suds/suds.h

/usr/include/suds/suds_descr.h

/usr/include/suds/suds_codes.h

/usr/mclude/suds/st_error.h

17 April 1988 USGS

Page 28: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

STJNTRO ( 3S) UNIX Programmer's Manual ST_INTRO (3S)

AUTHORPeter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

17 April 1988 USGS

n

Page 29: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

ASC2FIELD ( 3S ) UNIX Programmer's Manual ASC2HELD ( 3S )

NAMEasc2field, field2asc - convert ascii string to a suds field, convert a suds field to an ascii string

SYNOPSIS^include <suds/suds.h>

asc2field(string,ptr,type) char *ptr,*string; int type;

char *field2asc(ptr,type,verbose)char *ptr;int type,verbose;

DESCRIPTIONasc2field converts the ascii string to a variable of a specific type pointed to by ptr which is typically an address of a field in a suds structure. field2asc converts the field pointed to by ptr to an ascii string. type is defined by the "Integer defines for standard variable types" in <suds/suds.h>.

SEE ALSO DIAGNOSTICS

Errors are reported by st_error and the routines return a zero value or NULL pointer.

EXAMPLES AUTHOR

Peter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

18 May 1988 USGS

Page 30: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

ATOD (3S) UNIX Programmer's Manual ATOD (3S)

NAMEatod_open, atod_settime, atod_incrtime, atod_geterr, atod_reset - contol analog-to-digital converter

SYNOPSISint atod_open(device,ms_sample,numchan)char *device;int ms_sample, numchan;

int atod_settime(atod_fd,day,hour,min,seconds) int atod_fd,day,hour,min,seconds;

int atod_incrtime(atod_fd,milliseconds) int atod_fd,milliseconds;

int atod_geterr(atod_fd) int atod.fd;

int atod_reset(atod_fd) int atod.fd;

DESCRIPTIONThese routines provide the software interface to the Cutler Digital Design (CDD) Data Sampler. atod_open opens and initializes the atod with the pathname given by device, typically /dev/rstl, and returns an integer file descriptor, atod_fd, used in the other subroutines. atod_open checks the byte order on the host machine and adjusts the CDD atod accordingly. The year is initialized in the atod with the last digit of the current year in the host machine's clock. The msjsample, milliseconds per sample, may be any value such that the total throughput of the atod is 25,600 samples per second or less. Thus for 256 channels ms_sample may be 10 or larger, for 128 channels ms_sample may be 5 or larger, and for 16 channels (the minimum number of channels) msjsample may be 1 or larger, num­ chan is the number of individual channels of data to be collected and may be any number from 1 to the maximum number of input channels installed in the Data Sampler. Since the Data Sampler digitizes in units of 16 channels, this number is rounded up to the next multiple of 16 by the software.

atod_settime sets the internal clock in the Data Sampler. If day is a negative number, the internal clock is disabled, atodjsettime returns 1 if the time specified is impossible, such as a day of 34 or hour of 25, returns 4 if the atod buffer is overflowed, although the time will still be reset, and returns 0 if there are no errors.

atodjncrtime changes the internal clock by milliseconds, which may be positive or negative. atodjncrtime returns 4 or 0 as discussed above.

atodjreset clears the buffer in the Data Sampler and resets the digitizing process but leaves sample-rate, time, and other constants unchanged.

atod_geterr returns the error code from the Data Sampler. When an I/O error occurs the Data Sampler sends a message to the host machine that an error occurred. The host machine then asks the sampler for the error number and stores the value of the error in the driver software. atod_geterr returns this error value and resets the value to 0 so that a second call will return 0. Other return values are 4 mean­ ing the atod's buffer overflowed and 5 meaning an illegal command was sent to the atod.

DIAGNOSTICSThese routines use st_error(3s) to report errors and call die, which you must provide, after fatal errors.

SEE ALSOcdd(ls), plotatod(ls), st_error(3s)

BUGSThe maximum throughput rate of 25,600 samples per second may not be attainable on a continuous basis on a SUN 3/50, depending on the use of the SCSI bus by other peripherals such as the disk and tape drive. Digitization of 32 stations at 100 samples per second uses less than 10% of the system resources.

18 July 1988 USGS

Page 31: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

ATOD (3S) UNIX Programmer's Manual ATOD (3S)

AUTHORPeter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

18 July 1988 USGS

30

Page 32: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

DESCRJTRACE ( 3S ) UNIX Programmer's Manual DESCRJTRACE ( 3S )

NAMEdescr_trace - calculate minimum, maximum, average noise, and number of clipped values in a suds waveform

SYNOPSIS^include <suds/suds.h>

int descr_trace(sc,dt,waveform) struct stationcomp *sc; struct descriptrace *dt; char * waveform;

DESCRIPTIONdescrjrace calculates and sets the values in struct descriptrace for mindata (minimun value of waveform), maxdata (maximum value of the wavefonn), avenoise (average value of the first 200 sam­ ples), and numclip (number of clipped samples). If the wavefonn type is not short, long, or float, descrjrace has a return value of 1 and no change was made. Otherwise the return value is 0. If the pointer waveform is 0, the waveform is assumed to be contiguous to the end of struct descriptrace. The number of clipped samples is set only if the clip_value is not zero in struct stationcomp

AUTHORPeter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

4 May 1988 USGS

Page 33: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

FIND_CODE (3S ) UNIX Programmer's Manual FIND_CODE (3S)

NAMEfind_code, list_code - find or list codes used in suds structures

SYNOPSIS^include <suds/suds.h>

int find_code(string,list) char *string; struct codes *list;

char *list_code(code,list)int code;struct codes *list;

DESCRIPTIONMany fields in suds structures contain a char, short or int that represent a specific line of a list find_code returns the numeric code for a given string. The list is searched for a line beginning with all of the characters in string. If none is found, a 0 is returned. list_code returns a pointer to the string corresponding to the specified code. If the code is not found a string this code undefined is returned. list is a codelist specified in suds_codes.h.

AUTHORPeter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

10 May 1988 USGS

Page 34: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

ST_CLOSE (3S) UNIX Programmer's Manual ST_CLOSE (3S)

NAMEst_close, st_flush - close or flush a stream of suds structures

SYNOPSIS^include <stdio.h>

st_close(stream) FILE * stream;

st_flush(stream) FILE *stream;

DESCRIPTIONst_close causes any buffered data for the named stream to be written out, and the named stream to be closed. Buffers allocated by the standard input/output system are freed.

st_close is performed automatically for all open files upon calling exit (3).

st_flush causes any buffered data for the named output stream to be written out. The named stream remains open.

SEE ALSOfclose(3s), st_open(3S)

DIAGNOSTICSErrors are reported by st_error and then a user supplied subroutine called ctie(errno) is called (See st_error(3s) ).

BUGS AUTHOR

Peter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

21 April 1988 USGS

Page 35: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

ST_ERROR ( 3S ) UNIX Programmer's Manual ST_ERROR ( 3S )

NAMEst_error - general purpose error reporting and handling

SYNOPSIS^include <suds/st_errorJi>

st_error(function,errnum,format [,arg ]...)

int (*function)(); int errnum; char ^format;

extern char *progname;

extern char *st_errout;

DESCRIPTIONstjsrror reports errors on stderr and calls function before returning, progname should be set equal to argvfO] in the user's main. st_error outputs a message "ERROR in progname". The nextline is the message given in the printf type format and by args. The third line is the system error associated with errnum if errnum!=0. The following line is the system error associated with err no (INTRO(2)) if errnum! errno. errno is then reset to 0 and the function is called, if it is not equal to NULL, with err­ num as an argument.

function can be exit(2), any user defined function, or NULL.

Errors are normally output on stderr, however if st_errout is set to point at a file pathname before the first call to st_error, the errors will be put in that file.

Most st_routmes call stjsrror. If the error should be fatal, the function passed is die. A user must define this function. A simple definition could be:

die(err) int err; { exit(err); } If the user has set special tty modes, these should be restored in die.

errnum may be equal to errno(INTRO(2)) or one of the following manifest constants defined in st_error.h:

0 ENO_ERR Ignor errnum

1001 EBADDAY Illegal day

1002 EBADMONTH Illegal month

1003 EBADYEAR Illegal year

1004 EBADVALUE Illegal value

1005 EFEWDATA Not enough data

1006 ENOCONVRG Convergence failure

1007 EUNDERFLOW Underflow

1008 ENOSTATION No such station

1009 ESIZE Structure sizes mismatch

1010 ESINGULAR Singular matrix

1011 ETOODEEP Focal depth too great

1012 EBADPHASE No such phase

1013 ENOFEAS Constraints are inconsistent

1014 EINFIN Solution is unbounded

21 April 1988 USGS

Page 36: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

ST_ERROR ( 3S ) UNIX Programmer's Manual ST_ERROR ( 3S )

1015 EBADSYNC Structure tag sync code wrong

1016 ST_ERR Serious suds I/O error

SEE ALSOintro(2), st_intro(3s)

BUGSerrno is not typically reset by standard UNIX routines and thus could have a spurious value. It is a good idea to set errno=0 before calling any routines for which you plan to use st_error to report the errors.

AUTHORSPeter Ward and Bruce Julian, U.S. Geological Survey, Menlo Park, Ca. 94025.

21 April 1988 USGS

Page 37: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

ST_GET (3S ) UNIX Programmer's Manual ST_GET (3S )

NAMEst_get - get the next suds structure from stream

SYNOPSIS^include <stdio.h> ^include <suds/suds.h>

int st_get(st_ptr,type,length,stream)char **st_ptr;int *type,*length;FILE * stream; st_free(ptr,length)char *ptr;int length;

DESCRIPTIONst_get returns a pointer st_ptr to the next suds structure in the stream, the type of the structure, and the length in bytes of the structure. The return value of st_get is the total length of the structure plus the length of any data following the structure such as for structure type DESCRIPTRACE and MUXDATA.

st_get uses malloc(3) to allocate space for the structure. When the structure is no longer needed, the space should be freed using stjree.

SEE ALSOst_open(3S), st_put(3S), st_error(3S), st_unget(3S)

DIAGNOSTICSThe most common error is likely to be a Segmentation Violation caused by not passing the addresses of type and length. Errors are reported by stjsrror and a user supplied subroutine called die(errno) is called (See st_error(3s) ). st_get returns EOF on end of file and type and length are all set equal to zero.

BUGS EXAMPLE

^include <stdio.h>

char *ptr;

int type,Iength,in_num;

in_num=st_get(&ptr,&type,&length,stdin);

AUTHORPeter L. Ward, U. S. Geological Survey, Menlo Park, Ca 94025

21 April 1988 USGS

Page 38: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

STJNTT ( 3S ) UMX Programmer's Manual STJNIT ( 3S)

NAMEst_init - initialize a suds structure

SYNOPSIS^include <suds/suds.h>

st_init(type,pointer) int type; char ^pointer;

st_create(type,pointer,datalength) int type,datalength; char **pointer;

DESCRIPTIONstjnit initializes all fields of a suds structure to the default values defined in the file suds_descr.h This initialization is important since fields with no data should be initialized to one of the constants NODATA, NOTIME, NOCHAR, NOSTRG, or NOLIST defined in the file suds.h. st_create uses malloc to create space for a new structure and then initializes the structure, datalength is the length of data in bytes that follow the structure when appropriate, suds.h

AUTHORPeter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

10 May 1988 USGS

Page 39: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

STJDPEN ( 3S ) UNIX Programmer's Manual STJDPEN ( 3S )

NAMEst_open - open a stream containing suds structures

SYNOPSIS^include <stdio.h>

FILE *st_open(filename, type) char *filename, *type;

DESCRIPTIONst_open opens the file named by filename and associates a stream with it If the open succeeds, st_open returns a pointer to be used to identify the stream in subsequent operations.

filename points to a character string that contains the name of the file to be opened.

type is a character string having one of the following values:

"r" open for reading

"w" truncate or create for writing

"a" append: open for writing at end of file, or create for writing

"r+" open for update (reading and writing)

"w+" truncate or create for update

"a+" append; open or create for update at end-of-file

When a file is opened for update, both input and output may be done on the resulting stream. How­ ever, output may not be directly followed by input without an intervening fseek or rewind, and input may not be directly followed by output without an intervening st_seek, st_rewind, or an input operation which encounters end-of-file.

st_open may be called with filename equal to "stdin", "stdout", or "stderr" to allow easy specification of stdio defaults for files. It is not necessary to specifically open stdio streams.

SEE ALSOfopen(3s), st_close(3S), st_seek(3S),

DIAGNOSTICSst_open, returns a NULL pointer on failure. Errors are reported by stjsrror and a user supplied subrou­ tine called die(errno) is called (See st_error(3s) ).

BUGSIn order to support the same number of open files as the system does, st_open must allocate additional memory for data structures using malloc when each file is opened. This might confuse some programs which use their own memory allocators.

AUTHORPeter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

10 May 1988 USGS

Page 40: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

ST_PUT (3S) UNIX Programmer's Manual ST.PUT (3S)

NAMEst_putc - put a suds structure on a stream

SYNOPSIS#include <stdio.h>#include <suds/suds.h>

int st_put(st_ptr,type,length,stream)char *st_j)tr;int type;int len;FILE * stream;

DESCRIPTIONst_put writes the structure pointed to by st_ptr onto the named output stream

SEE ALSOst_open(3S), st_close(3S), st_get(3S)

DIAGNOSTICSErrors are reported by st_error and a user supplied subroutine called die(errno) is called (See st_error(3s) ).

EXAMPLE#include <stdio.h>

char *ptr;

int type,Iength,out_num;

out_num=st_piit(ptr,type,Iength,stdout);

AUTHORPeter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

21 April 1988 USGS

Page 41: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

ST_SEEK ( 3S ) UNIX Programmer's Manual ST_SEEK ( 3S )

NAMEst_seek, st_tell, st_rewind, st_j>eek - reposition a stream of suds structures

SYNOPSIS#include <stdio.h>

st_seek(stream, ofTset,direction) FILE ^stream; int offset,direction;

int st_tell(stream) FILE *stream;

st_rewind(stream) FILE ^stream;

DESCRIPTIONst_seek sets the position of the next input or output operation on the stream. The new position is just before the nth structure specified by offset counting the first structure in the stream as zero. The offset is relative to the beginning of the file if direction=0, relative to the present position in the file if direc- tion=l, and relative to the end of the file if direction=2.

st_rewind(streani) is equivalent to st_seek(stream,Q,0).

st_seek and stjrewind undo any effects of st_unget(3S).

After st_seek or stjrewind, the next operation on a file opened for update may be either input or output

st_tell returns the offset of the current structure relative to the beginning of the file associated with the named stream.

st_peek returns the number of the next structure to be read by st_get.

SEE ALSOfseek(3S), st_open(3S), st_unget(3S)

DIAGNOSTICSstjseek returns -1 for improper seeks, otherwise zero. An improper seek can be, for example, an st_seek done on a file that has not been opened via st_open.

DIAGNOSTICSErrors are reported by st_error and a user supplied subroutine called die(errno) is called (See st_error(3s) ).

BUGS AUTHOR

Peter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

21 April 1988 USGS

Page 42: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

STJTIME (3S) UNIX Programmer's Manual STJTIME (3S)

NAMEmake_mstime, decode_mstime, list_mstime, get_mstime - suds time and date utilities

SYNOPSIS^include <suds/suds.h>

ms.time make_mstime(year,month,day,hour,min,second) int year,month,day,hour,min; double second;int decode_mstime(time,year,month,day,hour,min,second)ms.time time;int *year,*month,*day,*hour,*min;double * second;char *list_mstime(time,form) ms_time time; int form;

ms.time get_mstime();DESCRIPTION

All times and dates in suds are kept in terms of Greenwich Mean Time (GMT) either as ms_time, mil­ lisecond time, a double precision decimal number of seconds since 00:00:00 GMT Jan. 1,1970 (8 bytes of storage) or as st_time, stamp time, a long integer representation of the same value (4 bytes of storage) as defined by typedef in suds.h. These routines provide simple conversion to and from other forms, year is a four digit number such as 1988, month may be 1-12, day may be 1-31, hour may be 0-23, min may be 0-59, and second is a double precision number of seconds with resolution to microseconds or better.

makejnstime returns an ms_time variable, decodejnstime returns through pointers the components of the time variable, list jnstime returns a pointer to a null terminated character string in one of several formats specified by form, getjnstime returns the computer's clock as an msjime variable.

OPTIONSform may be an integer representing one of the following formats where yr=year (2 digits), mo=month (1-12), dy=day (1=31), hr=hour (0-23), mn=minute (0-59), and sc=second (0=59):

0 yrmodyhnnnsc.OOO

1 yrmodyhrmnsc

2 yr mo dy hr mn sc.OOO

3 yr mo dy hr mn sc

4 mo/dy/yr hnmn sc.OOO GMT

5 mo/dy/yr hnmn sc GMT6 Aug 10, 1988 hnmn sc.OOO GMT

7 Aug 10, 1988 hnmn sc GMT

SEE ALSOgettimeofday(2), ctime(3), time(3C)

DIAGNOSTICSErrors are reported by stjsrror and the routines return a zero value or NULL pointer.

EXAMPLESTo use stjime simply cast the values appropriately: st_time stamp;

3 May 1988 USGS

Page 43: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

STJTIME ( 3S ) UNIX Programmer's Manual STJTIME (3S )

stamp=(long)get_mstimeO; printf("%sNn",list_mstime((double)stamp,l);

AUTHORSBruce Julian and Peter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

3 May 1988 USGS

Page 44: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

STJJNGET (3S ) UNIX Programmer's Manual STJJNGET (3S)

NAMEst_unget - push a suds structure back into input stream

SYNOPSIS^include <stdio.h>

st_unget(st_ptr, stream) char *st_ptr; FILE * stream;

DESCRIPTIONstjunget pushes the structure pointed to by st_ptr back onto an input stream. That structure will be returned by the next st_get call on that stream, stjunget leaves the file stream unchanged.

Only one structure may be put back on the stream.

An stjseek(3S) erases all memory of pushed back characters.

SEE ALSOst_get(3S), st_seek(3S)

DIAGNOSTICSErrors are reported by st_error. stjunget returns EOF if it can't push a character back and STJLRR (defined in st_error.h) if stream is an illegal file descriptor.

BUGS AUTHOR

Peter L. Ward, U.S. Geological Survey, Menlo Park, Ca. 94025

21 April 1988 USGS

Page 45: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

7/18/88

Connection of the Analog-to-Digital Converter to the Computer and to the SoftwareThere are four simple steps to connect the A/D converter to the computer

1. Reconfigure the operating system so that it knows that the device is attached.2. Create a symbolic name that can be referenced by users of the computer.3. Physically attach the A/D converter to the SCSI bus.4. Use the system software and special routines provided with this tape to control the sampler and

read data from it.You must be sure your computer is running SUN Operating System version 3.5. The interface

does not work for Version 3.4 because major, bug ridden changes to the SCSI interface software were made for that release. The interface may work for Versions 3.2 and 4.0, but has not been tested for these versions.

The computer reads data from the A/D converter sequentially in a manner similar to reading data from a magnetic tape recorder. Thus the command-set used for the SCSI bus interface is that specified in ANSI Standard X3.131-1986 for Sequential-Access Devices. For this reason the A/D converter uses the operating system driver for SCSI based magnetic tape drives. In UNIX this driver is located in /usr/sys/OBJ/sLo. This routine also calls the low level SCSI driver package /usr/sys/OBJ/si.o. To install these routines in the kernal of your version of UNIX and point to the new device to be used, you need to add one line to the configuration file for your system located in /usr/sys/conf and rebuild the operat­ ing system. On Sun computers this process is explained in detail in Chapter 8 Configuring the System Kernal in the manual section Installing UNIX on the Sun Workstation. The steps are as follows.Login as root. Edit the file in /usr/sys/conf that has been customized for your computer. If the system has not been customized and you are using a SUN 3/50 computer with one disk and one archive tape, you can use the file SEISMIC included on this software tape. If you do not use this file then add a line in your config file at least after the line

controller siO at obio ? csr 0x140000 priority 2and preferable immediately after the line

tape stO at siO drive 32 flags 1if it exists. The new line should read

tape stl at siO drive 40 flags 1If a line using drive 40 on this SCSI controller already exists it must be deleted if no device is actually attached or you must change the bus address of the A/D converter. There may be eight controllers attached to each SCSI bus, numbered from 0 to 7. The highest priority is assigned to controller 0 which is usually the system disk. A single tape unit is usually put at level 4 and the computer's SCSI controller is at level 7. Pick a level appropriate for your hardware configuration. Set the DIP switch inside the A/D converter to that number and change the 40 in the above line to 8 times the number set in the DIP switch. Now write out the new configuration file and type:

/etc/config SEISMICbut substitute the name of your configuration file for the word SEISMIC. This name will appear on the banner line during login telling which version of the operating system you are running, /etc/config creates a new directory in /usr/sys with this config file name. Change to this directory. For example type:

cd /usr/sys/SEISMICand then type

makeMake compiles and links a new kernal called vmunix. You must move this to the / directory after you save the old version. Type:

mv /vmunix /vmunix.old mv vmunix /vmunix

Page 46: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

-2-

You may only be able to keep two system kernals in / at one time because of the size of the disk par- tion used. Be sure to keep the old version there until you know the new version works. If the new ver­ sion does not work you can then simply respond to the boot command with

bsd(0,0,0)vmimix.oldWARNING: If you did not save the old version in / and the new version does not work, you may need to reload all software and software distributions!

Now you must create two entries in the /dev directory that can be used by the software to access the A/D converter. Type:

cd /devmknod nrstl c 18 5mknod rstl c 18 1

chmod 0666 nrstl rstlOf course you may use st2 or st3 if two other tape drives already exist on the SCSI bus. In these cases add 1 or 2 to the last number, the minor device number. The minor device number should be the number following st in the name for rst and that number plus 4 for nrstl. Only four tape devices may be used with the sto kernal software. The major device number 18 should be the same used for rstO.

Is -1 rstO Type:to check that the number is the same. You may use a different name for these files if you wish such as rsaO and nrsaO meaning SCSI analog-to-digital converter. We recommend keeping the st designation, however, because that is the driver software being used. The programs provided with the A/D con­ verter assume the name /dev/rstl and /dev/nrstl. The difference between these two names is that the rstl device resets the A/D converter when it is opened or closed and the rstl device does not do an automatic reset. If you use different names, you will need to change the names used in the software provided.

Now shutdown UNIX by typing:/etc/halt

When the system halts turn off the power to the computer and all peripheral devices. Connect the SCSI bus cables between your computer and the A/D converter. The SCSI bus is a daisy chain with termina­ tors at each end. The total length of the bus should not be longer than 6 meters (19.7 feet). Terminators are included typically within the computer and the system disk. The terminators have been left out of the A/D converter so that it can be located between the computer and the system disk or between and other two devices on the bus. Connect the SCSI bus cable from the computer to the SCSI IN connector of the A/D converter. Connect the new SCSI bus cable provided to the A/D converter SCSI OUT con­ nector and to the connector formerly attached to the computer. Turn on the power to the peripherals and then to the computer. The computer should reboot automatically. During the boot process a line should appear showing the tape port for the address you specified, such as

stl at siO slave 40The A/D converter should now be ready for use.

Page 47: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds :/

usr/

suds

/incl

ude/

ahhe

ader

.h

structure

for data fi

le header f

or Lament

ah or ad hoc system

witt

en,

11 June 85

headers

and data for events ar

a stored i

n sa

me fi

la typ

ical

ly

naiMd ah.YHMODYHRMN

stat

ic char Ahhaadar_h[]

- "%

W% %G

%";

ffdafina AHHEADSIZE 1024

ffda

fina

TYFEMIH

1 define TCPEMAX

6ff

dafi

na LOGSIZE 202

ffdafina LOGENT

10ff

dafi

na N

EXTRAS

21ff

dafi

na NOC

ALPT

S 30

ffd

afin

a ah

TLO

AT

1ff

daf

ina

ahC

OM

PLEX

2

ffd

afin

a ah

VEC

TOR

3

ffd

afin

a ah

TEM

SOR

4

ffd

afin

a ah

DO

OBL

E 6

typ

ad

ef

stru

ct

{ fl

oa

t x;

fl

oa

t y;

} vec

tor;

£^

typ

ad

af

stru

ct

{fl

oa

t r;

^

flo

at

i;}

com

ple

x;

typ

ad

af

stru

ct

{ d

oub

la r

; d

oub

la i

; }

d_e

omp

lex;

typ

ad

af

stru

ct

{ fl

oat

xx;

flo

at

yy;

float

xy;

} ta

nso

r;

stru

ct

tim

e {

short

yr;

sho

rt

no;

sho

rt

day

;sh

ort

h

r;sh

ort

an

;fl

oa

t sa

c;

/* Sees Id *

/

stru

ct

cali

b {

coap

lax

pola;

coap

lax

zaro

;

stru

ct

stati

on

in

fo

/* yaar

/* month

/* day

/* hour

/* Minuta

/* sacond

/* pola

/* za

ro

*/ */ */ */ */ */ */ */

char

coda

[6]

chan[6]

float

flo

at

flo

at

flo

at

float

sla

t;sl

on

; l

ev

;D

S;

AC

;

/* st

ati

on

cod

e */

/* lp

z,sp

n,

etc

. la

st

char

eit

her z,

n

, o

r e

*/

/*

ww

ssn

,hglp

,r*tn

, sro

,asr

o,d

ww

ssn

etc

. */

/*

stati

on

la

titu

da

*/

/*

" lo

ngit

ud

e */

/*

" ele

vati

on

*/

/* i

MT

iaiim

gain

at

pea

k of

ca

lib

ra

tio

n cu

rve

*/

/*

norm

ali

zati

on

, fa

cto

r t

o m

ake

cali

brati

on

cu

rve

at

stru

ct>;

ilib

pea

k e

qu

al

1 fo

r a

specif

ic fr

equ

ency

ca

l[N

OC

AL

PT

S];

/* ca

lib

rati

on

cu

rve

stru

ct

even

t_in

fo

I fl

oa

t le

t;

float

Ion

; fl

oat

dep

; st

ruct

ti

me

ot;

char

*[80J; /*/* e

vent

latituda

*/

/*

" longitude

*/

/*

- de

pth

*/

/*

- origin time */

lit

*/

{st

ruct

xaco

rd_in

fosh

ort

ty

pa

;lo

ng

n

dat

a;fl

oat

dalt

a;

float

Bax

aap

;st

ruct

ti

ma

abst

ima;

flo

at

xmin

;ch

ar

rcon

man

t [8

0] ;

char

lo

g[L

OC

SIZ

EJ;

/* d

ata

typ

a fl

oa

t-1

, eo

«p

lex

«2

, ate

as

def

ined

ab

ove

*/

/* n

umbe

r of

sam

ple

s */

/*

sam

pli

ng

inte

rv

al

*/

/* «

*

< »«

am

pli

tud

e of

reco

rd

*/

/* st

art

tim

a of

reco

rd s

ecti

on

*/

/* m

inim

um v

alu

e of

ab

scis

sa

*/

/* c

omm

ent

lin

e

*/

/* lo

g o

f d

ata

ma

nip

ula

tio

ns

*/

typ

ad

af

stru

ct

{st

ruct

st

ati

on

_in

fo

stati

on

; /*

st

ati

on

in

fo */

stru

ct

aven

t_in

fo

even

t;

/*

even

t in

fo

*/

stru

ct

reco

rd_in

fo

reco

rd;

/* r

eco

rd i

nfo

*/

float

extr

a[N

EX

TR

AS]

; /*

fx

aeb

ies

*/

} ah

hed

;

Page 48: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

incl

ude/

suds

_des

cr.h

/*

SUD

S_D

ESC

RIP

T.H

: d

ata

st

ruct

ure

s u

sed

by

uti

lity

pro

gram

s to

acc

ess

and

des

crib

e an

y of

the

sud

s st

ruct

ure

s *

/fi

fnd

ef

SUD

S_D

ESC

RIP

_H

Idefi

ne

SUD

S D

ESC

RIP

H

tati

o

char

S

ud

s_d

escr

ip_

h[]

"e(|

)su

dsj

desc

r.h

fin

olu

de

<st

dio

.h>

fin

clu

de

"/u

sr/s

ud

s/in

clu

de/

sud

s.h

"

/* sp

ecia

l fo

rmat

* */

Idef

ine

STin

C

""Id

efin

e ST

TIM

"%

ld"

Idef

ine

MST

IM

-%lf

"Id

efin

e LT

TIM

"%

lf«

Idef

ine

CA

LfM

""

Idef

ine

COM

IM

""

1.2

11/17/88";

/* Se

e* Id */

Idef

ine DECIMAL

Idef

ine

INTEGER

Idef

ine NAMES

Idefine ASCII

Idef

ine

TYPICAL

Idef

ine

TIME

S

"0-9. NODATA"

"0-9 HODATA"

"a-z A-Z"

"0-9 a-zA-Z.,

"0-9.NOTIME'

Idef

ine

S(x

) (s

izeof(

x)/

sizeof

(str

uct

co

d**

))

,extern CODES in«t_typ«[] ,mach_typ«[] , qnip_aod«l

[ ] , qulp_r*a«on [

] ,a

nn con [

] , rookjbyp* [

] , *ti

auth

ority

[ J , f *t

_pha

»« [

] ;

~"

/* SDDSrORM:

Info

rmat

ion

on «a

ch mu

d* ctructur*

u««d fo

r in

put

from a

*oii

,output to a«

cli,

loading or unloading

th«

data

ba««

, «tc.

*/

SODS_r

ORM

«tfo

r»[]

-

{HOJSTKDCT,

"junk",

8TA

T_I

DE

NT

, " n

etw

ork

" ,

STA

T_I

DE

NT

, "

cta

tio

n

nan

a",

8TA

T_I

DE

NT

, " c

oop

onan

t " ,

8TA

T_I

DE

NT

, "

inat

ruB

Mn

t ty

",

STR

DC

TTA

G,

"sy

no

char

",

STR

DC

TTA

a,

"mae

hin*

ty

",

STRDCTTAa,

"ctruct numb*rH

,ST

RDCT

TA6,

"ctr

uct

l«ng

th",

TERM

INAT

OR,

"beginning at

ruct

",

/*10

*/TE

RMIN

ATOR

, "unuMd",

EQUI

PMENT,

"this

atat

ion/

comp

",EQCTIPMENT,

"la«t tation/comp" ,

EQUIPMENT,

"n«xt

ctat

ion/

comp

",EQUIPMENT,

"**rial

nunb

ar",

EQUIPMENT,

"Modal",

EQUIPMENT,

"kno

b 1

letting",

EQUIPMENT,

"kno

b 2

fatting",

EQUI

PMEN

T,

"rep

air

reas

on",

EQUIPMENT,

" frequency"

, /*20* /E

QUIP

MENT

, "date

effe

ctiv

e",

STATIONCCMP, "at at ion/ component",

STATIcaiCOMP,

"com

pone

nt az

imut

h",

STAXIONCCMP, "c

ompo

nent

in

cide

nce"

STAXIONCCMP, "latitude",

STATIONCONP,

" longitude "

,STAXIONCCMP, "e

leva

tion

, meter*",

STATIONCOMP, "enclosure

" ,

STAT

IONC

OMP,

"a

nnot

ated

comment",

STAXIONCOMP, "recorder

type

",

/*30*/SXATIONCOMP,"rock

clas

s",

ST

R,

ST

R,

ST

R,

CK

R,

SE

T,

CH

R,

CH

R,

SE

T,

LN

G,

SH

T,

SH

T,

ST

I,S

TI,

ST

I,S

TR

,S

HT

,S

HT

,S

HT

,S

HT

,F

LT

,S

IT,

ST

I,S

RI,

SE

T,

LL

T,

LL

T,

FL

T,

CH

R,

tax,

CH

R,

CH

R,

1,

4,

5,

1,

1,

1,

1,

1,

1,

1,

1,

1,

1,

1,

8,

1,

1,

1,

1,

1,

1.

1,

1,

1,

1,

1,

1,

1,

1,

1,

1,

0,

HULL,

0,

HULL,

4,

HULL,

9,

HULL,

10,

instjtype,

0,

HULL,

1, mach t

ype,

2,

HULL,

4,

HULL,

0,

NULL,

2,

HULL,

0,

HULL,

8,

HULL,

16,

NULL,

24,

HULL,

32, equip model,

34,

HULL,

36,

HULL,

38, equip reason

40,

HULL,

44,

HULL,

0,

NULL,

12,

HULL,

14,

HULL,

16,

HULL,

24,

NULL,

32,

NULL,

36,

NULL,

37,

ann com,

38,

NULL,

39,

NULL,

NOSXRG, "% ",

"lin

k".

*% *

NOSXRG, "%S",

NOCHAR, "%c",

NOLIST, "%d",

"S",

"%C",

MACHINE", "%c"

NODATA, "%d".

NODATA, "%ld",

NODATA, "%d",

NODATA, "%d",

NOSXRG, STIIM,

NOSXRG, STIIM,

NOSTRC, STIIM,

NOSXRG, "%S",

NOLIST, "%d",

NODATA, "%d",

NODATA, "%d",

, NOLIST, "%d".

NODATA, "%f",

NOTIME, STTIM,

NOSTRC, STIIM,

NODATA, "%d",

NODATA, "%d".

NODATA, LTTIM,

NODATA, LTTIM,

NODATA, "%f",

NOCHAR, "%c",

NOLIST, "%d",

NOCHAR, "%C",

NOCHAR, "%C",

o, o, 0, o, o, o,,

o, o, o, o, o,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

STAT IDENT, 0, 0,

STAT_IDENX, 0, 0,

STAT IDENT, 0,0,

o, o, o, o, o, o, 0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

STAT ID

ENT,

0,0

,o, o, o, o, o, o, 0, 0, 0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

3, 25, DECIMAL,

0,10, NAMES,

0,28, NAMES,

0,44

, "v

neVN

E",

2,25, INTEGER,

3, 25, DECIMAL,

5, 25,

DECIMAL,

7, 25,

INTEGER,

9, 25, INTEGER,

3, 25,

INTEGER,

5, 25,

INTEGER,

3, 10, DECIMAL,

7, 10, DECIMAL,

11, 10, DECIMAL,

15, 25

, DECIMAL,

17, 25, INTEGER,

19, 25, INTEGER,

21, 25

, INTEGER,

23, 25, INTEGER,

25, 25

, DECIMAL,

27, 25, TIMES,

3, 10, DECIMAL,

7, 25,

INTEGER,

7, 60, INTEGER,

9, 25,

DECIMAL,

9, 55, DECIMAL,

11, 25

, DECIMAL,

13, 25

, DECIMAL,

15, 25, DECIMAL,

17, 25

, DECIMAL,

19, 25

, DECIMAL,

Page 49: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

STAXIONCOMP, "rock type",

SRT,

STAXIONCOMP, "site condition",

CHR,

STAXIONCOMP, "sensor type",

CHR,

STATIONCOMP, "data type",

CHR,

STATIONCOMP, "data units",

CHR,

STATIONCOMP, "polarity",

CHR,

STATIONCOMP, "status",

MIN,

STATIONCOMP, "maximum gain",

FLT,

STATIONCOMP, "c

lipp

ing

value",

FLT,

/*40*/STATIONCGMP, "conversion to mvolts",FLT,

STAXIONCOMP, "channel",

SRT,

STAXIONCOMP, "spare",

SRT,

STAXIONCOMP, "e

ffec

tive

da

te",

STT,

MOXD

AIA,

"n

etwo

rk",

STR,

MOXDAIA,

"beg

inni

ng t

ime"

, MST,

MOXD

AIA,

"minutes wes

t of G

MT",

SRT,

MOXD

ATA,

"number of ch

anne

ls",

SR

T,MOXDATA,

"samples per second",

FLT,

MOXDATA,

"type of data",

CHR,

/*50

* /MOXDATA,

"data

desc

ript

or",

CH

R,MOXDAIA,

"spareG",

SHT,

MOXD

ATA,

"num

ber of sa

mple

s",

LNG,

DESC

RIPT

RACE

, " s

tat io

n/ component "

, STI

,DE

SCRI

PTRA

CE, "b

egin

ning tim

e",

MST,

DESC

RIPT

RACE

, "l

ocal

time di

ff",

SHT,

DESCRIPTRACE, "data type",

CHR,

DESC

RIPT

RACE

, "data

desc

ript

or",

CH

R,DESCRIPTRACE, "digitized by",

SHT,

DESCRIPTRACE, "processed b

y",

SHT,

/*60

* /DESCRIPTRACE, "nu

mber

of sa

mple

s",

LNG,

DESCRIPTRACE, "samples per s

econ

d",

FLT,

DESCRIPTRACE, "m

inim

um dat

a va

lue"

, FL

T,DE

SCRI

PTRA

CE, "maximum data

valu

e",

FLT,

^ DE

SCRI

PTRA

CE, "average no

ise"

, FLT,

DESCRIPTRACE, "num clipped samples", LNG,

LOCTRACE,

"station/ component",

STI,

LOCT

RACE

, "p

athn

ame"

, LNG,

LOCTRACE,

"tap

e name",

LNG,

LOCTRACE,

"Offset",

LNG,

/*70*/CALIBRATZON,

" sta

tion

/com

pone

nt"

,CALIBRATION, "normalization factor", FLT,

CALIBRATION, "calibration",

CAL,NOCALPTS,

CALIBRATION, "beginning time",

STT,

CALIBRATION, "ending ti

me",

STT,

FEATURE,

"station/ component",

STI,

FEAT

URE,

"obs

erve

d phase",

SRT,

FEATURE,

"ons

et de

scri

ptor

",

CHR,

FEATURE,

"first motion",

CHR,

FEATURE,

"signal/noise",

SHT,

/*80

*/FE

ATUR

E,

"data

source",

CHR,

FEAT

URE,

"tim

ing

qual

ity"

, CH

R,FE

ATUR

E,

"amp

litu

de qu

alit

y",

CHR,

FEAT

URE,

"amp

litu

de units",

CHR,

FEATURE,

"gain range fa

ctor

",

SHT,

FEAT

URE,

"pha

se time

",

MST,

FEAT

URE,

"phase amplitude",

FLT,

FEATURE,

"pha

se p

erio

d",

FLT,

RESIDUAL,

"eve

nt nu

mber

",

LNG,

RESI

DUAL,

"stat ion/ component",

STI,

/*90

* /R

ESID

UAL,

"p

hase

co

de",

SHT,

RESIDUAL,

"tim

ing

quality",

CHR,

RESI

DUAL

, "amplitude q

uality",

CHR,

RESIDUAL,

"traveltime residual",

FLT,

RESIDUAL,

"solution weight",

FLT,

RESIDUAL,

"delay time",

FLT,

1, If 1, If If 1, If 1, If 1, 1, 1, If 4, 1, 1, If If If If 1, 1, If If 1, 1, 1, 1, 1, 1, 1, If 1, If If If If If If STI,

1, 12,

If 1, If 1, 1, If 1, If 1, If If If 1, If 1, 1, 1, If 1, 1, 1, If 1,

ward

s:/u

sr/s

uds/

incl

ude/

suds

_des

cr.h

::::::

::::::

::::::-

':::::

:::::;

:::::::

::::::

::::::

:::-£-:::^

'^ :<'

<'^:-'

'-:^:-

:'-^:-

:>^

40, rock t

ype,

NO

LIST

, "%d",

0,

0,0,

21,25, INTEGER,

42,

HULL,

NOCHAR, "%c",

0,

0,0,

23, 2 5, DECIMAL,

43,

HULL,

NOCHAR, "%c",

0,

0,0,

2 5,

2 5, DECIMAL,

44,

NOLL,

NOCHAR, "%c",

0,

0,0,

27 ,25

, DECIMAL,

45,

NOLL,

NOCHAR, "%c",

0,

0,0,

2 9, 2 5, DECIMAL,

46,

NOLL,

NOCHAR, "%c",

0,

0,0,

31, 2 5, DECIMAL,

47,stat_proc,

NOLIST, "%d",

0,

0,0,

33

, 2 5,

DECIMAL,

48,

NOLL,

NODATA, "%f",

0,

0,0,

35, 2 5, DECIMAL,

52,

NOLL,

NODATA, "%f",

0,

0,0,

37, 2 5, DECIMAL,

56,

NOLL,

NODATA, "%£",

0,

0,0,

3 9, 2 5,

DECIMAL,

60,

NULL,

NODAXA, "%d",

0,

0,0,

41

, 25, INTEGER,

62,

NOLL,

NODATA, "%d",

0,

0,0,

43

, 25, INTEGER,

64,

NOLL,

NOTIME, STTFM,

0,

0,0,

45

, 25, TIMES,

0,

NOLL,

"unk",

"% ",

0,

0,0,

3, 25, DECIMAL,

4,

NOLL,

NOTIME, MSTFM,

0,

0,0,

5, 25,

TIMES,

12,

NOLL,

NODATA, "%d",

0,

0,0,

7, 25, INTEGER,

14,

NULL,

NODATA, "%d",

0,

0,0,

9,25, INTEGER,

16,

NULL,

NODAXA, "%f",

0,

0,0,

11, 25

, INTEGER,

20,

NULL,

NOCHAR, "%c",

0,

0,0,

13, 25

, DECIMAL,

21,

NULL,

NOCHAR, "%c",

0,

0,0,

15 , 25 , DECIMAL,

22,

NULL,

NODATA, "%d",

0,

0,0,

17, 25, INTEGER,

24,

NULL,

NODAXA, "%ld",

0,

0,0,

19

, 25

, INTEGER,

0,

NOLL,

NOSTRG, STIFM, STAT_IDENT, 0, 0,

3, 10, DECIMAL,

12,

NULL,

NOTIME, MSTFM,

0,

0,0,

7, 25,

TIMES,

20,

NOLL,

NODAXA, "%d",

0,

0,0,

9, 25,

INTEGER,

22,

NULL,

NOCHAR, "%c",

0,

0,0,

11, 25, DECIMAL,

23,

NULL,

NOCHAR, "%c",

0,

0,0,

13, 25

, DECIMAL,

24, authority,

NOLIST, "%d",

0,

0,0,

15, 25, INTEGER,

2 6, authority,

NOLIST,

"%d",

0,

0,0,

17

, 25

, IN

TEGE

R,28

, NULL,

NODAXA, "%ld",

0,

0,0,

19, 25, INTEGER,

32,

NULL,

NODAXA, "%f",

0,

0,0,

21, 25

, DECIMAL,

36,

NOLL,

NODAXA, "%f",

0,

0,0,

23, 25, DECIMAL,

40,

NULL,

NODAXA, "%f",

0,

0,0,

25, 25, DECIMAL,

44,

NULL,

NODAXA, "%£",

0,

0,0,

27, 25, DECIMAL,

48,

NULL,

NODAXA, "%ld",

0,

0,0,

29, 25,

DECIMAL,

0,

NULL,

NOSTRG, STIFM, STAT IDENT, 0, 0,

3, 10,

DECIMAL,

8,

NULL,

NODAXA, "%ld",

0,

0,0,

5

, 25 , INTEGER,

12,

NULL,

NODAXA, "%ld",

0,

0,0,

7, 25, INTEGER,

16,

NULL,

NODAXA, "%ld",

0,

0,0,

9, 25, INTEGER,

1,

0,

NULL,

NOSTRG, STIFM, STAT IDENT, 0,0,

3,25,DE

8,

NULL,

NODAXA, "%£",

0,

0,0,

5, 25,

DECIMAL,

NULL,

NODATA, CALFM,

CALIB,

0,0,

7,

25,

DECIMAL,

512,

NULL,

NOTIME, STTFM,

0,

0,0,

21, 25

, TIMES,

516,

NULL,

NOTIME, STTFM,

0,

0,0,

23, 25,

TIMES,

0,

NULL,

NOSTRG, STIFM, STAT IDENT, 0,0,

3, 10, DECIMAL,

8,feat_phase,

NOLIST, "%d",

0,

0,0,

5, 25, INTEGER,

10,

NULL,

NOCHAR, "%c",

0,

0,0,

7, 25,

DECIMAL,

11,

NULL,

NOCHAR, "%c",

0,

0,0,

9, 25, DECIMAL,

12,

NULL,

NODAXA, "%d",

0,

0,0,

11, 25, INTEGER,

14,

NULL,

NOCHAR, "%c",

0,

0,0,

13, 25

, DECIMAL,

15,

NULL,

NOCHAR, "%c",

0,

0,0,

15, 25, DECIMAL,

16,

NULL,

NOCHAR, "%c",

0,

0,0,

17, 25, DECIMAL,

17,

NULL,

NOCHAR, "%c",

0,

0,0,

19, 25, DECIMAL,

18,

NULL,

NODATA, "%d",

0,

0,0,

21,25, INTEGER,

20,

NULL,

NOTIME, MSXFM,

0,

0,0,

23, 25, TIMES,

28,

NULL,

NODAXA, "%£",

0,

0,0,

25, 25, DECIMAL,

32,

NULL,

NODAXA, "%£",

0,

0,0,

27, 25

, DECIMAL,

0,

NULL,

NODATA, "%ld",

0,

0,0,

3, 25,

DECIMAL,

4,

NULL,

NOSTRG, STIFM, STAT IDENT, 0, 0,

5, 10, DECIMAL,

12, feat_phaae,

NOLIST,

"%d",

0,

0,0,

7,

25, INTEGER,

14,

NULL,

NOCHAR, "%c",

0,

0,0,

9, 25, DECIMAL,

15,

NULL,

NOCHAR, "%c",

0,

0,0,

11, 25

, DECIMAL,

16,

NULL,

NODATA, "%£",

0,

0,0,

13, 25, DECIMAL,

20,

NULL,

NODATA, "%£",

0,

0,0,

15, 25, DECIMAL,

24,

NULL,

NODATA, "%£",

0,

0,0,

17, 25

, DECIMAL,

Page 50: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

ward

s:/u

sr/s

uds/

incl

ude/

suds

_des

cr.h

RESIDUAL

, "azimuth to station",

RESIDUAL,

"RESIDUAL,

"EVENT,

"/*100*/EVENT,

EVENT,

"EVENT,

"EVENT,

"dist

anca

to

station",

angl

a of a

marg

anca

",or

gani

zati

on"

,avant

numb

ar",

numb

ar fa

it ra

port

s",

MM i

ntan

sity

",avant

typa",

EVENT,

"tactonism",

EVENT,

"watarwavas" ,

EVENT,

"EVENT,

"machanism typ

a",

axplosiva ma

dium

",EVENT,

"magnituda or Ibs TNT",

EV DESCRIPT,

'aarthquaka

nama

",/*110*/EV DESCRIPT, "county",

EV_DESCRIPT,

"stata" ,

EV DESCRIPT, "local tima diff",

EV_DESCRIPT,

"unusad",

ORIGIN,

" avant numbar",

ORIGIN,

ORIGIN,

"ORIGIN,

ORIGIN,

"ORIGIN,

"/*120*/ORIGIN,

'ORIGIN,

'ORIGIN,

ORIGIN,

'ORIGIN,

*ORIGIN,

*ORIGIN,

'. ORIGIN,

'|

ORIGIN,

ORIGIN,

/*130*/ORIGIN

/

ORIGIN,

'ORIGIN,

'ORIGIN,

'ORIGIN,

ORIGIN,

orga

n! zat ion"

,varsion" ,

proc

assi

ng st

atus

",pr

afar

rad

loca

tion

",pr

ocas

sing p

rogr

am",

dapt

h cont

rol"

,co

nvar

ganca"

,ragion"

,or

igin

tima",

lati

tuda

",lo

ngit

uda",

'dap

th,

km",

horizontal

arro

r" ,

arror in

dapt

h",

'rms of ras

idua

ls",

'cru

stal

modal

usad",

'azi

muth

al gap",

'clo

sast

station, km",

'num

bar of s

tati

ons"

,'n

umba

r p phasas rapt."

'num

bar p phasas

usad",

ORIG

IN,

"numbar

m phasas rapt",

ORIGIN,

ORIGIN,

ORIGIN,

/*140*/ORIGIN,

ORIGIN,

ORIGIN,

ORIGIN,

ORIGIN,

ERROR,

rOCAIMECH,

FOCALMECH,

rOCALMECH,

rOCALMECH,

"num

bar

m phasas usad",

'magnituda t

ypa"

,'n

umba

r mag raadings",

num

bar mag m

us

ad",

mag

nitu

da"

, magnituda waight",

"magnituda r

ms",

dat

a so

luti

on d

ona",

"cov

aria

nca ma

trix

","strika plana

a",

"dip pla

na a"

,"raka plana

a",

"strika plana

b",

/*150*/rOCALMECH, "dip plana b",

FOCALMECH,

rOCALMECH,

FOCALMECH,

MOMENT,

MOMENT,

MOMENT,

MOMENT,

MOMENT,

VEIMODEL,

/*! 60*/VEIMODEL,

"raka pl

ana

b",

"prafarrad pla

na",

"unusad",

"dat

atyp

as",

"con

stra

ints

" ,

"unusad",

"scalar mo

mant

","momant ta

nsor

","n

atwo

rk na

ma",

"modal na

ma",

rLT,

IXT,

IXT,

SHT,

LNG,

SHT,

CHR,

CHR,

CHR,

CHR,

CHR,

CHR,

rLT,

SIR,

SIR,

SIR,

SHT,

SHT,

LNG,

SHT,

CHR,

CHR,

CHR,

CHR,

CHR,

CHR,

LNG,

MST,

LLT,

LLT,

rLT,

rLT,

rLT,

rLT,

SIR,

SHT,

rLT,

SHT,

,8HT,

SHT,

SHT,

SHT,

SHT,

SHT,

SHT,

rw,

ra,

rLT,

sir,

rw,

XT,

rLi,

rw,

rLT,

rw,

rw,

CHR,

CHR,

BTS,

CHR,

CHR,

riar

,ru?,

STR,

SIR,

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20,

16,

16,

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10,

1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 6, 4, 6,

28,

32,

36,

NULL,

NULL,

NULL,

0, authority,

2, 6, 8, 9, 10,

11,

12,

13,

14,

0, 20,

36,

52,

54,

o,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

HULL,

HULL,

HULL,

NULL,

NULL,

4, aut

hori

ty,

6, 7, 8, 9, 10,

11,

12,

16,

24,

32,

40,

44,

48,

52,

56,

62,

64,

68,

70,

72,

74,

76,

78,

80,

82,

84,

88,

92,

96,

0, 0, 4, 8, 12,

16,

20,

24,

25,

o, 1, 2, 4, 8, 0, 4,

NULL,

NULL,

NULL,

NULL,

HULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NOLL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

HULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NULL,

HULL,

HULL,

HULL,

NULL,

NULL,

NULL,

HULL,

NULL,

NULL,

NULL,

NULL,

NULL,

NODATA, "%£",

NODATA, "%f",

NODATA, "%f",

HOLI8T, "%d",

NODATA, "%ld",

NODATA, "%d",

NOCHAR, "%c",

HOCHAR, "%c",

HOCHAR, "%c",

HOCHAR, "%c",

HOCHAR, "%c",

HOCHAR, "%c",

NODATA, "%f",

NOSTRG, "% -,

NOSTRG, "%s",

NOSTRG, "%s",

NODATA, "%d",

NODATA, "%d",

NODATA, "%ld",

NOLI8T, "%d",

NOCHAR, "%c",

NOCHAR, "%c",

NOCHAR, "%c",

NOCHAR, "%c",

NOCHAR, "%c",

NOCHAR, "%c",

NODATA, "%ld",

NOTIME, MSTIM,

NODATA, LTTHC,

NODATA, LTTrM,

NODATA, "%f",

NODATA, "%f",

NODATA, "%f",

NODATA, "%f",

NOSTRG, "%s",

NODATA, "%d",

NODATA, "%f",

NODATA, "%d",

NODATA, "%d",

NODATA, "%d",

NODATA, "%d",

NODATA, "%d",

NODATA, "%d",

NODATA, "%d",

NODATA, "%d",

NODATA, "%f",

NODATA, "%f",

NODATA, "%f",

NOTIME, STTrM,

NODATA, "%f",

NODATA, "%f",

NODATA, "%f",

NODATA, "%f",

NODATA, "%f",

NODATA, "%f",

NODATA, "%f",

NOCHAR, "%c",

NOCHAR, "%c",

"0",

"%X",

HOCHAR, "%c",

NOCHAR, "%c",

NODATA,

M%fM

,NODATA, "%f",

NOSTRG, "%s",

NOSTRG, "%s",

o, o, 0, 0, o, o, 0, 0, o, 0, o, o, o, o, o, o, 0, 0, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, 0, 0, o, o, o, o, o, o, 0, o, o, o, o, o, 0, o, o, 0, o, o, o, o, o, o, o. o, o, 0, o, o, 0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

19, 25

, DECIMAL,

21, 25

, DECIMAL,

23, 25, DECIMAL,

3, 25, INTEGER,

5, 25,

INTEGER,

7, 25, INTEGER,

9, 25, DECIMAL,

11, 25

, DECIMAL,

13, 25

, DECIMAL,

15, 25, DECIMAL,

17, 25

, DECIMAL,

19, 25, DECIMAL,

21, 25, DECIMAL,

3, 25, DECIMAL,

5, 25,

DECIMAL,

7, 25, DECIMAL,

9, 25, INTEGER,

11, 25

, INTEGER,

3, 25,

INTEGER,

4,25, INTEGER,

5, 25,

DECIMAL,

6, 25,

DECIMAL,

7, 25,

DECIMAL,

8, 25, DECIMAL,

9, 25,

DECIMAL,

10, 25, DECIMAL,

11, 25

, INTEGER,

12, 25

, TIMES,

13, 25

, DECIMAL,

14, 25

, DECIMAL,

15, 25

, DECIMAL,

16, 25

, DECIMAL,

17, 25, DECIMAL,

18, 25

, DECIMAL,

19, 25, DECIMAL,

20, 25, INTEGER,

21, 25

, DECIMAL,

22, 25, INTEGER,

23, 25, INTEGER,

23, 55, INTEGER,

24, 25, INTEGER,

24, 55, INTEGER,

25, 25

, INTEGER,

26, 25, INTEGER,

26, 55

, INTEGER,

27, 25, DECIMAL,

28, 25

, DECIMAL,

29, 25, DECIMAL,

30, 25

, TIMES,

3, 25, DECIMAL,

3, 25,

DECIMAL,

5, 25,

DECIMAL,

7, 25,

DECIMAL,

9, 25, DECIMAL,

11, 25, DECIMAL,

13, 25

, DECIMAL,

15, 25

, DECIMAL,

17, 25, DECIMAL,

3, 25, DECIMAL,

5, 25, DECIMAL,

7, 25, DECIMAL,

9, 25,

DECIMAL,

11, 25, DECIMAL,

3, 25, DECIMAL,

5, 25,

DECIMAL,

Page 51: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

incl

ude/

suds

_des

cr.h

VELMODEL,

VELMODEL,

VELMODEL,

VELMODEL,

VELMODEL,

VELMODEL,

LAYERS,

LAYERS,

LAYERS,

/*170*/LAYER8,

LAYERS,

LAYERS,

LAYERS,

COMMENT,

COMMENT,

COMMENT,

"unused",

o3

PROFILE,

SHOTGATHER,

/*180*/CALIB,

CALIB,

COMPLEX,

COMPLEX,

TRIGGERS,

TRIGGERS,

TRIGGERS,

TRIGGERS,

TRIGGERS,

TRIGGERS,

/*190*/TRIGGERS (

TRIGGERS,

TRIGSETTING,

TRIGSETTING,

TRIGSETTING,

TRIGSETTING,

TRIGSETTING,

TRIGSETTING,

TRIGSETTING,

TRIGSETTING,

TRIGSETTING,

TRIGSETTING,

TRIGSETTING,

"latitude pt A",

"longitude pt A",

"latitude pt B",

"longitude pt B"

,"thickness, km

","p

velocity at to

p",

"p velocity at base",

"s velocity at to

p",

"s velocity at ba

se",

"velocity function",

"spa

re",

"structure identifier",

"field number",

"comment le

ngth",

"unused",

"not right",

"not right",

"pole",

"zero",

"real",

"imaginary",

"station/component",

"short-term average",

"long-term average",

"ah-term aba average",

"Ig-term aba average",

"trigger level",

"number of triggers",

"time of first trigger"

"network na

me",

"time of first trigger"

"constl",

"const2",

"threshold",

"const3",

"const4",

"weighted ave increment

"sweep in seconds",

"aperture",

"spa

re",

CHR,

CHR,

LLT,

LLT,

LLT,

LLT,

FLT,

FLT,

FLT,

FLT,

FLT,

SHT,

SHT,

SHT,

SHT,

SHT,

SHT,

SHT,

SHT,

CPX,

CPX,

FLT,

FLT,

STI,

SHT,

SHT,

SHT,

SHT,

SHT,

SHT,

,MST,

STR,

,MST

,SHT,

SHT,

SHT,

SHT,

SHT,

",SHT,

FLT,

FLT,

LNG,

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,

10,

11,

12,

20,

28,

36,

0, 4, 8, 12,

16,

20,

24,

o, 2, 4, 6, 6, 6, 0, 4, o, 4, 0, 12,

14,

16,

18,

20,

22,

24,

o, 4, 12,

14,

16,

18,

20,

22,

24,

28,

32,

NOLL

,NO

LL,

NOLL

,NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOLL,

NOCHAR,

NOCHAR,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NOSTRG,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NOT ME,

"unk",

NOT ME,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

NODATA,

"%C",

0,"%C",

0,LTTFM,

0,LTTFM,

0,LTTFM,

0,LTTFM,

0,"%f",

0,"%f",

0,"%f",

0,"%f",

0,"%f",

0,"%d",

0,"%d",

0,"%d",

0,"%d",

0,"%d",

0,"%d",

0,"%d",

0,"%d",

0,COMFM, COMPLEX,

COMFM, COMPLEX,

"%f",

0,"%f",

0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

STIFM, STAT IDENT, 0, 0,

"%d",

0,"

"%d",

0,"%d",

0,"%d",

0,"%d",

0,"%d",

0,MSTFM,

0,"%s",

0,MSTFM,

0,"%d",

0,"%d",

0,"%d",

0,"%d",

0,"%d",

0,"%d",

0,"%f",

0,"%f",

0,"%ld",

0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

0,0,

7, 25, DECIMAL,

9, 25,

DECIMAL,

11, 25, DECIMAL,

13, 25, DECIMAL,

15, 25

, DECIMAL,

16, 25, DECIMAL,

3, 25, DECIMAL,

5, 25,

DECIMAL,

7, 25,

DECIMAL,

9, 25,

DECIMAL,

11, 25, DECIMAL,

13, 25, INTEGER,

15, 25, INTEGER,

3, 25, INTEGER,

5, 25,

INTEGER,

7, 25, INTEGER,

9, 25, INTEGER,

3, 25,

INTEGER,

3, 25, INTEGER,

0,25, DECIMAL,

1,25, DECIMAL,

0,25, DECIMAL,

0,55, DECIMAL,

3, 10, DECIMAL,

7, 25, INTEGER,

9, 25, INTEGER,

11, 25

, INTEGER,

13, 25

, INTEGER,

15, 25

, INTEGER,

17, 25, INTEGER,

19, 25, TIMES,

3, 25,

DECIMAL,

5, 25, TIMES,

7, 25,

INTEGER,

9, 25, INTEGER,

11, 25, INTEGER,

13, 25, INTEGER,

15, 25, INTEGER,

17, 25, INTEGER,

19, 25, DECIMAL,

21, 25

, DECIMAL,

22, 25, INTEGER,

int »tf onu_len (ciieof (*tf o

rm) /m

i. zeof (atruct audaform) ) ;

/* Indeciec in at form for beginning of each atructure type

*/

LG_INT beg_*truct[]«{

0,1,5,9,11,21,44,53,66,70,75,88,99,109,114,145,146,154,159,167,174,178,179,180,182,184,192,

); /*

wid

th o

f a

acii

fi

eld

for

inp

ut

and

outp

ut

of

each

va

ria

ble

ty

pe

*/

LG

_IN

T w

idth

_fi

eld

[]«

{0,

1, 5

, 25,

5, 1

0, 1

2, 1

6, 1

6, 1

2, 1

6, 1

6, 1

6, 1

2, 1

2,

LG

_IN

T a

ize_

*tr

uct[

]«{

o, izeof (STATIDENT) ,

aizeof (atruct atructtag) ,

izeof (atruct terminator),

izeof ( truct equipment) ,

izeof (ctruct atationconp) ,

Page 52: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

incl

ude/

suds

_des

cr.h

sizeo

f (s

tru

ct B

uxd

ata

),

sizeof

(str

uct

des

crip

trace

) ,

sizeo

f (s

tru

ct

loct

race

) ,

sizeof

(str

uct

ca

lib

ra

tio

n),

si

zeo

f (s

tru

ct

£ a

tura

) ,

is«of

(vtr

uct

*id

oal)

, i

s«of

(vtr

uct

«

nt)

, i

s«of

(vtr

uct

«v_d

«»cr

ipt)

, i

s«of

(vtr

uct

orig

in),

is«of

(vtr

uct

«

rro

r) ,

isa

of (ctruct £ oca

ln«c

h) ,

ix

«o

f (s

tru

ct

moM

nt)

, i

sa

of

(str

uct

v«l

mod

«l)

, i

sto

f (s

tru

ct

lay

ers)

, si z

*o

f (s

tru

ct

con

nw

at)

, si x*of

(str

uct

p

ro

file

),

si x

«of

(str

uct

sh

ot g

ath

er)

, i

s«of

(str

uct

cali

b),

si

z*

of

(CG

MPL

EXX)

, si

x«of

(str

uct

tr

iggers)

, si

z*of

(str

uct

tr

ig sett

ing

) ,

fen

dif

SU

DS

DE

SC

RIP

H

Page 53: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

incl

ude/

st_e

rror

.h

/*

ST

_IR

RO

R.H

* B

ruo*

R.

Ju

lian

, U

SGS

Iton

lo P

ark

Cali

f.,

15 D

«c.

1983

* M

od

ifie

d P

UT

ard,

U

SGS

Iton

lo

Par

k C

ali

f.,

Ap

ril

8,

1988

*/|i£nd«f SODSERR_H

|d«fin« SODSERR H

tatic char 8

t__«

ror_

h[]

- He(t)*t_«rror.h

1.2

11/17/

88";

/* Se

es Id */

|d«fin«

ERRB

ASE

td*fiM 1BADDAY

td«fiM BBADMONTH

fdafiiM 1BADYIAR

|d«fin« IBADVALUK

fd*fin* ETIHDATA

id«fiM BHOCONVR6

|d«fin« tOHDKRTLOW

|d«fin« BHOSTAXIOH

|d«fin«

ISIZI

fdAfilM 1SIMGUIAR

|d«fin« KTOODEEP

fdafiM 1BADPHAS1

|d«f

in« BHORAS

|d«fin«

IZNT

IHfd«fin« 1BADSYNC

|d«fin« ST ERR

fd«£in« KCAMTBRACKET

1000

(BRRBASB + 1)

(BRRBASB + 2)

(ERRBASX + 3)

(CRRBASK + 4)

(ERRBASX + 5)

(ERRBASX + 6)

(ERRBASX + 7)

(BRRBASB + 8)

(BRRBASB + 9)

(BRRBASB + 10)

(ERRBASB + 11

)(BRRBASB + 12)

(BRRBASB + 13

)(ERRBASB + 14

)(ERRBASB + 15)

(ERRBASB + 16)

(ERRBASB + 17)

|«ndif SDDSERR H

Page 54: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

incl

ude/

suds

.h

/* SODS:

Version 1.

2 AUG 1

0,19

88Son* ca

r* ha

* been tak

en t

o ke

ep bytes aligned

on 4 byte boundaries

for

port

abil

ty.

Indi

vidu

al fielda wi

thin

al

l structures ha

ve un

ique

names

for

conpatability

with th« database sy

stem

. Ex

pand

abil

ity

i* accomplished by adding new str

uctu

res

and by adding maw

fiel

ds to the and of these atructures.

Such a

ddit

ion*

naad to ba

coordinated among all uaera and ahonld not ba takan li

ghtl

y.

PLNa

rd,

U.S. Geological Su

rvey

, Manlo Pa

rk,

Ca.

94025

lifndaf

SODS

H

Idafina 8ODSJK

atatic char

Suds

_h[]

"%W%

%G

%";

/* sees Id *

/

/* Daf

ina

coda for typ

e of machine cu

d* ia

being c

ompiled

on.

See

anda

_cod

ea.h

COOKS

mach

_typ

e[]

THIS DEFINE MOST BX CHANGED FOR MACHINES MOT A SON 3

*/

Idef

ine MACHINE '3'

/* Define sy

mbol

s for miaaing d

ata.

See

auda deacr.h

*/ Idef

ine NODATA "-

3276

7."

Idefine NOTIME "-2147472000"

/* Dec 1

4, 19

01 00:00

00 GMT, near l

arge

st long */

Idef

ine NOCHAR "

" Idefine NOSTRG "~

Idef

ine

NOLIST "0

"

/* St

anda

rd variable t

ype*

*/CHAR;

/*

MINI;

/*

STRING; /*

/*

/*

redefined

for portability a

nd clarity

A aingle

aacii

character

A 1

by

te integer

(0 to 255)

A cha

ract

er st

ring

, nu

ll byte ter

mina

ted

An 8 bit

field

A 1

6 bit

aigned integer

A 32 bit

aign

ed in

tege

rA 32 bit

floating point n

umber, IEEE

A 64

bi

t double precision n

umbe

r, IEEE

*/ */ */ */ */ */ */ */

typedef cha

r typedef char

typedef cha

r^V typedef char

BITS

8;

X>J typedef a

bort

SH_INT;

typedef lo

ng

LG_INT;

/*

typedef f

loat

FLOA

T;

/*

typedef double

DOUBLE;

/*

typedef struct

{ FLOAT

fx;

FLOAT

fy;

} VECTOR;

typedef a

truc

t {

FLOAT

cr;

FLOAT

ci;

} CO

MPLK

XX;

typedef a

truct

{ DO

UBLE

dr

; DO

UBLE

di;

} DJCOMPLEX;

typedef a

truc

t {

FLOAT

jcz;

FLOAT

yy;

FLOAT

xy;

} TENSOR;

/* Sp

ecia

l variable types

*/ty

ped

ef a

tru

ct

{ /*

st

ati

on

co

mp

onen

t id

en

tifi

er

*/

STR

ING

n

etw

ork

[4];

/*

n

etw

ork

nam

e */

STR

ING

st

_n

am

a[5

];

/*

nam

e of

stati

on

wh

ere

equ

ipm

ent

ia

loca

ted

*/

CHAR

component;

/*

SH_INT

instjtype;

/*

} STATIDENT;

typedef LGJHT RJCXMB; /*

component

v, n, e

inst

rume

nt typ

e

stamp GM

T time in

seconds before or after Ja

n 1,

19

70,

reso

luti

on i

a on

e se

cond

*/

typedef DOUBLE MSJ

TIME

; /*

GM

T time in s

econds before or after Ja

n 1,

~~

1970,

reso

luti

on fi

ner than microseconds*/

typedef DOUBLE L

ONLA

T;

/* latitude or l

ongi

tude

in

deg

rees

, N and E p

osit

ive*

/

typedef a

truct

codes

LG_I

NT n

um;

STRING *meaning;

} CO

DES;

/* SODSFORM:

Information on each su

ds st

ruct

ure us

ed for

input

fzou

tput

to aa

cii,

loading or unloading the d

atab

ase,

et

c.

*/

typedef atruct

audaform

{

aaci

i,

LG_IHT

faty

pe;

STRI

NG

*fna

me;

LG INT

ftype;

LG~I

NT

flen

gth;

LG_IHT

offs

et;

CODE

S *codelist;

STRI

NG

*initval;

STRI

NG

*f fo

rmat

;LG

_INT

ne

xtfa

type

;LG I

NT

frecord;

LG_I

NT

ffie

ld;

LG_I

HT

formjcow;

LG INT

form c

ol;

STRI

NG

*allowchar;

} SODS_FORM;

/* Integer

defines

for

*/Idefine

CHR

1Idefine

MTN

2Id

efin

e ST

R 3

Idefine

BTS

4Idefine

SET

5Idefine

LNG

6Idefine

FLT

7Idefine

DBL

8Idefine

STI

9Id

efin

e STT

10Idefine

MST

11Id

efin

e LLT

12Idefine

CAL

13Idefine

CPX

14

/* St

ruct

ure

type

s or

ide

ntif

iers

*/

/* Name uae

d to identify structure item

*//* Type of var

iabl

e in f

ield

*/

/* Le

ngth

of variable in the field

*//* Of

fset

of v

ariable pointer from beginning of s

truc

ture

mneaaured in

byt

es,

where

firs

t byte of structure-0.

This field

ia p

oten

t ai

l machine dependent

and ideally

should be de

term

ined

by a program l

ike th

e ddlp

(Data Description Language Pr

oces

sor)

of db v

ista

.Aad long aa structures ar

e carefully

defined to

alig

n 4 bytes

boun

dari

es,

we can

get

away wit

hout

writing

such a

complex program for moat machinea

*//* If val

ue indexes

a codes

liat,

this ia

li

st

*//* Value t

o in

itia

lize

st

ruct

ure

*//* Printf typ

e fo

rmat

to rea

d + write field

*//* If s

tructure,

this

ia

fa

type

*/

/* da

taba

se record for this fi

eld

*//* da

taba

se field

for this field

*//* row of fie

ld in f

orma edi

tor

*//* be

ginn

ing

column of f

ield

in

fo

rma

editor

*//* al

lowe

d characters on input

*/

standard variable types

/* char 1 byte

*//* char number 1 byte

*//* st

ring

*/

/* char 1 byte

*//* abort

2 bytes

*//* long 4 bytes

*//* float

4 bytes

*//* do

uble

8 by

tes

*//* struct atatJLdent 8 bytes

*//* at time 4 by

tes

*//*

ms~

~tim

e 8 bytes

*//* Io

n la

t 8 by

tes

*//* at

ruct

calib

500 bytes

*//* at

ruct

complex

16 b

ytes

*/

/* Structure

types

or id

enti

fier

**/

Idefi

ne

NO

JST

RU

CT

0

Idefi

ne

STA

TJC

DK

NT

1

Page 55: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

CO §^CO

I8

J«*

«

I

^4 V*ii 311a - :

!! :Si*jj.29§ * a 385

: 3

0*U

4111!«ir.2*3

«««« ««««««

§5 §s?« ^u: I 53

& ^ * ti- i -8 !--6 H 1 H O

* ' *1*^ i :-!i> J 0 >x

4» -9 4» 4>

! l«jj JJ-JL f Jfl!i an- -"'"' ns: f| . a,«tCa*i^'J^8 <g'355. & -g4* 5 i S 555 fi Jlr3-a. !4»-rl_0^ 4JM3fl«*>lM<IT34J - fl.^1 M ;j iiij;ji^4.tii|iJi]% 0 Tii^ k |fiir

31 cjl1^^^:?r5AMf f «*K«5§4 "u tflWWftfi[Hill!«]!«. ...- IS'.S.-fleSs., ..38 .s sKmsj'mmiitfHiiifii

rl -rl 5 5 4> -rl * fl 4> P. f 0 Ofl9 H i H iH4< 44 & fr -rlOfeJ Qff&Cfri ^ 0 0 « Q f -H H00** 94*

3«««« *«««NV «

s. ! 5 < i

rl » O ". 41 Qi «. .

41 0, f 0 - - S R f " - *i r, * *i mni1 ft i, P i O ) - T> «O>-0 4J fi O 4J 0 0 | | MJJ" H 2 S j Tl HI HI & 7{ 2 8 « 5 8 <f <f *,il igs 1 «vl1 itlhi i i &«'

J!'!' 111! iii!'ii i i N

s3s 3'fV

l!1 !

51M&£ I

CO

£jco :

1:

||jJJj|«««3JJ333J3JJ3mjIIIIIIIHIIIISIIIII'"'"'"'"'"'"

u ^ e .£9*

M J -rl Ol O 4j

IHl*i«11 i3«n11 «« >i

9 -

1 iff'ftggi'" 58 -Sraaasss&B

K II H H H.H.H.H.II I l<H'H'H'HI

M M M M I

Page 56: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds :/

usr/s

uds/

incl

ude/

suds

.h

MS_

TIM

E b

egin

tim

e;

SH__

INT

loca

ltim

e;

CHAR

d

ata

typ

e;

CHAR

SH'I

NTLG

__IN

T FLOAT

FLOAT

FLOAT

FLOAT

LGJtNT

descriptor;

digi_by;

proc

esse

d;

length;

rate;

mindata;

maxdata;

avenoise;

numc

lip;

/* t

ime

of

first

data

sa

mp

le

*/

/* m

inu

tes

to

add

to

GM

T to

get

lo

cal

tim

e */

/* s-

sho

rt (

16 b

it),

r-

12 b

it

data

, 4

lab

tim

e,l-

lon

g(3

2 b

it),

f-

float,

d-double,

c-co

mple

x, v-

vect

or,

t-te

nsor

*/

/*

g-

good

, t-telemetry n

oise,

ocallbration, etc*/

/* agency co

de who digitixed

record

; 0-

orig

inal

*/

/* processing done on this waveform

*/

/* number of

samples

in trace

*/ */ */ *//* average value of first

200

samp

les

(typ

e s,l,f onl

y)*/

/* nu

mber

of clipped

data

poin

ts

*/

/* sa

mple

s per second

/* minimum value of dat

a (type

s,l,

f on

ly)

/* maximum value of data

(type

s,l,

f o

nly)

/* LO

CTRA

CE:

loca

tion

of trace

V

stru

ct lo

ctra

ce

{STATIDENT lt__name;

STRING

*fileloc;

STRI

NG

*tapeloc;

LG_IHT

begin!oc;

/* station

comp

onen

t id

enti

fica

tion

/* pointer to pathname in

fi

le system

/* pointer to name of tape or offline s

tora

ge/* bytes

from begining of fi

le to trace

*/ */ */ */

/* CALIBRATION: calibration

info

rmat

ion

for

a st

atio

n component

*/

Idef

ine NOCALPTS 30

struct ca

libr

{ COMPLEXX

pole;

COMPLEXX

xero

;

struct calibration

{ STATIDENT

c _

FLOAT maxgain;

FLOAT

nozm

alix

;

/* po

le

/* ze

ro*/ */

/* station

component

iden

tifi

cati

on

*/

/* maximum gain of calibration

curv

e */

/* fa

ctor

to multiply standard cali

b by to make

peak at given fr

eque

ncy-

l */

struct oa

lib

cal[NOCALPTS

]; /* calibration info

*/

STJTIME

begi

nt;

/* ti

me this calibration bec

omes

effective

*/ST_TH E

);endt;

/* time thi

s calibration is no

longer eff

ecti

ve */

/* FE

ATUR

E: Observed

*/struct feature

{STATIDEHT

fejn

ame;

SH INT

obs_

phas

e;

CHAR

onse

t;CH

AR

dire

ctio

n;

phase /* /*

/* /*SH_INT

sig_

_noi

se;

/*

CHAR

data source;

/*CHAR

tim_qual;

CHAR

amp_qual;

CHAR

ampunits;

/* /* /*

arrival

time,

amplitude, and

period.

SH_INT

gain

ra

nge;

/*

MS_TIME timej

/*FLOAT

ampl

itud

e;

/*FLOAT

period;

/*

station

component

iden

tifi

cati

onob

serv

ed phase code

wave o

nset de

scri

ptor

, i or e

first

moti

on:

0,D,+,-

ratio

ampl

. of first peak or

trough to

nois

ei-

inte

ract

ive,

a-au

toma

tie,

r-rt

p, or user

code*/

timing quality given by a

nalyst

: 0-4, etc.

n-ignore timing

*/

amplitude quality given by ana

lyst

: 0-4, et

c.n-ignor amplitude in

form

atio

n */

unit

s amplitude measured i

n: d-

digi

tal

counts

m^gm on develocorder,

etc.

*/

1 or gain multiplier if

gai

n range

in effect */

phase

time

, x value where pick was made

*/

peak

-to-

peak

amplitude of phase

*/

period of waveform measured

*/

/* RE

SIDU

AL:

Calc

ulat

ed*/

struct residual

{LG_INT

event_num;

STATIDENT

re_n

ame;

SH_INT

set_phase;

CHAR

set_tim_qual;

CHAR

set_amp_qual;

FLOAT

residual;

FLOAT

weightjused;

FLOAT

delay;

FLOAT

axim

uth;

FLOAT

distance;

FLOAT

emergence;

resi

dual

s for arrival

time

s, ma

gnit

udes

, etc.

/* unique event

number

*/

/* st

atio

n co

mpon

ent

identification

*/

/* phase

code set

for this solution

*/

/* tim

ing quality ass

igne

d for this so

luti

on:

0-4*/

/* amplitude

quality as

sign

ed for this so

luti

on:

0-4*/

/* traveltime re

sidu

al or pha

se magnitude

*/

/* we

ight

used in

this solution

*/

/* delay time or station correction used

*/

/* aximuth

event

to station, 0 no

rth

*/

/* distance in km event to station

*/

/* an

gle of eme

rgen

ce fr

om s

ourc

e, 0«down,180«up*/

/* EV

ENT:

ge

nera

l information

about an e

vent

*/

stru

ct ev

ent{

SH_INT

auth

orit

y;LG_INT

number;

SH_INT

felt;

CHAR

mintensity;

CHAR

ev_type;

CHAR

tect

onis

m;

CHAR

wate

rwav

e;CH

AR

mech

anis

m;CH

AR

medium;

FLOAT

sire

;

/* or

gan!

rati

on pro

cess

ing the data

*/

/* un

ique

event

numb

er ass

igne

d by organixation */

/* number of fe

lt re

port

* */

/* Maximum Modified Mercali Intensity

*/

/* e»

eart

hqua

ke,

E«ex

plos

ion,

n-nuelear,

i-icequake,

b»b__type, n-

net,

r-

regi

onal

, t»teleseism, ^calibration, n-noise

*/

/* ob

serv

ed u-u

plif

t, s-

subs

iden

ce,

S-strikeslip

faul

ting

, N-normal fa

ulti

ng,

T-th

rust

*/

/* se

iche

, ts

unam

i, etc.

*/

/* t«thrust,

s-strike-slip, n-

norm

al,

e-explosive*/

/* medium containing exp

losi

on or event

*/

/* mag

nitu

de or

pou

nds

THT

for explosions

*/

/* EV_DESCRIPT: descriptive

information

abou

t an e

vent

typically used fo

r major, destructive

eart

hqua

kes.

This structure

is typically associated

with

EVENT st

ruct

ure.

struct ev_descript

{ STRING

eqna

me[2

0];

STRING

oountry[16],

STRING

stat

e[16

];

SH_INT

localtime;

SH_INT

spareB;

/* Popular

name

used to re

fer to this

eart

hqua

ke*/

/* country of ear

thqu

ake

*/

/* st

ate,

province or other political subdivision*/

/* ho

urs to add to GNT to ge

t lo

cal time

*/

/* ORIGIN:

information about

a sp

ecif

ic so

luti

on for

a given eve

nt*/

struct or

igin

{

LG_INT

number;

SH_INT

authority;

CHAR

version;

CHAR

or_status;

CHAR

pref

erre

d;CH

AR

prog

ram;

/* un

ique

event

number ass

igne

d by organixation */

/* or

gani

xati

on pro

cess

ing the data

*/

/* version of so

luti

on wit

hin organixation

*/

/* processing st

atus

: f-final, a-

auto

mat!

c, et

c */

/* p-pref*rred lo

cati

on

*/of pro

cess

ing program

h-hypo71,

1-hypolayer,

CHAR

depcontrl;

CHAR

convergence;

LG_IHT

region;

MSJTXME orgtime;

LONLAT

orJLat;

LONLAT

or_long;

FLOAT

depth;

i-is

c, c-centroid,

etc.

*//* depth

cont

rol:

f-fixed, et

c.

*//* hypocentral

convergence

char

acte

r */

/* geographic region co

de ass

igne

d locally

*//* or

igin

time

*//* la

titu

de,

nort

h is plus

*//* lo

ngit

ude,

east is plus

*//* de

pth

in kil

omet

ers,

+ down

*/

Page 57: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

incl

ude/

suds

.h

FLO

AT

FLO

AT

FLO

AT

STR

ING

SB

m

FLO

AT

SH_I

NT

sH_n

reSH

~IN

TSH

~INT

SH

_INT

SH

~INT

SH~INT

SH~INT

FLOAT

FLOAT

FLOAT

STIIME

err_horiz;

err_depth;

res_rms;

erustmodel [

6]

a«p;

nearstat;

num_stats;

/* horizontal error in km

/* vertical error in km

/* rm

s of residuals

;/*

code for model used in this location

used_p;

«*p_«;

used_s;

rep_m;

used_m;

magnitude;

weight;

mag_xms;

effective;

/* ERROR

*/

struct error

{FLOAT

covarr[10];

/* FOCALMECH

*/

struct focalmech

{FLOAT

astrike;

FLOAT

FLOAT

C^

FLOAT

FLOAT

FLOAT

CHAR

CHAR

adip;

arake;

bstrike;

bdip;

brake;

prefplane;

spareC[3];

/* azimuthal gap in degrees

/* distance in km to nearest station

/* number of stations reporting phases

/* number of p phases reported

/* number of p times used in the solution

/* number of s phases reported

/* number of s times used in the solution

/* magnitude type: eoda,tau,xmag ml,

mb,m

s,i

/* number of magnitude readings reported

/* number of magnitude readings used

/* magnitude value

/* average magnitude weight

/* rms of magnitude

/* time this solution was calculated

/* covariance matrix

/* strike of plane a

/* dip of plane a

/* rake of plane a

/* strike of plane b

/* dip of plane b

/* rake of plane b

/* preferred plane a or b or blank

/* MOMENT TENSOR (M

ight

be used instead of focal mechanism)

*/

struct moment{

BITS8

datatypes;

/* sum of

: 1-polarities, 2«amplitudes,

4-waveforms, etc.

CHAR

constraints; /*

solution constrained: d-deviatoric,

c-double couple

CHAR

spareD[2];

FLOAT

sc_moment;

/* scalar moment

FLOAT

norm_ten[6]; /*

normalized moment tensor

/* VELMODEL: Velocity model

*/

struct velmodel

{STRING

netname[4];

/* network nan

STRING modelname[6];/* model name

CHAR

spareE;

CHAR

modeltype;

LONLAT

latA;

LONL

AT

longA;

LONLAT

latB;

LONLAT

longB;

*/ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */

/* p profile A to B, a^area within corners A B

/* latitude of point A, north is plus

/* longitude of point A,

east is plus

/* latitude of point B,

north is plus

/* longitude of point B, east is plus

*/ */ */ */ */ */ */ */ */ */ */

/* LAYERS:

Velocity layers

*/

struct layers

{FLOAT

FLOAT

FLOAT

FLOAT

FLOAT

SB INT

thickness;

pveltop;

pvelbase;

sveltop;

svelbase;

function;

/*

/*

/*

/*

/*

/*

SB_INT

spar

eF;

thickness in kilometers

p velocity at top of layer

p velocity at base of layer

s velocity at top of layer

s velocity at base of layer

velocity function in layer: 0»eonatant,

l«linear, 2-exponential, et

c.

/* COMMENT: Comment tag to be followed by the bytes of comment

*/struct comment

{SH_INT

refer;

/* structure identifier comment refers to

SB_INT

item

; /* item in structure comment refers to

SB_INT

leng

th;

/* number of bytes in comment

SB INT

unused;

/* PROFILE: Grouping of shotgathers by profile

*/

struct profile

{int junkl;

/* What is your suggestion? */

/* SBOTGATHER: Grouping of waveforms by source event

*/

struct shotgather

{int ju

nk2;

/* What is your suggestion? */

/* TRIGSETTING: Settings for earthquake trigger system

*/

struct trigsetting

{STRING

netwname[4]; /* network name

MSJTIME beginttime;

/* time these values in effect

/* trigger constant 1

/* trigger constant 2

/* trigger threshold

/* trigger constant 3

/* trigger constant 4

/* weighted average increment

/* trigger sweep time in seconds

/* seconds for coincident station triggers

/* spare

SH__

INT

constl;

SH_INT

cons

t2;

SHJENT

threshold;

SH_INT

cons

t3;

SH_INT

cons

t4;

SH__INT

wav_inc;

FLOAT

sweep;

FLOAT

aperture;

LG_INT

spar

el;

*/ */ */ */ */ */ */ */ */

/* TRIGGERS: Earthquake detector trigger statistics

*/struct triggers

{STATIDENT tr_name;

/* station component identification

SH_INT

sta; /* short term average

*/SH_INT

Ita;

/* long term average

*/

SH_INT

abs_sta;

/* short term absolute average

SH_INT

abs_lta;

/* long term absolute average

SH_INT

trig_yalue;

/* value of trigger level (e

ta)

SH_INT

num_triggers;/* number of times triggered during this event

MSjrnOt trigjtime;

/* time of first trigger

*/ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */

Page 58: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

incl

ude/

suds

.h

/* K

i*e.

d

*fi

n*a t

o p

rote

ct

*lo

pp

y p

zogr

anoM

r*

fin

clu

d*

tdio

.h>

xt«

rn

riU

E

**t_

op*n

() ,

* £o

p«n

() ;

xt«

xn

LG

_ZM

T «

rrn

o,d

i* x

t«x

n D

OD

BLC

ato

f ()

,m

a_

«xt«

rn S

DD

S_rO

RM

*tf

ozm

[];

xt«

xn

JM

jan

«

ix«

tru

ctt

],b

^i_

«tr

uct[

],w

idth

_fi

«ld

[];

CO

D«8

in

rt_ty

p«[]

,mach

_ty

p«[]

,«q

uip

_»od

«l[

],«q

uip

_r«

a«on

[J,j

k

_typ

« [ ]

, «ta

t_p

roc

[ ], a

uth

ori

ty [ ],

£«a

t_p

haM

[ ],

tru

ct_

na

»«

« [

];

l«n

dif

SU

DS

H

tt_

CO

«[]

,

Page 59: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

incl

ude/

suds

_cod

es.h

/* co

des:

structure

relating numeric codes to st

ring

sEACH CODEUST MOST BE TERMINATED BY A "0

, 0, "

to designate the end of lis

t When add

ing new

code arr

ays

add new names to extern

at en

d of suds.h

and put na

mes

in su

ds_d

escr

.h.

You must then rec

ompi

le suds_io.c

FIMa

rd,

U.S. Ge

olog

ical

Su

rvey

, Menlo P

ark, Ca 94025

*/fifndef 8UD8jCODES_H

ffdef ine SUD8jCODES_H

static

ch

ar B

uds_codes_h[J

- "e

(|)s

uds_

code

s.h

1.2

11/17/88";

/* Se

es Id

*/

finclude "/usr/suds/include/suds.h"

CODES struct

_names[]«{

0,

"no

stru

ct",

1.

"station ident",

2.

"str

uctu

re t

ag",

3.

"ter

mina

tor"

,4.

"e

quip

ment

",5.

"stat io

neom

p",

6.

"mux

data",

7.

"descriptrace",

8.

"loctrace",

9.

"calibration",

10.

"feature",

11.

"residual",

12.

"event",

13.

"ev_descript",

14.

"ori

gin"

,15.

"error",

16.

"foc

alme

ch",

17.

"mom

ent"

,18.

"velmodel",

19.

"layers",

20.

"com

ment

",21.

"pro

file",

22.

"sho

tgat

her"

,23.

"calib/points",

24.

"co

mp

lex

num

ber"

,25

. "

trig

ger

s",

26.

"tr

igse

ttin

g"

,0,

0,

/* instrument ty

pe*:

*/

CODES

in*t_t

ype[]»{

u*e

a number l

e** th

an 100

except in

equipment ct

ruct

ure*

0,

"not sp

ecif

ied"

1.

"*p u*g*

H,

2.

"*p mr**n",

3.

"Ip ww**n",

4.

"»p dm

r**n

",5.

"Ip dw

w**n

",6.

"hglp la

ment

",7.

"Ip hglp l

amen

t",

8.

"*p

*ro"

,9.

"Ip

*ro"

,10.

"*p

a*ro",

11.

"Ip a*ro",

12.

"*p

r*tn",

13.

"Ip

r*tn",

14.

"*p uofa V of

alas

fca"

201.

"acceleration

censor"

202. "v

eloc

ity

sens

or",

203.

"

dis

pla

cem

ent

204.

"s

trai

n se

nsor

",20

5. "temperature se

nsor

",20

6. "pressure

sens

or",

207.

"t

ilt

sensor",

208.

"gravity sensor",

209.

"magnetic

sens

or",

210.

"radon s

ensor",

300.

"amplifier",

301. "amp/vco",

302.

"filter",

303. "summing a

mp",

304.

"transmitter",

305.

"r

ecei

ver"

,306. "antenna",

307.

"battery",

308.

"s

olar

ce

ll",

309.

"d

iscr

imin

ator

",31

0. "d

iscr

. ra

ck",

311.

"paper recorder",

312.

"film recorder",

313.

"smoked

glass

reco

rder

"314. "atod co

nver

ter"

,31

5. "c

ompu

ter"

,31

6. "clock",

317.

"time

receiver",

318.

"m

agne

tic tape",

319. "magnetic disk",

320.

"o

ptic

al disk",

0,

0,

CODE

S an

n_c

om[]

«{

0,

"no

com

men

t

CODE

S ro

ck_

typ

e[]-

{ 0,

"n

one

give

n"

1,

"

soil

",

CODE

S m

ach

_ty

pe[

]-{

_',

"

not

g

iven

",

3',

"

sun

3"

, 4',

"

sun

4"

, 6

',

"80

386"

, i'

"i

bm",

0, );o,

CODE

S eq

uip

_m

od

el[]

*{

0,

"non

e g

iven

",

1.

"14

geop

hon

e",

2.

"hslO

geop

hone

",3.

"ev!7

geop

hone

",10

0. "J302

amp/voo

usgs

101.

"J302ml

amp/voo

usgs

102.

"J402

amp/voo usgs

103.

"J4021

amp/voo

usgs

104.

"J

402h

amp/voo us

gs10

5. "J402h3

amp/voo

usgs

106.

"jSOl

amp/voo

usgs

107.

"J502

amp/

voo

usgs

108.

"j

502a

amp/voo

usgs

Page 60: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

incl

ude/

suds

_cod

es.h

200. "g

sl

sum

amp

usgs

",201. "gs2

sola

r_su

m_am

p usgs",

300. "r

41f

transmitter

moni

tron

",301. "r45f

rece

iver

mo

nitr

on",

302.

"dt200

transmitter r

itro

n",

303. "dr200

rece

iver

ri

tron

",304. "ht200

transmitter mot

orol

a",

305. "ht200

rece

iver

motorola",

400.

"c

a5-1

50h

ante

nna

scal

a",

401.

"ca5-150v

ante

nna

scal

a",

402.

"ca7-460

antenna

scal

a",

403.

"cl-150hc

antenna

scal

a",

404. "cl-150hr

antenna

scal

a",

405.

"el-150v

antenna

scal

a",

406.

"caS-450

antenna

scal

a",

407. "raS-450

antenna

scal

a",

408.

"pr-450u

antenna

scal

a",

500.

"1481

solar_panel

arco

",501. "4

35h

sola

r_pa

nel

sola

rez"

,0,

0,

CODES

equip_reason[]»{

0,

"none

give

n",

1.

"initial installation",

2.

"routine site v

isit

",3.

"battery change ne

eded",

4.

"vandalism",

5.

"flo

odin

g",

6.

"lan

dsli

de",

7.

"seismic noise",

8.

"electronic

noise"

,9.

"seismically dead",

10.

"signal

not

aeroed

", S?

11,

"signal too h

igh",

12.

"signal

too

weak",

13.

"unit

repl

acem

ent"

,14.

"reinstall after re

pair

*15.

"configuration chan

ge",

0,

0,

CODE

S re

co_

typ

e[]-

{0,

"not sp

ecif

ied"

CODE

S rock

_cla

ss[]

-{

0,

"n

ot

spec

ifie

d"

/* lo

gic

al

sum

of

these

fi

eld

s */

CODE

S st

at_

proo[]

-{

0,

"n

one"

,1.

"d

c o

ffse

t re

mov

ed"

,2.

"corrected for

inst

r. re

sp."

,3.

"dc offset removed and

corrected

for

inst

r. re

sp."

,4.

"fil

tere

d",

5.

"fil

tere

d and

dc of

fset

removed",

6.

"filtered and corrected

for

instr. re

sp."

,7.

"filtered, dc of

fset

removed and

corrected

for

inst

r. resp.

0,

0,

CODE

S fe

at_

ph

ase

[]-{

0,

"

not

giv

en"

,

1. 2. 3. 50.

51.

52.

53.

54.

55.

56.

57.

58.

59.

60.

61.

62.

63.

64.

65.

66.

67.

68.

69.

70.

71.

72.

73.

74.

100.

101.

102.

103.

104.

105.

106.

107.

108.

109.

110.

111.

112.

113.

114.

115.

116.

117.

118.

119.

120.

121.

122.

201.

202.

203.

204.

205.

206.

207.

208.

209.

301,

0,

"win

dow"

, /* am

plit

ude

is th

e du

rati

on o

f th

e window

*/"f fi

nis"

, /* for

coda

mag,

time when si

gnal

is

about

twice no

ise*

/"x maximum a

mplitude",

"p first

arri

val"

,/*

coul

d be p

, pn,

pg,

etc.

*/

"p",

"P*",

"PP",

"PPP",

"PPP

P"»

"pn",

"pdi

ffra

cted

","pep",

"pcs",

"PP",

MPPP

"»"pkp",

"pkp

pkp"

,"p

kppk

s",

"pkp

sks"

,"pk»",

"ppk

s",

"pkk

p",

"pkks",

"pcspkp",

"s fi

rst

s wave"

"s",

"s*",

"sss

s"

"sg",

sn",

scs",

spc

s""s

s",

"sss

",

"sos

pkp"

,"scp",

"sks

", skfcs",

skkks",

"skssks",

" kp

","s

kkp"

,"s

kkkp

",

"Ir",

"t",

0,

CODES

authority[]-{

Page 61: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

incl

ude/

suds

_cod

es.h

0, 101.

102.

103.

104.

120,

0,

not

giva

n",

caln

at u»g» aanlo p

ark,

ca",

alaa

ka nat u»gm manlo park, ca",

'katvai

nat

umgm

manlo pa

rk,

ca",

cal

nat

u«g«

paaadana, ca

.",

bumagin na

t lament paliaadas^ny",

0,

|«n

dif

SU

DS_

CO

OE

S H

Page 62: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

lib/s

uds/

Mak

efile

SCCSID - «e(t)Hak«fil«

1.2 11/18/88"

CTIAGS - -g -£68881

INCDZR /ucr/cuds/includ*

INC - $(INCDIR)/«ud»_d««cr.h $(INCDIR)/«ud«_cod««.h $(INCDIR)/«ud«.h \

$(INCDZR)/ct_«rr.h

LXBO

BJ -

acc2fi

«ld

.o d

«cc

rjb

rac*

.o

fin

d_

cod

«.o

ct

_*

rro

r.o

ct_

init

.o

»t_

tim

«.o

\

mud

m io

.o

SRC

ud

c_io

.c «

t_ti

.c «

t_in

it.c

«t

rror.c

fi

nd

cod

«.c

d««cr

_tr

ac«

.c \

m

cc2£i«

ld.o

~

~

libcuds.a: $(

LIBO

BJ)

ar re

libcuda.m

$(LI

BOBJ

) rm

nlib

libcudc.m

inst

all:

lict:

cp libtudi.a /ucr/lib

ranlib /u«r/lib/lib«ud».a

nacriptW $(SRC) Kak«fil«

_rao*.o find_cod«.o «t_init.o

t_tim*.o mudm_io.o

ud«_d*ccr.h «ud«_cod««.h t«dit.o a«c2£i«ld.o

t_tiin*.o cud«_io.o t_«rror.o

ud*_io.o

mudm io.o

$(ZNCDIR)/cudc.h

$(ZNCDIR)/*udc.h

$(INCDIR)/«ud«.h

$ (INCDIR) / t_*rror. h

$ (INCDIR) /»udc_dMcr.h

$ (INCDIR) /*u

dc_c

od«*

. h

Page 63: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

lib/s

uds/

asc2

fiel

d.c

/* convert a atructure field to an aacii atring and viaa-veraa

PLNard, U.S. Geological Survey, Menlo Park,

Ca 94025

5/16/66

*/atatic char Sc

cald

[] - "%W%\t%G%";

Idefine MAXSTR 36

Iinclude "/uar/auda/include/cuda.h"

extern double atof();

extern in

t atoi();

char *field2aac (pt

r,ty

pe, verboae)

char *p

tr;

int

type,verboae;

CHAR

*ch;

STRING

*at;

SH_IHT

*ah;

LG_INT

*lg;

FLOAT

*ft;

DOUBLE *db;

char tenp [MAXSTR]

;

witch (type)

(caae CHR: ch-ptr; aprintf(temp,"%c",*eh); break;

caae BTS:

caae NIN

: ch-ptr; aprintf (te

mp, "%d", (i

nt)*

ch);

break;

caae STR: at-ptr; aprintf (temp, "%a",at); break;

caae SH

T: ah-(abort *)(ptr);

if (*ah atoi (NODATA)) aprintf (temp, "NODATA");

elae aprintf (te

np, "%d",*ah); break;

caae LNG: Ig-(long *)(ptr);

if (*lg atoi (NODATA)) aprintf (te

mp, "NODATA")

;elae aprintf(temp,"%ld",*lg); break;

caae FLT: ft-(float *)(ptr);

if (*ft atoi (NODATA)) aprintf (temp, "NODATA") ;

elae aprintf(temp,-%f«,*ft); break;

caae LLT:

caae DBL: db-(double *)(ptr);

if (*db atoi (NODATA)) aprintf (temp, "NODAT

A")

;elae aprintf(temp,"%lf",*db); break;

caae ST

T: lg-(long *)(ptr);

if(verboae)

( *db- *l

g;if (*lg atoi (NO

TIME

)) aprintf (temp, "NOTIMB") ;

elae aprintf (te

mp, "%a", liat_matime (*db,

7))

;

V

elae

{if (*lg atof (NOTHaE)) aprintf (t«

elae aprintf (tea%>, "%ld", *l

g) ;

"HOTIME");

break;

caae MST: db-(double *)(ptr);

if(verboae)

(if (*db atof (NO

TIME

) ) aprintf (temp, -NOTIME") ;

elae aprintf (temp, "% ", liatjnatime (*db,

6))

;

elae

(if (*db atof (NO

TZNB

) ) aprintf (t«

elae aprintf (t«mp,"%lf",*db);

} break;

>, "NOTIME");

caae CAL:

caae CPX:

caae ST

I:

defa

ult

:at

rcp

y(te

mp

,"E

RR

OR

");

b

reak

;

retu

rn (

ten

p);

aac2field(atring,ptr,type)

char *ptr,*atring;

int

type

;

char *f

ield

;

field

-atr

ing

; w

itch

(ty

pe)

ca

ae

CH

R:

caa

e S

IR:

caae 9X8:

caae NZH:

caae SHT:

caae IM

G:

caae FLT:

caae DB

L:

caae STT:

caae MST

:

caae LLT:

default:

if (atrcap (at

ri&g

, "HOCHAR") 0) field-NOCHAR;

aacanf(field,"%c",(CHAR *)(ptr));

break;

if( trc»p(atring,"NOSTRG") 0) field-NOSTRG;

atrcpy(ptr,field) ;

break;

* ((MINI *) (ptr))-atoi(field);

break;

*((SH_INT *) (ptr))-atoi(field);

break;

* ((LG_INT *)(ptr))-atoi(field);

break;

* ((FLOAT

*)(ptr))-atof(field);

break;

* ((

DOUB

LE *)

(ptr))-atof(field);

break;

if(atro^>(field,"NOTIME") 0) field^JOTIME;

*((STJTIME *)(ptr))-atof(field);

if( trc»p(field,"NOTIME") 0) field-NOTIME;

* ((MSjriMB *)(ptr))-atof(field);

break;

* ((

LOHL

AT *)(ptr))-atof(field);

break;

at_error(die,0,"unrecognized type %d",type);

break;

Page 64: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

lib/s

uds/

desc

r_tr

ace.

c

/* de*cr_trace: put mlndata, naxdata, avenoiae, numclip in deccriptrace

tructure for *b

ort,

long,

and float type trace*. Structure must include

other value*, trace follow* deacriptrace structure unless argument trace!-0.

PXMard U.S.Geological Su

rvey

, Menlo Pa

rk,

Ca 94025

5/4/88

*/static char Sccsld[] - "%W%\t%C%";

finclude n/u*r/*ud*/include/*ud*.h"

fdefine HOISELEM 200

/* number of sample* to get average noi*e over

*/

int de*crjtrace(*c,dt,trace)

struct *tationconp **

c;

struct deccriptrace *d

t;

char *trace;

reg

iste

r i

; h

ort

**h

; lo

ng

*

lg, cl

ipn

ua;

flo

at

*ft

,ain

,Ba

x;

dou

ble

av

e;

av

e 0

.0;

dt-

>n

uB

clip

»0;

wit

ch(*

c->

da

ta_

typ

e)

(ca

*e

' ':

*

h-(

sho

rt

*) (

tra

ce 0

?

(ch

ar

*) (

dt+

1):

trace

);fo

r(i«

0,d

t->

min

data

«*h

[0],

dt-

>aaxd

ata

-*h

[0];

i<d

t->

len

gth

;i

if (

*h

[i]<

nin

) d

t->

nin

da

ta-*

h[i

];

if(*

h[i

]>n

ax)

dt-

>n

ax

da

ta-*

h[i

] ;

if(*

c->

cli

p_valu

e!-

0

fifi

^

(*h

[i]>

*c-

>cl

ip_valu

e ||

*h

[i]<

*c-

>cl

ip_

va

lue)

)dt-

>n

um

clip

++

; >

if (K

HO

ISE

LE

N)

ave+

-*h

[i];

*-

i ) bre

ak;

ca*e

'!':

lg

»(l

on

g *

) (t

ra

ce 0

?

(ch

ar *

) (d

t+1):

trace

) ;

for(

i-0,d

t->

min

data

«lg

[0],

dt-

>n

axd

ata

«lg

[0];

i<d

t->

len

gth

;i+

+)

{ if

(lg

[i]<

^n

in)

dt-

>m

ind

ata

lg[i

];

if (

lg[i

]>n

aac)

d

t->

maxd

ata

-lg[i

] ;

if(*

c->

cli

p_

va

lu«

!-0

fif

i(l

g[i

]>*

c->

cli

p_

va

lue ||

lg[i

]<*c-

>el

ip_

va

lue)

)dt-

>n

um

clip

++

; if

(KH

OIS

EL

EN

) ave+

-lg[i

];

bre

ak;

case

':

ft-(

float

*) (

trace 0

?

(ch

ar

*) (

dt+

1) :

trace

) ;

for

(i-0

, dt-

>m

ind

ata

-ft [0

], d

t->

naza

ata

-ft [0

];i<

dt-

>le

ng

th;

i++

) {

i£(£

t[i]

<m

in)

dt-

ind

ata

.ft[

i];

i£(£

t[i]

>m

ax)

dt-

>m

axd

ata

-ft[

i];

i£(*

c->

cli

p_valu

«!-

0

££(f

t[i]

>*c->

cli

p_valu

e ||

ft[i

]<*

c->

elip

_valu

e))d

t->

nu

mel

ipf+

; i£

(i<H

OIS

EL

EN

) ave+

-ft[

i];

bre

ak;

def

au

lt:

retu

rn(1

);

dt-

>av

enoi

*e-a

ve/(

dt-

>le

ngt

h<

NO

ISE

LE

H?d

t->

l«n

gth

:HO

ISE

LE

H)

; re

turn

(0);

Page 65: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

lib/s

uds/

find

_cod

e.c

/* rind numeric or ascii code* in codelists stored in suds_codes.h

PXMard,

U.S.Geological Su

rvey

, Menlo Park,

Ca 94025 5/4/88

*/

static char Sc

csld

[] - "%W%\t%G%";

include N/u*r/*ud*/include/*ud*.h"

in

clu

de <

ctyp

e.h

> i

nclu

de <

std

io.h

>

defi

ne M

OC

STR

100

int

fin

d_cod

e(s

tr,l

ist)

ch

ar

*st

r;

tra

ct

cod

e* *li

st;

reg

iste

r i,

j;

cha

r te

mp[

MA

XST

R];

j-»

trl«

n(«

tr);

for{

i-0;

i<M

AX

ST

R

££

i<t«

np

[MO

C8T

R-1

] -'

\0 '

;j-

«tr

l«n

(t«

op

) ;

£or(i

-0;l

i*t

[i]

. mea

nin

g f-0

;i+

+)

if (

trn

ca^

>(t

e«?>

, lis

t [

i] .

mea

nin

g, j) 0

)

retu

rn (li

st

[i]

.nu

n);

> return (0);

char

*li

st_cod

e(c

od

e,l

ist)

in

t co

de;

t

ract

cod

e* *li

st;

reg

iste

r i;

for(i

-0;l

ist

[i].

nu

m!-

cod

e

££

list

[i].

mea

nin

g!-

0;i

++

),

if (li

*t[

i] .

nu

m c

od

e)r

et u

rn (li

st

[i]

.mea

nin

g)

; retu

rn

("th

is

cod

e u

nd

efin

ed"

);

' a' -'

A' :«

tr [i]

,

Page 66: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds :/

usr/s

uds/

src/

Ub/

suds

/st

erro

r.c

Init

iali

ze li

st

of

erro

r m

essa

ges

Bru

ce

R.

Ju

lian

, O

SGS

Men

lo P

ark

Cali

f.,

15

Dec

19

83R

evis

ion

1.1

86/0

5/1

6

16:4

5:4

6

Ju

lian

Init

ial

revis

ion

Mod

PU

fard

4/7

/88

fst

ati

c

char

Sce

sld

[] -

"%W

%\t%

G%

";

Iin

clu

de

"/u

sr/s

ud

s/in

clu

de/

st_er

ror.

h"

char

*errli

st[]

-

( "

Err

or 0

",

"Il

leg

al

day

",

"Il

legal

mon

th"

, "

Ille

gal

yea

r",

"Il

leg

al

va

lue"

, "N

ot

enou

gh d

ata

",

"C

onve

rgen

ce fa

ilu

re"

, "

Un

der

flow

",

"No

such

sta

tion

",

"S

tru

ctu

re si

zes

mis

mat

ch"

, "

Sin

gu

lar

ma

trix

",

"F

ocal

d

epth

too g

reat"

, "N

o su

ch p

has

e",

"C

on

stra

ints

a

re in

con

sist

ent"

, "

Solu

tion

is

u

nb

oun

ded

",

"S

tru

ctu

re t

ag

syn

c co

de

wro

ng"

, "

Ser

iou

s su

ds

I/O

err

or"

, "C

an n

ot

bra

cket

ro

ot"

,

int

st_n

err

- (

sizeo

f errli

st/s

izeof

errli

st[0

] };

in

t st

_er

rba

se -

ER

RBA

SE;

fin

clu

de

<st

dio

.h>

Ii

ncl

ud

e <

vara

rgs.

h>

ir

*pro

gnam

e-N

UL

L;

cha

r *

st er

rou

t»"

std

err"

; FI

LK

*

eou

t;

int

init

ou

t-1

;

st_error(v

a_ali

st)

va

_d

cl

int

(*fe

n)

() ;

char

*f

mt;

int

errn

um

;ex

tern

in

t er

rno,s

ys_

ner

r,n

err;

exte

rn

char

*sy

s_errli

st[]

;va_li

st

ap;

if(i

nit

ou

t)

(if

(str

eam

? (s

t_er

rou

t, "

std

err"

) 1*

0)

(if

((e

ou

t«fo

pen

(st

_er

rou

t, "

w")

) N

UL

L)

(fp

rin

tf (s

tder

r, "

st_

erro

r:

un

able

to o

pen

err

or

ou

t fi

le

%s\

n", s

t_er

rou

t);

eou

t«st

der

r;

else

eo

ut«s

tder

r;initout-

0;

) va_s

tart

(ap)

;fen-(int

(*) ()

)va_

arg(

ap,i

nt *)

errnum-va_arg(ap,int)

; fi

nt»»

m_«r

g (a

p,ch

ar *);

fpri

ntf

(eou

t,"

\nE

RR

OR

")

;if

(pro

gnam

e)

fprin

tf(e

ou

t,"

in

%

s",p

rogn

ame)

;fp

rin

tf(e

ou

t,"

:\n

");

_d

op

rnt(

fmt,

ap

,eou

t);

fprin

tf(e

ou

t,"

\n

");

if(e

rrn

oX

) &

£ er

rno<

«ys_

ner

x)

fprin

tf(e

ou

t,"

%

s\n

",s

ys_

errl

ist[

errn

o])

,if

(err

au

m?-e

rrn

o

erra

um

>«E

RR

BA

SE

fifi

errn

um <

- st

_ner

r+E

RR

BA

SE)

fprin

tf(e

ou

t,"

%

s\n

",e

rrli

st[e

rrn

um

-ER

RB

AS

E])

; er

rno«

0;if

(fen

)(*fe

n)(

errn

um

);

Ta_

end

(ap

);

Page 67: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

srcA

ib/s

uds/

st_i

nit.c

/* in

itia

lize a

st

ructu

re b

aaed

on

tab

le in

suds_

des

cr.h

*/

sta

tic ch

ar S

ccsl

d[]

-

"%W

%\t%

G%

"; include <stdio.h>

finclude "/uar/auda/include/auda.h"

exte

rn st

ruct

su

dsfo

rm stform[];

exte

rn int

beg_

stru

ct[]

; extern double

atof();

extern int

atoi();

init

valu

e(i,

ptr)

int

i;

char *p

tr;

sho

rt

*sh

;lo

ng *

ig;

flo

at

*ft

; double

*d

b;

STJT

IME

*st

; K

SJTI

ME

*m»;

swit

ch(s

tform

[i].

fty

pe)

{ca

se C

HR:

*

ptr

-atf

orm

[i].

init

val[

0];

bre

ak;

case

BIS

: ca

se K

IN:

*p

tr-a

toi(

stfo

rm

[i].

init

va

l);

bre

ak;

case

8T

R:

strc

py(p

tr,s

tfo

rm[i

].in

itv

al)

;b

reak

; ca

se S

HT:

*((

short

*

)ptr

)-a

toi(

stfo

rm

[i].

init

va

l);

bre

ak;

case

UTO

: *((

long *)p

tr)-

ato

i (s

tform

[i].

init

val)

; x

b

reak

;^

case FLT: *((float *)ptr)-atof(atform[i].initval);

i break;

case LL

T:

case DBL: *((double *)ptr)-atof(stform[i].initval);

break;

case STT: *(

(ST_

TIME

*)

ptr)

-ato

i(at

form

[i].

init

val)

;br

eak;

case M

ST:

*((M

S_TI

ME *)ptr)-atof(atform[i].initval);

break;

case CAL:

case CPX:

case ST

I:

default:

break;

st_init(type,ptr)

int

type;

char *p

tr;

register i;

char

*p

trlo

c;

ptr

loc^p

tr;

for(

i-b

eq_atr

uct[

type];

atf

orm

[i]J

if

(stf

ozm

[i].

nextf

sty

pet-

0)

{st

JLn

it(s

tfo

rm[i

].n

ex

tfst

yp

e,p

trlo

c+

stfo

zm

[i].

off

set)

;

els

e in

itvalu

e(i

,ptr

loc+

stfo

m[i

] .o

ffse

t) ;

at_

cr«

at«

(ty

pe,

ptr

, dat

al*

ng

th)

int

typa;

ch

ar *

*p

tr;

xt*

rn c

har

*m

allo

c();

*p

tr-«

all

oc (*

iz«

_atr

uct [

typa]

+dat

al*ngth

) ;

at_

arr

or(

0,0

, "0

nab

l« t

o n

all

oc p

oin

ter

in t

_cr«

at«

of

l«n

gth

%d"

,aix

«_

atr

uct [

typ«] +

dat

al*

ng

th)

; r*

turn

;} tJL

nit

(ty

pe,

*ptr

) ;

ffif

def DEBOG

die(

n) int

n;

mai

n()

{st

ruct

atat

ion

com

p s

c;FI

LE

*st

,*st

_open()

;

stJL

nit(

ST

AII

OH

CG

MP

,fis

c);

st"s

t_o

pen

(" s

tdo

ut"

, "W

) ;

st_p

ut(f

isc,

SIX

TIO

NC

XX

fP,s

izeo

f (st

ruct

atat

ionco

mp),

at),

) le

nd

if D

EBO

G

Page 68: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

tib/s

uds/

st_t

ime.

c

/* *t_time: tin* and date utility routine* for suds

Bruoa Julian and PLNaxd

, O. S. Geological Survey, Menlo Pa

rk,

Ca.

94025

*/

static char Sc

c*Id

[] - "%W%\t%G%";

linclude "/usr/suds/includo/suds.h"

linclude "/u*r/*ud*/include/*t_error.h"

{include <sy*/time.h>

ftinclude <math.h>

linclude <*tdio.h>

Idefine BASEJDN

2440588

/* 1 January 1970

*/

/* H

oder

n c

ale

nd

ar

*/

/* O

ld-s

tyle

ca

len

dar

*/

/* Calendar code* */

fdefine GREGORIAN

1 Idefine JULIAN

0

/* Time interval* */

Idefine SECOND

1 Idefine MIHDTE

(60*

SECO

ND)

fdefine HOUR,

(60*

MHTO

TE)

fdefine DAY

(24*HOUR)

typedef int

bool;

/* floor(x/y), where x, y>0 are integer*, using integer arithmetic */

fdefine qfloor(x, y) (x

>0 ?

(x)/

y : -((y-1- (x))/y))

static in

t eom[2][15] -

{{

0, 31,

59,

90,

120, 15

1, 18

1, 21

2, 243, 27

3, 304, 334, 365, 396, 424 J,

{ 0,

31,

60,

91,

121,

15

2, 18

2, 21

3, 244, 27

4, 305, 335,

366, 397, 425 J,

/* Recogniie leap year* */

bool

i*le

ap

(yr,

cal)

<5">

in

t yr;

/*

Y

ear

>J

int

cal;

/*

C

alen

dar

typ

e

bool 1;

if (y

r < 0)

yr++;

1 - (y

r%4 0)

; if (cal GREGORIAN)

1 - 1

fifi

(yr%100

I- 0

|| yr%400 0);

return 1;

J /* Compute day of year */

int

yrday(mo, day, Ip)

int

mo,

day;

/* Month, day

bool Ip

; /*

Leap year?

*/

*/

*/

*/

retu

rn e

om[l

p]

[mo-

1]

+ d

ay;

/* Calculate month, day from day of year */

void

mnday(d, Ip,

pm,

pd)

int

d;

/* Day of year

bool Ip

; /* Leap year?

int

*pm,

*pd;

/* Mo

nth,

day

int

i;

*/ */ */

int

*et - eom[lp];

for (i-1;

d>et[i];

*pm - i;

*pd - d -

/* Compute Julian Day number from calendar date */

long

jdn(

yr,

mo,

day,

cal)

int

yr,

mo,

day;

/* Ye

ar,

month, day

int

cal;

/* Calendar type

*/ */

long ret;

if (y

r < 0)

yr++;

/* Move Ja

n. £

Feb.

to end of previous year */

if (mo <« 2)

{ -

yr;

mo +- 12;

J ret-

qfl

oo

r (

(lo

ng

)(4

*3

65

+1

)*(y

r+4

71

2),

4)

+

eom

[0][

mo-

1]

+ d

ay +

(cal

GR

EG

OR

IAN

?

-qfl

oo

r(y

r,

100)

+

qfl

oor(

yr,

40

0)

+2

:

0) ;

retu

rn

(ret)

;

/*

Com

pute

ca

len

dar

da

te

from

Ju

lian

Day

Num

ber

*/

vo

idd

ate

(n,

py,

pm

, p

d,

cal)

long n;

/* Julian day number

int

*py,

*p

m, *p

d;

/* Ye

ar,

month, day

int

cal;

/* Calendar type

*/ */ */

long d,

t;

int

y;

/* rind position within cycle* that are nd day* long */

Idefine CYCLE (n, nd)

{ t-qfloor (d-

1, nd);

y+-t*n; d t*nd;

}

/* The sa

me,

with bound on cycle number */

Idefine LCYCLE(n, nd

, 1)

{ t-qf loor (d-

1, nd);

if (t

>l)

t-1; y+-t*n; d t*nd;

)

y - -4799;

if (c

al GREGORIAN)

{d - n + 31739;

CYCLE(400, 14

6097

) LCYCLE(100, 36524, 3)

J Ise d - n + 31777;

CYCLE(4, 14

61)

LCYCLE(1, 365, 3)

/* JD -31739 - 31

Dec 4801 B.

C. */

/* Four-century cycle

*/

/* 100-year cycle

*/

/* JD -31777 - 31 Dec 4801 B.C. */

/*

Fo

ur-

yea

r cy

cle

/* Y

earl

y c

ycl

e*/ */

if (y

<- 0) ~y;

*py -

y;mnday((int)d, i*leap(y,

cal)

, pm

, pd);

extern int errno;

MS_TIME get_m*time()

Page 69: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

i

o nilg Illl -ill^5. Wm. § O :;:;:i:::|x;::>:

;

£ -3

§"" 4J"

i>1

1 ! . o Q 2

I I 1 I: &m en

1 s1 $H o3 dP0 -0

4J CM

N T>

3 O

^ w4) CM 4> 0

i s?« r g I tf '^ u mstime (tim*,

«) (

printf (out hour, min

break;

0 0

lr: S23 ^S

14)1iar-1900,1

>i5

CMO 0

odP oCM

5O

"0 ^^

S5f ? W-.Su~ printf (out hour, min

tH

3

1

iStH

en

O

CMO

CMO

dP

CMO

oCMO dP

CM .-. 2 "gdP 0 s Ou"

u i

break;

printf (out hour, min

M

3

icT 8

iio

CMO

CMO

dP

CMO

o »CM .

CM 0 NdP .

MJM -HU~

break;

printf (out hour, min

en

3

* O

rH

isi1

4)*

i <»»o

CMO

..CMO

CM

*CMO

§..CM *-,2"SdP B'.8M *

break;

printf (out hour, min

3

cT

ft

ii4)

c 0

odP

CMO

oCMO dP

CM

o -CM -*S'S^, 5CM 0 NdP .

ilU^t

break;

printf (out hour, min

break;

in

I

s s,14)

J

<Mm

o

CMO dP

CM

3

s.. 91dp a * i u" « ".

printf (out hour, min

«o

1

14?

"5"

i5

S 0CMO

0CMO dP

CM

3-'1. S

dP .

iiu~*3 2- "..«w H - 4) g »11*1 -H 1 i * 1

-"H

I 5Y Ya 3

» i a.. « 4* 4*«-« n - »

^ -- . « «lifs- sTH"]?£ ^j?I 3 «*? ?*

jj-

kk

M

141

1*

8 J-H'

!s c 1 ^*o fl "w «H

H 0 ~ 1

I 3 ". 3 S "3 i. - M >n u a «M" >l 3 «H § -H «H.. S-S.gs!;: 1

-» -H m » - >i H 3 ^^IfUM-dQU

;^8-f*$*«^5J?itiu,8-^^u,S 5-M-l* ,S*o-*

«w i > ^ nl^iH-H-H-HM-H

J .SS'S'gNhS'g S,j^J^8^J

^>4* yH f 4* » >, | 4*

II3||41I?J4,M jlHtll

4>'-0 2||L.^L.|L. >HlJfltHM«HfltH

|||i||hj|4> A 1" -S 4> OtV 6,4> 6»

o

Q*M

|8 <4k

. o

1 3I ?,

~8

>, .. * »»^SS°.

8s

fcV«S§ 5

I H

I

i I s I* I J *.« S iil

o

r

If I

I

S -

»M M M^-S

5 -5 -5 -

Page 70: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

lib/s

uds/

suds

_io.

c

/* BASIC SUDS INPUT AND OUTPUT ROUTINES

These routines are meant to be used like fo

pen,

fr

ead,

fw

rite

, ff

lush

, fc

los<

fs

eek,

ftell, and rewind except that basic error handling is done for you.

WARNING: Do not mix these routines with the standard I/O routines for the

same files at the same time.

While these routines use the standard I/O

libr

ary, you may mess up these routines by interspersing the standard

I/O calls.

First close with st_close and then open the same file with

fopen or close with fclose and then open with st_open.

Error handling uses st_error. Errors that should cause termination call die,

a user supplied program that might simply call exit but might also

reset terminal characteristics, clear buffers, etc.

die(

n) int n; {exit(n);)

To get a warning on

ly,

but continue, make die not call

ex

it.

To allow for

this option,

calls to st_error in this file are followed by return(ST_ERR).

PLWard,

U S Geological Survey,

Menlo Park,

Ca.

4/8/88

*/static char Sc

csld

[] - "%W%\t%G%";

(include <stdio.h>

(include <string.h>

(include <sys/types.h>

(include <sys/stat.h>

(include "/usr/suds/include/suds.h"

(include "/usr/suds/include/st_error.h"

(include "/usr/suds/include/suds_codes.h"

(include "/usr/suds/include/suds descr.h"

(define ST_EOF

(-99

9)

(define ST_NOTAG (-

843)

char *malloc(), *realloc(),

extern in

t errno,die ();

/*

inte

rna

l co

de

for

EOF

kep

t in

next.

id_st

ru

ct

*/

/*

inte

rnal

cod

e fo

r in

itia

liza

tio

n of

std

in */

/* streamtags structure: one instance is

not opened by this software package

*/

struct streamtags

{struct structtag this;

struct structtag next;

char *st_ptr;

int

nu

m_s

tru

ct;

int

st_m

ode;

/*

0-

<ch

ar *

file

nam

e;

} *

av

ail

; in

t s

fdsi

ze-0

;

crea

ted

fo

r ea

ch o

pen

fil

e,

even

th

ose

/* st

ruct

tag fo

r d

ata

re

ad *

//*

st

ruct

tag

fo

r d

ata

to b

e re

ad */

/* la

st d

ata

pu

t b

ack

on

str

eam

*/

/*

num

ber

of

stru

ctu

res

read

or

wri

tten

*/

lose

d,

1-o

pen

to r

ead

, 2

-op

en t

o w

rite

*/

/* filename */

/* st

_fi

rst

: re

ad f

irst

stru

ctt

ag

in

a

stre

am.

Sh

ould

be

not

call

ed

by

use

r.*

/ in

t st

_fi

rst

(st

ream

, fd

)FI

LE

*s

trea

m;

int

fd;

int

ret;

ret-

frea

d((

char

*) (

avail

[fd

].n

ext,

1,s

izeof(

stru

ct

stru

ctta

g),

stre

am

) ;

if(r

et!

-siz

eo

f(st

ru

ct

stru

ctt

ag

))

{if

(ret-

»0

It

errn

o 0

) re

turn

(0);

st_er

ror

(die

, er

rno

, "

st_get

: re

ad st

ru

ctt

ag

ret

urn

s %

d"

,ret

);re

turn

(ST

_ER

R);

if (

avail

[fd

].n

ext.

syn

c!-S

TJIA

GIC

)st

_err

or(d

ie,E

BA

DS

YN

C,"

st_g

et:

init

ial

stru

ctt

ag

. syn

c-%

d",

avail[fd].next.sync);

if(avail[fd].next.aachinel^lACHINE)

st_error(0,0, "st_get:

machine type %c is different fr

ont current type %c"

avail[fd].next.machine,MACHINE);

return(ST_ERR);

/* st_initit: open st

dio.

Should not be called by user.

*/

char *st_names[]»{"stdin","stdout","stderr"};

int

st_initit()

int

i,fd;

if(s_fdsize>-3) return(0);

avail-(struct streamtags *)malloc(3*sizeof(struct streamtags));

if (avail NULL)

{st_error(die,errno, "st

_get

: malloc of streamtags for stdio");

return(ST_ERR);

avail

[i].

this

.id

_st

ru

ct-

0;

avail

[i].

nex

t.id

_st

ruct

-iX

)?0:S

T_N

OT

AG

;avail

[i].

nu

m_st

ruct

-0;

avail

[i].

st_p

tr-N

UL

L;

avail[i] fil*name-st_names[i];

avail[i].st_mode-i>0?2:1;

s fdsize-3;

/* efopen: fopen with error handling

*/

FILE *efopen(filename,type)

char *filename, *type;

{in

t fd

;FILE *input;

errno 0;

if (strcmp(filename, "stdin") 0)

{if (type[0] 'r'

) return (stdin) ;

else st_error(die,errno,"cannot fopen stdin with type-%s",type);

return(NULL);

> if (strcmp (fi

lena

me, "stdout") 0)

{if (type[0] 'w' M type[0] 'a') return (st

dout

) ;

else st_error(die,errno,"cannot fopen stdout with type-%sH,type);

return(NULL);

} if(strcmp(filename,"stderr") 0)

{if (type[0] 'w

' M type[OJ 'a') return (st

derr

) ;

else st_error(die,errno,"cannot fopen stderr with type-%s",type);

return(NULL);

} if ((input-fopen (filename,type)) HULL)

{st_error(die,errno,"cannot fopen file %s with type-%s",filename,type)

return(NULL);

> return(input);

) /* st_open: open a suds file for reading or writing structures

Page 71: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds :/

usr/

suds

/src

/lib/

suds

/sud

s_io

.c

FILE *st_open(filename,type)

char *f

ilen

ame,

*type;

int fd

; FILE *input;

if(s

_fd

site

<3)s

t_in

itit

();

if((

inp

ut-

efo

pen

(fil

en

am

e,t

yp

e))

--N

UL

L)

retu

rn(H

UL

L);

f d

-fil

en

o (

inp

ut)

;if

(fd

>-s

_fd

site

) {

/* in

crea

se all

ocati

on

of

av

ail

*/

free (

avail

);avail

-(st

ru

ct

stre

am

tags

*)r

ea

llo

c(a

va

il,

(fd

+l)

*si

zeo

f(st

ru

ct

stre

am

tag

s));

if

(av

ail

HU

LL

) {

st_er

ror(

die

,err

no,"

st_get

: reall

oc o

f st

rea

mta

gs"

);

retu

rn(N

UL

L);

s_fd

size-f

d+

l;

avail [fd] .this.id__struct

-0;

avail[fd].next.id~struct-0;

avail[fd].num_struct-0;

avail [fd]. st_ptr-NULL;

avail[fd].filename-filename;

switch (t

ype[

0])

{case 'r

': avail[fd].st_mode-l; st_first(input,fd); break;

case 'w':

case 'a

': avail[fd].st_mode-2; br

eak;

default: st_error(die,0,"st_open: unrecognized file type %s",type);

avail[fd].st_mode-0;

return (MULL

) ;

return (input);

/* efclose: close with error handling

*/int efclose (st

ream

) FILE *stream;

int ret;

if((ret-fclose(stream))1 0) st_error(0,errno,"fclose returns %d",ret);

return(ret);

/* st

__cl

ose: close a suds file

*/int st_close (st

ream

) FILE *stream;

int ret,fd;

fd f

ilen

o(s

tream

);

if(f

d<

0 ||

fd>

-s_

fdsi

ze)

{st

_error(0

,0,"

st_te

ll:

ille

ga

l fi

le d

escr

ipto

r",f

d),

retu

rn(S

T__

ER

R);

avail

[fd

].th

is.i

d_st

ru

ct-

0;

avail

[fd

].n

ext.

id_st

ru

ct-

0;

avai1

[fd

].n

um

_st

ruct

-0;

av

ail

[fd

]. i

avail

[fd

].fi

lt

avail

[fd

].st

_m

od

e-0;

retu

rn(e

fclo

se(s

trea

m))

;

/* st

fl

ush

: fl

ush

th

e st

ruct

ure

st

ream

V

"in

t st

_fl

ush

(str

eam

) F

ILE

*st

ream

;

int

ret,

fd;

fd-fileno(stream);

if(fd<0

|| fd>-s_fdsize)

{st_error(0,0,"st_flush: illegal file descriptor",fd);

return(ST_ERR);

if(avail[fd].st_mode1-2)

{st_error(0,0,"st_flush: file %s

not open for writing",fd);

return(EOF);

~

if ((ret-fflush(stream))!-0)

st_error(0,errno,"st_flush: fflush of file %s returns %d

",avail[fd].filename,ret);

return(ret);

/* st unget: put one structure back on the stream

*/

int st_unget(st_ptr,stream)

char *st_ptr;

/* pointer to structure

*/

FILE *stream;

/* input stream from fopen()

*/

int fd

;

fd-fileno(stream);

if (fd

<0

11 fd>-s_fdsize)

{st_error(0,0,"st_unget: illegal file descriptor",f d);

return(ST_ERR); ~

if(avail[fd].st_mode1-1)

{st_error(0,0,"st_unget: file %s not open for reading",avail[fd].filename);

return(EOF);

if (

av

ail

[fd

] .n

um

_st

ruct

0)

{st

_er

ror(

0,e

rrn

o,"

st_

un

get

: ca

nn

ot

un

get

at

beg

inn

ing

of

file

%

s",

avail

[fd

].fi

len

am

e);

re

turn

(EO

F);

if(a

va

il[f

d].

st_

ptr

I-H

UL

L)

{st

_er

ror(

0,e

rrn

o,"

st_

un

get

: ca

n o

nly

un

get

one

stru

ctu

re f

or f

ile

%s"

,avail[fd].filename);

return(EOF);

avai1[f d].st_ptr-st_ptr;

avail [fd] .num_struct 1;

return(0);

/* st_tell: find the number of the structure that is about to be read counting

the first structure as 0.

*/ lon

g s

t_te

ll(s

trea

m)

FIL

E

*str

eam

;

int

fd;

if(s_fdsize<3)st_initit();

fd-fileno(stream);

Page 72: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds :/

usr/

suds

/src

/lib/

suds

/sud

s_io

.c

if(fd<0

|| fd>-s_fdsize)

{st_error(0,0,"st_tell: illegal file descriptor",fd);

return(STJSRR);

> if (avail [fd].*t_mode 0)

{st_error(0,0,"st_tell: file % is not open",avail[fd].fil

return(S

TJCR

R.);

} return(avail[fd].num_struct) ;

/* st_rewind: return to the beginning of the file.

Can not be used on stdin, stdout,

stderr, or pipes.

*/ int

st_re

win

d (

stre

am)

FIL

E

*str

eam

;

int

fd;

fd-fileno(stream);

if(fd<0

|| fd>-s_fdsixe)

{st_error(0,0,"st tell: illegal file descriptor",fd);

return(STJERR); ~

if(fd<3)

{st_error(0,0,"st_rewind: you can not rewind %s",avail[fd].filename);

return(STJERR);

if (av

ail [f d] .

st jnode 0)

{st_error(0,0,"st_rewind: file %s is not open",avail[fd].filename);

return(STJERR);

. avail[fd].this.id_struct-0;

j^ avail [fd].

next. id_struct-0;

avail[f d].num_struct-0;

avail [fd].

st_ptr-NULL;

rewind(stream,OL,0);

st_f irst (stream, fd)

;return(0);

/* st_seek: position to read the nth structure in a file counting the first as 0.

Can not be used on pipes.

*/in

t st_seek (stream, offset, ptrname)

FILE *stream;

long offset;

int ptrname;

int f d,numwant,typ,len,inp, i;

char *p

tr;

fd fileno(stream);

if(fd<0

|| fd>-s_fdsixe)

{st_error(0,0,"st_tell: illegal file descriptor",fd);

return(STJERR);

if(s

_fd

sixe<

3)s

t_in

itit

();

if (

avail

[fd

] .n

ext.

id_

stru

ct S

TJ

fOT

XG

) st

_f i

rst

(st

din

, 0)

;sw

itch

(ptr

nam

e)

{ca

se

0:

nu

mw

an

t-off

set;

b

reak

;ca

se

1:

nu

mw

an

t-o

ffse

t+st

jbel

l (s

trea

m);

b

reak

;ca

se

2:

if(f

d<

3)

{st_error(0,0,"st_seek: you can not seek from end of %s",

avail[fd].f11

return(STJERR);

st_re

win

d(s

trea

m);

for

(nu

mw

an

t-0;(

inp

-st_

get

(fip

tr,t

typ

,fil

en,s

trea

m))

(-E

OF

;nu

mw

an

t++

)st

jFree(p

tr,i

np

);

st__

rew

ind

(str

eam

);

if(o

ffse

t<0

)off

set-

-o

ffse

t;

nu

mw

ant

nu

mw

ant-

offs

et;

bre

ak;

def

au

lt:

st_error(d

ie,0

,"st

_se

ek

: p

trn

ame

mu

st

be

0,

1,

or

2,

no

t %

d",

ptrname);

return(STJERR);

if(numwant<avail[fd].num_struct ££ fd<3)

{st_error(0,0,"st_seek: you can not seek backwards on %s",avail[fd].filename);

return(STJERR);

if (numwant avail [fd

]. num_struct) return (0)

;if(numwant< avail[f d].num_struct) stjrewind(stream);

while(numwant>st_tell(stream))

{inp-st_get (fiptr, fityp, fi

len,

stream);

st_free (pt

r, inp);

return(0);

/* st_peek: what is the id number of the next structure to be read

*/

int st_peek (st

ream

)FILE *stream;

{int

fd;

if(s_fdsixe<3)st initit();

fd-f ileno (st

ream

)";

if(fd<0

|| fd>-s_fdsixe)

{st_error(0,0,~st_tell: illegal file descriptor",fd);

return(STJERR);

if(avail[fd].stjDode!-1)

{st_error(0,0,"st_tell: file %s is not open for reading",avail[fd].filename);

return(STJERR);

if (av

ail [f

d] .ne

xt. id_*truct STJJOTAC) st_f irst (st

din,

0)

; if(avail[fd].st_ptr!4IULL) return((int)avail[fd].this.id_struct);

return((int)avail[fd].next.id_struct);

> /* st_get: get the next structtag and structure from opened stream.

Returns

through arguments the pointers to the structure type and the structure.

Return value is if > 0

length of the structure

if 0 end of file

if < 0

error

This routine uses malloc(3) to allocate space for each new structure.

The user must use st_free(3) to deallocate the space.

This routine reads the structtag for a file to identify the structure.

It then reads the structure and the next structtag to be sure the structure

ends properly. This latter structtag is kept in the array structure av

ail,

with one element for each open stream, when an EOF is encountered,

the structtag entry is modified so that on the next ca

ll,

the EOF is

returned

to the caller.

Page 73: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

srcA

ib/s

uds/

suds

_io.

c

int st_get (st

_ptr

, stjtyp, st_len, stream)

char **st_ptr;

/* pointer to structure returned. Space malloc'd

*/

int

*st_

typ;

/* structure id returned

*/

int

*st_

len;

/* structure length

*/

FILE *s

trea

m;

/* input stream from fopen()

*/

int ret,i,fd,numin,numget;

char *temp,*tempp;

struct st

at stt;

struct muxdata *mx;

*st ty

p«0;

*st~"len

-0;

if (s"

_fds

ixe<

3) st_initit ()

; fd-fileno(stream);

if(fd<0

|| fd>-s_fdsi»e)

{st_error(0,0,"st_get: illegal file descriptor",fd);

return(STJERR);

if(avail[fd].st_mode!-1)

{st_error(0,0, "st_get:

file %s is not open for reading. Mode-%d",

avail[fd].filename,avail[fd].stjoode);

return(STJERR);

if (avail[fd].st_ptr!-NULL)

{ /* read structtag put back by st unget */

*st_typ-avail[fd].this.id_struct;

~"*st_len-avail[fd].this.len_struct;

*st_ptr-avail[fd].st_ptr;

avail[fd].st_ptr-NULL;

return(avail[fd].this.len_struct+avail[fd].this.len_data);

if (av

ail [f

d]. next. id_struct STJNOTAG) st_f irst (stdin, 0)

; if (av

ail [f d]

. next. id_struct STJBOF) return (EO

F) ;

avail[fd].this.sync-avail[fd].next.sync;

avail[fd].this.machine-avail[fd].next .ma

chin

e;

avail[fd].this.id_struct-avail[fd].next.id struct;

avail[fd].this.len struct-avail[fd].next.len_struct;

avail[fd].this.len~data-avail[fd].next.lenjdata;

/* If reading MOXDATA structure and len_data not set (-

0),

assume data goes to

end of this file,

and add that length to the structure

*/ if (

ava

il [

fd].

th

is.

id_s

tru

ct 4

CJX

DA

TA

fifi

av

ail

[fd

] .t

his

. len

_d

ata

0)

{if

(fsta

t(fd

,fis

tt)

-1

) st

_er

ror

(0,0

, "C

anno

t get

le

ngth

of

inp

ut

file

%

d"

,fd

),

av

ail

[fd

] .t

his

. le

n_d

ata

-stt

.st_

size-f

tell

(st

ream

) -a

vail

[fd

] .t

his

. len

_st

ruct

;

nu

mget

-avail

[fd

] .t

his

.len

_st

ru

ct+

av

ail

[fd

] .t

his

.len

_d

ata

;te

mp

^a

all

oc(

nu

mg

et);

/*

ma

llo

c sp

ace

for

new

str

uct

*/

if (t

emp

NU

LL

) {

st_error(die,errno,"st_get: malloc fails for struct %d with length %d",

avail[f d].this.id_struct,numget);

return(STJBRR);

numin-fread (te

mp, 1,

numget, st re

am)

; /*

read struct */

if(numin!-numget)

{st_error(die,errno,"st_get: reading struct id-%d returns %d expect %d

",

avail[fd].this.id_struct,numin,numget) ;

return(STJBRR);

if (

avail

[f d

] .t

his

. id

_str

uct

«4iU

XD

AT

A)

{ te

mp

p-t

emp

;m

x-(

stru

ct

mu

xdat

a *)

tem

pp

; sw

itch

(mx

->ty

ped

ata

) {

case

'd

' ca

se 'f

def

au

lt

i-2;

bre

ak;

i-4;

bre

ak;

i-8;

bre

ak;

i-12;

bre

ak;

st_error(0

,0,

"Unk

now

n d

ata

ty

pe

%c

in st

ruct

ure

typ

e %

d"

mx-

>typ

edat

a,M

DX

DA

TA

);

mx->

nu

msa

mp

s-avail

[fd

].th

is.l

en_

da

ta/i

;

/*

read

nex

t st

ru

ctt

ag

ret-fread((char *)fiavail[fd].next,1,siseof(struct structtag),stream);

if (ret!-sixeof(struct structtag))

{if (ret 0

fifi errno 0) avail [fd

] .n

ext,

id struct-ST_EOF;

else

{ ~

st_error(die,errno,"st_get: read structtag returns %d",ret);

return (ST_ERR);

~"

if (avail [£d]

. next. syn

c! -STJMAGIC)

{st_error(die,EBADSYNC,"st_get: structtag.sync-%d",avail[fd].next.sync);

return(ST_ERR);

if (avail[fd].next.machine!-MACHINE)

st_error(0,0, "st

__ge

t: machine type %c is different from current type %c

",avail[fd].next.machine,MACHINE);

avai1[f d].num_struct +-1

;*

st_

typ

-av

ail

[fd

].th

is.i

d_

stru

ct;

*st

_le

n-a

vail

[fd

].th

is.l

en

_st

ru

ct;

*st

_p

tr-t

emp

; re

turn

(nu

min

);

/*

st_p

ut:

w

rite

o

ut

stru

ctt

ag

and

str

uct

ure

*/

int

st_p

ut (s

t_p

tr, st

_ty

p, st

_le

n,

stre

am)

char

*st

_p

tr;

/* p

oin

ter

to st

ruct

ure

int

st_

typ

; /*

st

ruct

ure

id

int

st_le

n;

/*

stru

ctu

re le

ngth

FIL

E

*str

eam

; /*

ou

tpu

t st

ream

fro

m f

op

en()

*/ */ */ */

int

retl

,ret2

,fd

; st

ruct

st

ru

ctt

ag t

emp

;

if (sj

Cd

sixeO

) st_

init

it (

) ;

fd-f

ilen

o(s

trea

m);

if

(fd

<0 ||

fd>

-s_

fdsi

xe)

{

st_er

ror(

0,0

,~st

__p

ut:

il

legal

file

d

escr

ipto

r", f

d)

;re

turn

(ST

_ER

R);

if (

avail

[fd

].st

_m

od

e!-2

) {

st error(0,0,"st_put: file %s

is not open for writing. Mode-%d"

"avail[fd].filename,avail[fd].st_mode);

return(STJERR);

temp.sync-ST_MAGIC;

tem

p .m

achi

ne^

fAC

HIN

E;

tem

p.i

d_

stru

ct s

t_ty

p;

tem

p.l

en_

stru

ct-s

i ze_

stru

ct[

stjt

yp

];te

mp

.len

_d

ata

-st_

len

-six

e_st

ruct

[st

jtyp

] ;

ret2

-six

eof(

stru

ct

stru

ctt

ag);

Page 74: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

lib/s

uds/

suds

_io.

c

if((retl-fwrite (ttemp,I,ret2,stream))i-ret2)

st_error(0,errno, "st_p

ut:

tag: wrote only %d out of %d",retl,ret2);

if ( (ret2-fwrite (st

jptr

, 1, stJLen, stream)) !-«t_len)

»t_error(0,errno,"st_put: da

ta:

wrote only %d out of %d",ret2,temp.len_data)

avail[fd].num_struct+«l;

return(retl+ret2);

/* st_free: free a block of memory malloc'd in «t_get

While this routine simply calls free,

it is important to use it to

allow for future code that might optimize the malloc and realloc calls

for massive but predictable utilization.

*/st_free (ptr,

length)

char *p

tr;

int

length;

return(free(ptr));

Page 75: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

» Hrt tr H- to K> 8ft .T p

8 g to n

." £

; ! to _ » lan n b *"*

^fr

11

Mb H- H

ft »

g.

b

^^ ^^

66v.v.g g g.g.H- H- S go n H H

ft|

8 I*'tr

n^ 5-s.ftftftft:g.f.s §5ifr£?R?!rs *"P«B*««Ct I

P .T 8 " S .T " fr i H- 0 to ft.0.01)1)1) » » b* » rt » » 0 » & "0 "0 "0 "0 "0 n ^-. ft ^> .to ^-. ft ^> ^-. to rr 0.

A&&SR. £ 8|8"8&8^8&8ft»r; rTfrfrBp' »^P ' « » ' ' ' aronro rt rt o 0 rt OOO

rtoort rt o nSn *fi ?l o rtrt

g'fg'g'S * 5 6 g. 5 5 £ £ ft 8H * 2 8 i* M " ncro o n g ^fi g g * * b "" *"'*-' oS- c c c o. i i i i i i ta h a a o o o o o o

D1 B D1 D1 H- rr rr rr rr p" J-P-E-E-B a M ro p K> ?* s>^aa S:SS.£b)S.fiL> rs H-»er»»rth* tr rt o o ft ti

5- ,, I ft . . S- f P rt rr to rt fo o a. p- ? to ft ft »ft ft o n ft b Q.O a . H- ro0*100 i rt H H rtH fi S H H 5 0

i P fr | ! & it m N> o rtH H b

8*8

SCT

»0

A|

M Ml SiwSSp. ox:::;:::;:::::

M X;Xi:|:o:;:|:

j-1 ssgiiM SlSSiSU> S:S:S:S >». ::o:::<W:¥ K> ;:;:g;:;:::::;::K) ::x::::::::¥x

^5 ill! V <<<<--^s ::::::::::::::;X;

Jl) gill § iiS &*

111 "^isli c«

Hi °-

Ilim1111 Q111 B

; : :-: ;-:-: : :-: ^^

H |

Page 76: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds :/

usr/

suds

/src

/cm

d/ah

2st.c

stati

c

char

Scc

ald

[] -

"8 (

I)a

h2

«t.

c ii

ncl

ud

e "

/usr

/su

ds/

incl

ud

e/su

ds.

h"

ii

ncl

ud

e <

tim

e.h

>

#in

clu

de

<st

dio

.h>

ii

ncl

ud

e <

stri

ng

.h>

idefine MAXCOK 300

idefine AHHEADSXZE 1024

idefine TYPEMXN

1 idefine TYPEMAX

6 idefine LOGSI2B 202

idefine NEXTRAS

21

idefine NOCALPTS 30

1.2 11/17/88'

ah2st(infile,outfile,network,makeint,clipval,factor)

char *infile,*outfile,*network;

int makeint;

float clipval,factor;

truct

time

{ hort

yr;

hort

mo;

hort

day;

hort

hr;

hort

mn;

float

sec;

truct

station info

/* year

/* month

/* day

/* hour

/* minute

/* second

*/ */ */ */ */ */

char

char

char

float

float

float

float

float

code[6];

chan[6];

typ

e[8]

j sl

at;

Ion;

elev

; DS;

AO;

/* station code

/* lp

s,*p

n, etc. last char either s, n, or e

/* wwssn,hglp,rstn,sro,asxo,dwwssn et

c.

/* station latitude

/*

" longitude

/*

" elevation

/* nm

Ttim

uff gain at peak of calibration curve

/* normalisation, factor to make calibration curve at

peak equal 1

for a

specific frequency

struct

calib

cal [NOC

ALPT

S] ;

/*

calibration curve

*/ */ */ */ */ */ */ */ */

truct

event_info

float

lat;

float

Ion;

float

dep;

truct

time

ot;

/* event latitude

*/

/*

" longitude

*/

/*

" depth

*/

/*

" origin time */

char

it [80]; /*

it line

*/

tru

ct

r h

ort

lo

ng

fl

oat

float

tru

ct

float

ch

ar

char

eco

rd_

info

(

ndata

; d

elt

a;

max

amp;

ti

me

ab

stim

e;

rmin

; rc

omm

ent [

80]

; lo

g[L

OG

SX

ZE

];

/* data type float-1, complex-

2, etc as defined above */

/* number of ample*

*//* sampling interval

*//*

m«Tlmiiin amplitude of record

*//*

start time of record section */

/* minimum value of abscissa

*//* comment line

*//* log of data manipulation*

*/

typ

edef

st

ru

ct

{ t

ru

ct

*ta

tion

__in

fo

rtati

on

; t

ru

ct

even

t_in

fo

even

t; t

ru

ct

reco

rd_in

fo

reco

rd;

flo

at

extr

a[H

KX

TR

AS]

; }

ahh

ed;

ztern in

t errno,die();

ztern double make_matime ();

/* station info

/* event info

/* record info

/* freebie*

*/ */ */ */

register i;

ahhed ah;

truct tationcomp me

; truct devcriptrace *d

t; truct calibration ca

; truct origin or;

truct tm t;

int

ret,*ize,*is,yr;

char

te

mp

[20],

datt

yp

e; h

ort

*

ou

t;fl

oa

t *in

;F

ILE

* in

f, *

ou

tf,*

ef o

pen

() ,

**t_

op

en()

;ch

ar

coot

[HA

XC

OM

] ;

inf-

efo

pen

(in

f ile

, "r

" ) ;

ou

tf«*t_

op

en (

ou

t fil

e,

"w")

;w

hil

e ( (

ret-

frea

d(f

iah

,l, A

HH

EAD

SIZB

, in

f ) )

AH

HE

AD

SIZ

E)

{ t

_in

it (S

XATZ

OH

COM

P, C

MC)

; c

. cli

p_

va

lue-c

lip

va

l;

if (

net

wor

k [

0] f

-'\0

')

{ t

rncp

y ( c

.*c_

nam

e. n

etw

ork

, net

wor

k, 4

) ;

c.*

c_n

am

e. n

etw

ork

[3 ]«

'\0

' ;

> trn

cpy (m

e. *

c_na

me

. *t_

nam

e, a

h . s

tati

on

. cod

e, 5

) ;

me.

sc_

nam

e . s

t_n

ain

e [4

] '

\0 '

; te

mp

[0]«

ah

.«ta

tion

.ch

an

[0];

te

mp

[l]

-ah

. sta

tion

. ch

an

[l]

; /*

p

ick

up

m

p or

Ip */

treat

(tem

p, a

h. r

tati

on

. vty

pe)

; c

. sc

_nam

e . i

n*t

_typ

e*>

(sh

ort

) f i

nd

_cod

e (t

emp

, in

st_

typ

e) ;

ret-

strle

n (

ah . s

tati

on

. ch

an)

;if

(ret>

-l)

swit

ch

(ah

. sta

tion

. ch

an [re

t-1 ])

{

cave

ca

se

cave

'Z':

'V :

'e'

: 'B

' :

'n'

: 'H

':

c.

c_n

ame.

com

pon

ent-

' v'

c.a

sim

»0

;sc

.in

cid

-0;

bre

ak;

sc.s

c_n

am

e.co

mp

on

ent«

'e'

c.a

sim

-90;

sc.i

ncid

-90;

bre

ak;

c. c_name.component-'n'

c.asim 0;

c.incid-90;

break;

c. *t_lat-ah. station, slat ;

c. *t_long-ah.station.slon;

c.elev-ah.*tation.elev;

witch(ah.record.type)

{case 1:

dattype-'f; *ize-4; break;

case 2:

dattype 'c'

size-8; break;

case 3:

dattype 'v'

size-8; break;

case 4:

dattype-'t'

size-12; break;

case 6: dattype 'd'

size-8; break;

default: dattype-'f

; size-4; break;

size»*i se*ah.record.ndata;

Page 77: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds :/

usr/

suds

/src

/cm

d/ah

2st.c

dt=

(st

ru

ct

desc

rip

trace

*)m

all

oc

(siz

e+

sizeo

f (s

tru

ct

desc

rip

trace))

;if

(d

t N

UL

L)s

t_er

ror

(die

, err

no,

"U

nab

le to

mall

oc

stru

ct

desc

rip

tra

ce"

) ;

st_

init

(D

ESC

RIP

TR

AC

E, d

t) ;

dt -

>d

a ta

t yp

a d

at t

yp

e ;

for (i-

0; i<

sizeof

(ST

AT

IDE

NT

) ; i

++

) d

t->

dt_

nam

e .n

etw

ork

[i

] -sc

. sc

_nam

e .n

etw

ork

[i

] ,y

r a

h .r

eco

rd . a

bet

in* .

y r ;

if (

yr<

19

00

)yr+

-19

00

;dt->begintime-make_mst ime (yr

, ah. record . aba time .mo,

ah . record . abstina . day, ah . record . abstina . hr

,ah

. record. abstina. in

n, (do

uble

) ah. re

cord

. abstime. sec)

; dt->length-ah . record . ndata ;

dt->rate- 1.0/ah. record. del

ta;

fread (dt

+1, 1, siz

e, inf )

; if(makeint fid dt->datatype ' f

' )

{in- (fl

oat

*) (dt+1

);ou

t- (

ab

ort

*)i

n;

for (i-

0;

i<d

t->

len

gth

; d

t->

data

typ

a-'

'

; i

za-2

*d

t->

len

gth

;

ou

t [i

] -i

n[i

] * fa

cto

r;

c . d

ata

_ty

pe d

t->

data

typ

e ;

desc

rjt

ra

ce (

fisc

, dt,

dt+

1)

;st

_p

ut

(fis

c, S

TA

TIO

NC

GM

P, s

izeof

(str

uct

stati

on

com

p)

, ou

tf)

;

ah

.record

. nain

not

use

d*/

st_

pu

t(d

t,D

ES

CR

IPT

RA

CE

,siz

e+si

zeof(

stru

ct d

esc

rip

trace),

ou

tf);

if

(str

len

(ah

.record

.rcom

men

t)>

0)

{si

z^B

ake_

com

men

t(co

m,D

ES

CR

IPT

RA

CE

,0,a

h.r

ecor

d.r

com

men

t);

st_p

ut

(com

,CO

MM

EN

T,s

ix,o

utf

);

if(s

trle

n(a

h.r

ecord

.log)>

0)

{si

z^n

ake_

com

men

t (c

om,D

ESC

RIP

TR

AC

E, 0

, ah

.record

, lo

g)

; st

_p

ut(

com

,CO

MM

EN

T,s

ix,o

utf

);

if(a

h.e

ven

t.la

t1-0

.0

fifi

ah

.even

t.Io

n1-0

.0

fifi

ah

.even

t.d

ep

!-0.0

) {

st_

init

(O

RIG

IN, f

ior)

;

or.o

r_la

t ah

.even

t.la

t;

or.o

r_lo

ng a

h.e

ven

t.Io

n;

or.d

ep

th-a

h.e

ven

t.d

ep

; y

r a

h.e

ven

t.o

t.y

r;

if (

yr<

1900)y

r+-1

900;

or. o

rgti

me»

«ia

ke_

mst

ime

(yr,

ah

. even

t. o

t .n

o, a

h. e

ven

t. o

t. d

ay

,ah

.even

t.ot.

hr,a

h.e

ven

t.o

t.m

n,(

do

ub

le)a

h.e

ven

t.ot.

sec);

st

_p

ut(

fio

r,O

RIG

IN,s

izeo

f(st

ru

ct

orig

in),

ou

tf);

if

(st

rle

n (

ah

. even

t. co

mm

ent )

X))

{

siz»

nak

e_co

mm

ent(

com

, OR

IGIN

,0,a

h.e

ven

t.ec

om

men

t);

st_p

ut(

com

,CO

MM

EN

T,s

iz,o

utf

) ;

if(a

h.s

tati

on

.DS

I-0.0

fif

i a

h.s

tati

on

.AO

I-0

.0)

{ st

_in

it(C

AL

IBR

AT

ION

,fic

a);

for(

i-0

;i<

size

of(

ST

AT

IDE

NT

);i+

+)

ca.c

a_n

am

e.n

etw

ork

[i]-

sc.s

c_n

am

e.n

etw

ork

[i],

ca

.maxgain

aah

.sta

tio

n.D

S;

ca

.nozm

ali

z-a

h.s

tati

on

.AO

; fo

r(i-

0;i

<M

OC

AL

PT

S;i

++

) {

ca.c

al[

i].p

ole

.cr-a

h.s

tati

on

.cal[

i].p

ole

.cr;

ca.c

al[

i].p

ole

.ci-

ah

.sta

tion

.cal[

i].p

ole

.ci;

ca

.ca

l[i]

.zero

.cr a

h.s

tati

on

.ca

l[i]

.zero

.cr;

ca.c

al[

i].z

ero.c

i-ah

.sta

tion

.cal[

i].z

ero.c

i;

st_p

ut(

fica

,CA

LIB

RA

TIO

N,s

izeo

f(st

ruct

ca

lib

),o

utf

);

free(d

t);

Lnt

m

ake_

com

nen

t (s

tr, refe

r, it

em,

com

men

t)

int

refe

r,i

tem

; ch

ar

*st

r,*co

mm

ent;

stru

ct

com

men

t *c

m;

cm-(

stru

ct

com

men

t *

)str

;cm

->refe

r r

efe

r;

cm->

item

-ite

m;

cm

->le

ng

th-s

trle

n( c

omm

ent)

;cm

->u

nu

sed

-ato

i(N

OD

AT

A);

strn

cat

(cm

+1,

com

men

t, c

m->

len

gth

) ;

retu

rn (

sizeof(

stru

ct

com

men

t)+

cm->

len

gth

);

die(n) int n;

(exit(n);}

t i n ( argc , ar

gv)

int argc;

char **

argv

;

register i;

int numfil,makeint;

char *network, *o

fil«

; extern char *progname;

float cl

ipva

l, fac

tor;

pro

gn

am

e-a

rgv

[0]

;n

um

fil-

0;

of i

le-"

std

ou

t" ;

net

work

" "

;m

ak

ein

t 0

;cli

pval-

0.0

;fa

cto

r-1

.0;

for(i

-l;i

<argc;i

++

) {

if(a

rg

v[i

][0

] '-

')

{ sw

itch

(argv[i

][l]

) {

'G':

if

(argv[i

][2]!

-'\0

')

cli

pval-

ato

f (f

iarg

v[i

] [2

]) ;

els

e cli

pval-

ato

f (a

rgv[+

+i]

) ;

b

reak

;'n

':

if(a

rgv[i

] [2

] l-

'\0')

n

etw

ork

- fi

arg

v[i

] [2

] ;

els

e

net

wo

rk-a

rgv

[+

+i ]

;

bre

ak

;'o

':

if(a

rgv[i

][2]

l-'\

0')

ofi

le-

fiarg

v[i

] [2

] ;

els

e ofi

le-a

rg

v[+

+i]

; b

reak

; ' m

' :

mak

ein

t 1;

if (

argv[i

] [2

]l-'

\0')

fa

cto

r-

ato

f (f

iarg

v[i

] [2

]);

els

e f a

cto

r-a

tof

(arg

v [+

+i ]

) ;

bre

ak

; d

efa

ult

: st

_error (0,0

, "

Un

reco

gn

ized

ar

gum

ent

%s"

,arg

v[i

]) ;

els

e

{ah

2st

(argv[i

] , o

file

, n

etw

ork

, ma

kei

nt,

cli

pval,

facto

r)

; n

um

fil+

+;

if (numfil 0)

ah2st ("s

tdin",

of ile

, network, makeint, clipval, fa

ctor

) ;

ca

se

ca

se

Page 78: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds :/

usr/

suds

/src

/cm

d/as

c2st

c

/* asc2st: convert an ascii file to suds format

PUTard,

U.S.

Geological Su

rvey

, Itenlo Park,

Ca 94025

*/static char Sccsld[] » ne(i)asc2st.c

1.2 11/17/88";

idefine MAXIM 256

/* maximum length of input line */

fdefine DATATYPE ptr[22]

/* character representing datatype is offset

22 bytes from beginning of MUXDATA and

OESCRIPTRACE

*/finclude "/usr/suds/include/suds.h"

extern in

t stform_len;

extern SUDS_FORM *st

form

[];

asc2st(inflie,outf,cflie,sepstr,verbose)

char *infile,*cfile,*sepstr;

int verbose;

int in

d«0;

in

t babble;

/* index of character on input line

char *next_field(stream,end)

FILE *streau;

int *e

nd;

register j;

int

isstr,ischr;

char c;

char buf[MAXIM];

/* buffer for actiive field in instr

*/

{

if(j

!-0

) goto

ou

t;

*en

d-l

; re

turn

(NO

LL

);

iast

r-i

sch

r-j

-0;

wh

ile

(1)

{sw

itch

(c

»fg

etc

(str

e

case

'\

n':

b

reak

; ca

se E

OT:

ca

se '\

t':if(j

0)

bre

ak;

if(i

sch

r)

{ fg

etc

(st

if(i

sstr

) {

bu

f[j+

+]

goto

ou

t;

:if

(iss

tr)

:if(

isch

r)

);

go

to ou

t;)

bre

ak

;}

( f g

etc

(str

eam

) ;

goto

ou

t;

{ fg

etc(

stre

am

);

goto

o

ut;

isst

l;

bre

ak;

isch

r-1;

bre

ak;

V"

\"

default:

ou

t: bu

f[j]

-'\0

';

retu

rn(b

uf)

;

int

getf ields (ptr, type, sle

n, inf

) char *p

tr;

int type,slen;

FILE *i

nf;

register i;

char

*field;

int

end;

end

-0;

f or

(i-b

eg_

stru

ct [

typ

e] ;

«tf

on

a[i

] .f

sty

pe t

yp

e

fifi

stfo

zm

[i].

off

set

<sl

en;i

++

) {

if(s

tform

[i].

nextf

styp

e!-

0)

getf

ield

s (p

tr+

stfo

rm[i

] .o

ffse

t,st

form

[i]

.nextf

styp

e,s

len

-stf

orm

[i]

.off

set,

inf)

; els

e

{field-nextjE ield (in

f, fiend)

; if(babble)

fprintf (stderr

, "Input (at

%5d bytes): '%s'\n",stfozm[i] .offset,field) ;

if(end)

st_error(die,0,"improper end to structure %d",type);

if(strcmp(field,"HODATA" ) 0) field-NODATA;

if(strcmp(field,"MOLIST") 0) field-HOLIST;

asc

2fi

eld

(fie

ld,p

tr+

stfo

xm

[i]

.off

set,

stfo

xm

[i]

.fty

pe)

;

FIL

E *ou

tf;

regis

ter i;

FIL

E

*in

f;in

t ty

pe;

int

int

int

char

char

in

t

slen

; d

len

; d

atl

en;

*p

tr;

*fi

eld

; en

d;

/*

inp

ut

stre

am

*/

/*

typ

e of

stru

ctu

re b

ein

g r

ead

in

*/

/*

len

gth

of

stru

ctu

re b

ein

g r

ead

in

*/

/*

len

gth

of

data

fo

llo

win

g t

his

st

ru

ctu

re,b

yte

s*/

/*

len

gth

of

da

ta

foll

ow

ing

th

is

stru

ctu

re,w

ord

s*/

/* p

oin

ter

to

stru

ctu

re

*/

exte

rn i

nt

beg

_st

ruct

[];

short

*s

h;

lon

g

*lg

; fl

oa

t *ft

; d

oub

le

*db

;

end

-0;

inf-

efo

pen

(in

file

,"r"

) ;

while((field-next_field(inf, fie

nd))

!-NU

LL)

{ type-atoi(field);

if(type<0

|| typeXrOTAL_STRUCTS)

st_error(die,0,"illegal structure type %d",type);

slen-atoi(next_field(inf,fiend));

dlen-atoi (ne

xt_f

ield(in

f,fiend));

if(babble)

fprintf(stderr,"Struct %d length-%d data length~%d\n",type,slen,dlen);

ptr«(ch«r *)malloc(slen-

Kilen) ;

if(ptr"HULL)st_error(die,0,"Unable to malloc for structure %d le

ngth

-%d"

,ty

pe, slen-t-dlen) ;

getfields(ptr,type,slen, inf

);

if(dlen)

{if(type!-MOXDATA

fifi type!-DESCRIPTRACE)

st_error(die,0,"data should not follow structure type %d",type);

Witch(DATATYPE)

{case '»

' datlen^dlen/2; sh-(short *)

(pt

r+sl

en);

break;

'!'

datlen-dlen/4; lg«(long *)

(pt

r+sl

en);

break;

datlen-dlen/4; ft-(float *)

(pt

r+sl

en);

break;

datlen-dlen/8; db-(double *) (pt

r+sl

en);

break;

st_error(die,0,"unknown data type %c after structure type %d"

DATATYPE,type);

case 'c'

case 'v

' case 't

' case '£

' case 'd

'

default:

for(i«0;i<datlen;i++)

{ switch(DATATYPE)

{case '«

' *(sh++)-(short)atoi(next_field(inf,fiend)); break;

case '!

' *(lg++) (long)atoi (ne

xt_f

ield

(inf

,fie

nd))

; break;

case

't

' '£

' 'd

'*(f

t++

)«(f

loat)

ato

f (n

extj

Cie

ld(i

nf,

fien

d))

; b

reak

;*(d

b+

+)»

(do

ub

le)a

tof

(nex

t fi

eld

(in

f,fi

en

d))

; b

reak

;

Page 79: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

asc2

st.c

«t_

pu

t (p

tr,t

yp

«,

01«n

+d

lan

, ou

tf)

; fr

ee(p

tr)

;

zt«

rn

ch

ar

*pro

gnam

*;

di«

(in

)in

t in

; {

xit

(in

) ;

main(argc,argv)

int argc;

char **argv;

r«gi*t«r i;

int v*xbo0«,numfil,outcl;

char **«p»tr,*ofil«, *cfil«;

FILE *outf;

pro

gnam

*«ar

gv[0

];

nu

mfi

l-0;

babbl«-0;

outcl-1;

/* /*

ofi

l«-"

«td

ou

t";

for

(i-1

; i<

arg

c; i-

H-)

{if

(arg

v[i

][0

] '-

')

{ w

itch

(a

rg

v[i

][l]

) {

'c':

if

(arg

v[i

][2

]!«

'\0

')

! cfi

l«-a

rgvt+

+i]

; b

r*a

k;*

/

c,«

,v fo

r fu

tur*

azp

an

aio

n */

-

fiar

<rr[i

][2];

«-

fiargv[i

][2];

ofi

l«-a

rgv[+

+i]

;

br»

ak;

' ':

if

(a

rgv

[i]

[2] !-

'\0')

«

p*tr

- fi

argv[i

][2];

!

««

tr-«

rgv

[-H

-i]

; b

r*ak

; */

'v'

: v

«rb

oc«

>l;

br»

ak

;*/

'V:

ba

bb

l«-l

; d

efa

ult

: «

t «rr

or

(0,0

, "

Un

r*co

gnis

*d a

rgu

m*n

t %

*H/a

rgv[i

])

if(o

utc

l)

{ou

tf»«t_

op

«n

(ofi

l«,

"w")

ou

tcl-

0;

a«c2

*t

(arg

v[i

] , o

utf

, n

um

fil-

H-;

, ««

p0

tr, v

erb

o««)

if (

nu

mfi

l«-0

) {

ou

tf«

*t_

op

«n

(ofi

l«,

"w")

;a«c2

«t

(" t

din

",o

utf

rcfi

l«,*

«p

*tr

,v*rb

o««)

} «t_

clo*« (

ou

tf)

;

Page 80: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds :/

usr/

suds

/src

/cm

d/st

2ah.

c

/*

st2ah

: co

nver

t d

ata

in

mt

(SU

DS)

fo

rmat

to

ah

(L

amen

t)

form

at */

/* E

ven

t in

form

ati

on

, if

pre

sen

t,

mus

t p

rece

ed t

races

Ass

um

es

inp

ut

file

n

an*

beg

ins

wit

h st

. an

d th

an

wri

t**

ou

tpu

t fi

l* t

o

ah.

Wri

tes

data

o

ut

a*

FLO

AT,

in

pu

t*

as

lon

g,

short

, fl

oat,

etc

.PL

Har

d 3

/22/8

9

*/

f in

clu

de

<st

dio

.h>

FI

LE

*in

file

,*ou

tfil

e;

f in

clu

de

<rp

c/rp

c.h

>f i

ncl

ud

e "

/usr

/su

ds/

incl

ud

e/a

hh

ead

er.h

"

lin

clu

d*

"/u

sr/s

ud

a/i

ncl

ud

e/su

ds.

h"

ah

hed

lam

;

di«

(n)

int

n;

(exit

(n);

} ex

tern

ch

ar *

pro

gnam

e;

mai

n (a

rgc,

arg

v)in

t arg

c;ch

ar *

*arg

v;

{in

t i,

stj

typ

e, *

t_le

n, t

r_

len

, le

ng;

char

*ch

,*st

_p

tr,o

utn

am

e[50]

;fl

oa

t ft

ra

ce;

dou

ble

se

c;st

ruct

st

ati

on

com

p *st

cp;

stru

ct

scri

ptr

ac«

*

dst

r;st

ruct

o

rig

in

*org

;short *s

h;in

t *i

n;float *£

1;int yer,mon, day, our,min;

progname argv[0]

;

/* zero unused parts of ah structure */

lam.

event . lat^O .

;la

m. avant . lon^O .

;lam. «vant . d«p«0 .

;la

m. «vant . ot . yr-0 ;

lam. avant . ot

.mo

-0 ;

lam. avant . ot

. day-0 ;

lam. «v«nt . ot

. hr 0

;lam. av«nt . ot

.mn

»0 ;

lam. avant . ot . s«c«0 . 0

;lam.avant.acoumant [0]

-'\0

' ;

lam

. sta

tion

. A0»

0 . 0

; fo

r(i«

0;i<

NO

CM

£TS

;i+

+)

{la

m. s

tati

on

. ca

l[i]

.p

ola

.r-0

.0;

lam

. sta

tion

. cal[

i] .

po

l«.i

-0.0

;la

m. s

tati

on

. cal [i

] ,z

aro.r

^).

0;

lam

. sta

tion

. ca

l [i

] . z

«ro

. i»

0 .

0 ;

for (i-

1;

i<arg

c; i-

H-)

if<

atr

ncn

p(a

rg

v[i

],"

st.

H t

_«rr

or

(0,0

, "

Ille

gal

Is*

{

str cp

y (o

utna

m*

, arg

v [ i

] ) ;

outn

ama

[()]

' a

' ;

ou

tnam

a[l

]«'h

' ;

infi

la«

at_

op

*n

(arg

v[i

] ,

"ou

tfil

a^

fop

an

(ou

tnan

a, "

w

3) 1

-0)

fila

%

s:F

ile n

ame

mu

st b

egin

wit

h st

.\n

");

wh

ila (

(tr_

lan

«st

_g

at

(Sst

_p

tr, fi

st_ty

pa, f

i«t_

lan

, in

f ila

))!

=EO

F)

{ sw

itch

(s t

_ty

pe)

{

caaa

ST

ATI

ON

CC

MP:

st

ep"

(st

ruct

at

atio

nco

mp

*)s

t_p

tr;

strc

py(l

am

.sta

tion

.cod

a,s

tcp

->sc

_n

am

a.s

t_n

am

a);

la

m. s

tati

on

.ch

an

[0]=

stcp

->sc

_n

am

a.c

om

po

nen

t;

strc

py(l

am

.sta

tion

.sty

pa,

list

_co

da

(stc

p->

sc_

na

ma

.in

st_

typ

a,i

nst

_ty

pa

));

if(s

tcp

->sc

_n

am

a.i

nst

_ty

pa «

O)

lam

.sta

tion

.sty

pa[0

]='\

0';

la

m. s

tati

on

.sla

t=st

cp

->st

_la

t;

lam

. sta

tion

.slo

n»st

cp->

st_lo

ng;

lam

.sta

tion

.«la

v«st

cp->

ala

v;

bra

ak;

casa

DE

SC

RlP

TR

AC

E:d

str-

(str

uct

dasc

rip

traca

*

)st_

ptr

; la

m.r

acor

d.t

ypa-

ahF

LO

AT

; la

m.r

aco

rd.n

da

ta«

dst

r->

l«n

gth

; la

m.r

acord

.dalt

a=

l./(

dst

r->

rat«

);

lam

. raco

rd. m

aaca

mp~

dst r

->m

axd

ata-

dst

r->

av

an

oi s

a ;

dac

oda_

mst

ima(

dst

r->

bag

inti

ma,

fiy

ar, f

imon

, fid

ay,f

iou

r,fi

min

, fia

ac)

;1 a

m. r

aco

rd. a

bat

ima.

yr^

yar

; 1 a

m. r

aco

rd. a

bst

ima. m

o >ta

on;

1 am

. raco

rd. a

bst

ima.

day

>nia

y;

lam

. raco

rd. a

bst

ima. h

r o

ur;

1 a

m. r

aco

rd. a

bst

ima.

mn>

tnln

; la

m. r

aco

rd. a

bst

ima. s

ac-

sac;

la

m.r

acor

d.x

min

^O

.0;

lam

.raco

rd.r

com

man

t[0]=

'\0';

la

m.r

aco

rd.l

og[0

]^'\

0';

la

m.s

tati

on

.DS

*0

.0;

fwri

ta(C

lam

,1,A

HH

EA

DS

I2E

,ou

tfil

a);

ch-s

t_p

tr+

st_la

n;

f or

(i-0

,lan

g-0

;i<

lam

. raco

rd. n

dat

a; i-

H-)

{

ch«c

h-t-

lang

; sw

itch

(d

str-

>d

ata

typ

a)

{ca

sa 'r

':

sh-(

short

*

)(ch

);

lan

2;

ftraca-

*sh

/16

.0;

bra

ak;

casa

's

':

ah

*(s

ho

rt

*) (

ch);

ft

ra

ca

- *s

h;

lan

g-2

; b

raak

; ca

sa '!

':

in»(

lon

g

*)(

ch);

ft

ra

ca

- *in

;la

ng

4;

bra

ak;

casa

'f

: fl-

(fl

oat

*) (

ch);

ft

ra

ca

- *fl

;la

ng

4;

bra

ak;

dafa

ult

:

st_

arr

or(

dia

, 0,

"Unk

now

n d

ata

typ

a in

st

ru

ct

dasc

rip

traca

of

%c"

d

str-

>d

ata

typ

a);

) ftra

ca»

(ftr

aca

-dst

r->

av

an

ois

a);

fw

rit

a(S

ftraca,4

,1,o

utf

ila);

) braak;

casa <»UGIH:

org-(struct origin *)st_ptr;

lam.avant.lat-org->or_lat;

lam.avant.lon-org->or_long;

lam

.avan

t.d

ap

org

->d

ap

th;

dac

oda_

mat

ima(

dst

r->

bag

inti

ma,

fiy

ar, f

imon

, fid

ay,f

iou

r,

fim

in,f

isac

);1 a

m. a

van

t. o

t.la

m.a

van

t .o

t .m

ola

m.a

va

nt.

ot.

day

-day

;la

m.a

van

t.ot.

hr

ou

r;la

m. a

van

t. o

t .m

n*«d

n;la

m. a

va

nt.

ot.

sa

c s

ac;

bra

ak;

casa

C

ALI

BRA

TIO

N:

st_

arr

or(

0,0

,"C

ali

bra

tio

n s

tru

ctu

re n

ot

tran

slate

d."

)

Page 81: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

e090t-i m »

~ 0. O <H.

Page 82: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

st2a

sc.c

/* st2asc:

convert cud* structures to ascii

PLHard,

US Geological Su

rvey

, Itenlo Pa

rk,

Calif 4/29/88

static char Se

esId

[]

fdefine MAXO0TLINE

/* DEFAULTS */

int

linelength-72;

char indentinit[]-"

char headeri[]«"";

char structhead[]«"

e(f)st2asc.c

300

STRUCTURE:

1.2 11/17/88'

finclude "/usr/suds/include/suds.h"

Iinclude "/usr/suds/include/st_error.h"

finclude <stdio.h>

die (in

)in

t in

; {

exit(in);

st2asc

(in

file

,ou

tfil

e,c

file

,sep

str,v

erb

ose

, n

oli

st, in

den

ti,h

ead

er)

char

*

infi

le,*

ou

tfil

e,*

cfi

le,*

sep

str,*

ind

en

ti,*

hea

der;

int

ver

bose

, noli

st;

int

type,len,inp;

FILE

*inf

, *outf,*conf,*st_open(),*efopen();

char

*ptr;

char outline[MAXOUTLXNE];

inf st_open(infile, "r"

);

outf-efopen(outfile,"w");

whil

e((inp-st_get(fiptr,

fitype,filen,inf))t-EOT)

{ if (type<0 T|

ty

pe>T

OTAX

i_ST

RUCT

S)

{ fprintf(outf,

"Skipped unrecognized structure type %d of length %d

\n"

continue;

,typ

e,le

n)

list struct (ty

pe,p

tr, le

n, inp

, 0,

outf, outline, se

pstr

, verbose, nol

ist,

indenti, hea

der)

;

st_free(ptr,inp);

extern double atof();

extern int atoi ();

list struct (ty

pe, pointer, len

, in

p, level, outf, outline, sepst

r, verbose, nolist, indenti, hea

der)

in

t type,len,inp,level,verbose,nolist;

char *pointer,*sepstr,*outline,*indenti, *header;

FILE *outf;

register i,j;

short

*sh,shh;

long

*lg;

float

* re

­ double *d

b;

char

*ch,*ctime();

char

*ptr;

int

?>code,leng,dtype;

char

indent[MAXODTLIHE];

char

temp[MAXOUTLIHE];

extern char *list_code();

struct descriptrace *d

t;

struct muxdata *m

x;

ptr^pointer;

if(strlen(outline)>-linelength)

(fprintf(outf,"%s\n",outline);

outline [0]-'\0';

) if(verbose)

(for(i-0,indent[0]-'\0';i<level;i++) sprintf(indent,"% % ",indent,indenti);

if(level-O)

(fp

rin

tf(o

utf

,"%

% %

%

(len

gth-

%d+

%d«

%d

byte

s)\n

",i

nd

ent,

hea

der

, st

ruct

hea

d,s

tru

ct_

na

mes

[ty

pe]

.mea

nin

g,l

en,i

np

-len

, in

p)

;} els

e

fpri

ntf

(ou

tf,"

%s%

s%s\

n"

,in

den

t,st

ruct

hea

d,s

tru

ct_n

am

es[t

yp

e].m

ean

ing);

for(i

-0,i

nd

en

t[0]-

'\0';

i<-l

evel;

i++

) sp

rin

tf (i

nd

ent,

"%

s%s"

, in

den

t,in

den

ti)

; } els

e

{if

(le

vel

0)

(sp

rint

f(ou

tlin

e,"%

s%d%

s%d%

s%d%

s",

head

er,t

yp

e,s

ep

str,l

en

,sep

str,i

np

-len

,sep

str);

} if

(str

len

(ou

tlin

e)>

-lin

ele

ngth

) {

fpri

ntf

(ou

tf,"

%s\

n"

,ou

tlin

e);

spri

ntf

(ou

tlin

e,"

%s"

,in

den

ti);

)

) for(i

-beg_st

ru

ct[

typ

e];

stfo

r»[i

].fs

typ

e t

yp

e

fifi

stfo

rm

[i].

off

set<

len

;i+

+)

{ se

p 1

;if

(verb

ose

) sp

rin

tf(o

utl

ine,

M%s%

-20s:

\t"

,in

den

t,st

form

[i].

fnain

e);

cod

e- -1

; sw

itch

(stf

orm

[i].

fty

pe)

{ca

se

CH

R:

ch

^tr

+st

fom

[i]

.off

set;

sprin

tf(t

em

p,s

tfo

[i].

ffo

za

at,

*ch

);

sprin

tf(o

utl

ine,

"%

s'%

s'"

,ou

tlin

e,te

mp

);

if(s

tform

[i].

cod

eli

stl-

0)

cod

e- *

ch;

bre

ak;

case

B

TS:

ca

se M

ZN:

ch

-ptr

+st

form

[i].

off

set;

sprin

tf(t

e»p

,stf

orm

[i].

fform

at,

(in

t)*

ch);

sp

rin

tf(o

utl

ine,

"%

s%s"

,ou

tlin

e,te

mp

);

if(s

tform

[i].

cod

eli

stt-

0)

cod

e- *

ch;

bre

ak;

case

SI

R:

ch

^tr

fstf

om

[i]

.off

set;

sprin

tf(t

em

p,s

tfor*[i

].ff

orm

at,

ch

);

sprin

tf(o

utl

ine,

"%s\

M%s\

"M,

ou

tlin

e,te

mp

);

bre

ak;

case

SH

T:

sh-(

short

*

)(p

tr+

stfo

rm

[i].

off

set)

;if

(*sh

ato

i (M

OO

ATA)

) sp

rin

tf (

tem

p, "

NOO

ATA"

) ;

els

e sp

rin

tf(t

emp

,stf

orm

[i].

ffo

rma

t,*

sh);

sp

rin

tf(o

utl

ine,

"%

s%s"

,ou

tlin

e,te

mp

);

if(s

tfo

rm

[i].

cod

eli

st!-

0)

cod

e- *

sh;

bre

ak;

case

LH

C:

lg-(

lon

g *

)(p

tr+

stfo

rm

[i].

off

set)

;if

(*lg

ato

i (M

OO

ATA

)) sp

rin

tf (t

emp

, "N

OO

ATA"

) ;

els

e sp

rin

tf(t

emp

,stf

orm

[i].

ffo

rma

t, *

lg)

; sp

rin

tf(o

utl

ine,

"%

s%s"

,ou

tlin

e,te

mp

);

if(s

tform

[i].

cod

eli

stt-

0)

cod

e- *

lg;

bre

ak;

case

FL

T:

ft-(

flo

at

*)(

ptr

+st

form

[i].

off

set)

;if

(* ft

ato

i (M

OO

ATA)

) sp

rin

tf (t

emp

, "NO

DAT A

" ) ;

els

e sp

rin

tf(t

em

p,s

tform

[i].

fform

at,

*ft

);

spri

ntf

(ou

tlin

e,"

%s%

s",o

utl

ine,

tem

p);

b

reak

; ca

se

LZiT

: ca

se D

BL

: d

b-(

do

ub

le *

)(p

trfs

tfo

rm

[i].

off

set)

;

Page 83: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

O 11

0 1103 ;SS:

1110 iSSi

a iiO3 o:ox:

03 i:ip;

03 |||

03 ;;s;;g

03 :*ssFrt :: :-: : :

W

xo:o "

oxo: -H

11 ti

I ? :-:-:-: : >»

:+:+:' 4J -H « i« a?

Ss * jf

i i !Wv: IH IH

m a a:SS -rt -rt

S-

mmmsss?mmmmmmmmmmmmmmmmmmm

if (*db=»=atoi (NODATA) ) sprintf (temp, "NODATA" else sprintf (temp, stform[i] .f format, *db) ;

sprintf (outline, "%s%s", outline, temp) ;

w

nr M

*"* H *~

51 *

M 3 1 4» |p

IH IH H -H

s **.

ip

OCVBJK;

case STT: lg-(long *) (ptr+stform[i] .offset) ;

if (verbose) { *db- *lg;

if (*lg atoi (NOTIME) ) sprintf (temp, "NOTE else sprintf (temp, "%s" , listjastime (*db, sprintf (outline, "% % ", outline, temp) ;

>

-P

\ i _

\\ &lenga* dtypes

)

ch-ptr+l< switch (di

1 "

i

else {

if (*lg atof (NOTIME) ) sprintf (temp, "NOTE else sprintf (temp, stform[i] .f format, *lg sprintf (outline, "%s%s", outline, temp) ;

i

MM

S

V

<M m* * 99

- - - H iH

3-3-S It III 31J3 J3 J3 iH iH

s-s-s -s-s

ti?ti titi000 00

i p. ' " '*8 *»f i5 i5 ii

H H « 0 V 41

88888883333333

9 £"

break;

case MST: db- (double *) (ptr+stf orm [i] .offset) ;

if (verbose) {

if (*db-«atof (NOTIME) ) sprintf (temp, "NOTE else sprintf (temp, "%s",list_mstime(*db, sprintf (outline, " % % " , outline, temp) ;

ict descriptrace of %c"

Cti

£+»> *

j§ tS i

ifs?\T ^;->^. S ^ '

*.3S S;

"i u ^ "

*4> v2-

8 IH ? iJ341 i5

s H ..

1

else {

if (*db-«atof (NOTIME) ) sprintf (temp, "NOTE else sprintf (temp, stform[i] .f format, *db sprintf (outline, "%s%s", outline, temp) ;

)

break;

case CAL:

ifF ! §

ISS - -IT « S

r 5 B 0 » 0 -# IH > xS JJ s. J!

e*> -0 0 « -0 iH ^O ^O M5* ~* * i . s v.S " 1 1 H A -H -H H iH iH

9 «^tia«&&H IH IH IH

H 0 -H -H

H 0 V

88883333

case CPX: case STZ:

default: if (verbose) {

fprintf (outf, "%s\n" , outline) ;

outline [0]-'\0' ;

ft [i], sepstr); break; i , db [i ] , sepstr) ; break;

5a -H H iH

+» ^

0 -

x * *

H iH* * «- -w

* * ^ .Z*' - A f -tif f &;J J

H -H -PC H iH iH 3 -H

00 -rt S sr^ t5ftit! £JU H -H f * S M H C --rl fli 0, -H >H iH

^ v «. 0 ^^^41 IH "^ ^^ IH IH (S (S

333 ticg1IH

*** «H

i H

|IH

g"^H

H

H

fr H -

1

if (stform[i].neztfstype!-0) {

liststruct(stform[i] .neztfstype,ptr,len sepstr, verbose, nolist, indenti, header

sep-0;

}

break;

):

ti

1 H

XC

1

H

^

|X

**

oIH P

J«^M

§

jl<«m

3

M

t

IH H

H

if (verbose fifi code>-0) {

sprintf (outline, "%s\t{ %s }", outline,

list_code (code, stf orm [i] .codelist) ) ;

i

-

g rt H

ti 0

C

s O

"" Si

1° IH V P O

H C -H -H iH

H IH o IH

*

I

if (verbose fifi outline [0 ]!»' \0') { fprintf (outf, " %s\n" , outline) ;

outline [0]-'\0';

)

else {

ti H H 0C

iI1 1 -8 §

sir «r

1 -

if (sep) sprintf (outline, "%s%s", outline, sepstr) ;

if (strlen (outline) >-linelength) { fprintf (outf, "%s\n" , outline) ; sprintf (outline, "%s", indenti) ;

J

)

*

3H

HH

*

M

H Q-O -H

* p * 2 M H M 0 -H

III !!!

( (type-^)ESCRIPTRACE | | type-^fOXDATA) fifi noliat 0) {

if (outline [0]!-'\0') {

fprintf (outf, " %s\n" , outline) ; sprintf (outline, "%s", indenti) ;

}

else if (verbose) {

Page 84: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

^ 1co :;*> etf ||

msiO -:-:-x

CO 3;3; T3 ||

"^5" SsiCO w*

<i MCO S3S

8 11& II

^S'-^^3

: : : : : : ,

Si: »?

3S «*

S3 -!

H){

'-') { [i][l]) {

: if (argv[i][2]f-'\0') cfi ! cfile-argv[++i] ;

l»...V

llfiliP

-

d«r= £argv[i] |

if(argv[i][2]l-'\0') hea ! head«r»argv[++i];

Kr-^.V .

3

^

£1

i 1" 0

5 -fi­

ll Sv

if (argv[i][2J!-'\0') ind else indenti«argv[++i];

break;

if(argv[i][2J!-'\0') lin ! linelength«atoi(arg

break;

! I

*,

le- fiargv[i][2

noliit«l; break;

if(argv[i][2]!-'\0') ofi ! ofile-argv[++i];

break;

5 *°

! f

- tr- £argv[i] [

if(argv[i][2]!-'\0') *ep elie p«tr-*rgv[-H-i] ;

break; v«rbo««=l;

ji V

3 3

^

IS

J?

B

break;

t_error (0,0, "Unrecognix*

default :

)

)

»i ». i

"M

1 a H"

| H H i-l

§

i

i] ,ofile, cfile, «p*tr,ver!

i|

-H

1

.^

IT 5I H a

1 H HiH

§a

If9

U

H H

0

a

s

U

f H

1

Page 85: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

stde

scri

be.c

/*

td

««

crib

«:

list

*tr

uct

ur«

« in

m

*trw

au*/

tati

c

char

Scc

sXd

[] -

"8(f

)*td

««cr

ib*.c

fi

ncl

ud

*

N/u

«r/

«u

/in

clu

/«u

d*

.h"

fi

ncl

ud

* <

ctd

io.h

>

1.2

1

1/1

7/8

8"

di*

(n)

int

n;

*x

t*rn

ch

ar

*li

«t_

cod

*()

;

td

*»crib

*(i

nfi

l,ou

tfil

*)

char

*in

fil;

F

ILE

*

ou

tfil

*;

int

typ

,l*n

,in

p,n

um

; ch

ar *

ptr

; ST

AT

IDE

NT

*m

i;

FIL

E *in

fil*

;

num»0;

infil*«*t_op*n (in

fil,

"r");

fprintf(outfil«,-ril« % :\n-,infil);

whil* ( (inp-«t_g«t (fiptr,

«typ, Cl*

n, infil*) )

f -EOF)

{fprintf (outf il«,«%3d

%3d

%-14* length %4d + %6d byt«

«",n

iiBf

+,ty

p,li«t_cod«(typ,*truct_nam««),l«n,inp-l«n);

if («tform[b«g_«truct [typ] ]

. n«xtf«typ« «STAT_IDEKT)

{ i-(STATIDENT *)pt

r;fprintf (ou

tf il«,

" % .% . %c. %d"

, »i

->n«

twor

)c, «i->*t nama, i->compon*nt,

i->in«t_typ«);

"~

^

fprintf(outfil*,«\n");

t_fr**(ptr,inp);

*t_clOM (infil*)

;

main(argc,argv)

int argc;

char **argv;

{

int

num

f il

, ou

t ;

char

*n

«tw

or)

c,*ofi

l«;

ztt

trn

ch

ar

*pro

gnam

«;

FIL

E *

ou

tfil

«;

ou

t«l;

pro

gn

aM

-arg

v [

0 ] ;

nu

mfi

l-0;

ofi

l«-«

*td

ou

t";

for (i-1; i<argc;i++) {

if(a

rg

v[i

][0

] '-

')

{ w

itch

(argv[i

][l]

) ca

««

'o':

if

(a

! o

fil«

»argv[+

+i]

; b

raak

; d

efa

ult

: «

t_«

rro

r (0

,0,

HDn

r*co

gnii

*d a

rgu

men

t %

if (

ou

t)

{o

utf

il«

-ct

ou

t-0;

td

Mcrib

* (

arg

v[i

] , o

utf

il«

) n

um

fil-

H-;

«-

Carg

v[i

] [2

]

if (n

umf il

0)

{o

utf

il«

-«t_

op

«n

(ofi

l«,"

w"

);

td

Mcr

ib* (

" t

din

", o

utf

il*)

} t_clo

M (

ou

tf il

«);

Page 86: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

sted

it.c

/*st

ed

it:

dis

pla

y a

nd ed

it

sud

s fi

les

This

p

rog

ram

is

a quic

k hac

k o

f anoth

er

pro

gra

m I

w

rote

to

show

how

an ste

dit

mig

ht

functi

on

. It

sh

ould

b* in

teg

rate

d w

ith

th

e

Lam

ent

wav

efoz

ed

ito

r an

d t

ho

ug

ht

ou

t m

uch

mor

e care

full

y.

PLW

ard,

U

.S.G

eolo

gic

al

Su

rvey

, M

enlo

P

ark,

Ca

9402

5 5/1

9/8

8

*/

sta

tic c

har

SeesI

d[]

- "8(#

)ste

dit

.c

1.2

1

1/1

7/8

8";

in

clu

de

<st

dio

.h>

fi

ncl

ud

e <

curs

es.h

> i

ncl

ud

e <

cty

pe.

h>

in

clu

de

"/u

ar/

sud

s/in

clu

de/

sud

s.h

"

defi

ne M

AXCO

L 80

defi

ne M

AXO

UT 1

00

/*

form

, / d

efi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

Vfd

efin

e d

efi

ne

fdefi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

defi

ne

MAX

Limc

20

MAX

TIEL

D 10

0E

RR

JT

1E

RR

_X

1IS

ST

JT

2IW

ST_X

1

CM

D_Y

2

CMD_X

iSPACE

'_'

BIGGEST 30

NONE

BREAK

CMTRLC

CMTRLD

BELL

BSP

LTD

TAB

RET

ESC

SPA

DEL

UPCOR

DMCUR

RTCUR

LfCOR

T2

F3

F4F5T6

F7TBT9

RlR2 R3

'\0'

00 03

04 07010

012

Oil

015

033

0177

05 06

0702

020

021

022

023

024

025

026

027

030

031

032

/* «

.«« < mm. length of any

link

string

/* «.

«« <

mm. length of any single input field

/* row of error messages

/* first

column of error mes

sage

s/* row of instructions

/* first column of instructions

/* row of command line

/* first column of command line

/* char to show a

spac

e fo

r input

/* dimension of largest

string in database

/* no

char

*/ */ */ */ */ */ */ */ */ */ */

FILE *c

ons;

extern int beg_struct [ ]

; extern int width_field[] ;

extern char *list_eode ()

; extern char *list_mstime() ;

extern int atoi () ;

extern double atof ()

;

/* primary active indecies form addressing screen

(def

ine NCOL stdscr->_curx

[define BROW stdscr->_cury

char AOP

toLO

(c)

chare;

( re

turn

(isupper(c) ?c-'A'+'a' :c);

}

beg_

curs

es()

{

if (initscr() ERR

) (

f printf (stderr, "Insufficient core to allocate a

window. \n"

) ;

exit (ER

R) ;

} noecho ()

; raw<);

crmode ()

; nonl ()

;

end_curses()

( refresh ();

mvcur (0, COLS-1, LINES-1, 0)

; echo();

no raw ()

; no crmode ()

;

*/

Lnt

re

fr

Lnt

err

acti

ve

1;

0;

/* current cursor column

/* current cursor row

/* if

true refresh

screen n

ext

/* if

true error

written, remove

*/ */

endwin ()

;

errf oxm (fmt

, ch)

char *fmt,ch;

int

ao, ro;

co-HCOL;

roHJ

ROW;

move (ERR_Y, ERRJC) ;

er ra ct i ve»l ;

if (chl-O)printw (fm

t, ch)

;clrtoeol ()

;move (ro, co

) ;

refresh();

ss(fmt,ch)

int

co,r

o;

co«HCOL;

ro-U

ROW;

move (ER

RJT,

ERRJC)

;er

ra ct iv

e 1

;if (ch!-0)printw(fmt,ch);

clrtoeol ()

;move (ro, co

) ;

refresh ()

;

inform (fm

t, a, b, c, d, e, f, g, h, i)

char *f

mt;

int a,

b, c, d, e, f, g, h, i;

int

co,r

o;

Page 87: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

sted

it.c

co-N

COL;

ro-NROW;

BOV* (ERRJT, ERR_X) ;

if (a!-0)printw(fint,a,b,c,d,e,f,g,h,i);

clrto*ol();

move(ro,co);

refresh ()

;

int pshow-0;

/* g*t from keyboard */

char getcode (allowed)

char * allowed;

{register char c,d, conv;

char

*

all

ow

;

getit:

c-0177

fi getch();

if (*rra

ctiv*)

{err form (""

,0)

;erractive-0;

/*

r*ad

ch

ara

cter

/*

if

err

or

me*

ca

ge,

*/

*/

{/*

if

ch

ar a

llow

ed r

etu

rn

*/

if (

O-'

'

fifi

c<

-'~

')

all

ow

-all

ow

ed;

for(

con

v-0

; *

all

ow

I-

HO

NK

;) {

if(*

all

ow

'!

')

con

v-

*(+

+a

llo

w)

>-

'a'

? 'A

'-'a

' :'

a'-

'A'

; if

(*

all

ow

'-

' fi

e *

(++

all

ov

-2)<

c fif

i c<

*all

ow

)re

turn

(c+

con

v)

; if

(*

all

ow

'\

\')

allo

w-H

-;

if(*

all

ow

c

) re

turn

(c+

con

v) ;

if

(* (

-H-a

llow

) I-

'-

')

con

v-0

; ) fp

utc

(BE

LL

, std

err)

;er

rmec

c ("

On

ly c

ha

ract

er*

all

ow

ed a

re

% '

, all

ow

ed)

; g

oto

get

it;

> wit

ch (

c)

{ /*

tr

eat

con

trol

chara

cter

*

*/

ca«*

E

SC:

c-0

17

7

fi g

etc

h()

;if

(cf-

'0'

fifi

cf-

' ['

) {

*rr

forn

("\0

07

Un

*zp

*ct

*d

ecc

ape

seq

uen

ce

%o"

,c);

g

oto

g

et it

; ) w

itch

(c-

0177

fi g*tc

h()

) {

'2':

c-

01

77

fi

get

ch()

; d

-017

7 fi

g*tc

h()

;if

((c!-

'2'

fifi

ct-

'3')

||

(d<

'0'

fifi

d>

'9')

) {

err

form

("\0

07O

nea

pec

ted

ecc

ap

e se

qu

ence

%

on,e

),

goto

g

et it

;} if

((0177

£ get

ch()

) f-

'x')

{

errfona ("\

007O

ne3c

pected cap* *qu*nc* ")

;goto get it;

} witch ((c-'0')*10+d-'0')

{cace

8: ret urn (Rl);

cace

9: ret urn (R2);

cace 10: return (R3);

ca** 25: return (F2);

caae 26: return (F3);

ca** 27

: ret urn (F4);

cace 28: return (r5);

caae 29: return (F6);

cace 30: return (F7);

cave

cace

cace

default:

case 31

: return (F8);

case 32 :

return (F9

) ;

default :

errf orn (

"\007Unexpected escape cod* %o",c)

( goto get it;

}

return (UPCUR) ;

/* UPCUR */

return (DN

CUR)

;

/* DNCUR */

return (RT

CUR)

;

/* RTCUR */

return (LFCDR) ;

/* LFCUR */

errform("\007Oneapected escape cod* %o",c);

goto get it;

case BSP:

case LTD:

case RET:

case TAB:

case DEL:

case CN

TRLD

:

case CNTRLC:

case BREAK:

default:

return(c);

return(BSP);

pchow-p*how?0:1;

if (fpshow) inform("«, 0)

;goto getit;

die(100);

errform(H\007Unexpected control code %o",c);

goto getit;

outchar(c,field,minf ,maxf,cnu

m, cmax)

char c;

int

*fi*ld,minf,naxf, *cn

um, cm

ax;

register i;

int

y;

repeat: switch (c)

{case UPCUR: *cnum -2;

goto out;

case DNCUR: *cnum cmaz; goto ou

t;

case RTCUR: if(*cnunKcmax-l)

{move(NRON,++NCOL);

goto out;

} else

{

goto out;

case LFCUR: if(*cnum>0)

{move (NROW, NCOL);

*cnum~ 2;

goto out;

else

{*cnum -2;

goto out;

case NONE:

default :

goto ou

t;

addch (c) ;

out:

(* cnum) ++;

if (re

f r) refresh ();

get field (index, ptr, ty

pe, baserow)

int index;

/* index into stform[] table

*/

Page 88: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

H- H- Hi H H|

"Bf "Bf &§ H| 0, H| 0. H- Rp.^. p.^ ft H,

H-. 0,*.'0: -tit i ? -

iri?

w n + m

fc!»

8*rft2

i

M i O H- O O

JSesrr 218*13 5-&H,8«Rc*m fl B -< H-

iihfrg

H- R !»

f-U'H,

ss^rt f. £:£

I IT

598 r-

s & f. f. 0. 0.

HI HI

.1 i

8

o- H-»r* b

Page 89: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

sted

it.c

gatf

iald

(cu

rfia

ld,f

icod

a,L

NG

,baaaro

w);

pri

ntw

("

(%a}"

,lia

t_co

da(c

od

a,a

tform

[cu

rfia

ld].

cod

ali

at)

);clr

toaol(

);

J if (

atfo

rm [cu

rfi

ald

]. f

typ

e M

ST

) {

gatf

iald

(cu

rfia

ld,

fiti

ad,M

ST

,baa

arow

) ;

if(t

iad

!-ato

f (N

OT

ZM

X))

prin

tw(-

{%

a} '

, lia

t_m

*ti

ma

(tia

d, 6

)) ;

clr

toa

olO

; } if

(atf

orm

[cu

rfi

ald

].ft

yp

a S

TT

) {

gatf

iald

(cu

rfia

ld,f

itim

l,S

TT

,baaaro

w);

if (ti

ml!

-ato

i (N

OT

IME

))pr

intw

("

{%.}

",l

i«t_

m*ti

me(

(dou

ble

)tim

l,7))

;clr

toaol

() ;

I char

num

-H-;

rafr

-1;

rafr

aah

();

goto

ba

gin

; I ala

a

char

nu

m-c

har

max

+1;

ra

fr-1

; g

oto

b

agin

; } in

itatf

orm

(p

tr,t

yp

e,la

n,b

aa

a)

char

*p

tr;

int

typ

e,la

n,b

aaa;

{ra

gia

tar

i,j;

int

nu

a,n

um

f,k

,col;

for(

i-b

ag_atr

uct

[typ

a];

atf

orm

[i]

.faty

pa«ty

fifi

atf

orm

[i]

.off

aat<

lan

;i+

+)

{ if

(atf

orm

[i].

na

ztf

aty

pa!-

0)

{in

itatf

orm

(ptr

,atf

ora[i

] .n

azt

faty

pa, la

n, a

tfo

rm[i

] .f

ozm

_rot

r);

J

sta

nd

ou

t ()

;n

oT*(

Mtf

ozm

[i]

. for

m_r

ow+

ba«

«,«t

form

[i]

.fo

zm_

cx>

l-«

trl«

ti(M

tfo

m[i

] ,f

nan

*)-

l) ;

pri

ntw

("%

", »

t for

m [ i

] . f

nam

«) ;

rt

and

*nd

() ;

col<

»«t f

ozm

[ i ]

. f oz

m_c

ol ;

inov

* (

tfozm

[i]

.foz

mjc

ow+

baM

a/M

tfoz

mti

] .f

ozm

_o

ol)

;

nu

mf-

1;n

uiv

nfi

dth

_fi

«ld

[«tf

om

[i]

.fty

p*

] ;

i f («tf

ozm

[ i

] . f

typ

» S

IR) n

uov>

»t fo

rm [ i

] . f

l«n

gth

;if

(«tf

orm

[ii

.fty

p«>

-SH

T

«tf

orm

[i]

.fty

p«<

-DB

L)

niB

t£««

tfoz

m[i

] .

for(

Jc-0

;Jc<

num

f;Jc

-H-)

{

for(

j-0;j

<n

um

;j-H

-)

{

k<

nu

mf-

l)

ba««

-H-;

pri

ntw

("_"

) ;

} if (c

x>l>

(MA

XC

OL

-nua

)

Iinclude <«gtty.h>

Iinclude <«y«/fil«.h>

load«tfoxa (ptr,typ«,l«n,ba««)

char *p

tr;

int

typ*,l«n,baM«;

reg

i«t*

r i,

j;in

t n

ua,

num

f, «*

p, c

ode,

col,

aft

er ;

char

t«B

»p[M

AX

OO

T] ;

ho

rt

*«h

; lo

ng *

lg;

flo

at

*ft

; d

oub

l*

*db

;

for(

i«b

ag_«tr

uct

[typ

«];

Mtf

orm

[i]

.f«ty

p« t

yp

«

M

tfo

rm

[i]

.off

«*t<

l*n

;i+

+)

cod

«-

-1;

nu

n*

vid

th_

fi«

ld[M

tfo

xm

[i]

.fty

pe];

if («

tfo

zm[i

] .f

typ

«=»S

TR

)nu

m-«

tfor

m[i

] .f

l«n

gth

; w

itch

(«tf

ora[i

].ft

yp

«)

{ca

««

CHR:

ch

=p

tr+

Mtf

orm

[i]

.off

««t;

prin

tf (t

emp

, at f

orm

[i]

.ff

orm

at,

*ch

) ;

if («tf

orm

[i].

cod

eli

«t!

-0)

cod

a-

*ch

;b

r*ak

; ca

M B

TS:

ca

«« K

IN:

ch=

ptr

+«tf

orm

[i]

.off

Mt;

prin

tf (t

emp

, atf

ozm

[i]

.f

form

at,

(in

t)*

ch

);

if ( t

form

[i].

cod

«li

Mt!

-0)

cod

«« *

ch;

braa

Jc;

ca«*

ST

R:

ch=

ptr

+«tf

orm

[i]

.off

aa

t; p

rin

tf (t

*mp,

mtf

orm

[ i ]

. f fo

rmat

, ch

) ;

bre

ak;

cac«

SH

T:

«h

-(«h

ort

*)

(p

tr+

*tf

ozm

[i]

.off

cat)

;if

(*

«h

=-a

toi

(NCX

3ATA

) ) M

pri

ntf

(tam

p, "

NODA

TA"

) ; !

Mp

rin

tf (t

amp,

«tf

orm

[i] .f

form

at, *

mh)

; if

( t

form

[i].

cod

ali

Mt?

-0)

cod

a-

*ah

; n

um

f««t

form

[i]

.fla

ngth

; b

raak

; ca

aa L

HC

: lg

»(l

on

g *

) (p

tr+

rtfo

rm[i

] .o

f fea

t) ;

if (

*lg

=-a

toi

(NO

DATA

) ) a

pri

ntf

(ta

mp,

-H

OD

ATA

") ;

laa ap

rin

tf (t

amp,

«tf

orm

[i]

. ffo

rma

t, *

lg)

;if

(«tf

orm

[i]

.co

da

lia

tl-0

) co

da

- *

lg;

num

f ««

tf or

m [i]

.fl

an

gth

; b

raak

; ca

aa F

LT

: ft

- (f

loat

*) (

ptr

+atf

orm

[i]

.off

aa

t) ;

if (*ft

-=ato

i (N

CX3A

TA) )

ap

rin

tf (t

amp,

"H

ODA

TA"

) ;a

laa

ap

rin

tf (t

amp,

at f

orm

[i ]

. ff

orm

at ,

*f t

) ;

nu

mf«

atfo

rm[i

] .f

lan

gth

; b

raak

; ca

aa D

EL:

db

-(d

ou

bla

*)

(p

tr+

«t f

orm

[i]

.o

ffse

t) ;

if (*d

b a

toi

(NCX

3ATA

) ) .p

rin

tf (t

amp,

"HO

D AT A

" ) ;

ala

a ap

rin

tf (t

amp,

atf

orm

[i]

. ffo

rma

t, *

db

) ;

nu

mf«

atfo

rm[i

] .f

lan

gth

; b

raak

; ca

aa L

LT

: d

b»(

dou

bla

*)

(p

tr+

atf

orm

[i]

.off

aat)

;if

(*d

b a

toi

(NCX

3ATA

) ) a

pri

ntf

(tam

p, "

NO

DA

TA")

;a

laa

ap

rin

tf (t

amp,

«tf

orm

[i]

. ffo

rma

t, *

db)

;b

raak

; ca

aa S

TT

: lg

-(lo

ng

*)

(ptr

tfo

zm[i

] .o

ffaat)

;if

(*lg

ato

f (N

OTI

ME)

) a

pri

ntf

(ta

mp,

"NO

TZM

B" )

;a

lia

ap

rin

tf (t

amp,

at f

orm

[i

] . f

form

at ,

*lg

) ;

bra

ak;

caaa

MST

: d

b-(

do

ub

la

*) (

ptr

+at f

orm

[i]

.off

aat)

;if

(*d

b a

tof

(NO

TXM

B) )

ap

rin

tf (t

amp,

"NO

TZM

B" )

;ala

a ap

rin

tf (t

amp,

at f

orm

[i]

.ff

orm

at,

*db

) ;

bra

ak;

caaa

CA

L:

caaa

CPX

: ca

aa

STZ

: d

afa

ult

:if

(atf

orm

[i].

na

xtf

aty

pa

!-0

) (

load

atf

orm

(ptr

, atf

orm

[i].

nazt

faty

pa,l

an

,atf

ora

[i].

form

_ro

w)

;

) bra

ak;

Page 90: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

sted

it.c

tam

p [n

um] -

NO

NE

; fo

r(aft

«r-

j-0;J

<n

um

;j-H

-)

{if

(t«

np

[j] H

ONE

) aft

«r»l;

if(a

ft*r ||

t«n

p[j

]--S

PA

)t[ j

] -S

PA

CE

;

ov

* (

*tf

orm

[i]

. for

m_r

ow+

ba«

«, *

tfom

[i]

. for

m c

ol)

; p

rin

tw ("

% "

, t*m

p);

~~

""

if

(cod

«>

-0)

{p

rin

tw ("

{%

}"

, li*

t_co

(co

,*tf

orn

[i]

.cod

«li

«t)

)

if (»

tfo

rm[i

] .f

typ

*--

KS

T

fifi

«trn

cap

(t«m

p, "

NO

TIM

E", 6

) f-

0)

pri

ntw

("

{% }

", l

ictj

Mti

n* (

*db

, 6)

) ;

if (»tf

orm

[i]

.fty

pe-

-ST

T

IS,

«trn

cmp

(t«m

p, "

NO

TIM

E", 6

) f-

0)

pri

ntw

("

{% }

", l

i«t

mat

in*

( (d

oub

le)

(*lg

) , 7

) )

; > r*

frM

h()

;

«*

tfo

rm(p

tr, t

yp

a, l

*n

,ba

««

,ba

««

row

)ch

ar

*p

tr;

int

typ

*,l

*n

,baB

«,b

a««ro

w;

rwg

i*t*

r i;

for(

i-b

*g_atr

uct

[typ

e];«

tfozm

[i].

1

if(«

tfo

rm

[i].

n*

xtf

«ty

p*

f-0

) (

av

**

tfo

rm (p

tr, tf

orm

[i].

naztf

aty

p*,i

t

form

[i].

form

_ro

w+

ba

««

row

);

g«tfi«ld(i,ptr+ba««+*tform[i] .

char

*in

fil«

n-H

UL

L;

char

*o

utf

il«

;ch

ar t

«mp

lat«

[ ] -

" *

t*d

it .X

XX

XX

X"

FIL

E *

«t_

inf ,

t_o

utf

;

t«d

it (

inf i

l«)

char

*

infi

l«;

(in

t in

p, t

yp

*,l

*n

, «t

num

, r«t;

char

*

ptr

; z

t«rn

ch

ar *

mk

t«m

p()

;ch

ar in

»tr

[5];

fifi

«tf

orm

[i]

.

, *tf

orm

[i]

.

tfo

rm

[i]

. f ty

p« , b

»««r

ow)

;

t_

inf-

«t_

op

«t (i

nf i

l«,

"r")

;if

(ft

rcm

p (

"ct

din

" , in

f il«

) 0)

*t_

ou

tf-*

t_op

«n

( "

ctd

ou

t M ,

"w"

) ;

t_ou

tf-«

t op

*n (

ou

tf il

«,

"w")

;

cl*arok (*td*cr, TR

0E)

; cl*ar();

r«fr««h();

/* n*«d«d to g*t un-cmd window in proper «ync

for («tnum-0; (inp-«t_g*t (fi

ptr,

fityp*, fil«n, «t_inf )

) f -EOF; «tn

um++

) {

cl«ar();

*/

BO

TO

(C

MD

_Y, C

MD

JX)

;p

rin

tw (

"E

dit

ct

ruct

ur*

%

d of

typ

* %

d (%

) of

len

gth

%

d b

yt««

",

tn

um

, typ

a, l

i«t_

cod

* (

typ

«, *

tru

ct_n

am««

) , l

«n

) ;

ta

nd

ou

t ()

; »O

Tr«

(0,1

5);

pri

ntw

("

F7

zt

ctru

ctu

r*

F2 a

bor

t w

ith

ou

t ch

ang*

");

tan

d*n

d()

;in

itvtf

orm

(p

tr, t

yp

*, l

*n

, 0)

;lo

ad

ctf

orm

(ptr

, ty

pa

, l*n

, 0)

;B

ov«(*

tfora

[beg

_«tr

uct

[ty

p«]

] .f

orm

_row

, «tf

om

[beg

tru

ct [

typ

*] ]

.form

_co

l)r*

f r««

h ()

;r«t-

«d

it«tf

or» (p

tr, t

yp

*, l

*n

, -1, 0

) ;

if(r

»t

F2

) br

wak

; a

v«*tf

orm

(p

tr, t

yp

a, l

«n

, 0, 0

) ;

t_p

ut

(ptr

, ty

, l«n

, *t_

ou

tf )

;> rw

fr«

«h

();

nd

_cu

r«««

()

;if

(r«

t F2

) u

nli

nk

(ou

tf il

«)

;if

(«tr

cm

p("

«td

in"

,in

fil«

)f-0

) {

in»tr

[0]-

SP

A;

wh

il«

(in

«tr

[0]l

-'y

' it

in

«tr

[0]

»-'

fp

rin

tf (*

td«

rr,

"Do

you

wan

t to

f*

can

f («

tdin

, "%

", i

nct

r) ;

*av«

th

«««

chan

g««?

(A

ncw

«r y

or

n)

")

if(i

n«tr

[0]

'y')

{

«t_

clo«« (

*t_

ou

tf )

;ty

p«-

r«n

am*

(ou

tf 1

1*, i

nf i

l«)

;if

(ty

-l

)«t_

«rror(d

i«,0

, > !

u

nli

nk

(ou

tfil

*);

t_in

f ) ;

r*na

iM of

%

to

%

f ail

ad

", o

utf

il«, in

f il

int

in;

char in*tr[5];

int

typ«;

_if (in

f il«n» -NULL fi£ trcmp(N*tdinM,infil*n)l-0)

( whil«(in»tr[0]»«'y'

fifi in

*tr[

0] !-'

n')

{fprintf (*td«rr, "Do you want to «av« th««« chang««? (Ancw«r y or n) ")

;f «canf (ctdin, " % "

, inc

tr)

;> if(in*tr[0] 'y'

|| in»tr[0] 'Y

' )

(«t_clo«« (*t_outf ) ;

typ«-r*nam* (ou

tf 11*

, inf il

«n)

;if(typ«M>- -l)«t_«rror(di«,0,

Mr«iaiM of % to % f ail*dM

, outf il

«, inf il

«n)

;

> ! unlink (outf il«);

> *t_cloM («t_inf )

; xit (in

) ;

zt*rn char *prognam*;

main(argc,argv)

int ar

gc;

char **

argv

;

r«gi*

t*r

i;

Page 91: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

sted

it.c

int nura£i

l,ou

tcl;

con

«»fo

p«n

("/d

«v/c

on

*ol«

",

"w")

;pz

ogna

ina>

*arg

v [0

] ;

nu

mfi

l 0;

ou

tcl-

1;

for

(i-1

; K

arg

c; i+

+)

{if

(*rov[i

][0]

'-')

{

dm fa

ult

: «t_

«rr

or

(0,0

, "

Un

r«co

gni c

«d a

rgu

nw

nt

% "

, a

rgv

[ i

] ) ;

!*

{ «t«

n

um

fil-

H-;

if (

nu

mfi

l-«

0)

{ t

«d

it("

«td

in"

);

Page 92: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/RE

AD

ME

Chang* pathname to your pathname

Put the>* lin«> in /etc/re.local

ju«t

before the 11n*

( eho

-n 'starting rpc and n«t *rvic*>:')

(echo

-n 'starting onlin* «q d*t*ctor:')

if

[ -£ /u«r/kataai/onlin«.run ]; th«n

/u>r/katmai/onlin*.run C

(*ch

o -n

( eho

'.')

fi

onlin*.run')

>/d«v/ooncol*

>/d«v/ooncol*

>/d«v/ooncol*

>/d«v/ooncol*

Page 93: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/Mak

efile

I H

ale*

eq

dete

cto

r,

real-

tim

e

eart

hq

uak

e d

ete

cto

r

OB

J-

04

4-

eq

dete

cto

r.o

get

mre

ep.o

cach

e.o

o

ut.

o a

rg

c.o

d

iag.o

d

yn

flag.o

eq

dete

cto

r.o

g

etsw

eep

.o

cach

e.o

o

ut.

o a

rg

c.o

d

iag.o

d

yn

flag.o

Ip

aop

en.o

rtp

.o

f u

«e

DL

PA l

ine fo

r

a D

EC P

DP

ll/4

4

or

11

/34

C

TIA

GS

m -g

68881

fCIT

AC

S -

-O

-DL

PA

eq

dete

cto

r:

$(O

BJ)

M

ak

efil

ecc

$(C

FIA

GS)

-o

eq

dete

cto

r

$(O

BJ)

..

/ato

d/C

DD

ato

d.o

-l

*u

-1m

on44

:

li*

t:

$(0

44)

Mak

efil

ecc

$(C

TIA

CS)

-i

-o eq

dete

cto

r

$(O

44)

en

«crip

t2

Te«tn

et.

c rtp

.c ou

t.c eq

dete

cto

r.c

Ip

aop

en.c

get

*w

eep

.c \

dyn

flag.c

d

iag.c

cach

e.c

argc.c

eq

dete

cto

r.h

Ip

a.h

k

ey

.h \

hea

der

.h M

ak

efil

e

insta

ll:

gecho

****

****

YOU Bust be cuperuaer to d

o thi«.

****

****

gecho

""chown root eq

dete

ctor

chmod

4755

eq

dete

ctor

cp eqd

etec

tor

/etc/eqdetector

out.o

: he

ader

.hargc.o

cach

e.o

d

iag.o

d

yn

flag.o

eq

dete

cto

r.o

getw

eep

.o ou

t.o

:

eq

dete

cto

r.h

Ipaopen.o

: key.h

Page 94: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/arg

s.c

/*

argv.c

proc*** command lin* argument* for onlin*.c

*/

finclud* "*qd*t*ctor.h"

fifnd*f LPA

finclud* <*tdio.h>

t*ndif

*xt*rn in

t di« ()

;

ffd

*fin

« AA

RG

arg

v[+

+i

< arg

e ?

i :

*t

*rr

or(

di*

,0,

"n

ot

*nou

gh a

rg*"

) ]

fd*fi

n*

IAR

G

ato

i (A

AR

G)

~~ff

d*

£in

*

FAR

E

«tof

(AA

RG

)

pro

c_arg

* (

arg

c, a

rgxr

) ch

ar

**arg

v;

{ r*gi*

t*r i;

in

t j,

n;

cha

r *arg

; fl

oat

ato

f ()

;

if(a

rge <

3){

prt_

arg*()

; *xit

(0);

}

for(i

»l;

i<

arg

c;

i++

) {

if(a

rgv[i

][0]~

'-')

{

for(a

rg-a

rgv[i

];

*arg!-

0;

arg+

+)

swit

ch

( *arg

)

{ca

** '-

'

ca** 'a

'ca

** 'b

'ca

**

'd

' ca

**

a

.2*s

ca**

' '

*4ca

**

'g

'ca

**

'j'

ca*

* '!

'ca

** 'n

'ca

** 'q

'ca

**

'r

'ca

** ' '

ca** 'u

'ca

**

'

ca*

* 'x

fca*

* ' v

'^ W

V

Jf

ca*

*

' i '

ca** 'c

'ca

** ' f

'ca

**

' o

'

fifd

af

LPA

ca** '0

'ca

** '!

'f*

ndif

LPA

|ifn

d*£ L

PAca

**

'0

'ca

**

'!

'

aft

*r

- FA

RG

;b*fo

r*

- FA

RG

;d*ci

m

- IA

RG

;convtl

-

ZAR

G;

con*t2

»

IAR

G;

thr*

*hold

-

ZAR

G;

dif

faam

-

1;

contt

ap*

« 1

;apart

ur*

«

FAR

G;

nch

an

« IA

RG

; h

ort

cut

« 1

;ra

t*

- IA

RG

; w

«*p

m

FAR

G;

nb

uf

- IA

RG

;co

n*t3

-

IAR

G;

con*t4

-

ZAR

G;

wav

_in

c «

IAR

G;

xch

g_

tap

* -

IAR

G;

dy

n_

flag

«

1;

buf*

s -

ZAR

G;

cach

_fi

l* -

AA

RG

;d

i*k

_fi

l* -

AA

RG

;lo

g_fi

l*

- A

AR

G;

tap

*_

fil*

«

AA

RG

;

tap*_fi

l* -

"/

d*v/n

rmtl

";ta

p*

_fi

l* -

"/d*v/n

rmt3

";

tap*_fi

l* -

"/d*v/n

r*tO

";ta

p* fi

l* -

"/d*v/n

r*tO

";

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

brM

k;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*a

Jc;

brM

k;

br*

ak;

br*

ak;

t*n

dif

fpri

ntf

(atd

*rr

,"O

nly

on*

ta

p* d

riv

«\n

"),

x

it (

1);

b

r*ak

;

ca*

*

'p':

p

**u

do

a2d

- A

AR

G;

br*

ak;

prt

_ca

chp

rt_

a2

dp

rt_ou

t

1;

cav*

caa*

caa*

caa*

ca>

*ca

>*

cav*

caa*

cav*

cav

*ca

«*

caa*

cav*

ca«

*ca

v*

cav

*ca

a*ca

a*

d*

fat

'D':

'C'

'E'

T'

'H'

'L'

'N'

'M'

'0'

'P'

'Q'

'R'

'S'

"C1

'XT

''V 'X

''2

'

lit

prb

_dia

g »

1;

prb

_*ta

a

» 1;

prt

vtr

g <

1;

prt

jbri

g -

1

;p

rt v

b«*

» 1;

prt

«t

av «

1

;p

rt

«t_

ab«

av

« 1;

prt

_caeh <

1;

prt

*

taa

> p

rt dia

g

« 1

;fa

k*_tr

ig-

1;

~"n

o

h*ad

»

1;

prt

_a2d

- 1;

not_

rtp

» 1

;p

rt_

»all

-

1;

prt

_p«t

«1;

prt

_p

arm

-

1;

fak*_ok

- 1;

prt

_»t_

ab»_av

-

prt

_d

iag

p

rt

«t_

av -

prt

dia

g «

1;

prt

tr

ig -

1;

prt

jtim

-

1;

prt

_vb«*

» p

rt tr

ig «

1

; x

it_

**

rly

m l;

prt

_«tr

g »

prt

__

dia

g 1

;

fpri

ntf

(*td

*rr

, "o

nli

n*

: c<

prt

_arg

«()

; *xit

(l);

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

br*

ak;

'%e'

n

ot l*

ga

l\n

",

*«rg

);

if(i

+2!-

«xgc)

t_*rr

or(

di*

,0,"

Zn

corr

*ct

nu

mb*

r of

fil*

na

me*

. t

atj

E il

*-a

rgv[i

++

]; u

bn

*t

Sta

tio

n fi

l* i*

%

,arg

v[i

]);

ta

tic c

har

*d

oc_p

arm

[]

» {

"PA

RA

MET

ERS"

, "a

aft

*r

cc"

, "b

b*£

or*

"

, "d

d*ci

mati

on

fa

cto

r",

"

*ta

co

nst

*

(3)"

, "g

dif

f M

m b

*f

con

pu

",

"1

l*n

ap

art

or*

«

c«"

, "n

num

ch

an f

rom

a2d

",

"q q

uic

k

ab

ort

cu

t*"

, "r

ra

t*

in h

«",

"

*w«*

p l*

n *

«c*"

, "u

num

a2d

bu

f*"

, "w

w*i

ght*

d a

v*

con

st*

",

"x x

chg

tap

* «

v«n

t*"

, "y

*n

abl*

d

yn f

lag

*"

, "I

bu

f *

ii*

in

wor

d*"

, "

- alo

n«:

d*fa

ult

*"

, 0

); t

ati

c c

har

*d

oc_

fil*

[] -

{ "F

ILE

S",

"c

each

*",

"f

di*

k fi

l*

ou

t",

"i

inp

ut

n*t"

, "p

p**

ud

o a2

d f

il*"

, "t

ta

p* o

ut"

, "0

ta

p* u

nit

0"

,

Page 95: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/arg

s.c

"1 tape unit 1",

"j write cont tape fi

le",

0 };

static char *doc_di»g[]

{ "DIAGNOSTICS",

"A al

l",

"C cache",

"D misc diagnstcs",

"K etas",

"T one fake trig",

"H no header write",

"L a2

d«,

"N no RI

P",

"M print malloc",

"o diag output file na

me",

"O output",

"P params",

"Q quit:

fake trig",

"R st_abs_av, lt_abs_av",

"S st

_av, lt_av",

"T trigger",

"U time usage",

"V verbose trigger",

"X exit after startup",

"Z station trigger",

o };

fdefine ge

t(s)

( *s

? *s++

: "«

)

prt_args()

{char **p-doc_parm, **f-doc_file, **d-doc_diag;

fprintf(stderr,"Arguments for online processing program version 7/27/88:\n\n") j

while( *p

|I *f

|| *d

)fprintf(stderr,"%-25s

%-25s

%-25s\n", get(p),

get(f), get (d) );

Page 96: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/cac

he.c

cache.c cache routines for online seismic detection system

There are three external routine* to be called from online.c:

cach_init(file_name, nbufbef, nbufaft, bu

fsz)

file_name: file name of disk cache or 0

for core cache

nbufbef:

time before trigger to save data in buffer load*

nbufaft:

time after trigger to continue writing in bufs

bufsz:

buffer size in words (s

ame a* Ipa buffer size)

trig_on ()

this function is called each time the system triggers.

pu

tea

ch(I

pa

bu

f)call

ed

fr

om

Ipar

ead

wit

h p

oin

ter

to m

ost

recen

tly f

ille

d b

uff

er

fft

incl

ud

e <

sys/

file

.h>

char

co

ntt

ap

[]-"

/dev

/nrs

tO"

;st

ati

c

sho

rt

*con

bu

f;

fin

clu

de

"eq

det

ecto

r.h

"

null«in core cache, else file name

*/

/* size of cache in buffers

*/

index of next cache buffer to use

*/

number of valid buffer* (u

su size)

*/

bool and number of future bufs to write */

/* initial value for trig ie nbuf to write */

/* buffer size in bytes (s

ame

size as Ipa) */

/* buffer size in words (s

ame

size as Ipa) */

/* in core buffer size in bytes (c

f cb

uf)

*/

cache file descr for get if not in core */

/* cache file descr for put if not in core */

/* pointer to in-core cache buffer space

*/

/* cache size in bytes (c

f in core malloc) */

/* diagnostic switch for cache routine*

*/

/* diagnostic switch for malloc printout

*/

cach_init(file_name, nbufbef, nbufaft, bufsz) char *file_name;

{ cach_file» file_name;

bufszw

bufsz;

/* xfer to global variable

*/

bufszb

- bufszw

* sizeof(short);

/* buf size on bytes from words */

nbuftrig - nbufbef + nbufaft;

/* on trig output nbuftrig bufs */

size

- nbufbef;

/* cache size in bufs

*/

cachszb - nbufbef * bufszb;

/* cache size in bytes

*/

if(cach_file)

{cbufszb - bufszb;

if(

(p_fd -

open(cach_file,

1))

< 0

){

if((p_fd - creat(cach_file, 06

64))

< 0

)st

_er

ror(

die

,0,"

Un

ab

le t

o cr

eate

ca

che

file

%

s",c

ach

_fi

le);

> if

((g

_fd

«

op

en(c

ach

_fi

le,

0))

<

0 )

st_er

ror(

die

,0,"

Un

ab

le t

o o

pen

ca

che

file

%

s",c

ach

_fi

le);

) els

e

{cb

ufs

zb

cach

szb

;if

(cb

ufs

zb

!-

cach

szb

)per

r("

on

lin

e/ca

che:

n

ot

enou

gh co

re"

);

)

if(prt_mall) *t_error(0,0,"cache:

malloc(%u)\n", cbufszb);

cbuf - (sho

rt *)malloc(cbufszb);

if(cbuf 0

|| cbufszb 0){

/******* malloc error *******/

st_error(0,0,***********

In-core cache is too large.

**********\n");

st_error(0,0,"Heed to re-adjust parameters or use disk-file cache.\n\n");

prt_mall - prt_cach 1;

}

/* call st_error() after more diags */

static ch

ar *cach

file-NULL;

/'static int

size;"

int

curr

ent;

static int

vali

d;£\

int

trig;

int

nbuftrig;

Static int

bufszb;

static

int

bu

fszw

;static int

cbuf

szb;

static

int

g f

d;static int

p~fd;

static short ~

~*cbuf ;

static long ca

chsz

b;extern int

prt

each

;ex

tern

int

prt

mall;

/* /* /* /* /* /* /* /* /* /* /* /* /* /*

if(prt_mall) fprintf(stderr,"cache:

malloc(%u) %u\n\n", cbufszb, cb

uf);

if(prt_cach){

fprintf(stderr,"cache nbufs nbytes bufszw bufszb nbuftrig cbufszb\n");

fprintf(stderr,"%5s %5d %6D %6d %6d %8d %7d\n\n", cach_file?"disk":"core",

size,

cach

szb,

bufszw, bufszb,

nbuftrig, cbufszb);

)

if(cbuf 0

|| cbufszb 0)

st_error(0,0,"error in init_cach: attempt to malloc(%u)\n", cbufszb);

if (conttape)initconttape();

sho

rt

*g

etca

ch(n

) {

if(c

ach

_fi

le){

if(l

*eek

(g_

fd,

(lon

g)n

*

(lon

g) b

ufs

zb,

0)

< 0

)*t_error(die,0,"Unable to l*eek in cache file");

if(read(g_fd, cbuf,

bufszb)

!- bufszb

)*t_error(die,0,"Unable to read cache file");

return(cbuf);

return(cbuf + n*buf*zw);

/* called from a2dread */

puteach(Ipabuf) short *Ipabuf;

{ if(cach_file){

if(write(p_fd,Ipabuf,buf*zb) !-

bufszb)

*t_error(die,0,"Unable to write full buffer to cache file");

if(current+l >- size)l*eek(p_fd, OL

, 0);

) else copyw(Ipabuf, cbuf+current*buf*zw, bufszw);

if(conttape)writecont(Ipabuf);

if (++

curr

ent

> size)current £;

/*

now index of oldest buffer

*/

if (va

lid

<

size)valid++;

/* oldest valid when valid size */

if (trig SS valid size) {

wrtfile( geteach(current) );

trig ;

if (I

trig

) tr

ig_p

f f ();

)

trig

_on

()

{if

(prt

_ca

ch)f

pri

ntf

(std

err,

"\n

cach

e:tr

ig_on

: %

tr

igg

er\n

",t

rig

?"

old

":"

new

"),

if (I

trig

) n

ewf i

le (

) ;

trig

^n

bu

ftri

g;

tatic trig_off ()

{if (pr

t_ca

ch) st_error (0,

0, "\ncache :tr

ig_o

ff:

trigger just went off\n");

endf ile ()

;

tatic copyw (fr

om, to, nw

ords

) short *f

rom,

*to;

{ short *f

, *t;

f«fr

om;

t-to

; while (nw

ords

> 0) *t++ - *f

++;

int

fdco

ntt

ap

e;

int

con

nu

m,b

lock

*z;

int

init

con

tta

pe

(){

connuu-5120/bufszw;

blocks ZBConnum*bufszw*sizeof (short) ;

Page 97: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds :/

usr/

suds

/src

/cm

d/eq

dete

ct/c

ache

.c

fdconttap*«op*n (co

ntta

p, O W

R.ON

LY)

; if(fdconttap*<-2)

{ ~

*t_*rror(0,0,"Unabl* to op*n tap* %s for writing.\n",conttap);

conttap*

««0;

r*tttrn (0

);

) conbuf*(short *)malloc(block*z);

if (conbuf 0)

{ t_*rror(0,0,"Dnabl* to malloc(%d) for continuous tap*.\n",blocksz);

do** (fdconttap*)

;conttap*«0;

r*tu

rn(0

);

) fpri

ntf

(*td

*rr

,"W

riti

ng

ta

p*

: %

d b

uff

*r*

or

%d

byt

pwc

blo

ck.\

n"

,co

nn

um

,blo

ck*a

);

r*tu

rn(1

);

int numb*r«0;

writ* co nt(Ipabuf)

hort *lpabuf;

{in

t r*

t;

copyw(Ipabuf,conbuf+numb*r*buf*zw,buf*zw);

if(++numb*r> connum)

{ret-writ*(fdconttap*, conbuf,block*z);

^

if(r*t<block*z)

{cl

oc*

(fd

con

ttap

*);

co

ntt

ap

*-0

; fp

rin

tf(*

td*

rr,

"C

onti

nu

ous

tap

*

i* fi

nis

hed

. W

rot*

%

d b

lock

s o

f %

d b

yt*

s.\n

",

nu

mb

*r,

blo

cksz

);

r*tu

rn(0

);

} nu

nb

*r-0

;

Page 98: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/dia

g.c

/*

diag.c

diagnostic printouts for online.c

*/

finclude "eqdetector.h"

fdefine

MLIME

16

f define

MXNN(x,y)

(x < y ? x

: y)

wrt

_par

ams

()

{ in

t i,

j,

k

; lo

ng n

ow,

tim

e()

; ch

ar *

ctim

e();

dou

ble

sp

b «

bu

fsi/

(dou

ble

)(n

cha

n*

rate

);

/*

sees

per

bu

f */

now

»

tim

e(0);

fpri

ntf

(std

err,

"E

qd

etec

tor:

n

etw

ork

%

s:

beg

in a

t lo

cal

tim

e:

%s"

, n

etw

ork

,cti

me(

fin

ow

));

if(!

prt

_p

axm

fifi

!p

rt_

dia

g)

{ if

(pse

ud

o_a2d

)fp

rin

tf(s

tderr,"

data

fr

om p

seu

do

a2d

fi

le

%s,

no

t a2

d\n

",

pse

ud

o_a2

d);

re

turn

; }

fprin

tf(s

tderr,"

b

efore

aft

er

wri

te ap

ertu

re

swee

p

rate

\n"

);

fprin

tf(s

tderr,"

pse

cs

%8g

%

8g

%8g

%8g

%8g

l/

%D

\n"

,b

efo

re,

aft

er,

bef

ore

+aft

er,

ap

ertu

re,

swee

p,

rate

);

fpri

ntf

(std

err,

"sa

mp

s %

8D

%8D

%

8D

%8D

%

8D

%Sd

\n",

ns_

bef

ore

, n

s_a

fter

, n

s_w

rite

, n

s_a

per

ture

, n

s sw

eep

, 1);

fp

rin

tf(s

tderr,"

bu

fs

%8d

%

8d

%8d

%

8.3g

%

8.3g

\n"

,~n

bjb

efo

re,

nb

_aft

er,

nb

_b

efo

re+

nb

_a

fter

,(n

sw_

ap

ertu

re*sw

eep

)/sp

b,

swee

p/s

pb

);

_£)

fprin

tf(s

tderr,"

ase

cs

%8g

%

8g

%8g

%

8g

%8g

\n\n

",n

b_b

efor

e*sp

b,

nb

_a

fter

*sp

b,

(nb_before+nb_after)*spb,nsw_aperture*sweep, sweep);

fprin

tf(s

tderr,

"n

sta

dec

im c

on

stl/

con

st2

thre

sh co

nst

3/c

on

st4

wav

_in

c b

ufs

i n

bu

f n

chan

sec

/bu

f\n

' fp

rin

tf(s

tderr,

"%4d

%

5d

%6d

/%-6

d %

6d %

6d/%

-6d

%6d

%Sd

%

4d %

5d %

7g\n

\n"

,n

sta

tio

ns,

dec

im,c

on

st1

,co

nst

2,t

hre

sho

ld,c

on

st3

,co

nst

4,w

av

__

inc,

bu

fsi,

nb

uf,

nch

an

,sp

b);

wrt

_sn

et(s

tan

am

es,

sub

net

, n

sta

tio

ns)

;

fpri

ntf

(std

err,

"T

rigger

ing c

omp

uta

tion

wil

l b

e d

one

on t

hes

e st

ati

on

s:\n

");

fp

rin

tf(s

tderr,"

\n"

);

for(j-0; j<nlook; J+-NLXNE){

k - MIN»(j+NLINe, nlook);

for(i-j; i<k; i-H-) fprintf (st

derr

, "%4d ",

i ); fprintf(stderr,"\n") ;

for(i-j; i<k; i-H-)fprintf(stderr,"%4d ",looksta[i]); fprintf(stderr,"\n") ;

for(i-

j; i<k; i-H-)fprintf(stderr,"%4s ", stanames[ looksta[i] ]);

fprintf(stderr, "\n\n");

)

if(cach_file)fprintf(stderr,"cache is on disk file %s\n",cach_file);

else fprintf(stderr,"cache is in core\n");

if(tape_file)fprintf(stderr,"output to tape: %s\n",

tape_file);

if(disk_file)fprintf(stderr,"output to disk:

%s<date+time>\n",disk_file);

if(diffsam

)fprintf(stderr,"samples differenced before computation\n") ;

if(dyn_flag )fprintf(stderr,"dynamic flags enabled\n");

if(pseudo_a2d)fprintf(stderr,"data from pseudo a2d file %s,

not a2

d\n"

,pseudo_a2d);

fprintf(stderr,"\n");

) wrt_snet(staname, subnet,

nsta

) char staname[][HSZ]; int *subnet;

{ int i,

j,

k, nsub-0,

lensub-0, thresh,

st_num;

for(j-0;

j<nsta; J+-HLINE){

k -

MX

NN

tj+N

LX

NE

, n

sta)

; fo

r(i

-j;

i<k

; i-H

- ) f

prin

tf (

std

err,

"%

4d

for(i

-j;

i<k

; i-

H-)

fp

rin

tf (

std

err,

"%

4s

fprin

tf (

std

err,

" \n

" )

; )

, sta

nam

e [i

] );

fprin

tf(s

tderr,"

\n"

),

fprin

tf(s

tderr,"

\n"

),

wh

ile

( (t

hre

sh

« su

bn

et [l

ensu

b-H

-])

!- -

1

) {

fprin

tf (st

der

r, -

\nsu

bn

et

%d:

%

3d

",

nsu

b+

+,

thre

sh);

w

hil

e (

(st_

nu

m

- su

bn

et[l

ensu

b+

+])

!-

-1

) fp

rin

tf (

std

err,

"

% "

, st

anam

e [s

t_n

um

] );

)

fprin

tf(s

tderr,

"\n

\nsu

bn

et v

ec:"

);

for(i

-0;

Kle

nsu

b;

i-H

-) f

prin

tf (

std

err,

%d

",s

ub

net

[i])

; fp

rin

tf(s

tderr,"

\n\n

"),

Idef

ine

PR

T(m

es,v

ar,f

mt)

{f

pri

ntf

(std

err,

"%

s:«

,mes

),

for(i

-j;

i<k

; i-

H-)

{

\ st

_nu

m -

lo

ok

sta

[i];

\

fprin

tf(s

tderr,f

mt

,va

r);

)

fprin

tf(s

tderr,"

\n«);

)

wrt

_d

iag

s(fo

rce)

{

int

i,

j,

k,

st_n

um

;

/*

fprin

tf(s

tderr,"

\n"

);*/

for(j

-0;

j<n

loo

k;

J+-N

LIN

E-1

){

k -

MT

NN

(j+M

I.Z

HE

-l,

nlo

ok

);PR

T("

nam

",

PRT

("nu

m",

if(p

rt_

st_av ||

forc

e)P

RT

("st

a"

, if

(prt_

st_

av

||

forc

e)P

RT

("lt

a"

, if

(prt

_st

_a

bs_

av

||

forc

e)P

RT

("st

aa"

if

(prt

_st

_a

bs_

av

jj

fo

rce)

PR

T("

Itaa

"

i f(p

rt_

eta

s ||

forc

e)P

RT

("

eta"

, if

(prt_

strg

|j

forc

e)P

RT

("tr

g"

, fp

rin

tf(s

tderr,"

\n"

);

)

stan

ames

[st_

nu

m]

st_n

um

stas[st_num]

ltas[st_num]

abs_stas [st

_num

]r

abs_ltas[st_num]

etas[st_num]

sta_trigger[st_num]

%4s"

"%5d

" "%

5d"

"%5d

" "%5d"

"%5d

" "%

5d"

"%5d"

perr(message) char ^message;

{st_error(0,0,"online: error on st

ate

xit (1);

int

\"%s\"\n",message);

Page 99: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/dyn

flag

.c

dynflag.c

Subroutina dynflag (na

ma_o

f_fl

ag)

for

controlling tha

calling

program dynamically through usa of a

dasignatad namad fi

la.

Tha

flag is

signaled ait

har by cr

aati

on or

tou

chin

g of a fi

la.

Jamas

N. Harriot

Sapt

amba

r 1,

1986

B«ijing, China

finc

luda

"aqdatactor.h"

fincluda <sys/typas.h>

fincluda <sys/stat.h>

fdaf

ina

MAXDICT

16fd

afin

a MAXLEN

16fdafina

aq

tstr

cmp

ck_fl

ags(

) {

stati

c s

av

a_

«t_

av

, sa

va

_st

_a

bs_

av

, sa

va a

tas,

sa

va_st

rg,

sava_d

iag,

notf

irst

ima;

if(t

notf

irst

ima

){

/*

ram

amba

r in

itia

l st

ata

of

fla

gs

*/

sav

a_

dia

g -

prt

_d

iag;

sav

a_

st_

av

« p

rt_st

_av;

sava_st

_ab

s_av «

prt

_st

_ab

s_av;

sava_ata

s -

prt

_ata

s;

sava_st

rg -

prt

_st

rg;

no

tfir

stim

a -

1;

)

if (

fsava_st

_av)

prt

_st

_av -

dy

nfl

ag

("st

_a

v"

);

/* if

no

t in

it sa

t th

an

dyn

*/

if (

f sa

va

_st

_a

bs_

av

) p

rt_st

_ab

s_av -

dyn

f lag (

"st

_ab

s_av

")

; if

(fsa

va_ata

s)

prt

_ata

s « d

yn

flag("

ata

s");

if

(fsa

va

_st

rg

) p

rt_

strg

« d

yn

fla

g("

strg

");

if (

dyn

f la

g ("

all

")

) p

rt_st

_av -

prt

_st

_ab

s_av -

prt

_ata

s -

prt

_st

rg -

1;

if(

fsa

va

_d

iag

){

if

(prt_

st_av

| als

ap

rt_st

_ab

s_av

| |

prt

_ata

sp

rt_

strg

) p

rt_

dia

g <

p

rt_d

iag «

0;

}

if(

dyn

flag("

trig

gar"

) )f

ak

ajb

rig

- 1

; if

( d

yn

fla

g("

ha

rik

ari

")

)st

_arr

or(

0,0

,"\n

(sim

ula

tad

) LP

A r

aad

fail

ura:

pla

asa

rast

art

on

lin

a p

rogr

am"

);

) char

st

atdi

ct[M

AX

DIC

T][

MA

XL

EN

];

lon

g

stat

tim

a[M

AX

DIC

T];

look

up

(nam

a)

{ in

t i;

for(i

-0;

i<M

AX

DIC

T

CC st

atd

ict[

i][0

];

i++

) if

( aq

(nam

a,

statd

ict[

i])

) ratu

rn

(i);

if(i

MAXDICT)

{ fprintf (s

tdar

r,"s

tat

dictionary ovarflow\n")

; az

it(l

);

)

strcpy (statdict [i] ,

nama

);

stattima [i] -

0;

raturn(i)

;

lon

g g

atti

ma(

nam

a)

char

*

pu

ttim

a (

nam

a,

t)

char

*;

{ ra

turn

( st

att

ima [

look

up

(nam

a) ]

) ;

} ;

lon

g t

; {

sta

ttim

a [

look

up

(nam

a )]

«

t;

}

long fi

ltim

a (nama) ch

ar *

nama

; (

int

fd;

stru

ct stat st

atb;

fd

> opan (nama,

0) ;

if(fd

< 0) raturn(O);

fsta

t(fd

, Cstatb);

closa(fd);

raturn(statb.st_mtima);

dynflag(nama)

char

*nama;

{ int

fd;

long t

, f;

/* rtns la

st filtima

or 0

1st tima

/* rtns mod tim

a or 0 if

nonazistant

t g

atti

ma(n

ama)

;f -

filt

ima (nama);

puttima (nama, f);

/* fprintf (s

tdar

r,"d

ynfl

ag(%

s) t-%D f-%D\n", na

ma,

t, f);

*/

ratu

rn(

f >

t);

/* fi

la must

axis

t an

d ba naw

or nawar */

fifdaf DEBQ6

main

(arg

c, ar

gv)

char

**a

rgv;

{

int

s, i;

if(argc <

3){

fprintf (s

tdar

r, "Us

aga:

dynflag

slaa

ptim

a namas\n");

xit

(l);

)

s -

atof(argv[l]);

whil

a(l)

{

for(

i-2;

i<

argc

; i+

+)if

(dyn

flag

(arg

v[i]

)) fprintf(stdarr,"Got

dynf

lag:

%s\n", ar

gv[i

]),

slaap(s);

) ) fandif

Page 100: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/eqd

etec

tor.c

eqdetector.c

Online aeiamic processing system with LPA or CDD Data Sampler

J. Harriot

and

D. long

USGS

, Manlo Park,

CA,

August, 1982

PLHard, Auguat 1987,

Juna,

July

, 1988

Program faaturaa:

1. DMA from LPA (buffer

ai ze and numbar of bufa se

t dynamically) .

2. Cacha in oora or on disk fila (raw or cookad)

as desired.

3 Automatic triggaring and all i/o in ona raal-tima procaaa.

4. Final output on diak or tapa or both aa desired.

5. Output ia compatabla with Ping and Pong programa.

6. Hoat parameters dynamically aa

t from command li

na.

7. Many aaiamically important arguments ara in aaconda (not buf a)

.8. Khan executed with no arga,

option* ara documented.

*/

Idefine GROUPZD

2Idefine USERZD

2Idefine DETECTDIR

"/uar/eqdetector/detected"

Idefine DETECTLOG

"detect.log"

Idefine PERMISSIONS 0133

/* umaak */

linclude <atdio.h>

linclude <aya/file.h>

linclude <aignal.h>

linclude "eqdetector.h"

char *progname;

_£} die (n)

Cs

int

n;

{fprintf(atderr,"%a: Die called with arg~%d\n",progname,n);

exit(n);

/*-

atatic char *aqdot

tatic char *onsta

aet_defaulta()

{

aet_defaulta c param_init

-*/

"online.ata"

/* if no diak or tapa uaa thia

/* default network input fila

*/ */

nchan

befo

reafter

aper

ture

aweep

decim

bufaz

conatl

cona

t2th

resh

old

cona

t3co

nat4

wav in

cdiffaam

dyn

flag

lifd

ef LP

Arate

nbuf

lendif LPA

lifn

def LPA

m m m « m m m m m m m m m m m

16 20.

60.

20. 3. 1

20482 1 5 7 8 1 0 0 50 2

/* numbar of a2d channela

*/

/* aaconda of data aave bef trig

*/

/* aeconda of data aave aft trig

*/

/* aeca for coincident atatn trig */

/* aeca of data for short term av */

/* decimation for trigger caIcing */

/* buffer aize for a2d reada, ahorta */

/* numerator of long-term weight

*/

/* denominator of long-term weight*/

/* minimum ata for a trigger

*/

/* weigted average numerator

*/

/* weigted average denominator

*/

/* weigted average increment

*/

/* don't diff aampa bef computatn */

/* dynamic flaga are not enabled

*/

/* sampling rate in aamplea/aec

/* nun of bufa for a2d to uae

*/ */

param_init()

{long nhunk

(long)nchan

rate

nbuf

lendif

100

; 1

;/*

sampling rate in aaaplea/aec

/* num of bufa for a2d to uaa

*/ */

* de

cim;

/* getaweep az worda */

bufaz

bufaxb

(bufaz/nhunk) *

nhunk;

/* want multiple

bufaz

* aizeof(short);

/* in bytea

*/

*/

na_

bef

ore

« b

efo

ren

a_aft

er

a

fter

na_

wri

te

n

a_b

efore

na_

aper

ture

«

(ap

ertu

ren

a_aw

eep

(aw

eep

nb

_bef

ore

nb a

fter

« (n

a_

bef

ore

«

(na

aft

er

* ra

te;

/*

num

aam

pla

a ...

*/

* ra

te;

+ n

a_aft

er;

* ra

te)

/ d

ecim

;*

rate

) /

dec

im;

/*

Not

e:

dec

im d

iv */

* n

chan

+ b

ufa

z -

1) /

bu

faz;

* n

chan

+ b

ufa

z -

1) /

bu

faz;

naw

_ap

ertu

re

« ap

ertu

re/

awee

p;/*

aperture of aweepa */

lifdef LPA

/* for 44

unix,

veraion 7

*/onquit(){signal(SIGQUZT,onquit); fake_trig»l; fprintf(atdarr,"\nFaka trigger\n");}

lendif LPA

lifndaf LPA

/* for unix veraion 4.2bad */

onquit(){fake_trig»l; fprintf(atderr,"fake trigger\n");}

lendif

/* .

main(argc,argv)

int

argc;

char **

argv

;

in

-*/

FIL

E *te

mp

file

,*ef

op

en()

,

pro

gn

am

e«a

rgv

[0];

/*

um

aak

(PE

RM

ISS

ION

S);

ch

dir(

DE

TE

CT

DZ

R)

;if

(a

etg

id (G

RO

UPZ

D))

st_

erro

r (0

,0,

"u

nab

le t

o aet

gid

")

; if

(aet

uid

(US

KR

ID

))a

t_er

ror(

0,0

,"u

na

ble

to

aet

uid

");

*/

aet

_d

efau

lta()

; /*

a

et a

ll

par

amet

ara

to d

afa

ult

a */

pro

c_arg

a(a

rgc,

arg

v);

/*

ch

ange

par

amet

er*

giv

en i

n

com

man

d li

na

*/

/* D

isco

nn

ect

sta

nd

ard

in

pu

t fr

om t

erm

inal

and

att

ach

to

/d

ev/n

ull

*/

/*

clo

se(f

ilen

o(a

tdin

));

op

en("

/dev

/nu

ll"

, O

_RD

ON

LY);

*/

/* D

iver

t st

and

ard

ou

tpu

t an

d st

and

ard

err

or

to a

lo

gfi

la */

/*

tem

pfi

le-e

fop

en(D

ET

EC

TL

OG

,"a+

");

fclo

ae

(std

ou

t);

fclo

ae(a

tderr);

dup(fileno(tempfile));

dup(fileno(tempfile));

fcloae(tempfila);

*/

/* Increase priority where initial priority is unknown */

/*

if(nice(-40)!-0) st_error(0,0,"Unable to set nice 20");

if (ni

ce (

16) !-

0) at error (0,

0, "Unable to set nice 4");

*/if

(!d

isk

_fi

le

*c

ttap

a_fi

la)d

isk

_fi

le e

qd

ot;

/*

fi

nal

ou

tpu

t */

hea

d_in

it()

; /*

re

ad in

on

lin

e.a

ta n

et fi

le

*/

para

m_in

it()

; /*

d

eriv

ed p

aram

eter

* ca

lula

ted

*/

Page 101: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/eqd

etec

tor.c

wrt

_par

ama

() ;

if(e

xit

_ea

rly

)ex

it (

0) ;

if(f

aka_

ok)a

ign

al(S

IC<

2OX

T,

on

qu

it);

/*

dis

pla

y v

alu

ea o

f p

aram

eter

* */

/* fo

r t

aati

ng o

nli

ne

ata

rtu

p

*/

I*

fak

e tr

igger o

n c

ntl

-\

key

*/

cach

_in

it(c

ach

_fi

le,

nb

_bef

ore,

n

b_aft

er,

bu

fax

);

a2d

op

en(r

ate

, 0,

1

, n

chan

, n

bu

f,

bu

fax

);/*

in

it

each

* */

/*

open

a2d

*/

lifd

ef

LPA

if(!

not_

rtp

cc

!pae

ud

o_a2

d

CC rtp

(l)

0)

/* rea

l ti

me

pro

ceaa

*/

fprin

tf(a

tderr,"

on

lin

e

pro

ceaa

%

d aet

to

ru

n R

TP

\n"

,getp

id()

);

ela

e fp

rin

tf(a

tderr,"

on

lin

e p

roce

aa

%d

HO

T aet

to

ru

n K

FP

\n"

,get

pid

());

le

nd

if L

PAeq

det

ecti

on

() ;

/* eq

det

ecti

on

: calc

ula

te r

un

nin

g aver

agea

an

d tr

igger o

n a

uap

acte

d e

ven

ta */

eqd

etec

tion

()

int

i,a

,j,a

am

p,d

iff;

abor

t *p

aam

p;a

tati

c i

nt

laat

aan

p[M

AX

_ST

A],

thia

aam

p;

for(

awee

pn

um

-0;

1;

awee

pnum

++){

for(a

-0;

a<

na

tati

on

a;

a++

)at_

aum

[a]»

at_a

ba_

aum

[a]-

0;

if(a

hortc

ut

cc tr

ig){

for(i

-0;

i<n

a_aw

eep

; i+

+)g

eta

wee

p()

; co

nti

nu

e;

/* «p**d abort cut

*/

/* ignor* a2d data

*/

/* don't call trigger */

for(i-0;

pcaop - g«t«w««p();

/* for *ach mmpl*

/* g«t 1

anpl«/«tat

*/

*/

o/*

for(

a-0

;a<

16;a

++

)fp

rin

tf(a

tder

r,"

%d

M,

paa

mp

[a]S

OxT

);fp

rin

tf(a

tderr,"

\n"

);

*/

/* p

rin

t h

ead

era

to

ahow

a2d

wor

kin

g */

/*

juat

aom

e ata

tion

a */

/* g

et ata

tion

num

ber

*/

/* get

a2d

aa

mp

le

*/

/*

uaa

dif

fere

nce

*?

*/

/*

aave

cu

rr

aam

ple

*/

/* d

iff

wit

h l

aat

*/

/*

rem

embe

r la

at

aam

p */

/* d

iff

for

aba

fun

c */

/*

add

to

reg

aum

a */

/*

and

recti

fied

au

ma

*/

for(j»0; j<nlook;

a - lookata[j];

aamp - paamp[a] - A2D_ZERO;

if(diffaam){

thiaaamp

«aamp;

aamp

«thiaaamp-laataamp[a];

dif

f -

rnm

op -

lta«[«

]; t

_«u

m[«

] +m

a

ap

; t

_ab

«_«u

m[c

] +

- A

ba (

dif

f ) ;

if(

dyn

_fl

ag

) ck

_fl

«g«()

; if

( tr

igger (

) )

trig

_on

();

/* ck dynamic flaga

/* may trigger

*/

*/

/* tr

igg

er:

don

a on

e* a

fta

r a

ach

na_

aw*a

p»a

w»«

p+

rate

/dac

im

*/

trig

ger()

{

/* ca

lc a

taa,

ata

tion

and

maa

tar

trig

ger

* */

regia

ter i,

m

; /*

re

turn

: l^

aate

r t

rig

ger,

0-n

o tr

igger */

int

eta

, ata

, ab

a ata

, n

ew_

lta

, ne

w a

ba

_lt

a,

tbre

ah

;a

tati

c f

iratt

ime-

T;

~*

if(f

iratt

ime){

for(i

-0;

i<

nlo

ok

; i+

+)

{a

- lo

ok

ata

[i];

Itaa [

a]«a

t_au

m[a

]/n

a_a

wee

p;

ab

«_lt

aa[a

]»at

aba_

aum

[a]/

na_

awee

p;

firatt

ime-0

; ~

if

(prt

_d

iag)w

zt_d

iaga (

0) ;

re

turn

(0);

if(fake_trig)

{ fake_trig-0; return (1);

}/*

one-time fake trig */

for(i

-0;

i<

na

tati

on

a;

a -

loo

ka

ta[i

];

ata«

at_a

um

[ a ] /

na_

awee

p;

aba_

ata«

at_a

ba_

aum

[a]

/na_

awee

p;

eta - aba_ata -

(conatl

* aba_ltaa[a]) /

conat2 -

aba (Itaa [a] -ata) - threahold;

new_lta - (ata +

conatS *

Itaa [a]

) /

cona

t4;

if(new_lta ltaa[a]){

if (ata > ne

w_lt

a)ne

w_lta-H-;

if (

ata

< n

ew_lt

a)n

ewJL

ta ;

) new

_ab

e_lt

a«(a

ba_ata

+co

nat3

*ab

a_lt

aa[a

])/c

on

at4

; if

(new

_ab

a_lt

a a

ba_

ltaa[a

] )

{if

(ab

a_at

a >

new

_ab

a_lt

a)n

ew_a

ba_

lta-

H>

way

_in

c;if

(ab

a_at

a <

new

_a

ba

_lt

a)n

ew_

ab

a_

lta

-«w

av

_in

c;

) Itaa [a

] -

new

_lta

; ab

a_lt

aa[a

]

naw

_ab

a_lt

a;

if(a

ta_tr

igger[a

])ata

_tr

igger[a

]~;

if (et

a >

0)a

ta_

trig

ger

[a]

- n

aw_a

per

ture

;

eta

a[a

]^et

a;

ata

a[a

]«ata

; ab

a_ata

a[a

]«ab

a_ata

;

/* weighted avg

*//*

if no change

*//* favor ata...

*//*

over long avg

*/

/* weighted avg

*//*

if no change

*//*

favor ata...

*//*

over long avg

*/

/* age trigger

*/

/* aet atatn trig */

/* aave for diagn */

if (prt_diag) wrt_diaga (0) ;

if (log_f il

e) f f luah (at

derr)

;

/* loop thru aubnet vector looking for a particular aubnet

whoae number of triggered atationa ia >- to tbreah for that net.

Structure of aubnet where threahvthreahhold and an-atation num ia

: <threah> <an> <an> ...

-1 <threah> <an> <an> ..

. -1

...

-1 -1

ie

, threah-an groupa aeparated by -1 all terminated by -1 -1

i-0;

wh

ile

( (t

hre

ah

- au

bn

et [i+

+])

!-

-1

)

wh

ile

( (a

-

aub

net

[i+

+])

!-

-1

)

if(

(th

rea

h a

ta_

t rig

ger

[a]

> 0

)

retu

rn (0

) ;

<-

0) r

etu

rn (1

);

Page 102: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/get

swee

p.c

get sweep, c m2d read routines for stdio-like access

The following routine* are called from online. c:

open and ioctl for SCSI atod or for Ipa call

a2dopen(rate, ichan,

ch

ani,

nc

han,

nbuf,

buf si

) Eg

: SO

L,

0,

1,

16,

2,

2048

Open* a2d.

Lock* in core mo no Bailees after this point.

get sweep ()

Return* pointer to a vector of cample* of one time *lice.

If decim I-

1 time *lice* will be skipped accordingly.

a2dread()

This routine is only called by get* weep or a getsweep macro.

Lparead read* one buffer from a2d and call* put each.

f include "eqdetector.h"

include <*tdio.h>

include <*y*/type* . h>

include <*y*/*tat.h>

include <*y*/timeb.h>

ifdef LPA

include <whoami.h>

include " Ipa . h"

define BSIZE 1

fendif LPA

lifndef LPA

I define BSIZE 4096

f include <*y*/file.h>

I include <*y*/ioctl . h>

I include <*y*/type* . h>

stati

c

char

A2D

[] -

"/d

ev

/rst

l";

fin

clu

de

<*ig

nal.

h>

in

t in

tr-0

; on

intr

()

{ in

tr*l;

lendif

f d

efin

e H

BPN

iie

of(

*h

ort)

/*

num

ber

of

by

te*

per

wor

d */

tati

c d

oub

le b

efjb

ime,

aft

jtim

e,

now

jbim

e; t

ati

c

dou

ble

cl

ock

()

{ st

ruct

ti

meb

tp

; ft

ime(

tt

p );

re

turn

( tp

.tim

e +

tp.m

illi

tm

* .0

01

);

int

prt

_a

2d

; /*

d

iag

no

stic

sw

itch

*et

in

arg

*.c

*/

int

prt

jbim

; /*

d

iag

no

stic

w

itch

to p

rin

t ti

me

*/

int

dec

im;

/*

dec

ima

tio

n fa

cto

r fo

r ge

t*w

eep

*/

int

fake

__ok

; /*

all

ow

fa

ke

trig

ger

from

*ig

nal

*/

char

*p

*eu

do_

a2d

;/*

dat

a fr

om f

ile in

stea

d o

f a2

d

*/

int

prt

_m

all

; /*

p

rin

t o

ut

ma

llo

c*

*/

tatic char *a2dbuff;

tatic int

a2dfd;

tatic int

a2dbuf«i;

tatic char

a2dbufn;

tatic char *a2dbed;

int

a2dsiie;

/* entire contiguous a2d data area

*//* file descriptor for a2d

*//* siie of one a2d buffer in byte*

*//*

idx of current buff (0..nchan-1) */

/* pointer to current buffer

*/

/* sise of sample vector

in bytes

*/

char *a2dptr;

int

a2dcount;

/* pointer to next sample vector

*/

/* num byte* still valid in cur buf */

a2dopen(scrate,ichan,chani,nchan,nbuf,bufsi)

int

ichan,chani,nchan,nbuf,bufsi;

long scrate;

a2dsize

- nchan *

(dec

im>l ? decim

: 1)

* NBPW;

a2dbufsi

(bufsi/nchan)*nchan * NBPW;

if(prt_mall) fprintf (stderr,"a2dopen: malloc(%u)\n"

a2dbuff - (c

har

*)malloc(a2dbufsi*nbuf);

a2dbufsi*nbuf);

fifdef LPA

if(a2dbuff 0

|| (Iong)a2dbufsi * nbuf > 65535L){

/* malloc err */

fprintf(stderr,***********

«2d buffer* are too la

rge.

**********\n")

; fprintf(stderr,"Need to re-adjust parameters or use disk-file cache.\n\n"} ;

lendif LPA

lifndef LPA

if(a2dbuff 0){

/* malloc err */

lendif

st_error(0,0,"a2dopen: malloc(%u)\n", a2dbufsi*nbuf);

> if(prt_mall) fprintf(stderr,"a2dopen: malloc(%u) - %u

\n",

a2dbufsi*nbuf, a2dbuff);

if (ps

eudo

_a2d

) {

if(prt~a2d) fprintf(stderr,"pseudo_a2d to be used. Ipa not opened.\n");

a2dfd

> openjpseudo ()

;return;

)

lifdef LPA

if(

(a2dfd - adopen(a2dbuff, a2dbufs«/HBPW, nb

uf,

scrate*nchan, ichan,chani,nchan)) < 0

) st_error(0,0,"online/a2dopen: cannot open a2d");

if(prt_a2d)

{fprintf(stderr,"a2d: scrate ichan chani nchan nbuf bufsi

siie bufsi\n");

fprintf(stderr,"

%6D %5d %5d %5d %4d %5d

%4d %5d\n\n",

scrate,ichan,chani,nchan,nbuf,bufss, a2dsize,a2dbufsi) ;

)

) fendif LPA

lifndef LPA

signal(SIGINT,onintr);

a2d£d « atod_open(A2D,1000/rate,nchan);

if(prt_a2d){

fprintf(stderr,

Ma2d:

scrate ichan chani nchan nbuf bufsi

siie bufsi\nn);

fprintf(stderr,"

%6D %5d %5d %5d %4d %5d

%4d %5d\n\n",

scrate,ichan,chani,nchan,nbuf,bufsz, a2dsiie,a2dbufsi);

}

lendif

short *getsweep()

{short *s

p;char *a2dread();

register i;

if(a

2d

cou

nt

<-

0)a

2d

read

();

a2d

cou

nt

-« a

2d

*ii

e;sp

-

(sh

ort

*)a

2d

ptr

;a2

dp

tr

retu

rn(

p);a

2d

size

;

Page 103: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/get

swee

p.c

char *a2dread()

{ int

r;

/****

befo

re ****/

/* if(prt_a2d)fprintf(«td

err,

-a2d

");

*/

if(p

rt_t

im){

nowjtime-clock();

if(a

ft_t

ime1

-0)f

prin

tf(*

tder

r,"c

alc ti

n* - %-6.5g/%-6.5g - %-6.3g\n",

nov_

time

-aft

_tim

e,

now_

time

-bef

tin

*,

(nov_time-aft_time)

/ (now_time-bef~tin«)

);

bef_time-nowtime;

} ~~

lifd

ef LPA

if(pseudo_a2d) r » g

et_p

seud

o(Ca

2dbu

fn);

/*

get

data from a

fi

le */

Ise

r - r

ead(

a2df

d,Ca

2dbu

fn,B

SZZK

);

/***

** read the a2d *****/

if(r

! BSZ

ZK

fifi fa

ke ok)

r - r

ead(a2dfd,Ca2dbufn,BSZZK);

/* tr

y again

*/

lendif

lifn

def LPA

if(i

ntr)

{fprintf(stderr,"\nOnline program interrupted by Cnt

r-C.

\n")

; if(stderr!-stdout)

fprintf(stdout,"\nOnline program interrupted by C

ntr-

C.\n

");

close(a2dfd);

exit

(O);

if(pseudo_a2d) r - g

et_p

seud

o(a2

dbuf

f);

/* get

data from a

fi

le */

Ise

r - read(a

2dfd

,a2d

buff

,BSZ

ZE);

/*

****

re

ad the

a2

d **

***/

if (r EOF

fifi !pseudo_a2d)

{

if(a

tod_

gete

rr(a

2dfd

) 4)

{ /*

a2

d buffer is full */

st_e

rror

(0,0

," AtoD buffer ove

rflo

w. Re

sett

ing.

");

_

atod

_rez

ero(

a2df

d);

r - read(a2dfd,a2dbuff,BSZZK);

/***

**

if(r

!-

BSZ

ZK

fifi

fak

e ok

) r

- re

ad(a

2dfd

,a2d

bu

ff,B

SZ

ZE

);

len

dif

~

the

a2d

*****/

/* try again */

if(r !» BSZZK)«t_error(0,0,"\n A2D read fa

ilur

e: pl

eace

re

star

t online p

rogr

am")

;

if(p

rt

tin

) a

ft t

ime-c

lock

();

lifd

ef

LPA

if(p

rt_a2d

)fp

rin

tf(s

tder

r,"

(%d

) ",

a2

db

ufn

);a2

dco

un

t »

a2d

bu

fsz;

a2d

bed

a2

dp

tr «

a2d

bu

ff +

a2d

bu

fn *

a

2d

bu

fsz;

le

nd

if

lifn

def

LPA

/*

if

(prt

_a

2d

)fp

rin

tf(s

tder

r,"

(%d

) ",

r);

*/

«2d

cou

nt

a2d

bu

fsx;

a2d

bed

-

a2

dp

tr -

a2d

bu

ff;

len

dif

fflu

sh(s

tderr);

putcach(a2dbed);

/* put

cache

is in cache.c

*/

retu

rn a

2dbed;

open_pseudo()

int

i, n, r, fd;

char *h,

buf[

2048

];

/***

* after ****/

/***

* after

****/

/*

n « *ixeof_h();

HEED TO FIX THIS 0P TO NORK 7/27/88 PUT

*/

h

> n < 20

48 ? buf

: (c

har *)

mall

oc(n

);

/* try to av

oid malloc to sa

ve space

*/

if(h 0

) st

_err

or(0

,0, "Can't malloc(%d)

for

for reading

a2d

header.",

n);

fd «

open(p*eudo_a2d,

0) ;

if (fd

< 0) «t

_err

or(0

,0, "C

an't

open % a*

pseudo a2

d fi

le",

ps

eudo

_a2d

);

r read (f

d, h, n);

if(r

!« n

) t

_err

or(0

,0,"

Erro

r in reading pseudo

a2d

file

he

ader

. r»

%d",

r);

free

(h);

if(p

rt_a

2d)

fprintf(stderr,"open_p*eudo

() called n

-%d\

n",

n);

retu

rn(f

d);

get_

pseu

do(n

) int

*n;

{ int

r;

r - read (a2dfd, a2dbuf f,

a2dbuf») ;

if(prt_a2d)

fprintf(«tderr,"get_p*eudo:

%d r

ead(

%d,

%u,

%u)\

n",

r, a2

dfd,

a2dbuff, a2dbuf») ;

if(r !«

a2dbufn) «t

_err

or(0

,0,"

End of file reached

on %

pseudo a2

d fi

le",

p«eu

do_a

2d);

*n - 0

; ret ur

n (1

);

Page 104: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/get

tim_.

c

|d«fi

n« M

SK4

OzT

/*

4

l«a*t

sig

nif

ica

nt

bit

s */

g*ttim_(tbuf, yr, dy,

hr,

mn, <

:)short *tbu

f;in

t *yr,*dy,*hr, *min;

float *s«e

; {

*yr-

tbu

f[l]

£MS

K4;

*d

y(t

bu

f[2]

£ M

SK

4)*

10

0+

(tb

uf [

3]

£ M

SK4)

*10+

(tb

uf

[4]

£ M

SK4)

;*h

r-(

tbu

f[5]

£ M

SK

4)*

10

+(t

bu

f[6

] £

MSK

4) ;

*m

n-(

tbu

f[7

] *

MS

K4

)*1

0+

(tb

uf[

8]

£ M

SK4)

;*««c-(

tbu

f[9]

£ K

SK

4)*

10

.0+

(tb

uf[

10

] £

MS

K4

)*1

.0+

(tb

uf[

11

] £

MS

K4)

*0.1

+

(tb

uf[

12

] £

MS

K4)*

0.0

1+

(tb

uf[

13]

C M

SK

4)*0

.001

;

Page 105: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/lpao

pen.

c

* adopenQ

* open Ipa for a / d in

put.

* for no

w,*

exit* on error?

*/ I include <whoami.h>

f include <*y*/param.h>

I include "I

pa.h"

I include <«gtty.h>

f include "key.h"

truct Ipactty «g

;

tatic char A2D[] -

tatic char MCODE[] -

tatic char DMDT[] -

"/dev/adO";

"/kmcll/dmavt.dat *

"/kmcll/dndt.dat";

int adopen(buf,buf*ix,nbuf,rate,ichan,chani,nchan)

hort *bu£;

hort bufciz;

hort nb

uf;

long rate;

hort ichan,chani,nchan;

/*ptr to buffer**/

/*buf size in word**/

/**buffer«*/

/**anple rate in hz*/

/**can sequence*/

o

extern char *malloc();

char junk[2048];

reg int nread;

int ffd,fd;

/*expand preparatory to locking in core*/

free(nalloc(2048));

takup(lO);

if( (f

fd - open(A2D,2))<0

) t error(0,0,"can't open Ipa file %«",A2O);

if( (f

d open(MC<»K,0))<0

) t_error(0,0,"can't open microcode %*",MCODE);

if(

(nread - read(fd,junk,*izo junk))<0

) t_error(0,0,"read error on microde %«M,MCODE);

if( write(ffd,junk,nread)I-nread

) t_error(0,0,"write error on microcode %«

",MC

ODE)

, cloce (f d

) ;

if(

(fd open(DMDT,0))<0

) t_error(0,0,"can't open table %*",DMDT);

if( (nread - read(fd,junk,*izo junk))<0

) t_error(0,0,"read error on table %«",DMDT);

if( write(ffd,junk,nread)I-nread )

t_error(0,0,"write error on table %*",DMDT);

close(fd);

g.lbufvad buf;

g.lcrate - -lOOOOOOL/rate;

g.lbufdecc - (nbuf-l)«13

| bufciz;

if( nchan<-0

) nchan 1;

if(

nchan>l ££

chani<-0

)chani - 1;

if( chani1-0

) /*S

eq

uen

tial

nod

e */

g.l

noch

an

- L

_MCH

N |

nch

an;

el«

e g

.ln

och

an

i

cha

n;

g.l

cin

c c

ha

ni«

8

| ic

han

;

g.l

clk

bit

* -

KK

AC

TR

|R1M

|MF

ZE

|MR

I;/*

«ta

rt

it

up

*/if

( i

oct

l(ff

d,S

ET

LP

AP

,£«g)<

0

) t_error(0,0,"init error on Ipa file %*

",A2

D);

return ffd;

tatic int «takup(n)

int n;

int junk[10];

if ( ~n>-0

)return vtakup(n);

Page 106: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/out

.c

/*

ou

t.c

fin

al

outp

ut

rou

tin

e* fo

r o

nli

ne.c

*

/

ffinclude <stdio.h>

ffinclude

"eqdetector.h"

static FILE *d_fd, *t_fd;

ffinclude <sys/time.h>

ffdefine MSK4 OxF

int striptime(tbuf,mstime, locdiff,timstr)

short *tbuf,*locdiff;

MSJTIME *m

stia

e;

char *t

imst

r;

int

yr,dy,hr, mn,

err, i;

double se

c;MS_TIME make_mstime();

extern char *list_mstime();

int

diff

;struct timeval tp;

struct timezone ti

p;struct tm *gt;

/* d

isk

an

d t

ap

* f

ile d

escr

ipto

rs

*/

/*

4 le

ast

si

gn

ific

an

t b

its

*/

dif

f-get

tim

aofd

ay (f

itp

, fit

zp)

; if

(d

iff

-1)

{st

_er

ror

(0,0

, "

Un

able

to

get

ti

me

of

day

fro

m U

NIX

");

retu

rn (0

) ;

} gt-

loca

ltim

a (

fitp

) ;

dif

f-60

*gt-

>tm

_hou

r+gt

->tm

_min

; gt

<*gm

tim

e (f

itp

) ;

dif

f- (

60*g

t->

tm_h

our+

gt->

tm_m

in) -d

if f ;

if (

dif

f>72

0) d

iff

14

40

; els

e if

(d

iff <

-720

) dif

f +-1

440;

*lo

cd

iff-

dif

f ;

/* ca

lcu

late

dif

feren

ce

GM

T-l

ocal

ti

me

*/

i-tb

uf

[l]f

iRS

K4;

yr

-gt-

>tm

_yea

r+19

00;

/*

calc

ula

te t

he

mst

ime

dy-1900+ ( (gt->tm_year/10) *10

) +i;

if (dy

-yr>

l) dy 10;

else if (dy-yr<l)dy+-10;

yr-dy;

} dy

-(tb

uf[

2]

fi K

SK

4)*1

00+

(tb

uf

[3]

fi M

SK

4)*1

0+(t

bu

f[4]

fi

KSK

4) ;

h

r-(t

bu

f [5

J fi

MS

K4)

*10+

(tb

uf[

6]

fi M

SK4)

; «n

-(tb

uf[

7]

fi M

SK

4)*1

0+(t

bu

f[8]

fi

MSK

4);

sec-(

tbu

f[9]

fi M

SK

4)*1

0.0+

(tb

uf[

10]

fi M

SK4)

*1.0

+ (

tbu

f [1

1]

fi K

SK

4)*0

.1+

(tb

uf[

12

] fi

MS

K4)

*0.0

1+(t

bu

f[13

] fi

MS

K4)

*0.0

01;

*a

stia

e^B

ak

e_m

stia

e (y

r, 0

, d

y, h

r, m

n, s

ec)

; st

rcp

y (

tim

str,

lis

t_m

stim

e (*

mst

ime,

1)

) ;

if (

(err

-tb

uf[

14]*

MS

K4))

/*

ch

eck

aagic

an

d e

rror

bit

s st

_er

ror(

0,

0, "

Clo

ck e

rror

bit

s at

tim

e %

s-%

d", t

imst

r, e

rr)

;if

((i

«tb

uf[

15]S

MS

K4)

!-

14)

st_er

ror

(0,0

, "D

ata

erro

r:

Mag

ic t

ime

bit

s a

t ti

me

%s-

%d"

, tim

str, i

) ;

newfile ()

*/

full_name[100], *unit num;

int

i,j;

long

time() ,timep;

char

*ctime(),timestring[14];

struct tm *gntime(), *stmp;

struct muxdata md;

struct trigsetting ts;

struct triggers tr;

extern short *geteach();

extern int current;

even

t_nu

m4~

l-;

wrt

_nu

m-0

;

if (

noj

bea

d) re

turn

;/*

d

ont

wri

te

hea

der

*/

stJL

nit

(M

DX

DA

IA, f

imd)

;st

rncp

y(m

d.n

etn

am

e,n

etw

ork

,4);

tri

pti

ne(

get

each

(cu

rren

t),f

imd

.beg

inti

me,

fim

d.l

oct

ime,

tim

estr

ing)

fpri

ntf

(std

err,

"E

ven

t d

etec

ted

at

%s\

n"

,tia

estr

ing);

md

.nu

mch

an

s n

stati

on

s;md

. dig__rat e»rate;

md.typedata-'r';

if(disk_file){

sprintf(full_name,"%s%s",disk_file,timestring) ;

d_fd»st_open(full_name,"w");

if (

tap

e_

file

) {

if(x

chg

_ta

pe

fifi

even

t_n

um

> x

chg

_ta

pe)

{u

nit

jnu

m -

ta

pe_

file

+

strle

n(t

ap

e_fi

le)

- 1;

*un

it_n

um

*un

it_n

um

«

'!

' ?

'3'

: '!

';/*

?????

even

t_n

um

-

0;

Wha

t ab

out

dis

k_fi

le n

amin

g ??

???*

/fp

rin

tf(s

tder

r,"

chan

gin

g t

ap

e ou

tpu

t to

%

s\n"

, ta

pe_

file

);

if((t_fd-fopen(tape_file,«w")) !-

NU

LL)

st_error(die,0,"Unable to open tape file %s",tape_file);

if(p

rt_

trig

) {

st_

init

(T

RIG

SET

TIN

G,f

its)

;st

rncp

y (

ts.n

etw

nam

e,n

etw

ork

,4);

ts.b

egin

ttim

ein

d.b

egin

tim

e;ts

.co

nst

l«co

nst

l;ts

.con

st2«co

nst

2;

ts .t

hre

shold

^rt

hre

shold

;t

s.co

nst

3*

con

st3

;ts

.con

st4-c

on

st4;

t s.

wav_in

c-w

ay_in

c;t s.sweep sweep;

t s.aperture aperture;

st_put(fits,TRIGSETTIHG,sixeof(struct trigsetting),d_fd);

for(j-0; j<nlook; j+

+){

i«lo

ok

sta[j

];st

_in

it(T

RIG

GE

RS

,fit

r);

strn

cpy(t

r.tr

_n

am

e.n

etw

ork

,sti

ds[

i].n

etw

ork

,4);

strn

cpy

(tr.

tr_

na

me.

st_

na

me,

stid

s[ij

.st

_n

am

e,5)

;tr

.tr_

na

me.

com

po

nen

t-st

ids[

i].c

om

po

nen

t;tr

.tr_n

am

e.i

nst

_ty

pe-s

tid

s[i]

,in

st_

typ

e;tr

.sta

«st

as[

i];

tr.l

ta«lt

as[i

];tr

.ab

s_st

ab

s_st

as[

i];

tr.a

bs_

lta

-ab

s_lt

as[

i];

tr.t

rig

_valu

e-e

tas[

i];

tr. n

um

__tr

igger

s«st

a_tr

igger

[ i

] ;tr

.tri

g_ti

me^

Bd

.beg

inti

me;

st_p

ut(

fitr

,TR

IGG

ER

S,s

izeo

f(st

ruct

trig

gers)

, d

_fd

);

Page 107: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/out

.c

t_put(£md,MOXDATA,iiz*of(atruct nuxdata),d_fd);

if (prt_vba*)wrt_diaga (1) ;

wrtfil*(buf) abort *b

uf;

{ if(diak_fil*){

if(fwrit*(buf,l,bufazb, d_fd) !-

bufazb)

t_*rror(0,0,"Unabl* to writ* full data buff*r to diak");

if(prt_out)fprintf (atd*rr,"diak");

if(tap*_fil*){

if(fwrit*(buf,l,bufazb,t_fd) I- bufazb)

at_*rror(0,0,"Unabl* to writ* full data buff*r to tap*")

if(prt_out)fprintf(atd*rr,"tap*");

if(prt_out)fprintf(atd*rr,"(%d)

", wrt_nu»);

wrt_nuttf+

;r*c nu

m++;

ndf il* ()

if(diak_fil*)

if (f cloa* (d_fd) EOF) at_*rror(di*,0, "Unabl* to cloa* diak fil*");

if(t

ap

*_fi

l*)

if(f

clo

a*

(t_

fd)

EO

F)

at_

*rr

or(

di*

,0,

"Una

bl*

to cl

oa* t

ap

* fi

l*"

);

h*ad

_in

it (

) {

int

i, ,

at

ik [M

AX

_STA

] ;

natation* g*t«tatM(>tat_fil*, ctanam**) ;

g*t>ubn*t> (>u

bn*t

_fil

*, >ubn*t);

if (natation* > MAX_STA)*t_«rror(0, 0, "Too many station* %d

", natation*);

for(i

-0;

i<n

*ta

tion

*;

i++

)*ta

ma

*k

[i]

- 0;

i-0

;w

hil

*(

>u

bn

*t[i

++

] \m

-i

)w

hil

*(

(*-*

ub

n«t

[i-

H-]

) !-

-1

) *

t aa»

*k [

]+

+,

for(nlook-*-0; *<n*tation«; +

+) if (*ta»»*k[*] )

loo

k*ta

[nlo

ok-H

-] - ;

) int g*t*tat>(*tat*_fil*,*tanaB*)

/* r*ad atationoomp atruetur* information */

char **tati_fil*, *tanam*[] [HSZ] ;

I

FILE **tatfil*;

truet ct

at ion coop **c_ptr;

int i,

j,max*tat, *t_

typ«

, *t_l*n;

maxstat- -1

; tatf il*-*t_op*n (*tat*_f il*

, "r") ;

i- -1

;w

hil

* (

*t_

g*t

(«*

c_p

tr, &

*t_t

yp«,

&*t

_l*n

, *ta

tf il

*)

I -E

OF)

{

if ( «t_

typ

*~

STAT

IOM

CX3S

MP )

{

if (

c_p

tr->

ch»n

n*l

i (ab

ort )

NO

DA

IA)

t_*rror(d

i*,

0, "

Cba

nn*!

n

uob

*r n

ot

a««i

gn*d

fo

r st

ati

on

%

",

c_p

tr->

>c_

nam

* . *

t_na

m*)

;

if (>

c_p

tr->

chan

n*l

>^

lAX

_ST

A)

«t_

*rr

or(

di*

,0,

"Cba

nn*!

n

un

b*r

to

o la

rg*

. %

d>-%

d",

c_p

tr->

ehan

n*l

,MA

X_S

TA

) ;

j «c_

ptr

->ch

an

n«l-

l ;

if (

j>m

ax«ta

t)m

az«

tat-

j ;

if (j

il)«

trn

<5

)y (n

etw

ork

, c_

ptr

->>

c_n

am*.

n*t

wor

k, 4

) ;

*trn

cpy(

*tan

am*[

j] ,

>c_

ptr

->>

c_n

am*.

at_n

am*,

5);

mtr

ncp

y (m

tidm

[ j]

. net

wor

k,

c_p

tr->

*c_

nam

*. n

etw

ork

, 4)

; t

rncp

y(«

tid

>[j

] . t

_naB

*,«c

_ptr

->>

c_n

am*.

Mt_

nam

*,5)

;*

tid

*[j

] .c

omp

on*n

t«*c

_ptr

->>

c_n

am*.

com

pon

*nt;

tid

*[j

] .i

nM

t_ty

p*«

*c_p

tr->

>c_

nam

*.in

Mt_

typ

*;

t_

f r**

( c

_p

tr)

;} *t_

cloM

(a

tatf

il*)

;r*

turn

(m

ax«t

at+

l) ;

|d*fi

n*

EQ

(atr

g)

( t

rcm

p(a

, atr

g)

|d*fi

n*

CET

_TO

K

( fa

can

f (f

p,

"% "

t

ati

c

char

*r

dac

c*M

»

"r";

g*t*ubn*t* (fnam*, aubn*t)

char *f

naa*

; int

*>ub

n*t;

0 )

1 )

char

[1

28

];in

t n

*t»

l,

nct

a,

ncu

b;

FIL

E *

fp,

*fo

p*n

();

if (

(fp

- f

op*n

(fn

am*,

rd

acc

*M

))

0 )

t_*rror(d

i*,0

, "U

nabl

* to

op

*n

>u

bn

*t fi

l*

%>

",fn

am*)

; w

hil

*(

CET

JPO

K

) {

if(

IQ("

/*"

) )w

hil

*(

CET

_TO

K &

& !E

Q("

*/"

) );

/*

«

kip

co

mm

*nt>

!

if

(* >

-' 0

' &&

* <

-'»')

{

/*

r*ad

u

bn

*t«

if (

niu

b)

«ub

n*t

[n

>u

bf+

] -

-1;

ub

n*

t [n

*ub+

+] -

ato

i (

) ;

) !

>u

bn

*t [

n>

ub

f+]

n

am2*

nu

m(*

, «t

anam

*>,

na

tati

on

*);

aubn*t [na

ub++

] au

bn*t

[n>

ubf+

] f clo

a* (fp)

;

-1;

-1;

anam

2an

tai(

a,

ctan

am*,

n

ata)

ch

ar

*m,

*tan

am*[

][H

SZ

];

int

nata

;

int

i;fo

r (i

-0;

i<n

ata

; i-

H-)

if(

IQ(a

tan

am

*[i

])

)r*tu

rn

(i);

fprin

tf (

atd

*rr

,"on

lin

*:r

*ad

n*t:

un

know

n a

tati

on

nam

* x

it(l

);

Page 108: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/onl

ine.

run

whil* cbo restarting onlin* *y*t*m

do

onlin* -v -o onlin*.log

don*

Page 109: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

/* onliM.h

Online seismic processing system with LPA

J. Ha

rrio

t and

D. Fong

OSGS

, itonlo P

ark,

CA

, August,

1982

Program features:

1. DMA from LPA (buffe

r si

xe and number of

bufs set

dyna

mica

lly)

.2. Cach

* in core or on disk fi

le (r

aw or

cook

ed)

a* desired.

3 Automatic triggering and all

i/o

in on

* real-time

proc

ess.

4. Final

outp

ut on d

isk or tap*

or both a*

de

sire

d.5. Output i*

compatabl* with Ping and Pong pro

gram

*.6.

Most parameters dy

nami

call

y se

t from command

line

.7. Many seismically im

port

ant

argument*

are

in s

econds (n

ot bu

fs)

8. When executed with no args,

option*

are

document

ed.

tinclude <seis/suds.h>

tinclude <s

tdio.h>

Idef

ine

MA

X_S

TA

Idef

ine

MAX

_HET

Id

efin

e H

SZ

lifdef LPA

Idefine A2D_ZERO

lendif LPA

lifn

def LPA

Idef

ine A2D ZE

RO

le

ndif

wQ^Idefine Abs

(n)

32 196

5 (4096/2)

/* maximum number o

f st

atio

ns

/* maximum size of

su

bnet

ve

ctor

/* nb

ytes

in station name i

ncl null

int

int

int

int

int

int

int

int

floa

tfloat

float

float

long

int

int

int

int

int

int

int

- se

ccaD

xa ]

bufs

x;nbuf;

const 1;

const 2;

thre

shol

d;const 3;

const 4;

wav_inc;

befo

re;

afte

r;aperture;

sweep;

rate

;de

cim;

nstations,

ncha

n;xchg_tape,

shortcut;

diffsam;

dyn_

flag

;

/* lo

gica

l xe

ro fo

r Ipa

0 /* lo

gica

l xero fo

r Ipa

(n<0

? -n

: n)

/*

macro for

abso

lute

value

parameters either by command

args or by d

efault

*/ */ */ */ */ */

/* buffer sixe for a2d re

ads

*/

/* number of buffers

for a2d to use

*/

/* numerator for trigger

cons

t */

/* denominator fo

r trigger

cons

t */

/* threshold for trigger

*/

/* weigted average numerator

*/

/* weigted average

deno

mina

tor

*/

/* weigted average

increment

*/

/* se

cond

s of data to save bef

ore

trig

ger*

/ /* se

cond

s of data to sa

ve a

fter trigger */

/* secondss for

coincident station trig

*/

/* se

es of

da

ta for

short te

rm average

*/

/* sampling rate

in sa

mple

s/se

c */

/* decimation factor f

or averages

*/

/* number of

stat

ions

in

network

*/

/* num cha

nnel

s from a

2d,

dflt natations

*/

/* ex

chan

ge tape units

after event

*/

/* suppress trigger c

omputations

*/

/* di

ffer

ence

sa

mple

s before computation

*/

/* en

able

use

of dynamic

flag

s */

/* fi

l« na

mes also se

t by command arguments

or by default

char

ch

ar

char

char

ch

ar

char

char

*sta

t fi

le;

*subnet_fil«

*cac

h file;

*disk~file;

*tap

*Tfi

le;

*pseudo_a2d;

*log

_fil

e;

/* stationcomp

structure

file

*/

/* network

and

subn

et fi

le name

*//* usually 0»core or

"/dev/rrllb"

*//* final

outp

ut to disk

file

nam

e */

/* final

outp

ut to tap

e file name

*//* data in

put

from file,

not

a2d

*//* output fi

le for diagnostics

*/

o/eq

c

int

/*

int

Lon

gin

tL

ong

int

Lon

gL

ong

Lon

gin

t

/*

lete

ctye

qaet

ecto

r.

co

ntt

ap

e;

bufs

xb;

ns_

befo

re;

nb

befo

re;

ns_

aft

er;

nb

_aft

ar;

ns_

wri

te;

ns_

ap

ert

ure

;ns_

swee

p;

nsw

_ap

ertu

re;

......

......

......

......

......

......

......

......

......

......

......

......

......

......

......

.....I

B

/* if

tru

e w

rite

all

data

co

nti

nu

ou

sly

to ta

pe

*/

calc

ula

ted

fr

om

para

mete

rs ab

ov

e *

/

/* buff

er

sixe in

by

tes

(cf

bu

fsx

) */

/*

num

of

sam

ple

s to

sa

ve

befo

re t

rigger

*/

/*

num

of

buff

ers

befo

re t

rig

ger

(cac

he)

*/

/*

num

of

sam

ple

s to

sa

ve

aft

er

trig

ger

*/

/*

num

of

buff

ers

to

sa

ve

aft

er

trig

ger

*/

/* to

tal

num

sam

ple

s to

wri

te

on t

rigger

*/

/*

num

sa

mp

les

for

quasi

-sim

ul

trig

ger

*/

/*

num

sa

mple

s in

one

trig

ger

swee

p */

/*

num

of

swee

ps per

apert

ure

*/

lon

glo

ng

int

int

int

int

int

int

int

ch

ar

int

st_

sum

st_

abs_

sun

sta*

sab

s sta

sIt

as

abs

Itas

eta

s'

[MA

X

ST

A];

l [M

AX

_ST

A];

[MA

X

ST

A];

[MA

X

ST

A];

[MA

X_S

TA]

;[M

AX

~STA

] ;

[MA

X_S

TA]

;st

ajb

rig

ger

[MA

X_S

TA]

;su

bnet

stan

ames

lookst

aST

AT

IDE

NT

sti

ds

int

ch

ar

nlo

ok;

net

wo

rk

[MA

X_N

ET]

;[M

AX

ST

A]

[HSZ

][M

AX

_STA

] ;

[MA

X_S

TA]

;

[4];

/* short-term s

ums

for

one

swee

p */

/* rectified short-term s

ums

*//* regular sh

ort-

term

averages

*//* rectified sh

ort-

term

averages

*//*

regular long-term averages

*//* rectified lo

ng-t

erm av

erag

es

*//*

eta values fo

r each station

*//* in

divi

dual

st

atio

n trigger

*//* subnet configuration

*//* st

atio

ns names pe

r a2d

chan

*//* st

a in a

subn

et,

s»looksta[i]

*//*

station

component

iden

tifi

ers

*//* num stations in lo

okst

a vector

*/

/* network name read fr

om STA

TIDE

NT fo

rstation on channel

1 */

misc glo

bal

variables

int

lon

gin

tin

tin

tin

tch

ar

int

lon

g

even

t_num

;re

c_n

um

;w

rt_n

um;

trig

;nbuft

rig;

a2dsi

xe;

*a2

dp

tr;

a2d

count;

swee

pnum

;

/* ev

ent

number beg a

t 1

for ou

tput

/*

co

unt

of al

l non-header records

/* co

unt

of p

er-event non-hd records

/* master t

rigg

er,

ages to

0 off

/* num of buffers to

wr

ite

on trigger

*/ */ */ */ */ */ *//*

sixe of

sample vec

tor in bytes

/* pointer to ne

xt sa

mple

ve

ctor

/* num bytes still valid in cu

rren

t buffer*/

/* gl

obal

count

of sw

eeps

from s

tart

*/

/*-

dia

gn

ost

ic s

wit

ches

to p

rod

uce

te

rmin

al

outp

ut

int

int

int

int

int

int

int

int

int

int

int

int

int

prt

_d

iag

;p

rt_p

arm

;p

rt_et

as;

prt

_st

rg;

prt

jbri

g;

prt

_y

bsa

;p

rt_

st_

av

;p

rt_st

_ab

s_av;

prt

_ca

ch;

prt

_a

2d

;p

rt_

pu

t;p

rtjb

im;

prt

_m

all

;

/* p

rin

t o

uts

of

mis

c d

iag

no

stic

s/*

p

rin

t o

uts

of

init

ial

par

ams

/* p

rin

t ou

ts of

eta v

alu

es/*

p

rin

t o

uts

of

stati

on

s tr

iggers

/* p

rin

t o

uts

of

ma

ster

trig

ger

/* p

rin

t o

uts

of

trig

er v

erb

ose

/* p

rin

t o

uts

of

st_av a

nd

lt_

av

/* p

rin

t ou

ts o

f st

_a

bs_

av

an

d l

t_ab

s_av

/* p

rin

t ou

ts of

cach

e acti

vit

y/*

p

rin

t o

uts

of

a2d

acti

vit

y/*

p

rin

t o

uts

of

ou

tpu

t a

cti

vit

y/*

p

rin

t o

uts

of

tim

e in

a2d

rea

d/*

p

rin

t ou

ts m

all

oc

ca

lls

d

iagn

ost

ic s

wit

ches

fo

r d

ebu

ggin

g th

e sy

stem

int

int

no

t_rt

p;

fak

e ok

;/* su

ppre

ss KC

P (r

eal-

time

pr

oces

s)

/* allow fake trigger from si

gnal

*/

*/

*/

*/

*/

*/

*/

*/

*/

*/

*/

*/

*/

--*/

*/

*/

Page 110: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/eqd

etec

tor.h

int

int

int

fak«_trig;

no_h

*ad;

xit

_«ar

ly;

/* fa

k« trigger fro

m si

gnal

8X

GQOX

T /* «uppr«M w

rit* o

ut of header

/* for testing program

*tartup

/*

short

*g*t«w««p

()

global de

clar

atio

n*

/* r«

turn

« ptr to 1 vector of data

*/ */ */ **/ */

Page 111: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/hea

der.h

HEAD

ER atructura of 11/34

aaiamic

data

-

- -

-Thaaa ara tha

data includad in

tha

t part of tha common

tra

ctur

a wh

ich

ia writtan a

t tha bag

inin

g of aach tr

igga

rad

avant

on 11/34

tapa.

It ia

of a

fixad

aixa indapandant

of how many channala ara baing digitixad.

*/ Idafina MAXSTA 32

tract

haa

dar

{

abort

tchan;

abort

rata;

abort

bufa

ixa;

char tim

a[8]

; hort

data

[3];

long

a [MAXSTA] ;

long r [MA

XSTA

] ;

hort

abrb

r [M

AXST

A];

hort

rbrbr [MAXSTA];

hort

ata [MAXSTA];

hort

atri

g [MAXSTA];

hort

atrval [MA

XSTA

] ;

hort

tri;

hort

trva

l; hort

dacim;

char st

atio

n[MA

XSTA][

4] hort

aubn

at[1

96];

hort

flag[100];

Idaf

ina HEADSZZE aixaof(h)

/*

/* total

numbar of ch

anna

la in

data

/* nwbar of

aaap

laa par aacond par ch

anna

l /* Ta

pa ra

cord

aixa

/* aa

cii

br,Bin

rand

aac

from

113

4 ra

alti

na cl

ock

/* Data (day,

month, yaar)

in binary

/* Running

aum of aignal for aach cb

an

/* Running

aum of ractifi

ad a

ignal

/* long tarm a

igna

l av

arag

a /*

long tarm ractifiad si

gnal

avaraga

/* Triggar

critaria:

plua for tr

igga

rad

atation

/* Triggar a

tata for aach at

atio

n /*

Sat valua

for aach at

atio

n triggar

/* Tha maatar triggar

/* Tha

aat valua

for tha maatar triggar

/* Dacimation fa

ctor

for triggar routina

;/*

Station

liat

/* Su

bnat

liat (c

hang

ad to 1

96 2/

12/8

0 /*

Odd* and anda and

inta

rtaa

k oomunication

*/ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */ */

Saa tha

comm

on block at

ruct

ura

of 11/34

rout

inaa

for dataila

i of moat

of tha abova.

flag valuaa

that ar

a of intaraat to

ua ha

ra ara

liatad b

alow

. fl

ag[3

] Ev

ant

numbar o

n tapa.

flag[4],£lag[5]

fraction for computing ata

flag

[7]

numbar of buff ara to p

roca

aa in

ona triggar awaap

flag

[8]

langth o

f di

ac dalay "tank" in buf

fara

. fl

ag[9

] nu

mbar

of tapa racorda

writtan

(fig

urad

out by "g

at34

")

*/

Page 112: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/key

.h

dod*

fin*

until (z)

i*o

lid*

d*fin* LONG

bool

ix«

of

continu*

un*i

gn«d

lo

ng) (u

n«ig

n«d

char

/* f d*fin* n*w(z)

((a

i d*

fin*

noT*(

z,y)

*/

Page 113: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

eqde

tect

/ipa.

h

LPA drivar haadar fila

Asa Rombargar

modifiad by HFJoliti, D.

Fong,

EJHaug

mathod of usaga:

opan

writa microcoda

writa dadicatad moda dispatch tabla

stty to sat paramatars

wordO

buffar addrass

wordl

rata

(-10**6/fraq_in_hm)

word2

nbufs

15:13 tbuffars-1

bufsz

12:0

buffar siia in words

word3

moda

15:15 1

for saq channal moda

0 for sg

l channal moda

chan

7:0

tchannals for saq moda

channalt for sgl channal moda

word4

incr

15:8

channal incr for saq moda

ichan

7:0

start channal for saq moda

ignorad in sg

l moda

wordS

elk

usar raquastad elk params

raad -

1 charactar indicating buffar indaz

fill or anpty buffar

gtty to gat tha raal addrass of tha buffar*

wordO

hi ordar bits of buffar phys addr

wordl

lo ordar bits of buffar phys addr

word2

unusad

* t if

da

f n

otd

af

* minor davica nuabar DDCCCCCC whara:

DD

00 for analog input

01 for analog input with sacond adc

CCCCCC

» channal nuabar

* CCCCCC

ignorad in this varsion of tha drivar

* channal paramatars passad in as abova

t andif notdaf

*//*

CL

OC

K

ST

AR

Ttd

afi

na

CL

OC

K

1td

afi

na

CL

OC

KA

(0

«4

)td

afi

na

CL

OC

KS

(1

«4

)

CO

MM

AN

D*/

/*clo

ck

st

atu

s w

ord

*/

tdafi

na

EKA

CTR

1td

afi

na

RIM

(1

«1

)td

afi

na

RlO

OK

(2

«1)

tdafi

na

R10

K

(3«

1)

tdafi

na

RlK

(4

«1)

tdafi

na

R10

0 (5

«1

)td

afi

na

REX

T (6

«1)

tdafi

na

R60

(7

«1)

tdafi

na M

TZE

0100

tdafi

na M

SI

(0«

8)

tdafi

na M

RZ

(1«

8)

tdafi

na M

EET

(2«

8)

tdafi

na M

EE

TS

(3«

8)

tdafi

na

ST1E

C

020000

tdafi

na

ST1Z

E

04

00

00

/*moda ~ clock start*/

/*clock A*/

/* clock b */

/*anabla countar*/

/*! MHi rata*/

/*100 KHi rata*/

/*10 KHi rata*/

/*! KHi rata*/

/*100 Hi rata*/

/*axtarnal rata (from

stl input)*/

/*lina fraquancy rata*/

/*aoda flag intarrupt anabla*/

/*singla intarral aoda*/

/*rapaat intarral aoda*/

/*axtarnal arant tiota moda*/

/*axtarnal arant tima moda from iaro basa*/

/*stl anabla countar*/

/*stl intarrupt anabla*/

Idafina GETLPA*

tdafina SZTLPAP

Page 114: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

atod

/Mak

efile

CFIAGS « -g -£68881

LIBS- -1

m -l

iunt

ool

-iBunwindow

-lpi

xr*c

t

mil:

cdd plotmtod

odd: cdd.o

CDDmtod.o

$(CC)

$(CFIAGS)

-o cdd

cdd.o CDDmtod.o

-Icudc -1m

plot

mtod

: plotmtod.o CDDmtod.o

$(CC

) $(CFIAGS)

-o plotmtod p

lotmtod.o

CDDmtod.o

-Icudc $(

LIBS

)

inst

all:

cp plo

tmto

d cd

d /uar/Mic/bin

plotmtod.o

: /u

«r/i

nclu

d*/«

«i*/

«ud*

.h

plotmtod.o

: /u

«r/i

nclu

d*/«

«i«/

«*i«

.ico

n

Page 115: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

atod

/CD

Dat

od.c

fdefine WRTBUF

4096

/* size buffer to write data to CDDatod

*/

char wrtbuf[WRTBUF];

iinclude <stdio.h>

iinclude <sys/file.h>

iinclude <sys/ioctl.h>

iinclude <sys/types.h>

iinclude <sys/mtio.h>

struct mtop

ctl;

struct mtget st

at;

extern die();

extern int errno;

int atod_rezero(fd_atod)

int fd_atod;

int ioc;

ctl.mt_op-5;

ctl.mt_count-l;

ioc-ioctl(fd_atod,MTIOCTOP,Sctl) ;

if (ioc -1) st_error (0,

err

no,

"Unable to rezero CDD Data Sampler on file number %d",fd_atod);

return(ioc);

~~

int atod_open(device,ms_samp,numchan)

char *device;

int ms__

samp, numchan;

int

fd_atod,ret,nummux,maxi;

short*b;

char

a [2]

;double sc;

extern double get_mstime();

int yr,mo,dy,hr,mn;

if((fd_atod-open(device,O_RDWR)) -1

) st_error(die,errno,

"Unable to open CDD Data Sampler on filename % ",device);

/* Calculate number of multiplexers (g

roup

s of 16 channels) */

nummux-(numchan+15)/16;

/* check ms_samp is within limits of at

od:

aggregate rate 25,600 samps per sec */

maxi-(nummux*10) /16;

if(ms_samp < maxi) st_error(die, 0,

"%d milliseconds per sample too sm

all.

Must be at least %d for %d channels",

ms_samp,maxi,nummux*16);

/* test byte order *b-780 on SUN3/50 and *b is 3075 on DEC 11/70

*/

II]

-12

;b

-(sh

ort

*

)&a

[0];

if(*

b-«

30

75)s

pri

ntf

(wrt

bu

f,"

MS

IC1

\n"

) ;

els

e sp

rin

tf(w

rtb

uf,

"L

SIC

1

\n«

);

/* se

t a

tod

fo

r tw

os

com

ple

men

t ari

thm

etic

*/

spri

ntf

(wrt

bu

f,"

%s2

S

COM

P \n

",w

rtb

uf)

;

/* se

t y

ear

cou

nte

r in

ato

d */

dec

ode_

mst

ime

(get

_mst

ime

(), S

yr, f

imo,

£d

y, £

hr,

tan

, tsc

) ;

spri

ntf

(wrt

bu

f,"

%sY

EA

R %

d\n

",w

rtb

uf,

yr)

;

sprin

tf (

wrt

bu

f, "

%sI

NIT

AT

OD

%

d %

d\n"

, wrt

bu

f ,m

s_sa

mp,

num

mux

) ;

atod_rezero(£d_atod);

ret-write(fd_atod,wrtbuf,WRTBUF);

if (ret

f -NRTBUF) st_error (di

e, errno,

"Unable to initialize CDD Data Sampler on file %s.

Write returns %d

",device,ret);

return(f d_atod);

int

ato

d_se

ttim

e(fd

_ato

d,d

ay, h

ou

r,m

in,s

ec)

int

fd_ato

d,d

ay,h

ou

r,m

in,s

ec;

int

ret,

err,

if(day<0)

{sprintf(wrtbuf,"EXTERNAL RT

C\n"

);

ret-write(fd_atod,wrtbuf,WRTBUF);

return(atod_geterr(fd_atod));

ret-0;

i£(day<0

|| day > 36

6) {r

et-H

-; fprintf(stderr,"Incorrect day of %d\n",day);)

if(hour<0

|| hour > 23

) {ret-H-; fprintf(stderr,"Incorrect hour of %d\n",hour);)

if(min<0

|| min

> 59

) {ret-H-; fprintf (st

derr

, "Incorrect minute of %d\n",min);)

if(sec<0

jj sec > 59)

{ret

-H-;

fprintf(stderr,"Incorrect second of %d\n",sec);)

if (ret 0)

{sp

rint

f (wrtbuf, "INTERNAL

RTC\nTIME %d

%d %d

%d

\n",

day

, ho

ur, min, sec

) ;

ret-write(fd_atod,wrtbuf,WRTBUF);

return(atod_geterr(fd_atod));

return(1);

int

ato

d_in

crti

me(

fd_ato

d,m

sec)

in

t fd

_ato

d,m

sec;

int

ret,

err

;

if(msec<0)sprintf(wrtbuf,"RETARD %f\n",-msec)

else sprintf (wrtbuf, "ADVANCE % An", msec);

ret-write(fd_atod,wrtbuf,WRTBOF);

return(atod_geterr(f d_atod));

int atod_geterr(fd_atod)

int fd_atod;

int ioc;

ioc-ioctl(fd_atod,MTIOC6ET,tstat);

if (ioc»-" -1

) st_error (di

e, err

no,

"Unable to get error from CDD Data Sampler on file number %d",fd_atod);

return(stat,mt_erreg);

Page 116: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

atod

/cdd

.c

/* E

xer

ci*e

the

Cu

tler

Dig

ital

De*

ign

Dat

a S

amp

ler

/* W

hen

wri

tin

g t

o A

tod

, m

tut

*en

d f

ull

bu

ffer

*/

tdefine DEVICE

"/dev/r*tl«

tdefine NRTBOF

4096

tdefine NUMPRH WRTBUF/2

tdefine LOW4BITS OxF

char wrtbuf [WR

TBUF

];

I include <*tdio.h>

tinclude <*y*/ti»e.h>

extern int errno;

extern char *progname;

die(

n) int n;

(exit(n);}

char

men

u[]

~"

\no

open

(ty

pe

nse

c/aaap

le

and

num

ber

of

chan

nel

*) \n

r re

zero

ato

d\n

g g

et

data

\nh

get

h

ead

mai

n (a

rgc,

arg

v)in

t arg

c;ch

ar *

*arg

v;

{in

t d

ev, i

oc, i,

j, e

rr,m

**aa

ip, n

uac

han

*, d

ay, h

r,m

in, *

ec;

char

in

pu

t [1

00];

char

bu

f [H

RTB

OF]

; h

ort

*ib

uf;

tru

ct

tiaeval

tp;

tru

ct

tin

e z

one

tzp

; t

ru

ct

tm *

taa.

, *gm

ti»*

()

;

pro

gnam

*«ar

gv[0

] ;

-1;

f printf (*td*rr, "%«",a*nu) ;

g«ta( input)

; fprintf (at

darr

, "\

n")

; witch (input [0])

{ro':if(d*v!-0)cloM(d«v);

ioc-

**«c

*nf (c

inp

ut

[2]

, "%

d %

d", t

mm

tmm

p, f

inun

chan

a) ;

if(iocf-2)

{

numchan«'16;

d*v-«

tod

op

«n (D

EV

ICE

, m*«

anp,

num

chan

a) ;

fp

rin

tf (

0td

«rr

,"O

p«n

th« C

DD D

ata

Sam

ple

r on

f il

« d

escr

ipto

r %

d \n

" ,

d«v

) ;

fprin

tf (

0td

*rr

, "

for

%d

c

/ch

an

na

l an

d %

d ch

an

nel

*. \

n"

,

bre

ak;

case

' r

' :a

tod

_re

zero

(d

ev)

;fp

rin

tf (

td

err,

"R

eser

o a

tod

on

fil

e d

escr

ipto

r %

d\n

",d

ev);

b

reak

; ca

*e

' g'

: ioc-

read

(d

ev, b

uf,

WRT

BOT)

;

if (io

c

-1)

{ t

_error (

0,0

, "

Err

or

%d

on d

ev

%d:

" ,

err

no

, dev

) ;

err-

ato

d_g«te

rr (

dev

) ;

if (err 4

) fp

rin

tf (

ctd

err,

"A

tod

bu

ffer

over

f low

ed. \

n"

);

els

e fp

rin

tf (

atd

err,

"E

rror

regis

ter is

%

d\n

",e

rr);

fprin

tf (

std

err,

"C

etd

ata

retu

rn*

%

d b

yte

*\n

", i

oc)

;

ibu

f- (

short

*)b

uf;

if (

ioO

O)f

or(

i-O

, j-

0;i<

HU

HP

RH

;i+

+)

{ fp

rin

tf (st

der

r, "

%6d

" , i

bu

f [i]

/16)

;

fprin

tf (st

der

r, «

\n"

) ;

j-o;

break;

iocTead (de

v, buf, NRTBUF )

; if (ioc -1

) {

st_error (0,

0, "Error %d on dev %d

: ", err

no, dev) ;

err~atod_geterr (de

v) ;

if (err 4)

fprintf (st

derr

, "Atod buffer overf lowed . \n

" );

else fprintf (st

derr

, "Error register i* %d\n",err);

> fprintf (st

derr, "Getheader return* %d byte*\n" , io

c) ;

ibuf- (abor

t *)buf;

j-o;

if(ioOO)for(i-0;i<NDMPRN;i-H-)

{fp

rin

tf (*

tder

r, »

%2d

"

,ib

uf[

i]

fi L

OW

4BIT

S) ;

j+

+;

if (j 1

6) {

fprin

tf (

*td

err,

«\n

«) ;

j-0

; }

> bre

ak;

fprin

tf (

std

err,

" S

end

: " )

;get

* (

wrt

bu

f ) ;

i«*tr

len

(wrt

bu

f ) ;

wrt

bu

f [i]

-'\n

' ;

wrt

bu

f [-H

-i]-

'\0'

;fo

r (i

-0 ;

i<*tr

len

(w

rtb

uf)

;if

(w

rtb

uf [

i)>

-' a

' ££

w

rtb

uf [

i]<

-'

fprin

tf (s

tder

r, «

%d

", w

rtb

uf [

i] )

;) w

rtb

uf [i

]-w

rtb

uf[

i]-'

a'+

'A'

case

't

case

'T

1

fprin

tf (st

der

r, "

%d

(% )

", w

rtb

uf [

i ] ,

wrt

bu

f) ;

f flu

sh (st

der

r);

ioc-write (de

v, wrtbuf, WRTBUF) ;

if (ioc -1

) {

fprintf (st

derr

, "\nError %d on dev %d

: ", err

no, de

v) ;

perror ("d

oit .put") ;

> fprin

tf (

*td

err,

"\n

Pu

t (%

) re

turn

*

%d\

n", w

rtb

uf ,

ioc)

; b

reak

;:*

*ca

nf

(fii

np

ut

[2]

, "%

d %

d %

d %

d", £

da

y,£

hr,

£m

in, £se

c) ;

fp

rin

tf (

std

err,

"S

et t

ime

to

%d

%d

%d

%d

\n"

,day

,hr,

min

, *ec

) ;

if (a

tod

_*et

tiaM

(d

ev, d

ay, h

r, m

in, s

ee) 4

)fp

rin

tf (st

der

r, "

Ato

d b

uff

er over

f low

\n"

);

bre

ak;

:if(

gett

imeo

fda

y(f

itp

,fit

zp

) -

1)

{fp

rin

tf (st

der

r, "

Un

able

to r

ead

*y

*te

a c

lock

");

bre

ak;

.tv_*ec

) ;

fprin

tf (

*td

err,

"S

et

tim

e to

%

d %

d %

d %

d\n"

,ta

«->

tax_

yday

+l,t

BB

B->

t«_h

our,

t«yt

t->

tin

min

, tau

n->

t»_*

ec)

; if

(ato

d_

*et

tia

M(

~

case

'c

'

__

fprin

tf (a

tder

r, "

Ato

d b

uff

er o

ver

f low

\n"

) ;

ec>

«tp

.tv_u

sec/

1000;

fprin

tf (

*td

err,

"C

hang

e ti

»e b

y %

d m

llli

seco

nd

*\n

",*

ec)

; if

(ato

d_i

ncr

tiaM

(d

ev, s

ec) 4

)fp

rin

tf (st

der

r, "

Ato

d b

uff

er over

f low

\n"

) ;

bre

ak;

: ssc

an

f (c

inp

ut

[2 ]

, "%

d" ,

CM

C)

;fp

rin

tf (

std

err,

"C

hang

e ti

me

by

%d

ill

i*econ

d*\n

",*

ec)

; if

(a

tod

_in

crti

me

(dev

, *ec

) 4

)fp

rin

tf (st

der

r, "

Ato

d b

uff

er over

f 1 o

w\n

" );

Page 117: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

atod

/cdd

.c

br«a

k;CM* 'q

':di

*(0)

; de

faul

t: fp

rint

f(*t

d«rr

,"Un

know

n option %c\n",input[0]);

Page 118: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

atod

/plo

tato

d.c

/* m

axim

um n

umbe

r of

stati

on

s */

/*

num

ber

of

atr

ip*

in x

dir

ecti

on

to

b*

plo

tted

*/

/* p

lota

tod

: p

lot

outp

ut

of

ato

d i

n a

SU

N w

indo

wP

eter

War

d,

USG

S,

Men

lo P

ark

, C

a h

ack

ed

up 8

/87

and

7/8

8

*/

128 4 2

4096

90

0 6511

52

820

100

/* d

efa

ult

d

ecim

ati

on

fa

ctor

*/

/* b

lock

size fo

r r

ead

ing a

tod

*/

/* b

egin

tra

ce*

th

is m

any

pix

el*

from

left

*/

/*

up

per

le

ft

x p

osi

tion

of

fram

e */

/*

up

per

le

ft

y p

osi

tion

of

fram

e */

/* x

wid

th o

f fr

ame

*/

/* y w

idth

of

fram

e */

/* d

efa

ult

p

erce

nt

nois

e w

ill

be

of

win

dow

*/

/*

num

ber

of

ato

d s

wee

ps

use

d t

o a

uto

aca

le

*/

/* d

efa

ult

nu

mbe

r of

sta

tion

*

*/

/* d

efa

ult

mil

lise

con

ds

per

sam

ple

*/

/*

len

gth

of

tim

e ti

c m

ark

in p

ixels

*/

Idef

ine

MA

XJS

TA

Idef

ine

SHO

WW

IDTH

Id

efin

e DE

CZM

Id

efin

e NU

MCE

T Id

efin

e BE

GZN

TRAC

E Id

efin

e XZ

ERO

Id

efin

e YZ

ERO

Id

efin

e X

SZZE

Id

efin

e Y

SZZE

Id

efin

e PE

RN

OIS

E

Idef

ine

GA

INSW

EEPS

10

00

Idef

ine

NU

MST

ATS

16

Id

efin

e M

SJ3A

MPL

E 10

Id

efin

e TI

CM

AR

K

20

sta

tic

char

*m

enu

item

[]-{

"A

uto

gain

",

"D

oub

le g

ain

",

"H

alve

gain

",

"D

oub

le t

imeb

aae"

, "

Hal

ve t

imeb

aae"

, "

Exi

t"

int

men

uto

t-6;

die

(n)

int

n;

(exit

(n);

)

Idef

ine

LCW

4BIT

S O

xF

Iin

clu

de

<st

dio

.h>

elu

de

<sy

s/fi

le.h

>

tin

clu

de

<si

gn

al.

h>

ii

ncl

ud

e <

sys/

typ

es.h

>

Iin

clu

de

<su

nto

ol/

sun

vie

w.h

>Ii

ncl

ud

e <

sun

tool/

can

vas.

h>

Iin

clu

de

<su

nto

ol/

pan

el.h

>Ii

ncl

ud

e <

sun

too

l/ic

on

.h>

Iin

clu

de

<p

ixre

ct/p

ixre

ct_

hs.

h>

Iin

clu

de

<se

is/s

ud

s.h

>

stru

ct re

ct

fram

esiz

e -

{XZ

ER

O,Y

ZE

RO

,XSZ

ZE

,YSZ

ZE

};

/* si

ze a

nd

posi

tion

of

fram

e */

sta

tic sh

ort

se

is_

ico

n[]

-{

Iin

clu

de

<se

is/s

eis

.icon

>

DE

FZ

NE

_ZC

OH

_FR

OM

_ZM

AG

E(m

y_ie

on,s

eis_

ieon

);

char

buf

[2*N

UM

GE

T];

char

decst

r[]

[7]-

{"

","

oth

er

","

3rd

"

);in

t en

dit

-0;

int

intr

-1;

on

intr

()

{ in

tr-0

;

sta

tic N

oti

fy_valu

e m

y_

fra

me_

des

tro

yer

(fra

me,

sta

tus)

F

ram

e fr

ame;

~~

D

estr

oy_st

atu

s st

atu

s;

on

intr

();

if(e

nd

it)

retu

rn(n

oti

fy_n

ext_

des

troy_fu

nc(

fr«

noti

fy_vet

o_d

estr

oy(f

ram

e);

retu

rn(N

OT

ZF

Y_D

ON

E);

i, s

tatu

s))

int

m*_

sam

p-M

S_SA

MPL

E;

int

num

*tat

«=N

UM

STA

TS;

dou

ble

a

tof(

);in

t d

ec,d

ev,y

size,y

z, y

incr

, yze

ro,n

um

stin

,nu

mch

an;

int

ptr

- -1

;in

t m

axpt

r**

-1;

flo

at

gain

-0.0

;fl

oa

t fa

cto

r-1

.0;

int

first-

-1

;in

t la

st-

-1;

int

pri

nt_

av

e=0

;in

t p

lotx

-1;

int

xfa

c-1;

lon

g S

ta_

off

set

[MA

X_S

TA

], st

amax

[MA

XJS

TA

], st

amin

[MA

X_S

IA];

float

sta_gain

[MA

X_S

TA

], co

nm

volt

s [M

AX

JSTA

] ;ch

ar s

tatn

ame[

MA

XJS

TA

][5]

,tem

p[1

2];

short

*

ibu

f;struct pi

xfon

t *f

ont;

Pixw

in *pw;

main(argc,argv)

int

argc;

char **

argv

;

int

i;

sig

na

l (S

ZGZH

T, o

nin

tr)

;

if(a

rgc<

3)

{fp

rin

tf (

std

err,

"U

sage

: p

lota

tod

arg

um

ents

st

ati

on

s d

evic

e\n

")

; x

it(l

);

dee-DECIM;

if (dec<l)dec-l;

endi

t-0;

ptr- -1

; maxptr- -

1;

intr

-1;

for(i-l;argv[i] [0] '

swit

ch(a

rg»[

i][l

])

'P'

dec-a

toi(

arg

v[+

+i]

);

if(d

ec<

l)d

ec-l

; b

reak

; fi

rst

-ato

i(a

rg

v[+

+i]

);

bre

ak;

ga

in -

ato

f(argv[+

+i]

);

bre

ak;

last

-a

toi(

arg

v[-

H-i

]);

bre

ak;

ms_

sam

p-a

toi(

arg

v[+

+i]

);

bre

ak;

nu

mst

ats

-ato

i(arg

v[+

+i]

);

bre

ak;

pri

nt_

ave-

l;

bre

ak;

/*

dec

ima

tio

n*/

def

au

lt:

pri

ntf

("p

lota

tod

: U

nkno

wn

argu

men

t %

s\n

",a

rgv

[i])

;

plo

tit(

arg

v[i

],a

rg

v[i

+l]

);

/* fi

rst

stati

on

in

sc

an

*/

/* fi

xed

gain

*/

/* la

st st

ati

on

in

sc

an

*/

/* m

illi

seco

nd

s p

er s

am

ple

*/

/*

num

ber

of

sta

tio

ns

*/

/* p

rin

t aver

ages

*/

au

tosc

ale

()

{in

t i,

j,io

c,n

um

,

pri

ntf

("B

egin

au

tose

ali

ng

by

read

ing d

ata

fo

r %

d se

con

ds.

\n"

, O

AX

HS1

RE

PS*

ms_

sam

p/10

00);

Page 119: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds :/

usr/

suds

/src

/cm

d/at

od/p

lota

tod.

c

for(i

-fir

at-

1;i

<la

at;

ata

max[i

]- -1

0000;

ata

min

[i]-

10000;

ata

_off

aet[

i]»0;

) if(n

um

chan

<-2

) {

/* d

eter

min

e acali

ng of

trace,

for (J

-0, n

um

-1;

j<G

AIN

SWE

EP

S; j-

H-,

num

-H-)

{

ioc-g

eta

weep

(ib

uf,

nu

mati

n,1

);

if(i

oc E

OF

) {

prin

tf (

"O

nly

%

d aw

eep

. of

data

d

ecim

ate

d b

y

%d.

\n

",j

,dec);

j-

G&

XN

SHE

EP

S-l;

) fo

r (i-

f ir.t

-1;

i<la

at;

i-H

-)

{ a

mp

-ib

uf[

i];

if(.

am

p<

at a

min

[i])

ata

min

[i]-

aam

p;

if(a

am

p>

at a

max[i

])ata

max[i

]-.a

mp

; ata

_off

aet[

i]+

».a

mp

; if

( j

GA

IHS

WE

EP

S-1

) {

ata

_off

.at [i

] -a

ta_

of f

.et

[i]

/nu

n;

if(p

rin

t_a

ve)p

rin

tf("

%5a m

in-%

5d m

ax-%

5d

ave»

%5d

\n"

,a

tatn

am

e[i

], a

tam

in [i]

,a

tam

ax

[i] ,a

ta_off

.et[

i])

; /*

ca

lcu

late

aa

mp

lea

per

pix

el

*/

if(g

ain

l-O

.O)

{a

ta_

ga

in[i

]-g

ain

;ata

min

[i]-

gain

/ (c

on

mvolt

.[i]

*yin

cr);

ta

_g

ain

[i]-

( (.

tam

axfi

]-ata

min

[i])

*100.0

/PE

RN

OIS

E)*

co;

ata

min

[i]

-(a

tam

ax[i

]-ata

min

[i])

*1

00

/ (P

ER

NO

ISE

*yin

cr)

; ) if

(ata

min

[i]<

1)a

tam

in[i

]-1;

) /*printf("%x ",aamp«LCW4BITS);*/

) /*printf("\n");*/

Notify_valu« d«ci«ion();

plotit («tat«, d*vic«)

char *ata

t*, *d«vic«;

{rraa* fr

ana;

Canva* ca

nvaa;

char fra»a_lab«l[120];

Icon ic

on;

tra

ct

prj

prp

o*

wh

«r«;

int

i, j

,k, , n

ux

ut,

ioe,y

y,y

yl,

«w

idth

;in

t zc

ou

nta

, xah

ow, d

x,t«

n^

pp

; b

ort

x, x

O ,

«zO

, y [M

AX

_ST

A] , y

O [

MA

X_8

TA

] ;

zta

zn

ch

ar

*m

all

oc()

; ch

ar

ttia

*[1

6];

F

ILE

**ta

tfil

«;

tract

ta

tio

no

oa

p *«c_

ptr

;in

t «t_

typ

«, *t_

l*n

, n»_tb

a««, p

i^>

*ra

«c,

ta;

*/

'It-Ill,

/*

r*a

d

ctati

on

coaq

> ctr

actu

r* in

form

ati

on

*

/ t

atf

il«-*

t_op

«n

(ata

ta,

"r"

) ;

i- -1

;w

hil

a (

«t_

g«t

(*ac_

ptr

, fi

atj

typ

*, «at_

l«n

, ata

tf il

a)

! -E

OT

) {

if (

«t_t

yp*«

-ST

AT

IO»C

OM

P }

{if

( c

_p

tr->

ch

an

n«l

i (ab

ort

)HO

OA

TA

) t_«rror (di«, 0, "Cbannal nunbar not aaaignad for atation % ",

ae_ptr->ac_name.at_name);

if(ae_ptr->chann«l>-MAX_STA)

at_error(die,0,"Channel number too large. %d>-%d",

c_p

tr->

chan

nel

,MA

X_S

TA

);

j-ac_p

tr->

ch

an

nel-

l;atr

ncp

y (at a

t nam

e [ j

], a

c_p

tr->

.c_

na

me.

at_

nam

e, 5

) ;

ata

tna

me[j

][4

]-'\

0'

;if

(*c_p

tr->

con

_m

vo

lta

ato

f (N

OD

ATA

) ||

ac_

ptr

->co

n_m

volt

. «

0)

«t_

erzor(d

ie,0

, "

con

_m

volt

. n

ot

aet

for ata

tion

%

.",

ae_

ptr

->ac_

nam

e.at_

nam

e);

cora

avolt

a[j

]-ac_

ptr

->co

n_m

volt

a;

) t_

free (

ac_p

tr);

) at_

clo

ae(a

tatf

ile);

dev

-ato

d_op

en (

dev

ice,

ma

_aa

mp

,nu

ma

tat.

) ;

ioc-r

ea

d (

dev

,bu

f ,NX

1MG

ET)

; if

(ioc

!-N

OM

CE

T)

{p

«rror("

firat

read

");

retu

rn

(1);

) ib

uf-

(ab

ort

*)b

uf;

fo

r(n

um

ch

an

-0,i

-0;i

<257;i

+-1

6)

{if

((j-

ibu

f[i]

«L

CW

4B

ITS

) >

nu

mch

an)

nu

mch

an-j

;) numcban++;

/* number of multiplexer. */

numat-numatin-numchan*16;

/* number of channel.

*/printf("Number of channel, received from device % i. %d.\n",device,numat),

if(firat>la.t)

{ tempp-firat; firat-laat; laat-tempp;

}if (laat -1

|| laat>numat) laat-numat;

if (f iratOO) f ir

at-1

;numat-laat-firat+1;

printf("Plot channel. %d through %d.\n",fir.t,laat);

if(dec<4).printf(frame_label,

"Input from %. for %d channel, and plotting every %a

poin

t.",

device,numat,decatr[d«c-l]);

elae .printf (fraM_label,

"Input from %. for %d channel, and plotting every %dth point.",

device,numat,dec);

yincr-(YSIZE-12)/numat;

y.ise-yiner*numat+12;

frameaixe.r_heigbt-yaix«+25;

font-pf_open("/nar/lib/fonta/f ixedwidthfonta/acreen.r.7");

where.pr-(Pixrect *) icon_get(6my_icon,ICON_IMAGE);

where.po..x 2;

where.po..y 60;

pfjtext(where,PIX_SRC,font,device) ;

icon_.et (tm

y_ic

on, ICOH_IMA

(«E,

wher

e.pr

, 0);

fram

e-w

ind

ow_c

reat

e(0,

FR

AM

E,

FRA

ME

_LA

BE

L,

fra

me_

lab

el,

FRA

ME

_IC

ON

, 6m

y_

ico

n,

FRA

ME

_OPE

N_R

EC

T,

fifr

am

e.is

e,0

);ca

nv

a.-

win

do

w_

cre«

te (

fram

e,C

AN

VA

S,

CA

NV

ASJ

U7T

O_S

BR

INK

, F

AL

SE,

CA

NV

ASJ

NID

TH

, X

SIZ

E,

CA

WV

AS_

HE

IGH

T,

yaix

a,

WIH

_EV

KH

T_P

RO

C,

deci.

ion

, 0);

(vo

id)

noti

fy_in

terp

oae_

dea

troy_fu

nc

(fra

me,

my_fr

am

e_d

eatr

oyer

) ;

Page 120: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

atod

/plo

tato

d.c

pw

«ca

nva«_p

ixw

in(c

an

va«);

w

ind

ow

_M

t(f

ram

*, N

INJS

HO

N, T

RU

E, 0

) ;

au

toccal*

()

;

yyi-

0; width-(XSIZE-BEGINTRACE+SHOWWIDTH)/SHOHWIDTH;

y z

«ro

=y

iner

/2 ;

for(i

-0;i

<n

uu

t;i+

+)

yO

[i]-

yz«ro+

i *

yin

cr;

dx-0

;yz»yin

cr/2

;p

w_

ba

tch

_o

n(p

w);

yz*

ro~

0;

for (i«

firit

-1;

i<la

*t;

i++

) {

pw

_v«

cto

r(p

w,0

,yz*

ro,B

EG

INT

RA

CE

,yz*

ro,P

IX_

SR

C,1

); p

rin

tf(t

«m

p,"

%3d

%

",i

-H, ta

tna

m*

[i])

; p

w_

t«xt(

pw

,1,y

z*ro

+yz+

6,P

IX_

SR

C,N

OL

L,t

«n

p);

prin

tf(t

am

p,"

%3

.0f"

,((f

loa

t)«

t*_

off

««

t[i]

*co

nm

vo

lt«

[i])

/fa

cto

r),

p

w_

t«x

t(p

w,6

5,y

z*ro

4yz+

8,P

IX_S

RC

,fo

nt,

tem

p);

prin

tf (

twn

p,

"%3.

Of"

, *ta

_gain

[i])

;p

w_t«

zt(p

w,6

5,y

z*ro

4yz-

l,P

IX_S

RC

,fon

t,t«

mp

);yx«ro

+-y

incr

; } printf("Now b«gin plotting data.\n");

pw_v«ctor(pw,0,yz«ro,BEGINTRACE,yz«ro,PIX_SRC,1);

atodr«x«ro(d*v);

ptr- -1

; aaxptr* -1

;/*

*/

X-B

EG

INT

RA

CE

;xO-BEGINTRACE;

xO-BEGINTRACE ;

xcount«-0;

x*ho

w»B

EG

INT

RA

CE

+«w

idth

;w

hil

*(i

ntr

££

((

ioc-g

«t.

w««p

(ib

uf,

nu

tn*t

in, d

«c)

)!-E

OF

) )

{y

z«ro

-yz;

if (x BEGINTRACE)

( /* chang* tim* at beginning of trac* */

for(i-0,j-"

--

! if

(i ll

)tti

nw

[i]-

'.';

! tt

im«[i

]-(c

r)

(ib

uf

[j-H

-]S

LO

W4B

ITS

)+'0

' ;

} ttia

*[1

5]»

'\0';

can

f (f

itti

nw

[1

2]

, "%

d- ,

fim

«_tb

«M)

; p

ixp

«r**c-x

f ac*

(10

00/m

«_M

UB

p) /p

lotx

; fo

r (t

m-B

EG

IHT

RA

CE

+ (

(100

0-K

M_t

ba«

«) *

pix

p*r«

*c)

/1000;t

«<

x«h

ow

;tm

+-p

ixp

«r«

«c)

pw v

ecto

r (p

w, t

m, 0

, tm

, TIC

MA

RK

, PIX

_SR

C, 1

) ;

pw

~v«ct

or

(pw

, tm

, YSI

ZE

, tm

, YSI

ZE

-TIC

MA

RK

, PIX

_SR

C, 1

) ;

yy

-yx

«ro

- (f

acto

r* (

ibu

f [i

] -c

ta_off

««t

[i]

) /

tw

ain

[i]

) ;

pw

_v«ct

or(

pw

,xO

,yO

[i],

x,y

y,P

nt_

SR

C,l

);yO

[i]-y

y;yz*

ro+

«yin

cr;

} xO

-x;

if (

-H-x

cou

nt«

>«^

>lo

tx)

{xco

un

tc-0

; x+

- d«c*

xfa

c; }

if

(x>

-x«h

ow

) {

pw

_t«

xt

(pw

, BEG

XN

TRA

CE,

iz*

-l,

PIX

_SR

C, M

OLL

, tti

a*

) ;

pw

_»h

ow(p

w);

if (x>-XSIZE)

( x-BEGIHTRACE;

xO-B

KGIN

TRfc

CE;

XM

how

BE

GX

HT

RA

CE

+nri

dth

;p

w_w

rit*

bac

kgx

oun

d(p

w,B

EC

INT

RA

CE

,0, «

wid

th+

10

, YS

IZE

,PIX

_SR

C),

pw_writ*background(pw,x, 0, «width-HO, YSIZE, PIX_SRC) ;

pixpar«*c«qEfac* (1000/m*_«amp) /plotx;

for(;tm<x«how;tm+^>ixp*r«*c)

{pw_v*ctor(pw,tm, 0, tm,TICMARK,PIX_SRC,1);

pw_v*ctor (pw

,tm,

YSI

ZE, tm

, YSIZE-TICMARK, PIX_SRC, 1)

;

(void

)noti

fy_d

i«p

»tc

h()

; > if

(in

tr)

{n

oti

fy_d

i«p

*tc

h()

;p

w_b

atc

h_off

(pw

) ;

nd

it-1

;w

ind

ow_m

ain

lo

op

(fra

rn*);

> do

c*

(d

*v)

;

tatic chort *i

buff

r;

int

g*t0w*«p(buff«r,numch,d*cim)

hort *buff*r;

int numch,dacia;

(

int

go

t,n

*x

t;

ptr

+«n

um

ch*d

*ciB

-nu

mch

;fo

r(i-

0;i

<n

um

ch;i

-H-)

{

if (

ptr

<m

axp

tr)

{b

uff

er [i]

-ib

uf f

r [

ptr

++

] ;

go

t»r«

ad

(d

«v, b

uf ,

HO

MG

ET)

; if

(in

tr 0

) r«

tura

(EO

F)

; ib

uff

r-(

«h

ort

*)b

uf;

if

(got

<HO

MG

ET

) {

if(g

ot

4)

{p

rin

tf ("

A

fcoD

bu

ffer o

verfl

ow

. R

*M

ttin

g.\

nM)

ato

d r«

z*ro

(d

«v)

;

ptr

-ptr

-maxp

tr;

maxp

tr- (g

ot/

2)

; b

uff

er [i]

-ib

uff

r[p

tr+

+]

/16;

itu

rn(O

) ;

Ho

tify

_v

alu

«C

anva

c ca

nv

a*

;arg

)

cad

dx_t

arg

;

Iton

u d

«ci

; in

t i,

wh

ich

;

Page 121: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

dsr/

usr/

suds

/src

/cm

d/at

od/p

lota

tod.

c

if (

even

t_id

(ev

ent)

! -M

S_R

ICH

T)

retu

rn(N

OT

ZFY

_ZG

NO

RE

D)

; d

ecid

e-M

nu

_cr

eate

(MEN

tr_J

XJM

P_A

FTER

_SEL

ECTI

OH

, TR

UE,

0,0

);fo

r(i-

0;i

<n

enu

tot;

i++

) m

enu

jiet

(de

cide

,ME

N0_

STR

ZN

G_Z

TE

M,n

enui

ten[

i] ,

1+

1,0

) w

hic

h-(

int)

men

u_«h

ow

(dec

ide,

can

vas,

can

va«_

win

dow

_eve

nt (c

an

va

s,ev

ent)

, 0)

; w

itch

(w

hic

h)(

cace

l:

gain

»0.0

;au

tosc

al*

()

; b

r*ak

; ca

c« 2:f

act

or»

fact

or*

2.0

;b

r*ak

; ca

«« 3

:facto

r-f

acto

r*0.5

;b

r*ak

;ea

«« 4:p

lotx

-plo

tx/2

; if

(plo

tx 0

) (

plo

tx=

l;

xfa

c^xfa

c*2;

} retu

rn;

cat* 5:if (xfacf-1) xfac-acfac/2;

! plotx«plotx*2;

return;

6:«zit(0);

/* modify label* on left of plot */

pw_writebackground (pw

, 0, 0, BEGZNTR&CE, YSZZE, PZX_SRC) ;

yzero 0;

for(i»fir*t-l;i<la*t;i++)

{pw_vector (pw

, 0,

yzero

, BEGZNTRACE,yzero, PZXJSRC, 1)

; printf(tenp,"%3d % ",i+1, tatname[i]) ;

pw__te

xt (pw

, l,yzero+yz+6,PIX_SRC,HULL, ten

p) ;

printf(tenp,»%3.0f",((float)«ta_off*et[i]*conmvolt«[i])),

pw_text (pw

, 65,yzero+yz+8, PZX_SRC, font, ten

p) ;

printf (tenp, "%

3. Of ",

*ta_gain [i

] /fa

ctor

) ;

pwjtext (pw

, 65,yzero+yz-l, PZX_SRC, font,tenp)

; yzero+-yincr;

Page 122: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

1I03 o§

w?C/2

l

Page 123: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

dem

ux/d

emux

.c

/* demux.c: demultiplex mx.* file* into mudm streams

v

*/Idefine

NOISE_SAMP

100

Idefine MAXINPUTBUF

4096

Idefine MUXPOSITION

1 Idefine

LOW4BITS

OxF

fdefine MAX_STA

128

linclud* <*tdio.h>

{include <sys/types.h>

Iinclude <sys/stat.h>

tinclude <sys/time.h>

Idefine MSK4 OxF

Iinclude "/usr/*uda/include/*ud*.h"

die(

n) int

n;

{exit (n) ;

int debug-0;

int remove-0;

int stat*out-l;

int noisenum NOISE_SAMP;

main(argc,argv)

int argc;

char **argv;

<int i,j,div,numsta;

int fi

rst;

char outfile[120];

/* number of cample* to calc noise of trace

/* maximum size of input buffer in byte*

/* position of mux number in header

/* bit mask for lower 4 bit*

/* maximum number of station*

*/

*/

*/

*/

*/

/*

4 le

ast

si

gn

ific

an

t b

it*

*/

first-1;

outfile[0]-'\0';

if(argc<3)

{fprintf (st

derr

, "Usage :

demux option* stations datafile*\n")

exit

(l);

for(

i-l;

i<arg

c;i-

H->

{

if(a

rgv[i

][0]

'-')

<

wit

ch (argv[i

][lj

)ca

se

'd'

: d

ebu

g I

; b

reak

;ca

se 'o

':

*tr

cpy (o

utf

ile,

argv

[i+

+]

)b

reak

; ca

se 'n

':

nois

enu

m-a

toi

(arg

v[i

++

] ) ;

bre

ak;

case

'r

':

rem

ove-

1;

bre

ak;

case

's

':

sta

tso

ut-

0;

bre

ak;

/* debug option

/* specify output file

*/ */

/* number samps to sum for noise*/

remove input file

no stations in outfile

default: fprintf (st

derr

, "Unrecognized option %s

ignored. \n",

*/ */

els

e

{if

(fi

rst

) {

first

-0;

num

st a

-load

«ta

t ion

s (a

rgv

[i]

);}

els

e

{if

(ou

tfil

e[0

] '\

0')

{

/*

chan

ge p

refi

x t

o

" t

"

for o

utp

ut

strc

py

(o

utf

ile, a

rgv[i

]) ;

for(j

-0,d

iv-0

;ou

tfil

e[j

J!-

'\0

';j-

H-)

if

(o

utf

ile [

j ] '

/')

div

-j;

ou

tfil

e[d

iv]-

's';

o

utf

ile[d

iv+

l]-'

t' ;

> dem

uxi

t (a

rgv

[i]

, ou

tfil

e,

nu

mst

a) ;

*/

stru

ct

sta

tio

nco

mp

*s

tats

[MA

X_S

TA

];

loa

dst

ati

on

s(st

atf

ile)

char

*st

atf

ile;

int

j,n

um

*ta

ts,s

t_ty

pe,

st_le

n;

stru

ct

sta

tio

nco

mp

*sc

_p

tr;

FIL

E *st

atf

;

nu

mst

ats

-0;

for(

j-0;

j<M

AX

_ST

A;j

++

)sta

ts[j

]-N

UL

L;

sta

tf-«

t_o

pen

(sta

tfil

e,"

r"

);w

hil

e(s

t_g

et(

Csc

_p

tr,t

stjt

yp

e,C

st_

len

, st

atf

)!-E

OF

) {

if(s

t_ty

pe

«ST

AT

ION

CO

MP

) {

if (sc

_p

tr->

ch

an

nel

(sh

ort

JNO

DA

TA)

st_

erro

r(d

ie,0

,"C

ha

nn

el

num

ber

no

t a

ssig

ned

fo

r st

ati

on

% "

,sc

_p

tr->

sc_n

am

e.st

_n

am

e);

if (

sc_p

tr->

chan

nel

>-M

AX

_ST

A)

st_

erro

r(d

ie,0

,"C

ha

nn

el

num

ber

too la

rge.

%

d> %

d",

sc_p

tr->

chan

nel

,MA

X_S

TA

) ;

nu

mst

ats-

H-;

j

sc_p

tr->

chan

nel

-l;

sta

ts [

j]-s

c_p

tr;

) ) st_close(statf) ;

for (j-

0; j<numstats; j-H

-) if (st

ats

[ j ] NULL)

st_error(0, 0, "Stationcomp structure for channel %d is missing",j)

return(numstats);

it(filein,fileout, num

sta)

char *filein, *fileout;

int

numsta;

<int i,j,mux,numin,numstats,yr,mo,dy,hr,mn,err, size,type, stlen;

short *input,data,*out;

char *ptr,*ptrout;

float mintr,maxtr;

double sec;

stru

ct m

uxd

ata

*mx;

stru

ct

des

crip

trace

*

dt;

MSJ

CD

fE m

stim

e,m

ake_

mst

ime(

);ex

tern

ch

ar *

li*

t_m

*ti

me(

);FI

LE

*

da

tain

,*d

ata

ou

t;

data

in -

*t_

op

en

(fil

ein

,"

da

tao

ut

*t_

op

en(f

ileo

ut,

ne

w: n

um

in-*

t_ge

t (t

ptr

, ct

yp

e, c

*tl

en, d

ata

in);

if

(typ

el^k

uXD

AT

A)

{ t

_p

ut(

ptr

,typ

e,c

tlen

,data

ou

t);

goto

ne

w;

*/

mx-(struct muxdata *)ptr;

numstats-numsta;

si ze>«x->numsamps/numstats;

if (numstaI ««x->numchans)

fprintf(stderr,

"MASHING: %d stations in stationfile but %d station* in muxdata tructure-",

/* number of station*

/* number of data cample* per *tation

Page 124: SUDS: Seismic Unified Data System - USGS · SUDS: Seismic Unified Data System Peter L. Ward ... to a wide variety of seismic data and seismic data processing. The primary concern

war

ds:/u

sr/s

uds/

src/

cmd/

dem

ux/d

emux

.c

c->

typ

edata

),

nu

mat

a,n

x >

nu

mch

ana)

; if

(m

x->

typ

edat

a! -' r')

at_

erro

r (d

ie, 0

,"

Exp

ect

da

taty

pe

'r':

C

an n

ot

inte

rpre

t d

ata

typ

* ' %

c'

if((

i-(n

um

in-a

tlen

)/2)

f- B

uc->

num

aain

pa)

at_error (die,0, "%d samples read but %d aamplea expected",i,mx->nua«amps);

input-(abort *)(ptr+atlen);

at_create(DESCRIPTRACE,£dt, ai>e*2);

out- (ab

ort

*) (dt

+1)

;

if(d

ebu

g)

{fp

rin

tf(a

tderr,"

Fir

at

hea

der

: );

fo

r (i

-0; i<

l6;

i-H

-) fp

rin

tf (atd

err,

%

x fp

rin

tf(a

tderr,"

\n"

);1,

inp

ut[

i]£L

OW

4BX

TS

) ;

i-in

pu

t[l]

£M

SK

4;

/* calc

ula

te t

he

Ba

tia

a of

firat

aan

pl*

*/

dec

od

ejn

stim

* (

mx-

>b

egin

tim

e, t

yr,

fim

o, t

dy, t

hr,

ban

, £a*

c) ;

dy

- (i

np

ut[

2]

& M

SK4)

*100

+

(in

pu

t[3]

£ M

SK

4)*1

0+(i

np

ut[

4]

£ M

SK4)

;b

r-

(in

pu

t[5]

£ M

SK4)

*10

+(i

np

ut[

6]

£ M

SK4)

;nm

- (i

np

ut

[7]

£ M

SK4)

*10

+ (i

np

ut

[8]

£ M

SK4)

; e

c-(

inp

ut[

9]

£ K

SK

4)*1

0.0+

(in

pu

t[10

] £

KS

K4)

*1.0

+(i

np

ut[

11]

£ M

SK

4)*0

.1+

(i

np

ut[

12]

£ H

SK

4)*0

.01+

(in

pu

t[13

] £

MS

K4)

*0.0

01;

ati

aa^

nak

*_iB

atim

* (y

r, 0

, dy,

br,

mn,

aac)

;if

(d

ebu

g)

fpri

ntf

(atd

err,

"T

ime

firat

aan

pl«

-%a

in f

ila

%a\

nn,

li

at_

Ma

tim

a(m

ati

na

,1),

file

ou

t);

if (

(err

-in

pu

t[14]

£MS

K4)

) /*

ch

eck

mag

ic

and

erro

r b

ita

at

erro

r (0

,0,

"Clo

ck

erro

r b

ita

at

tim

e %

a-%

d" , li

atj

uti

aa

(m

atin

*, 1

) ,a

rr)

;if

((i

-in

pu

t[15

]£M

SK

4)

?-

14)

at_error( 0,0

, "Data er

ror:

Magic time bita at time %a

-%d"

, liat_matima(»atima,l),i);

*/

for(

j-0

; j<

nu

mat

ata;

B

intz

-32

00

0.0

; m

ax

tr-

-32

00

0.0

; at_

init

(DES

CR

IPTR

AC

E, d

t) ;

for(i

-0;i

<a

iia

;i-t

-f)

{o

ut [i

] -i

np

ut

[i*n

um

atat

a+ j]

/16;

if (

out

[i]<

min

tr)a

intr

-ou

t [i

] ;

if (

out [i

] >m

aztr

) na

ztr-

ou

t [ i

] ;

> if(a

tata

ou

t)a

t_p

ut

(ata

ta [

j ] ,

STA

TIO

HC

OH

P, a

iiaof

(atr

uct

at

atio

nco

mp

) , d

ata

ou

t)

atr

ncp

y (

dt-

>d

t_n

ama

. net

wor

k , ata

ta [

j ] -

>ac

_nam

a . n

etw

ork

, 4

) ;

atr

ncp

y (

dt-

>d

t_n

ama

. at_

nim

e , a

tata

[ j

] ->

a c_

nam

a . a

t_n

aaa

, 4 )

; d

t->

dt_

nam

e . c

omp

onen

t-at

ata

[ j ]

->ac

_nan

e . c

omp

onen

t ;

dt-

>d

t_n

ame

. in

at_

typ

e a

tata

[ j

] ->

ac_n

ame

. in

at_

typ

e;

dt-

>b

egin

tim

e-«at i

me

; d

t->

da

taty

pe-

' a'

;

dt-

>d

igi_

by-0

; d

t->

len

gth

ai l

e ;

dt-

>ra

te-w

x->

dig

_ra

te ;

dt-

>m

ind

ata

^a

intr

;

for(

i-0

,aa

xtr

-0.0

;i<

no

iaen

uB

;i+

+)

max

tr+

-ou

t [i

] ;

dt-

>aven

oia

eaM

azt

r/n

oia

enm

;atj

pu

t (d

t, D

ESC

RIP

TR

AC

E, a

iie*

2-t

-aii

eof

(atr

uct

d

eacr

iptr

ace

) , d

ata

ou

t )

> st_cl

oae

(data

in)

; st

_cl

oae

(data

ou

t) ;