Skip to content

Commit

Permalink
Quadtree region class - QuadtreeGrid2D (#115)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
khawajasim and wsavran authored Jan 11, 2022
1 parent f48b110 commit 378ed35
Show file tree
Hide file tree
Showing 17 changed files with 54,897 additions and 33 deletions.
12,540 changes: 12,540 additions & 0 deletions csep/artifacts/Regions/california_qk_zoom=12.txt

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion csep/core/catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ def get_bvalue(self, mag_bins=None, return_error=True):

if self.get_number_of_events() == 0:
return None

# this might fail if magnitudes are not aligned
if mag_bins is None:
try:
Expand Down Expand Up @@ -835,8 +836,8 @@ def plot(self, ax=None, show=False, extent=None, set_global=False, plot_args=Non
Returns:
axes: matplotlib.Axes.axes
"""
# no mutable function arguments

# no mutable function arguments
plot_args_default = {
'basemap': 'ESRI_terrain',
'markersize': 2,
Expand All @@ -850,6 +851,7 @@ def plot(self, ax=None, show=False, extent=None, set_global=False, plot_args=Non
'title': self.name,
'mag_ticks': False
}

# Plot the region border (if it exists) by default
try:
# This will throw error if catalog does not have region
Expand Down
4 changes: 3 additions & 1 deletion csep/core/poisson_evaluations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from csep.models import EvaluationResult
from csep.utils.stats import poisson_joint_log_likelihood_ndarray
from csep.core.exceptions import CSEPCatalogException
from csep.core.regions import QuadtreeGrid2D


def paired_t_test(forecast, benchmark_forecast, observed_catalog, alpha=0.05, scale=False):
Expand Down Expand Up @@ -181,6 +182,7 @@ def conditional_likelihood_test(gridded_forecast, observed_catalog, num_simulati
_ = observed_catalog.region.magnitudes
except CSEPCatalogException:
observed_catalog.region = gridded_forecast.region

gridded_catalog_data = observed_catalog.spatial_magnitude_counts()

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

# grid catalog onto spatial grid
gridded_catalog_data = observed_catalog.spatial_counts()

# simply call likelihood test on catalog data and forecast
Expand Down Expand Up @@ -387,6 +388,7 @@ def likelihood_test(gridded_forecast, observed_catalog, num_simulations=1000, se
_ = observed_catalog.region.magnitudes
except CSEPCatalogException:
observed_catalog.region = gridded_forecast.region

gridded_catalog_data = observed_catalog.spatial_magnitude_counts()

# simply call likelihood test on catalog and forecast
Expand Down
Loading

0 comments on commit 378ed35

Please sign in to comment.