EQcorrscan
EQcorrscan copied to clipboard
Change template_gen naming of output.
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.
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?
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.
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.
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.
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.
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)
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.
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.
But i prefer something like this, even more better with dash and without dots.
Can I make this change if you would like?
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.
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.