jakewalter/easyQuake

Not an issue but a question

Opened this issue · 1 comments

Dear Jake,
I am doing some test with your easyQuake suite. It is a very nice "integrated" solution.
I am facing an issue about the location codes of the seismic stations. My network uses location codes (ie 00) but it seems that easyQuake suite drops the location code, and in the catalog produced all the station with pick have location empty location code.
This quite an issue when using after the catalog produced to review the event (with Seiscomp in my case).
Is there an easy way to modify the code ?
Or should I go deep inside to make the modification.
I encountered the same issue with EQT (I am also testing it in standalone mode), and I have had to make some modification in the associator.py script to take the location code in account.
Maybe, if it not easily faisible with the actual easyquake code you may give me some inputs on where I have to search in the code to use the location code of the stations ?

Hope my message is ok, maybe not really clear with my french-english...

Thanks in advance for you answer.
Regards,
Mickael.

Dear Jake,
I have been looking in the code and found how to make a "dirty hack" to save my issue.
Surely there is someting smarter, but it works.
If you are interested, I have done the modification of the "select_all_associated" routine to pass project_folder and dirname to it so that it can read the inventory file (dailyinventory.xml) and found the location codes to be added to the waveformID object :

def select_all_associated(conn, f0, project_folder, dirname):
"""
Query all rows in the associated table
:param conn: the Connection object
:return:
"""
cur1 = conn.cursor()
cur1.execute("SELECT * FROM associated")
stalistall = set()
rows = cur1.fetchall()
dfs1 = pd.DataFrame()
cat1 = Catalog()
# ADD ML
inv = read_inventory(project_folder+dirname+'/dailyinventory.xml')
#end ADD ML

for rownum, row in enumerate(rows):
#print(row)
#(row[0])
df4 = pd.DataFrame()
df4 = pd.DataFrame({'Time': row[1], 'Lat':row[3],'Long':row[4]}, index=[0])
dfs1=dfs1.append(df4)
origin = Origin()
origin.latitude = row[3]
origin.longitude = row[4]
origin.depth = 5000
origin.time = row[1]
origin.arrivals = []
strday = row[1][0:4]+row[1][5:7]+row[1][8:10]
cur1.execute('SELECT * FROM picks_modified WHERE assoc_id IN (?)',[int(row[0])])
picks1a = sorted(cur1.fetchall())
stas = []
event = Event()
evid = 'smi:local/Event/'+strday+str(rownum+1).zfill(3)
orid = 'smi:local/Origin/'+strday+str(rownum+1).zfill(3)
event.resource_id = ResourceIdentifier(id=evid)
origin.resource_id = ResourceIdentifier(id=orid)
event.resource_id = ResourceIdentifier(id='smi:local/Event/'+strday+str(rownum).zfill(3))
origin.resource_id = ResourceIdentifier(id='smi:local/Origin/'+strday+str(rownum).zfill(3)+'_1')
for pick1 in picks1a:
#ADD ML
loc_code = inv.select(network=pick1[3], station=pick1[1], channel=pick1[2]).networks[0].stations[0].channels[0].location_code
stream_id = WaveformStreamID(network_code=pick1[3], station_code=pick1[1], location_code=loc_code, channel_code=pick1[2])
#end ADD ML
p = Pick()
p.time = pick1[5]
p.phase_hint = pick1[6]

Of course the variable dirname has to be passed also to the "combine_associated" function (def combine_associated(project_folder=None, project_code=None, dirname=None, catalog_year=False, year=None, hypoflag=False, eventmode=False):)

Let me know if you will think about integrating that modification or solve the location code issue in an other way ?

Regards
Mickael.