mspass-team / mspass

Massive Parallel Analysis System for Seismologists
https://mspass.org
BSD 3-Clause "New" or "Revised" License
30 stars 12 forks source link

bug in index_miniseed #490

Closed pavlis closed 8 months ago

pavlis commented 8 months ago

I'm not sure if this bug is in index_minseed or how the new version of read_data handles miniseed data. The problem is easily seen in this output:

doc=db.wf_miniseed.find_one()
d = db.read_data(doc,collection='wf_miniseed')
print(d)
print(d.tref)

generates:

{'_id': ObjectId('6580a1519f5344e14cfdbd15'), 'chan': 'BHE', 'channel_endtime': 1427673599.000000, 'channel_hang': 90.000000, 'channel_id': ObjectId('6580a29030aaf53a22c03210'), 'channel_starttime': 1276646400.000000, 'channel_vang': 90.000000, 'delta': 0.050000, 'dfile': 'event401.mseed', 'dir': '/N/slate/pavlis/usarray/wf/2012', 'foff': 0, 'format': 'mseed', 'is_abortion': False, 'last_packet_time': 1344691259.549998, 'nbytes': 69632, 'net': '2G', 'npts': 72000, 'sampling_rate': 20.000000, 'site_endtime': 1427673599.000000, 'site_id': ObjectId('6580a29030aaf53a22c03210'), 'site_starttime': 1276646400.000000, 'source_id': ObjectId('6580a2a330aaf53a22c047c2'), 'sta': 'IUGFS', 'starttime': 1344687797.699998, 'storage_mode': 'file'}
TimeReferenceType.Relative

where the biggest issue is the last line printed: TimeReferencType.Relative. miniseed data is dogmatically UTC time standard.

The following trivial function is an easy workaround for a parallel workflow:

def set_tref(d):
     d.tref = TimeReferenceType.UTC
    return d

where you just use that function in map operator to fix the problem. We still need to fix it though as it is blatantly wrong. I think the main fix needs to be applied to index_mseed_file as it should be setting the metadata attribute "time_standard" and as the print(doc) statement shows that is not set in that or any other wf_miniseed the current container creates.

BTW I think this problem has been around for a while. I didn't touch index_mseed_file in the major revision of Database in the current container.