Skip to content

Commit 3ba5a38

Browse files
committed
refac: removed verbose default options from catalog readers
tests: updated vcr
1 parent cf4ed4c commit 3ba5a38

File tree

7 files changed

+64
-50
lines changed

7 files changed

+64
-50
lines changed

csep/__init__.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,17 @@
33
import time
44

55
from csep._version import __version__
6-
7-
from csep.core import forecasts
6+
from csep.core import catalog_evaluations
87
from csep.core import catalogs
8+
from csep.core import forecasts
99
from csep.core import poisson_evaluations
10-
from csep.core import catalog_evaluations
1110
from csep.core import regions
11+
from csep.core.exceptions import CSEPCatalogException
12+
from csep.core.forecasts import GriddedForecast, CatalogForecast
1213
from csep.core.repositories import (
1314
load_json,
1415
write_json
1516
)
16-
17-
from csep.core.exceptions import CSEPCatalogException
18-
19-
from csep.utils import datasets
20-
from csep.utils import readers
21-
22-
from csep.core.forecasts import GriddedForecast, CatalogForecast
2317
from csep.models import (
2418
EvaluationResult,
2519
CatalogNumberTestResult,
@@ -28,7 +22,8 @@
2822
CatalogPseudolikelihoodTestResult,
2923
CalibrationTestResult
3024
)
31-
25+
from csep.utils import datasets
26+
from csep.utils import readers
3227
from csep.utils.time_utils import (
3328
utc_now_datetime,
3429
strptime_to_utc_datetime,
@@ -366,7 +361,7 @@ def query_gcmt(start_time, end_time, min_magnitude=5.0,
366361
max_depth=None,
367362
catalog_id=None,
368363
min_latitude=None, max_latitude=None,
369-
min_longitude=None, max_longitude=None):
364+
min_longitude=None, max_longitude=None, verbose=True):
370365

371366
eventlist = readers._query_gcmt(start_time=start_time,
372367
end_time=end_time,
@@ -381,6 +376,17 @@ def query_gcmt(start_time, end_time, min_magnitude=5.0,
381376
name='gCMT',
382377
catalog_id=catalog_id,
383378
date_accessed=utc_now_datetime())
379+
380+
if verbose:
381+
print("Downloaded catalog from GCMT with following parameters")
382+
print("Start Date: {}\nEnd Date: {}".format(str(catalog.start_time),
383+
str(catalog.end_time)))
384+
print("Min Latitude: {} and Max Latitude: {}".format(catalog.min_latitude,
385+
catalog.max_latitude))
386+
print("Min Longitude: {} and Max Longitude: {}".format(catalog.min_longitude,
387+
catalog.max_longitude))
388+
print("Min Magnitude: {}".format(catalog.min_magnitude))
389+
print(f"Found {catalog.event_count} events in the gns catalog.")
384390
return catalog
385391

386392

csep/core/binomial_evaluations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def _simulate_catalog(sim_cells, sampling_weights, sim_fore, random_numbers=None
126126

127127

128128
def _binary_likelihood_test(forecast_data, observed_data, num_simulations=1000, random_numbers=None,
129-
seed=None, use_observed_counts=True, verbose=True, normalize_likelihood=False):
129+
seed=None, use_observed_counts=True, verbose=False, normalize_likelihood=False):
130130
""" Computes binary conditional-likelihood test from CSEP using an efficient simulation based approach.
131131
132132
Args:

csep/core/brier_evaluations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _simulate_catalog(sim_cells, sampling_weights, random_numbers=None):
7171

7272

7373
def _brier_score_test(forecast_data, observed_data, num_simulations=1000,
74-
random_numbers=None, seed=None, verbose=True):
74+
random_numbers=None, seed=None, verbose=False):
7575
""" Computes the Brier consistency test conditional on the total observed
7676
number of events
7777

csep/core/catalog_evaluations.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from csep.core.forecasts import CatalogForecast
2424

2525

26-
def number_test(forecast, observed_catalog, verbose=True):
26+
def number_test(forecast, observed_catalog, verbose=False):
2727
""" Performs the number test on a catalog-based forecast.
2828
2929
The number test builds an empirical distribution of the event counts for each data. By default, this
@@ -62,7 +62,7 @@ def number_test(forecast, observed_catalog, verbose=True):
6262
return result
6363

6464

65-
def spatial_test(forecast, observed_catalog, verbose=True):
65+
def spatial_test(forecast, observed_catalog, verbose=False):
6666
""" Performs spatial test for catalog-based forecasts.
6767
6868
@@ -148,7 +148,7 @@ def spatial_test(forecast, observed_catalog, verbose=True):
148148
return result
149149

150150

151-
def magnitude_test(forecast, observed_catalog, verbose=True):
151+
def magnitude_test(forecast, observed_catalog, verbose=False):
152152
""" Performs magnitude test for catalog-based forecasts """
153153
test_distribution = []
154154

@@ -224,7 +224,7 @@ def magnitude_test(forecast, observed_catalog, verbose=True):
224224
return result
225225

226226

227-
def pseudolikelihood_test(forecast, observed_catalog, verbose=True):
227+
def pseudolikelihood_test(forecast, observed_catalog, verbose=False):
228228
""" Performs the spatial pseudolikelihood test for catalog forecasts.
229229
230230
Performs the spatial pseudolikelihood test as described by Savran et al., 2020. The tests uses a pseudolikelihood

csep/core/forecasts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ def magnitude_counts(self):
669669
self.get_expected_rates()
670670
return self.expected_rates.magnitude_counts()
671671

672-
def get_event_counts(self, verbose=True):
672+
def get_event_counts(self, verbose=False):
673673
""" Returns a numpy array containing the number of event counts for each catalog.
674674
675675
Note: This function can take a while to compute if called without already iterating through a forecast that
@@ -730,7 +730,7 @@ def get_expected_rates(self, verbose=False):
730730
magnitudes=self.magnitudes, name=self.name)
731731
return self.expected_rates
732732

733-
def plot(self, plot_args = None, verbose=True, **kwargs):
733+
def plot(self, plot_args = None, verbose=False, **kwargs):
734734
plot_args = plot_args or {}
735735
if self.expected_rates is None:
736736
self.get_expected_rates(verbose=verbose)

csep/core/poisson_evaluations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ def _simulate_catalog(num_events, sampling_weights, sim_fore,
601601

602602
def _poisson_likelihood_test(forecast_data, observed_data,
603603
num_simulations=1000, random_numbers=None,
604-
seed=None, use_observed_counts=True, verbose=True,
604+
seed=None, use_observed_counts=True, verbose=False,
605605
normalize_likelihood=False):
606606
"""
607607
Computes the likelihood-test from CSEP using an efficient simulation based approach.

tests/artifacts/Comcat/vcr_detail.yaml

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ interactions:
2020
- '*'
2121
Access-Control-Allow-Origin:
2222
- '*'
23+
Age:
24+
- '24'
2325
Cache-Control:
2426
- public, max-age=60
2527
Connection:
@@ -29,25 +31,25 @@ interactions:
2931
Content-Type:
3032
- text/html; charset=UTF-8
3133
Date:
32-
- Fri, 07 Nov 2025 23:54:49 GMT
34+
- Sat, 08 Nov 2025 02:26:08 GMT
3335
Expires:
34-
- Fri, 07 Nov 2025 23:55:49 GMT
36+
- Sat, 08 Nov 2025 02:27:08 GMT
3537
Last-Modified:
36-
- Fri, 07 Nov 2025 23:54:49 GMT
38+
- Sat, 08 Nov 2025 02:26:08 GMT
3739
Location:
3840
- /fdsnws/event/1/query?eventid=ci3144585&format=geojson
3941
Server:
4042
- Apache
4143
Strict-Transport-Security:
4244
- max-age=31536000
4345
Via:
44-
- 1.1 638b173cd330df78700f2706cc7e6c8a.cloudfront.net (CloudFront)
46+
- 1.1 03a00118e0b935b7a21eca93697d226a.cloudfront.net (CloudFront)
4547
X-Amz-Cf-Id:
46-
- ATgdtPPDP03v_UIQ1aN6Xh4yeW5WPrB19p189Z9nliJk0YVi2UA89A==
48+
- -RLitbHPkvLfWxXDn6Df5cFj1Oq5XuKcJI6YdR2lNzrUh3NC8C7t_Q==
4749
X-Amz-Cf-Pop:
4850
- TXL52-P1
4951
X-Cache:
50-
- Miss from cloudfront
52+
- Hit from cloudfront
5153
X-Content-Type-Options:
5254
- nosniff
5355
X-Frame-Options:
@@ -143,18 +145,20 @@ interactions:
143145
- '*'
144146
Access-Control-Max-Age:
145147
- '86400'
148+
Age:
149+
- '22'
146150
Cache-Control:
147151
- public, max-age=60
148152
Connection:
149153
- close
150154
Content-Type:
151155
- application/json; charset=utf-8
152156
Date:
153-
- Fri, 07 Nov 2025 23:54:50 GMT
157+
- Sat, 08 Nov 2025 02:26:09 GMT
154158
Expires:
155-
- Fri, 07 Nov 2025 23:55:50 GMT
159+
- Sat, 08 Nov 2025 02:27:09 GMT
156160
Last-Modified:
157-
- Fri, 07 Nov 2025 23:54:50 GMT
161+
- Sat, 08 Nov 2025 02:26:09 GMT
158162
Server:
159163
- nginx
160164
Strict-Transport-Security:
@@ -164,13 +168,13 @@ interactions:
164168
Vary:
165169
- Accept-Encoding
166170
Via:
167-
- 1.1 1e3ea313dab573eb0f8714b435227a78.cloudfront.net (CloudFront)
171+
- 1.1 d82c2412e809a3e30a6396b85e4d6d9c.cloudfront.net (CloudFront)
168172
X-Amz-Cf-Id:
169-
- IGIg0FRuWCNt3KJAbxN-mrfYX7tbmnqCfE8ChzPs6QbmdVXJT5VLcg==
173+
- x98WD0hrUmTL4Y9EBpHmJx8Ceeiq4Fz2fuaJLKTeFu-EAW8xXojdyw==
170174
X-Amz-Cf-Pop:
171175
- TXL52-P1
172176
X-Cache:
173-
- Miss from cloudfront
177+
- Hit from cloudfront
174178
X-Content-Type-Options:
175179
- nosniff
176180
X-Frame-Options:
@@ -257,18 +261,20 @@ interactions:
257261
- '*'
258262
Access-Control-Max-Age:
259263
- '86400'
264+
Age:
265+
- '22'
260266
Cache-Control:
261267
- public, max-age=60
262268
Connection:
263269
- close
264270
Content-Type:
265271
- application/json; charset=utf-8
266272
Date:
267-
- Fri, 07 Nov 2025 23:54:50 GMT
273+
- Sat, 08 Nov 2025 02:26:10 GMT
268274
Expires:
269-
- Fri, 07 Nov 2025 23:55:50 GMT
275+
- Sat, 08 Nov 2025 02:27:10 GMT
270276
Last-Modified:
271-
- Fri, 07 Nov 2025 23:54:50 GMT
277+
- Sat, 08 Nov 2025 02:26:10 GMT
272278
Server:
273279
- nginx
274280
Strict-Transport-Security:
@@ -278,13 +284,13 @@ interactions:
278284
Vary:
279285
- Accept-Encoding
280286
Via:
281-
- 1.1 b22f104a676a3f4e13adba34eb669b5c.cloudfront.net (CloudFront)
287+
- 1.1 d0fbd668b0b800f172cbda367bd5a508.cloudfront.net (CloudFront)
282288
X-Amz-Cf-Id:
283-
- TkGHA60K3T_UZGs5BBrYIPyrfZTbaPZe1OsNE1_R47FdjAwvQlATmg==
289+
- KYAS18WdgVJaXontLmpQd5HeRxXU0LR4h59U6JcSrW0SFTapFKQIrQ==
284290
X-Amz-Cf-Pop:
285291
- TXL52-P1
286292
X-Cache:
287-
- Miss from cloudfront
293+
- Hit from cloudfront
288294
X-Content-Type-Options:
289295
- nosniff
290296
X-Frame-Options:
@@ -6873,13 +6879,11 @@ interactions:
68736879
Access-Control-Max-Age:
68746880
- '86400'
68756881
Age:
6876-
- '796'
6882+
- '9898'
68776883
Cache-Control:
68786884
- max-age=315360000
68796885
Connection:
68806886
- keep-alive
6881-
Content-Encoding:
6882-
- gzip
68836887
Content-Type:
68846888
- application/xml
68856889
Date:
@@ -6899,9 +6903,9 @@ interactions:
68996903
Vary:
69006904
- Accept-Encoding
69016905
Via:
6902-
- 1.1 1b73d2d63bf1d475138b6429983516f8.cloudfront.net (CloudFront)
6906+
- 1.1 d0fbd668b0b800f172cbda367bd5a508.cloudfront.net (CloudFront)
69036907
X-Amz-Cf-Id:
6904-
- jtUba261aDXSJDNnbFNwlXZ672dVhv5vxZaxuCAH4Eq2Z21uY-jHCA==
6908+
- Jglv6XxRof_47EiBaLwmW2SeM_MmC7b1P3wUWZC5yYRZ8R4XrYzFPg==
69056909
X-Amz-Cf-Pop:
69066910
- TXL52-P1
69076911
X-Cache:
@@ -6912,6 +6916,8 @@ interactions:
69126916
- SAMEORIGIN
69136917
X-XSS-Protection:
69146918
- 1; mode=block
6919+
content-length:
6920+
- '1744435'
69156921
x-amz-meta-modified:
69166922
- '2017-02-04T11:29:10.000Z'
69176923
x-amz-meta-sha256:
@@ -7043,18 +7049,20 @@ interactions:
70437049
- '*'
70447050
Access-Control-Max-Age:
70457051
- '86400'
7052+
Age:
7053+
- '21'
70467054
Cache-Control:
70477055
- public, max-age=60
70487056
Connection:
70497057
- close
70507058
Content-Type:
70517059
- application/json; charset=utf-8
70527060
Date:
7053-
- Fri, 07 Nov 2025 23:54:53 GMT
7061+
- Sat, 08 Nov 2025 02:26:13 GMT
70547062
Expires:
7055-
- Fri, 07 Nov 2025 23:55:53 GMT
7063+
- Sat, 08 Nov 2025 02:27:13 GMT
70567064
Last-Modified:
7057-
- Fri, 07 Nov 2025 23:54:53 GMT
7065+
- Sat, 08 Nov 2025 02:26:13 GMT
70587066
Server:
70597067
- nginx
70607068
Strict-Transport-Security:
@@ -7064,13 +7072,13 @@ interactions:
70647072
Vary:
70657073
- Accept-Encoding
70667074
Via:
7067-
- 1.1 c303e1e11f9af6d9db1d1e0a9f31eebe.cloudfront.net (CloudFront)
7075+
- 1.1 140f2df55faad62e5a3398dbaec419ac.cloudfront.net (CloudFront)
70687076
X-Amz-Cf-Id:
7069-
- 8O92BJu3IqtkVqx5lCIm_P8gwXw6fRwVcr-jTx4X43AXeL-67uj85A==
7077+
- rWAQmcjkVehem2dL1ny5gtUfKbIIKr8v4_1ljb_SIKbdztJK8lMlEw==
70707078
X-Amz-Cf-Pop:
70717079
- TXL52-P1
70727080
X-Cache:
7073-
- Miss from cloudfront
7081+
- Hit from cloudfront
70747082
X-Content-Type-Options:
70757083
- nosniff
70767084
X-Frame-Options:

0 commit comments

Comments
 (0)