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

Export: NonLinLoc Picks Exporter #7

Open
miili opened this issue Sep 14, 2023 · 1 comment
Open

Export: NonLinLoc Picks Exporter #7

miili opened this issue Sep 14, 2023 · 1 comment

Comments

@miili
Copy link
Member

miili commented Sep 14, 2023

No description provided.

@yetinam
Copy link
Collaborator

yetinam commented Sep 18, 2023

Here's my code for the task as an inspiration.

with open(obs_path, "w") as f:
    for event_idx, event_catalog in catalog.groupby("event_idx"):
        f.write(f"PUBLIC_ID E{event_idx:08d}\n")
        for _, pick in event_catalog.iterrows():
            # Example: GRX    ?    ?    ? P      U 19940217 2216   44.9200 GAU  2.00e-02 -1.00e+00 -1.00e+00 -1.00e+00
            if isinstance(pick["time"], datetime.datetime):
                time = pick["time"]
            else:
                time = datetime.datetime.fromisoformat(pick["time"])
            phase = pick["phase"].upper()
            station = self._station_mapper.translate_station(pick["station"])
            daystr = time.strftime("%Y%m%d")
            hourmin = time.strftime("%H%M")
            second = time.strftime("%S.%f")[:-2]

            f.write(
                f"{station:6s} ?    ?    ? {phase}      ? {daystr} {hourmin}   {second} "
                f"GAU  2.00e-02 -1.00e+00 -1.00e+00 -1.00e+00\n"
            )
        f.write("\n")

return obs_path

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

No branches or pull requests

2 participants