== Program Name == makeV0cont == PCS stream-state == group: EventStream table: state: ExportWF == Description == makeV0cont prepares [[http://www.strongmotioncenter.org/NCESMD/reports/cosmos_format_1_20.pdf|COSMOS format]] V0 files for qualifying new events. These files can be imported by the [[http://www.quake.ca.gov/cisn-edc/|CISN Engineering Data Center]]. makeV0cont uses the program mkv0 to do this work for an event. mkv0 is described below. makeV0cont runs a typical PCS client loop: * queries for the next event which is 600 or more seconds old in its assigned stream-state. The delay time is to allow waveforms to become accessible. * if an event is found, query the database for its magnitude. * if the event magnitude is at least the configured minimum (currently 4.0), run "exportWF -c mkv0.conf -FMSv " * set the stream-state event result to 1 and repeat the loop * if no event is found, sleep 30 seconds and repeat the loop == Program Location == post-proc systems: /home/ncss/ncpp/exportWF/bin == Configuration File == none; the configurable parameters for makeV0cont are hard-coded but should be changed as needed. # Location of exportWF directory tree: my $root = "$ENV{TPP_HOME}/exportWF"; # Command line (except event ID) for exportWF: my $exportWF = "$root/bin/mkv0 -c $root/conf/mkv0.conf -FMSv"; my $sleepTime = 120; # look for work ('next') this often (seconds) my $delayTime = 600; # require an event be posted this long before acting on it my $maxDaysBack = 7; # Don't process events older than this my $cutoff = (60 * 60 * 24 * $maxDaysBack); my $minMagnitude = 3.3; # minimum magnitude to export waveforms my $pausetime = 5; my $PCSgroup = "EventStream"; my $PCStable = $dbase; my $PCSstate = "ExportWF"; my $goodResult = 1; == Source of Database name == command line == Cron Starter Program == 5,15,25,35,45,55 * * * * /home/ncss/ncpp/exportWF/bin/startExpWF dcucb == Log File == /home/ncss/ncpp/exportWF/logs/exportWF.log == Other Programs Called == /home/ncss/ncpp/exportWF/bin/mkv0: mkv0 is a perl script that does all the work to create COSMOS V0 files for an event. mkv0 usage: mkv0 version 0.0.8 mkv0 - generate and publish COSMOS V0 waveforms files Syntax: mkv0 -c config [-d DB] [-FMSX] eventID mkv0 -h where: -c config - specify the configuration file (required) -d DB - specify masterDB instead of that returned by $TPP_BIN_HOME/masterdb. -f file - Add stations listed in to event list -F - Copy V0 files to configured FTP directory -M - Send email about new V0 files in FTP directory -S - Copy new V0 files to configured sendfile directory -X - don't replace existing V0 SCNL files (saves time) -h - print usage syntax and exit. -v - verbose mode: tell what's happening There are few configurable parameters within mkv0. Most adjustable parameters are on mkv0.conf. This configuration file includes lots of comments to explain the various parameters. mkv0 makes database queries for information about the event, and for the list of stations for which one or more channels have peak ground acceleration (PGA) at least 0.1 %g (configurable). It determines the distance from station to event hypocenter, computes P traveltime, and sets the time window for waveforms for that station. Requested waveform start is P arrival time minus configured PreEventTime; waveform end is start time plus event magnitude times configured SecsPerMag. Using this list of stations, mkv0 queries the database for the list of SNCLs that are elegible for use by mkv0. Then mkv0 tries to obtain waveforms for these SNCLs, using the "DataSource" methods given in mkv0.conf. The available methods are SQL query using the [[http://vault.gps.caltech.edu/trac/cisn/wiki/wave|Wave stored procedure package]], and the external program [[wvc]]. mkv0 uses each DataSource method in the order listed in the configuration file. After each method is tried, mkv0 evaluates the retrieved waveform. If its start and end times meet or exceed the requested times, that waveform is accepted and no further DataSource methods are tried for that SNCL. At this point the waveform for each SNCL has been read into mkv0 arrays. mkv0 queries the database for all the header information reuired for the COSMOS V0 file. Then for each SNL (station-network-location code) it finds the time period for which each channel's waveforms has data. A COSMOS requirement is that each of the waveforms for one S-N-L must have the same start and end times, with no gaps or missing data. The waveforms are now trimmed in mkv0's internal arrays. A COSMOS V0 file is written for each SCNL; these are then concatenated for each station (SN). Finally the COSMOS v0 files are distributed as specified by command-line options, with the details set in the mkv0 configuration file. mkv0 saves all its files in a directory named by the event ID under the configured WorkDir, currently /home/ncss/ncpp/exportWF/work. Other programs used by mkv0: /home/ncss/run/bin/wvc /usr/local/bin/qmerge /usr/bin/scp /usr/bin/mailx The parameters in makeV0cont are sufficient for the initial run of mkv0. For larger events of interest, it is likely that mkv0 wll need to be run manually in the hours or days following the earthquake. It is helpful to do a preliminary manual run of mkv0 without any of the publishing options: mkv0 -c ...conf/mkv0.conf eventID If this reports producing more V0 files than the previous run, then consider running mkv0 again with the appropriate publishing options.