xumi1993 / seispy

Python module of seismology and receiver functions
https://seispy.xumijian.me
GNU General Public License v3.0
95 stars 29 forks source link

Restricted data access (username, password) #66

Closed dtiger10 closed 11 months ago

dtiger10 commented 1 year ago

Is your feature request related to a problem? Please describe. Username and Password protected federated data cannot be accessed in IRIS web service

error received:

2023-09-01 22:55:27,784 [RF] ERROR: Error in loading station info: No data available for request. HTTP Status code: 204 Detailed response of server:

Describe the solution you'd like Area to enter username and password as a variable in the parameter file

Describe alternatives you've considered I tried to manually enter it into the code but was unsuccessful

Additional context Add any other context or screenshots about the feature request here. Thank you

xumi1993 commented 1 year ago

Hi, I'm sorry for delay on replying to you. Sorry I haven't downloaded data using username and password on the FDSN web service. Have you downloaded these data using obspy? If yes, I can embed the function into Seispy.

dtiger10 commented 1 year ago

Hi! thank you for your response. Yes I have downloaded restricted data before using obspy here is a general script that uses the client to set username and password then ultimately plots the seismic data:

from obspy import UTCDateTime from obspy.clients.fdsn import Client

Initialize client with creds

client = Client(base_url="http://service.iris.edu", user="", password="")

Define time range

t1 = UTCDateTime("2020-01-01T00:00:00.000") t2 = UTCDateTime("2020-01-02T00:00:00.000")

Download data

st = client.get_waveforms(network="", station="", location="", channel="", starttime=t1, endtime=t2)

Download station metadata

inv = client.get_stations(network="", station="", channel="*", starttime=t1, endtime=t2)

plot data up

st.plot()

xumi1993 commented 1 year ago

I have push the commit https://github.com/xumi1993/seispy/commit/39f149df114b191b0da8a39abbfeddde0b218888 to dev branch. please re-install seispy from source code.

I don't have the account of any web-service. can you help to test this function? First you can set up user and password to variables in para like

rf = RF()
rf.para.data_server = 'IRIS'
rf.para.cata_server = 'IRIS'
rf.para.stainfo.network = 'IU'
rf.para.stainfo.station = 'ULN'
rf.para.stainfo.channel = 'BH?'
rf.para.stainfo.location = '00'
rf.para.use_remote_data = True
rf.para.data_server_user = 'xxxxxx'
rf.para.data_server_password = 'xxxxxx'
# Other parameters
# ......

The other usage are the same as the previous version. Thank you very much.

dtiger10 commented 1 year ago

Definitely, I don't mind. Thank you for your help!

I installed the seispy-dev in a new env using ' pip3 install . '

when I try:

query = Query(server='IRIS') query.get_stations(network='', station='', level='channel', includerestricted=True)

I get:

KeyError Traceback (most recent call last) File python3.11/site-packages/obspy/core/util/base.py:408, in _read_from_plugin(plugin_type, filename, format, **kwargs) 407 try: --> 408 format_ep = eps[format] 409 except (KeyError, IndexError):

KeyError: 'STATIONXML'

During handling of the above exception, another exception occurred etc...

I did not receive that error when using the master version...


However, when running the rf.para._data_server_password and rf.para._data_server_user

I get:

Cell In[16], line 24 22 rf.para.date_begin = UTCDateTime('20190101') 23 rf.para.date_end = UTCDateTime('20221231') ---> 24 rf.para.data_server_user('xxx') 25 rf.para.data_server_password('xxx')

TypeError: 'NoneType' object is not callable