Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change template_gen naming of output. #345

Open
ikahbasi opened this issue Nov 4, 2019 · 10 comments
Open

Change template_gen naming of output. #345

ikahbasi opened this issue Nov 4, 2019 · 10 comments

Comments

@ikahbasi
Copy link
Collaborator

ikahbasi commented Nov 4, 2019

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 ikahbasi changed the title Change name of template & plots in template_gen function. Change template_gen naming of output. Nov 4, 2019
@calum-chamberlain
Copy link
Member

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?

@ikahbasi
Copy link
Collaborator Author

ikahbasi commented Nov 4, 2019

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.

@calum-chamberlain
Copy link
Member

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.

@ikahbasi
Copy link
Collaborator Author

ikahbasi commented Nov 4, 2019

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.

@calum-chamberlain
Copy link
Member

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.

@ikahbasi
Copy link
Collaborator Author

ikahbasi commented Nov 4, 2019

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)

@calum-chamberlain
Copy link
Member

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.

@ikahbasi
Copy link
Collaborator Author

ikahbasi commented Nov 5, 2019

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?

@calum-chamberlain
Copy link
Member

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.

@dr-glenn
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants