With this new PEER headline
PEER NGA STRONG MOTION DATABASE RECORD
Landers, 6/28/1992, Yermo Fire Station, 360
ACCELERATION TIME SERIES IN UNITS OF G
NPTS= 2200, DT= .0200 SEC
the ReadNGAFile.tcl gets me an error
What change should I make in the following code (ReadNGAFile.tcl) so that it gives me NPTs , DT and ground motion data without error ?
I played around a bit , however it didn't work yet !
# READNGAFILE.TCL
# ------------------------------------------------------------------------------------------------------------
#
# Written: fmk
# Date: July 2000
# Modified fmk, 2010
# A procedure which parses a ground motion record from the PEER
# strong motion database by finding dt in the record header, then
# echoing data values to the output file.
#
# Formal arguments
# inFilename -- file which contains PEER strong motion record
# outFilename -- file to be written in format G3 can read
# dt -- time step determined from file header
# nPts -- number of data points from file header
#
# Assumptions
# The header in the PEER record is, e.g., formatted as follows:
# PACIFIC ENGINEERING AND ANALYSIS STRONG-MOTION DATA
# IMPERIAL VALLEY 10/15/79 2319, EL CENTRO ARRAY 6, 230
# ACCELERATION TIME HISTORY IN UNITS OF G
# 3930 0.00500 NPTS, DT
proc ReadNGAFile {inFilename outFilename dt nPts} {
# Pass dt by reference
upvar $dt DT
upvar $nPts NPTS
# Open the input file and catch the error if it can't be read
if [catch {open $inFilename r} inFileID] {
puts stderr "Cannot open $inFilename for reading"
} else {
# Open output file for writing
set outFileID [open $outFilename w]
# Flag indicating dt is found and that ground motion
# values should be read -- ASSUMES dt is on last line
# of header!!!
set flag 0
# Look at each line in the file
foreach line [split [read $inFileID] \n] {
if {[llength $line] == 0} {
# Blank line --> do nothing
continue
} elseif {$flag == 1} {
# Echo ground motion values to output file
puts $outFileID $line
} else {
# Search header lines for dt
set count 0;
foreach word [split $line] {
if {$word != ""} {
if {$count == 0} {
set NPTS $word;
} elseif {$count == 1} {
set DT $word;
} elseif {[string match $word "DT"] == 1} {
set flag 1;
break;
}
incr count 1
}
}
}
}
# Close the output file
close $outFileID
# Close the input file
close $inFileID
}
}
Read from PEER NGA Files
Moderators: silvia, selimgunay, Moderators
Re: Read from PEER NGA Files
look at the ReadRecord.tcl file here:
http://opensees.berkeley.edu/WebSVN/lis ... dModels%2F
http://opensees.berkeley.edu/WebSVN/lis ... dModels%2F