jpjones76 / SeisIO.jl

Julia language support for geophysical time series data
http://seisio.readthedocs.org
Other
47 stars 21 forks source link

`get_data` using IRIS DMC PH5WS dataselect fails #52

Closed tclements closed 4 years ago

tclements commented 4 years ago

I'm trying to download data from the IRIS DMC PH5WS dataselect Web Service (https://service.iris.edu/ph5ws/dataselect/1/).

(@v1.4) pkg> st
Status `~/.julia/environments/v1.4/Project.toml`
[b372bb87] SeisIO v1.0.0

Request data from PH5WS:

julia> S = get_data("FDSN","YW.1002..DPZ",s=s,t=t,src="http://service.iris.edu/ph5ws/",v=2)
[ Info: 2020-07-08T21:19:11 ¦ Querying FDSN stations
Most compact request form = ["YW" "1002" "" "DPZ" ""]
request url:http://service.iris.edu/ph5ws/station/1/query
request body: 
level=response
format=xml
 YW 1002 * DPZ 2016-06-23T00:00:00 2016-06-23T01:00:00

[ Info: 2020-07-08T21:19:17 ¦ Building list of channels
data query strings:
YW 1002 * DPZ
[ Info: 2020-07-08T21:19:17 ¦ Data query begins
request url: http://service.iris.edu/ph5ws/dataselect/1/query
request body: 
format=miniseed
YW 1002 * DPZ 2016-06-23T00:00:00.000000 2016-06-23T01:00:00.000000
┌ Warning: Request failed!
│ URL: http://service.iris.edu/ph5ws/dataselect/1/query
│ POST BODY: 
│ format=miniseed
│ YW 1002 * DPZ 2016-06-23T00:00:00.000000 2016-06-23T01:00:00.000000
│ 
│ RESPONSE: 400 (Bad Request)
└ @ SeisIO ~/.julia/packages/SeisIO/pSAug/src/Web/0_essentials.jl:44
parsable = false
[ Info: 2020-07-08T21:19:24: done FDSNget query.
[ Info: n_badreq = 1
[ Info: 2020-07-08T21:19:24 ¦ Can't prune empty channels; web request wasn't fully parsed.
SeisData with 2 channels (2 shown)
    ID: YW.1002..DPZ                       XX.FAIL..001                       
  NAME: Node at Wavefields Community Expe…                                    
   LOC: 36.6223 N, -97.7398 E, 322.3 m     0.0 N, 0.0 E, 0.0 m                
    FS: 250.0                              0.0                                
  GAIN: 1.02964e9                          1.0                                
  RESP: a0 0.999813, f0 40.0, 2z, 2p       a0 1.0, f0 1.0, 0z, 0p             
 UNITS: m/s                                                                   
   SRC: http://service.iris.edu/ph5ws/dat…                                    
  MISC: 4 entries                          3 entries                          
 NOTES: 3 entries                          3 entries                          
     T:                                                                       
     X: (empty)                            (empty)          

Station request works well. I believe dataselect is failing because a reqtype of [fdsn shot, receiver] is required in PH5 queries. For now, it seems adding reqtype=fdsn would allow for PH5 queries but shot and receiver queries might require some more work/different syntax.

Here is the working request url: https://service.iris.edu/ph5ws/dataselect/1/query?reqtype=fdsn&format=mseed&net=YW&sta=1002&cha=DPZ&starttime=2016-06-23T00:00:00&endtime=2016-06-23T01:00:00&nodata=404

tclements commented 4 years ago

I'll note this is a feature request, rather than a bug!

jpjones76 commented 4 years ago

I promise I'll work on this, but it might be awhile. I'm still working on a reader for Silixa's TDMS (which may or may not be a variant on standard TDMS), and looking into GPU SeisIO. I also need to implement Dylan's instrument deconvolution.

There's more to it than that string, though. If that was the only change required, this would work:

s = "2016-06-23T00:00:00"
t = "2016-06-23T01:00:00"
S = get_data("FDSN","YW.1002..DPZ",s=s,t=t,src="http://service.iris.edu/ph5ws/",v=2,opts="reqtype=fdsn")

Yet that code returns 500 (Internal Server Error) on the timeseries query.

I could add an internal function for PH5WS requests, but it seems like IRIS wants PH5 query syntax to be interchangeable with FDSN. So it might be best to email IRIS about differences between PH5WS and FDSNWS with HTTP POST methods.

tclements commented 4 years ago

Okay, thanks for the tip on opts. I can talk to IRIS and try to write up a PR on this today.

tclements commented 4 years ago

After some digging, PH5 POST requests need to be made in this format

reqtype=FDSN
format=mseed
YW 1002 -- DPZ  2016-06-23T00:00:00 2016-06-23T01:00:00

the only changes required are the ordering of reqtype & format plus it looks like -- is needed when the location is empty.

Working on a solution for this right now.