Skip to content

Commit 378ed35

Browse files
khawajasimwsavran
andauthored
Quadtree region class - QuadtreeGrid2D (#115)
* QuadtreeGrid2D region added * Added condition to read QuadtreeGrid forecast * added spatial_count and spatio_mag_count functions * poission_evaluations - routed from QuadtreeGrid2D * modified requirements * unit tests for quadtree-grid * removed 'area' from requirements * modified doc strings * California quadtreegrid at L=12 added * california quadtreegrid loading function * Area function - Taken from Hanbao's code * setup.py modified-added mercantile * Area function name/docstring change * Modified get_cell_area function for quick computation * Improved func quadtree_grid_bounds * Removed boundary checks from _find_location() to improve performance * removed separate call for quadtree grid tests * func name changes * stylistic-changes relevant to compute_cell_area * unit test for area * changes * deleted cell area function * removed unnecessary comments from poisson_evaluations.py * deleted useless comments * Reader for Quadtree forecast format * documentation for quadtree grid * Cleaning docs * Commenting quadtree import in readers, just checking... * documentation refned * clean quadtree_forecast_reader * func name change - single_resoltion * func area name change * Documentation-Region.rst file * Quadtree example for documentation * Docs example - Combine both grids * Constructor arguments explained * get_xs_ys - Experiment for plotting * forecast.plot() for Single-res Quadtree * clean up unnecessary comments from code * pin numpy version to <= 1.25.0 Co-authored-by: William Savran <wsavran@usc.edu>
1 parent f48b110 commit 378ed35

17 files changed

+54897
-33
lines changed

csep/artifacts/Regions/california_qk_zoom=12.txt

Lines changed: 12540 additions & 0 deletions
Large diffs are not rendered by default.

csep/core/catalogs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ def get_bvalue(self, mag_bins=None, return_error=True):
794794

795795
if self.get_number_of_events() == 0:
796796
return None
797+
797798
# this might fail if magnitudes are not aligned
798799
if mag_bins is None:
799800
try:
@@ -835,8 +836,8 @@ def plot(self, ax=None, show=False, extent=None, set_global=False, plot_args=Non
835836
Returns:
836837
axes: matplotlib.Axes.axes
837838
"""
838-
# no mutable function arguments
839839

840+
# no mutable function arguments
840841
plot_args_default = {
841842
'basemap': 'ESRI_terrain',
842843
'markersize': 2,
@@ -850,6 +851,7 @@ def plot(self, ax=None, show=False, extent=None, set_global=False, plot_args=Non
850851
'title': self.name,
851852
'mag_ticks': False
852853
}
854+
853855
# Plot the region border (if it exists) by default
854856
try:
855857
# This will throw error if catalog does not have region

csep/core/poisson_evaluations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from csep.models import EvaluationResult
99
from csep.utils.stats import poisson_joint_log_likelihood_ndarray
1010
from csep.core.exceptions import CSEPCatalogException
11+
from csep.core.regions import QuadtreeGrid2D
1112

1213

1314
def paired_t_test(forecast, benchmark_forecast, observed_catalog, alpha=0.05, scale=False):
@@ -181,6 +182,7 @@ def conditional_likelihood_test(gridded_forecast, observed_catalog, num_simulati
181182
_ = observed_catalog.region.magnitudes
182183
except CSEPCatalogException:
183184
observed_catalog.region = gridded_forecast.region
185+
184186
gridded_catalog_data = observed_catalog.spatial_magnitude_counts()
185187

186188
# simply call likelihood test on catalog data and forecast
@@ -333,7 +335,6 @@ def spatial_test(gridded_forecast, observed_catalog, num_simulations=1000, seed=
333335
evaluation_result: csep.core.evaluations.EvaluationResult
334336
"""
335337

336-
# grid catalog onto spatial grid
337338
gridded_catalog_data = observed_catalog.spatial_counts()
338339

339340
# simply call likelihood test on catalog data and forecast
@@ -387,6 +388,7 @@ def likelihood_test(gridded_forecast, observed_catalog, num_simulations=1000, se
387388
_ = observed_catalog.region.magnitudes
388389
except CSEPCatalogException:
389390
observed_catalog.region = gridded_forecast.region
391+
390392
gridded_catalog_data = observed_catalog.spatial_magnitude_counts()
391393

392394
# simply call likelihood test on catalog and forecast

0 commit comments

Comments
 (0)