Binary Data File Formats

View Data Files

Binary files are provided for programatic access of data in an efficient manner. However it is important you understand the format of the binary file before attempting to read data. Pease read the section below that corresponds to the type of file you wish to download. For your convenience we also provide some sample source code (written in Java) for you to download to see how to properly read the binary files. See each section below to download the correct source code for that file type, or download them all right here. Some important facts to keep in mind if you choose to write your own parser.

  1. Some of the binary files will require you to swap the byte order of their data. This is because the files were originally created on a machine with a processor that uses the reverse byte order of your own. Since we don't know which processor you have we can not tell you which files you will need to swap the byte order with and which you do not.
  2. Some files contain binary “short” values which are two bytes long. After finishing reading a particular record from the binary file you must then skip two bytes in order to be on the proper “word boundary” to start reading data for the next record.
  3. File formats that specify the “numvals” are indicating the number of valid values to expect to find for the particular record, however the file format will actually always allocate the full number of bytes for that file format so you may need to skip aditional, invalid data before reaching the next record in the data file. For example, all the Hazard Curve files allocate 20 * 4 = 80 bytes of y-value data following the “numvals” value. However often times only 18 or 19 of those values will contain actual data. So after reading 18 or 19 float values (whatever is specified by numvals) out of the file you will need to advance your file pointer 2 or 1 additional bytes before the next record will start.

Design Ground Motions

These files contain SS and S1 ground motion data (corresponding to the 0.2 second and 1.0 second periods respectively). The basic format of the binary file is as follows:

<recnum><latitude><longitude><numvals><Ss><S1>

Where

  • recnum : 4-Byte Integer Just an index identifying the record number in the file.
  • latitude : 4-Byte Floating Point Number Specifies the geographic latitude of the location.
  • longitude : 4-Byte Floating Point Number Specifies the geographic longitude of the location.
  • numvals : 2-Byte Short Integer Specifies the number of valid values in this record. Generally for this file type there are always two (2) values. Names, the SS and S1.
  • SS : 4-Byte Floating Point Number The value of the short period (0.2 second) ground motion at this location.
  • S1 : 4-Byte Floating Point Number The value of the 1.0 second ground motion at this location.
Download example parser for this format

Design Retrofit

See Design Ground Motions

Hazard Curves

These files contain hazard curve data for gridded locations. One of the first lines in the data file will specify a latitude and longitude of 0.0 each. This line specifies the X-values each hazard curve contained in that file. Each subsequent line contains the Y-values for the corresponding latitude/longitude specified on that line. The files are formatted as follows:

<recnum><latitude><longitude><period><numvals><yval_1><yval_2>...<yval_numvals>

Where

  • recnum : 4-Byte Integer Just an index identifying the record number in the file.
  • latitude : 4-Byte Floating Point Number Specifies the geographic latitude of the location.
  • longitude : 4-Byte Floating Point Number Specifies the geographic longitude of the location.
  • period : 4-Byte Floating Point Number The spectral period for which this curve is defined. This is specified in seconds and 0.0 indicates PGA.
  • numvals : 2-Byte Short Integer The number of valid values in this record. This number is less than or equal to 20 and if it is less than 20 you must skip 4 * (20 - numVals) bytes before reading the next record.
  • yval_N : 4-Byte Floating Point Number The annual frequency of exceeding the correspnding ground motion (specified at the top of the file).
Download example parser for this format

Uniform Hazard Spectra

These files contain uniform hazard spectra for gridded locations. One of the first lines in the data file will specify a latitude and longitude of 0.0 each. This line specifies the X-values each spectra contained in that file. Each subsequent line contains the Y-values for the corresponding latitude/longitude specified on that line. The files are formatted as follows:

<recnum><latitude><longitude><fex><numvals><yval_1><yval_2>...<yval_numvals>

Where

  • recnum : 4-Byte Integer Just an index specifying the record number in this file.
  • latitude : 4-Byte Floating Point Number The geographic latitude for this location.
  • longitude : 4-Byte Floating Point Number The geographic longitude for this locaiton.
  • fex : 4-Byte Floating Point Number The frequency of exceedance for this spectrum.
  • numvals : 2-Byte Short Integer The number of values in this spectrum record. This number is less than or equal to 7 and if it is less than 7 you must skip 4 * (7 - numvals) bytes before reading the next record.
  • yval_N : 4-Byte Floating Point Number The UHS value correspnoding to the X-value specified at the top of the file.
Download example parser for this format

Zip Code Data Files

These files contain ground motion data for zip codes. Ground motion data is reported for the each of the zip code centroid, maximum value, and minimum value. These files are formatted as follows:

<zipcode><type><latitude><longitude><cen_ss><cen_s1><max_ss><max_s1><min_ss><min_s1>

Where

  • zipcode : 4-Byte Integer An integer representation of a 5-digit zip code. If the number read is less than 5-digits it should be left-padded with zeroes to become a 5-digit zip code.
  • type : 4-Byte Integer A type-code such that: 0 -> Area, 1 -> Point. Where an area is a regular zip code and a point indicates a single point that was given its own zip code (generally a post office).
  • latitude : 4-Byte Floating Point Number The geographic latitude for this location.
  • longitude : 4-Byte Floating Point Number The geographic longitude for this location.
  • cen_ss : 4-Byte Floating Point Number The centroid SS ground motion value.
  • cen_s1 : 4-Byte Short Integer The centroid S1 ground motion value.
  • max_ss : 4-Byte Floating Point Number The maximum SS ground motion value in this zip code.
  • max_s1 : 4-Byte Short Integer The maximum S1 ground motion value in this zip code.
  • min_ss : 4-Byte Floating Point Number The minimum SS ground motion value in this zip code.
  • min_s1 : 4-Byte Short Integer The minimum S1 ground motion value in this zip code.
Download example parser for this format