-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Added query_bsi, based on comcat query functions. Can be called from csep.__init__, wrapping the readers._query_bsi. This is based in csep.utils.comcat.search functions. mods: (i) Exception catchs for Hostname mismatch in SSL verification (the bsi does not go through https). (ii) in comcat and bsi, ids are set different. SummaryEvent now handles this with try/except. (iii) bsi returns datetimes as utc strings, instead of timestamp as comcat. * docs: added query_bsi to api reference and mentioned it in tutorial/catalog_filtering styl: modified query_comcat docstring * fix: added maxdepth to query_comcat and query_bsi wrappers at top and bottom level. default=1000. Maybe these functions should have the arguments to completely define an experiment catalog (perhaps just max_mag and its ready)
- Loading branch information
Showing
8 changed files
with
268 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Connection: | ||
- close | ||
Host: | ||
- webservices.rm.ingv.it | ||
User-Agent: | ||
- Python-urllib/3.10 | ||
method: GET | ||
uri: https://webservices.rm.ingv.it/fdsnws/event/1/query?format=geojson&starttime=2009-04-06T00%3A00%3A00&endtime=2009-04-07T00%3A00%3A00&limit=15000&maxdepth=1000&maxmagnitude=10.0&mindepth=-100&minmagnitude=5.5&offset=0&orderby=time-asc&eventtype=earthquake | ||
response: | ||
body: | ||
string: '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"eventId":1895389,"originId":755599,"time":"2009-04-06T01:32:40.400000","author":"BULLETIN-SISPICK","magType":"Mw","mag":6.1,"magAuthor":"--","type":"earthquake","place":"2 | ||
km SW L''Aquila (AQ)","version":1000,"geojson_creationTime":"2022-09-21T12:18:03"},"geometry":{"type":"Point","coordinates":[13.38,42.342,8.3]}}]}' | ||
headers: | ||
Access-Control-Allow-Origin: | ||
- '*' | ||
Cache-Control: | ||
- public, max-age=60 | ||
Connection: | ||
- close | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Wed, 21 Sep 2022 12:18:03 GMT | ||
Server: | ||
- nginx | ||
Transfer-Encoding: | ||
- chunked | ||
Vary: | ||
- Accept-Encoding | ||
- Accept-Encoding | ||
X-Cache-Status: | ||
- EXPIRED | ||
X-RateLimit-Limit: | ||
- '10' | ||
X-RateLimit-Reset: | ||
- '1' | ||
X-UA-Compatible: | ||
- IE=Edge | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Connection: | ||
- close | ||
Host: | ||
- webservices.rm.ingv.it | ||
User-Agent: | ||
- Python-urllib/3.10 | ||
method: GET | ||
uri: https://webservices.rm.ingv.it/fdsnws/event/1/query?format=geojson&starttime=2009-04-06T00%3A00%3A00&endtime=2009-04-07T00%3A00%3A00&limit=15000&maxdepth=1000&maxmagnitude=10.0&mindepth=-100&minmagnitude=5.5&offset=0&orderby=time-asc&eventtype=earthquake | ||
response: | ||
body: | ||
string: '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"eventId":1895389,"originId":755599,"time":"2009-04-06T01:32:40.400000","author":"BULLETIN-SISPICK","magType":"Mw","mag":6.1,"magAuthor":"--","type":"earthquake","place":"2 | ||
km SW L''Aquila (AQ)","version":1000,"geojson_creationTime":"2022-09-21T12:14:55"},"geometry":{"type":"Point","coordinates":[13.38,42.342,8.3]}}]}' | ||
headers: | ||
Access-Control-Allow-Origin: | ||
- '*' | ||
Cache-Control: | ||
- public, max-age=60 | ||
Connection: | ||
- close | ||
Content-Type: | ||
- application/json | ||
Date: | ||
- Wed, 21 Sep 2022 12:14:55 GMT | ||
Server: | ||
- nginx | ||
Transfer-Encoding: | ||
- chunked | ||
Vary: | ||
- Accept-Encoding | ||
- Accept-Encoding | ||
X-Cache-Status: | ||
- MISS | ||
X-RateLimit-Limit: | ||
- '10' | ||
X-RateLimit-Reset: | ||
- '1' | ||
X-UA-Compatible: | ||
- IE=Edge | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from datetime import datetime | ||
import os.path | ||
import vcr | ||
from csep.utils.comcat import search | ||
|
||
HOST = 'webservices.rm.ingv.it' | ||
|
||
|
||
def get_datadir(): | ||
root_dir = os.path.dirname(os.path.abspath(__file__)) | ||
data_dir = os.path.join(root_dir, 'artifacts', 'BSI') | ||
return data_dir | ||
|
||
|
||
def test_search(): | ||
datadir = get_datadir() | ||
tape_file = os.path.join(datadir, 'vcr_search.yaml') | ||
with vcr.use_cassette(tape_file): | ||
# L'Aquila | ||
eventlist = search(starttime=datetime(2009, 4, 6, 0, 0, 0), | ||
endtime=datetime(2009, 4, 7, 0, 0, 0), | ||
minmagnitude=5.5, host=HOST, limit=15000, offset=0) | ||
event = eventlist[0] | ||
assert event.id == 1895389 | ||
|
||
|
||
def test_summary(): | ||
datadir = get_datadir() | ||
tape_file = os.path.join(datadir, 'vcr_summary.yaml') | ||
with vcr.use_cassette(tape_file): | ||
eventlist = search(starttime=datetime(2009, 4, 6, 0, 0, 0), | ||
endtime=datetime(2009, 4, 7, 0, 0, 0), | ||
minmagnitude=5.5, host=HOST, limit=15000, offset=0) | ||
event = eventlist[0] | ||
cmp = '1895389 2009-04-06 01:32:40.400000 (42.342,13.380) 8.3 km M6.1' | ||
assert str(event) == cmp | ||
assert event.id == 1895389 | ||
assert event.time == datetime(2009, 4, 6, 1, 32, 40, 400000) | ||
assert event.latitude == 42.342 | ||
assert event.longitude == 13.380 | ||
assert event.depth == 8.3 | ||
assert event.magnitude == 6.1 |