megies / obspyck

ObsPyck is a GUI application that is intended to cover the tasks in a standard analysis workflow for seismic events in seismological observatory practice.
https://github.com/megies/obspyck/wiki
GNU General Public License v2.0
61 stars 32 forks source link

Correct setup of hypo2000.inp command file? #16

Closed cjhopp closed 8 years ago

cjhopp commented 8 years ago

Hi all,

I'm attempting to setup hypo2000 for use with Obspyck and I think I have everything in the right place. I have a symlink to the hyp1.40 binary (named hyp2000__Linux__64bit) along with the command file bay2000.inp and a velocity model, which are all located in ~/obspyck/hyp_2000.

At present, the event file which is being read from SeisHub only contains P-picks, no magnitudes, S-picks or locations.

When I click 'do hyp2000' I get the following output followed by an error message:

Phases for Hypo2000:
NS02?P?0 120625145705.94
NS03?P?0 120625145706.05
NS04?P?0 120625145706.40
NS06?P?0 120625145706.22
NS07?P?0 120625145706.72
NS08?P?0 120625145705.58
NS09?P?0 120625145706.53
RT01?P?0 120625145707.52
RT02?P?0 120625145706.89
RT05?P?0 120625145707.83
RT06?P?0 120625145707.37
RT07?P?0 120625145707.20
RT09?P?0 120625145707.21
RT11?P?0 120625145706.91
RT12?P?0 120625145707.67
WPRZ?P?0 120625145705.83

Stations for Hypo2000:
  NS02-38-33.26N17609.74E 375
  NS03-38-31.40N17612.55E 327
  NS04-38-32.55N17613.54E 345
  NS06-38-33.93N17611.67E 407
  NS07-38-33.65N17613.62E 345
  NS08-38-31.82N17611.13E 345
  NS09-38-34.53N17609.77E 451
  RT01-38-37.36N17610.32E 371
  RT02-38-36.10N17610.59E 346
  RT05-38-37.91N17611.76E 369
  RT06-38-37.02N17611.35E 366
  RT07-38-36.27N17612.39E 320
  RT09-38-36.75N17610.51E 339
  RT11-38-35.97N17611.64E 330
  RT12-38-36.85N17613.38E 400
  WPRZ-38-31.18N17609.74E 519

--> hyp2000 finished
Traceback (most recent call last):
  File "/home/chet/obspyck/obspyck.py", line 405, in on_qToolButton_doHyp2000_clicked
    self.doHyp2000()
  File "/home/chet/obspyck/obspyck.py", line 1968, in doHyp2000
    self.catFile(files['summary'], self.critical)
  File "/home/chet/obspyck/obspyck.py", line 2000, in catFile
    lines = open(file, "rt").readlines()
IOError: [Errno 2] No such file or directory: '/tmp/obspyck-6dyzld/hyp_2000/hypo.prt'

I've tried running hyp2000 by itself with the .sta and .pha files written to the /tmp directory by obspyck but hyp2000 has trouble reading the formats of these files:

chet@chet-Dell-Precision-M3800:~/hypo2000/hyp1.40/test$ ../bin/hyp1.40 
 HYPOINVERSE 2000 STARTING
6/2014 VERSION 1.40 (geoid depth possible)                            
 COMMAND? @bay2000.inp
  Read in stations:
 *** ERROR READING STATION FILE AT LINE:
   NS02-38-33.26N17609.74E 375 

I think there was a tab placed at the beginning of each line in the station file. When I removed this, it stopped throwing the error but instead threw the following:

chet@chet-Dell-Precision-M3800:~/hypo2000/hyp1.40/test$ ../bin/hyp1.40 
 HYPOINVERSE 2000 STARTING
6/2014 VERSION 1.40 (geoid depth possible)                            
 COMMAND? @bay2000.inp
  Read in stations:
    16 STATIONS READ IN.
  Read in crustal model(s):
  FIND INPUT PHASE FILE TYPE & SET PHS(COP) & ARC(CAR) FORMATS
  INPUT IS A TRADITIONAL HYPO71-HYPOINVERSE PHASE FILE
  SETTING FORMATS COP 1, CAR 1
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 NS02?P?0 120625145705.94
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 NS03?P?0 120625145706.05
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 NS04?P?0 120625145706.40
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 NS06?P?0 120625145706.22
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 NS07?P?0 120625145706.72
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 NS08?P?0 120625145705.58
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 NS09?P?0 120625145706.53
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 RT01?P?0 120625145707.52
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 RT02?P?0 120625145706.89
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 RT05?P?0 120625145707.83
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 RT06?P?0 120625145707.37
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 RT07?P?0 120625145707.20
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 RT09?P?0 120625145707.21
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 RT11?P?0 120625145706.91
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 RT12?P?0 120625145707.67
 *** SKIP PHASE CARD WITH UNKNOWN STATION:
 WPRZ?P?0 120625145705.83
 COMMAND? 

So it looks like maybe my command file is set up wrong (I've just been editing the example file provided with the hyp1.40 download) and hyp2000 is not creating any output for Obspyck to read. Would anyone be able to provide an example of a working plugin_dir and command file (or any other advice)?

Thanks,

Chet

Command file: bay2000.inp.txt Station and phase files written by Obspyck: hyp2000.pha.txt stations_original.dat.txt

megies commented 8 years ago

I don't use hyp2000 much with obspyck, so it might not be set up perfectly in all regards, but it works in general (I just did a dummy location..). Below is our input file, esp. the Choose between formats line will influence you, I think.. looks like we're using hypo71 format for all three files (phases, stations, location output), but it's kind of hard to find a good documentation on those.. for the stations it looks like it's what is described on page 13 of this pdf, labelled "Station format no. 1". Esp. be aware that station codes are limited to 4 letters (I have %6s in the code but I think it only works for station codes with 4 letters or less, compare pdf, two blanks then 4-letter station code)! It looks like yours are much longer? So you either have to change your station names, or adapt the obspyck code to handle those with hyp2000 differently (compare what I'm doing for focmec). Or.. you could try to switch obspyck code to use "new hypoinverse" formats (I guess it's this one and it supports 5 letters).

hope it helps..

*
*                               STATION DATA
*                               ************
*   You must read stations before using the ATE, DEL, FMC or XMC commands
*
* Enable year 2000 formats
* ************************
200 F 2000 0
* Use new station codes
* *********************
* LET 5 2 3 2 2
*
* Choose between formats.
* 1 = Summary format    (1=old hypoinverse; 2=hypo71; 3=new hypoinverse)
* 2 = Terminator format (1=hypoinverse; 2=hypo71; 3=get trial hypocenter from header record)
* 3 = Station format    (1=old hypoinverse; 2=hypo71; 3=new hypoinverse)
* ******************************************************************************************
* H71 2 3 3             hypo_mgr settings
* H71 1 1 3             cal2000.hyp settings
H71 2 2 2
*
* Read ascii file of all stations
* *******************************
*STA 'hypoinverse/stas/all2.sta'
STA 'stations.dat'
*
PHS 'hyp2000.pha'
FIL
* Read XMAG corrections
* *********************
* XMC 'hypoinverse/stas/all2000.xmc' T 0
*
* Read FMAG corrections
* *********************
* FMC 'hypoinverse/stas/all2000.fmc' T 0
*
* CUSP phony station codes
* ************************
* UNK 5 'IRG1' 'IRG2' 'IRG3' 'IRGE' 'WWVB'
*
* CRH @bw.crh
*                           MULTIPLE CRUSTAL MODELS
*                           ***********************
*
* Read multiple model info and station delays (in ascii)
* ******************************************************
@bayernmult.hyp
*
*                             MAGNITUDE CHOICES
*                             *****************
*
* Use Eaton for Fmag1 and logA0, Hirshorn for Fmag2
* *************************************************
* MAG 1 T 3 1
*
* Set Eaton's new magnitude constants
* ***********************************
* DUR -.81 2.22 0 .0011 0, 5*0, 9999 1
*
* Extra distance and depth terms for Eaton
* ****************************************
* DU2 .005 40, .0006 350, .014 10
*
* Zmag of Hirshorn; use -2.06=-.71-1.35
* -1.35 compensates for the 1.35 gain corr used for the 42db Z stations
* *********************************************************************
* DUB -2.06 2.95 0 .001 0, 1            /This comment is required for some reason (BUG!!!)
* DUB -2.06 2.95 0 .001 0, 5*0, 9999 1    /corrected 990111 by Klein
*
* Components for FMAG1; new code D
* ********************************
* FC1 'D' 4 'VHZ' 'VHE' 'VHN' 'VLZ'
*
* Use low-gain verticals for FMAG2 = Zmag
* Old codes: FC2 'Z' 1 'Z'
* ***************************************
* FC2 'Z' 1 'VLZ'
*
* XMAG components
* ***************
* XC1 'X' 7 'VHZ' 'VLZ' 'VLE' 'VLN' 'VDZ' 'VDN' 'VDE'
*
* Local Magnitude (ML) components
* *******************************
* XC2 'L' 6 'WLN' 'WLE' 'HHN' 'HHE' 'BHN' 'BHE'
*
* Use Berkeley's Nordquist logA0 relation
* for the WA & synthetic WA components
* ***************************************
* LA0 6 'WLN' 4, 'WLE' 4, 'BHN' 4, 'BHE' 4, 'HHN' 4, 'HHE' 4
*
* Component corrections for Eaton Fmags
* Old codes: FCM 3 'Z' -.06 'E' -.30, 'N' -.30
* ********************************************
* FCM 3 'VLZ' -.06 'VLE' -.30 'VLN' -.30
*
* Component corrections for Eaton Xmags
* Old codes: XCM 2 'V'  .33, 'Z'  .20
* *************************************
* XCM 2 'VHZ' .33, 'VLZ' .20
*
* Preferred magnitudes.
* Minimum number of readings and min, max magnitudes
* Changed as shown for hyp2000.
* **************************************************
* PRE 7,  3 4 4 9, 5 6 4 9, 1 1 0 9,  2 1 0 9, 4 4 4 9, 3 0 0 9, 4 0 0 9
* PRE 7,  3 0 4 9, 5 6 4 9, 1 1 0 9,  2 1 0 9, 4 4 4 9, 3 0 0 9, 4 0 0 9
*
*                         STANDARD CHOICES FOR CALNET
*                         ***************************
*
* Residual weighting
* ******************
RMS 4 .10 2 3
*
* Standard timing error
* *********************
ERR .10
*
* P to S ratio
* ************
POS 1.78
*
* Don't log events to terminal.
* Don't print unweighted stations.
* ********************************
REP F F
*
* Force location of junk events
* *****************************
JUN T
*
* Minimum number of stations
* **************************
MIN 4
*
* Use California region codes
* ***************************
* NET 2
*
* Trial depth
* ***********
ZTR 5
*
* Distance weighting
* ******************
DIS 4 15 3.5 7
*
* Weights for P weight codes 0-3
* Old values were: 1. .75 .5 .25
* New values are:  1. .5 .2 .1
* ******************************
WET 1. .5 .2 .1
*
*                                OUTPUT FORMAT
*                                *************
*
* Send error messages to terminal
* *******************************
ERF T
*
* No page ejects
* **************
TOP T
*
* No station list or models in printfile
* **************************************
LST 0 0 0
*
* Medium print output each event
* ******************************
KPR 2
*
* You should use the ATE command with the date and time of your first eq.
* using a year of 0 will always work, but is inefficient.
*
* An easy way is to use the ATE command below with a 0 year, then
* follow this command file with your own ATE command:
*    ATE 1* 84 1 1 0 0    This rereads the standard file but loads
*                         attenuations from your starting date.
*
* Use this line if first date is unknown
* **************************************
* ATE 'hypoinverse/stas/all2000.atn' 0
*
* Load cal factors for digital stations
* *************************************
* CAL 'hypoinverse/stas/all2000.cal' 0
*
* Specify phase format.
* 5 = archive file with shadow cards
* **********************************
* COP 5
*
* Set the archive file format.
* 3 = Full format with shadow cards
* *********************************
* CAR 3
*
*       for ARC, SUM, and PRT commands
*
* Name the print output file
* NOTE: filename must be enclosed in single-quotes for PRT command
* ****************************************************************
PRT 'hypo.prt'
*
* Name of summary file
* NOTE: filename must be enclosed in single-quotes for SUM command
* ****************************************************************
SUM 'hypo.sum'
*
* Name the archive output file
* NOTE: filename must be enclosed in single-quotes for ARC command
* ****************************************************************
ARC 'hypo.arc'
*
* Set the append flags to T or F.
* 1 = Printout file,
* 2 = Summary file,
* 3 = Archive file.
* *******************************
APP F F F
LOC
*
cjhopp commented 8 years ago

Hi Tobias,

This helped a lot, thank you! Hyp2000 now works fine with some minor tweaks.

When the input files were written for hyp2000, obspyck assumed N and E hemisphere locations. I made some minor changes to account for this and created a pull request (I really just wanted to acquaint myself with how Git worked in that regard so disregard it if you'd like).

Cheers,

Chet

megies commented 8 years ago

Thanks for sharing the improvements to the code, I'll happily merge them of course. Just a tip: In general it's best to work on a branch when you do things like this, so that the master branch at your fork and the master of the upstream repository stay in sync.

cjhopp commented 8 years ago

I appreciate the tip. I'm implementing a git-flow branching model to my forks as we speak.

Cheers,

Chet