EQcorrscan icon indicating copy to clipboard operation
EQcorrscan copied to clipboard

Change template_gen naming of output.

Open ikahbasi opened this issue 5 years ago • 10 comments

Is your feature request related to a problem? Please describe. All output's of template_gen are named by the trace's time. It makes it hard to find which template and plots (noise_plot&pretty_template_plot) are related to which event.

Describe the solution you'd like I'd like to replace the event's origin-time with the trace's time in template_gen naming and make related changes.

ikahbasi avatar Nov 04 '19 07:11 ikahbasi

I'm finding it hard to remember where this comes from: can you point to the code lines that cause this, and what lines you propose to change?

calum-chamberlain avatar Nov 04 '19 19:11 calum-chamberlain

I'd like to change all these "st1[0].stats.starttime" and etc to origin time of event. I made these changes in my local package and it's good.

in template_gen(): https://github.com/imankahbasi/EQcorrscan/blob/9132850a92ef5bcb0f022f7ada51d77a6b668816/eqcorrscan/core/template_gen.py#L403-L407

and https://github.com/imankahbasi/EQcorrscan/blob/9132850a92ef5bcb0f022f7ada51d77a6b668816/eqcorrscan/core/template_gen.py#L394-L397

in _template_gen(): https://github.com/imankahbasi/EQcorrscan/blob/9132850a92ef5bcb0f022f7ada51d77a6b668816/eqcorrscan/core/template_gen.py#L822-L836

And other related changes that is necessary for this implementation. Best regards.

ikahbasi avatar Nov 04 '19 20:11 ikahbasi

I don't think this can work in the way EQcorrscan currently defines templates: events are not strictly required for templates, and event then, events do not have to have an origin time.

calum-chamberlain avatar Nov 04 '19 20:11 calum-chamberlain

events are not strictly required for templates

I can't understand your means. How can we make a template without any event? We need to an event and their phase-times to generate a template. https://github.com/imankahbasi/EQcorrscan/blob/9132850a92ef5bcb0f022f7ada51d77a6b668816/eqcorrscan/core/template_gen.py#L360

events do not have to have an origin time.

It's easy, I define if event has origin time then use it and if not, use trace's start time same as now.

ikahbasi avatar Nov 04 '19 20:11 ikahbasi

A template made using the from_sac method will not have an event associated with it, a template instantiated without using a construct method does not have to have an event associated with it: it is not a required parameters, it can be set to None.

I would rather keep it consistent so that all template plots are named in the same way.

calum-chamberlain avatar Nov 04 '19 20:11 calum-chamberlain

What do you think about something like this?

if method=='sac_file':
    name = str(st[0].stats.statrtime)
else:
    if event.origins[0].time=='':
        name = str(st[0].stats.statrtime)
    else:
        name = str(event.origins[0].time)

And we can use some prefix to show which one saved with trace's time like: name = 'tr'+str(st[0].stats.starttime)

ikahbasi avatar Nov 04 '19 21:11 ikahbasi

If you do want to go down this route then you will need to get the origin time something like this:

try:
    origin = event.preferred_origin() or event.origins[0]
except IndexError:
   origin = None
if origin and origin.time is not None:
    name = str(origin.time)
else:
    name = str(st[0].stats.starttime)

but IMHO this is quite a bit of code for something that isn't that necessary.

calum-chamberlain avatar Nov 04 '19 21:11 calum-chamberlain

In this screenshot you can see the naming of files with trace's name. And it will be Worse in case of far epicentral distance. there is some change in trace's time in template picture. Although I think it will be solve simply by name = str(tr.stats.starttime) and be sure that name is unique. Screenshot from 2019-11-05 10:59:12

But i prefer something like this, even more better with dash and without dots. Screenshot from 2019-11-05 11:16:34

Can I make this change if you would like?

ikahbasi avatar Nov 05 '19 07:11 ikahbasi

I'm still not sure about this - I think it would be nice if the plots had the same name as the template, but templates are named (by default) by the earliest time in the template stream. I'm loath to change that default naming convention, which means I'm against changing how the plots are named - however they probably should be named by the earliest trace time, rather than just the first.

calum-chamberlain avatar Nov 05 '19 22:11 calum-chamberlain

Yes, they should be named by earliest trace time, rather than first. In my use of template_gen, I sort the traces by starttime and use the first (earliest) trace for the name.

dr-glenn avatar Dec 22 '21 21:12 dr-glenn