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

populating station coordinates #335

Closed
seismolab-uct opened this issue Mar 25, 2024 · 2 comments
Closed

populating station coordinates #335

seismolab-uct opened this issue Mar 25, 2024 · 2 comments

Comments

@seismolab-uct
Copy link

Hi everyone,

I have a novice question related to populating the station coordinates on MSNoise.

I currently have a couple hundred stations (nodal data) and although I could manually populate the lat and lon on the msnoise admin page I wanted to ask if there is an msnoise script that does this using an inventory. I have searched through the docs but haven't found an answer.

I imagine that this can be done via mysql (e.g., mysql> LOAD DATA LOCAL INFILE '/path/stations.txt' INTO TABLE stations; ) but perhaps there is a tool already present that I am missing.

Thanks for any help
Best

@ThomasLecocq
Copy link
Member

if you have the response files (any response format readable by obspy) - you can set the response_path to the right directory, and the msnoise config sync

if not, you'd better use the API (here comparing the "stations" column of an input csv file):

from msnoise.api import *

df = pd.read_csv("LargeMEM_winter_serial_coordinates.csv")

db = connect()

for sta in get_stations(db, all=True):
    tmp = df[df["station"]==sta.sta]
    sta.X = float(tmp["longitude"].values[0])
    sta.Y = float(tmp["latitude"].values[0])
    sta.coordinates = "DEG"
    db.commit()
    

@seismolab-uct
Copy link
Author

Thanks so much Thomas that definitely helps

Best

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