Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rupture ID type inconsistency #57

Closed
chrisdicaprio opened this issue Jan 17, 2025 · 1 comment
Closed

rupture ID type inconsistency #57

chrisdicaprio opened this issue Jan 17, 2025 · 1 comment
Labels
bug Something isn't working LIB solvis

Comments

@chrisdicaprio
Copy link
Collaborator

As a user I expect consistent types to be returned by the filter functions. The element type found when casting the ChainableSet object returned by FilterRuptureIds.for_polygon is different from what is returned by the other filter methods:

input:

from solvis import InversionSolution
from solvis.filter.rupture_id_filter import FilterRuptureIds
import solvis

soln = InversionSolution.from_archive('/home/chrisdc/tmp/NZSHM22_InversionSolution-QXV0b21hdGlvblRhc2s6MTA3MDEz.zip')
model = soln.model

# example filter functions
ham50 = solvis.circle_polygon(50000, -37.78, 175.28)  # 50km radius around Hamilton

# ruptures within 50km of Hamilton with magnitude between 5.75 and 8.0.
rupture_ids = FilterRuptureIds(model)\
        .for_magnitude(min_mag=5.75, max_mag=8.0)\
        .for_polygon(ham50)
print(list(rupture_ids))
print(type(list(rupture_ids)[0]))
print("")

# ruptures on any of faults A, B, with magnitude and rupture rate limits
rupture_ids = FilterRuptureIds(model)\
   .for_parent_fault_names(["Alpine: Jacksons to Kaniere", "Vernon 1"])\
   .for_magnitude(7.0, 8.0)\
   .for_rupture_rate(1e-6, 1e-2)
print(list(rupture_ids))
print(type(list(rupture_ids)[0]))
print("")

# ruptures on fault A that do not involve fault B:
rupture_ids = FilterRuptureIds(model)\
   .for_parent_fault_names(["Alpine: Jacksons to Kaniere"])\
   .for_parent_fault_names(["Vernon 1"], join_prior='difference')
print(list(rupture_ids))
print(type(list(rupture_ids)[0]))
print("")

output:

[np.uint32(264963), np.uint32(264964), np.uint32(264965), np.uint32(264966), np.uint32(264967), np.uint32(264968), np.uint32(264969), np.uint32(264970), np.uint32(264971), np.uint32(264972), np.uint32(264973), np.uint32(264974), np.uint32(264975), np.uint32(264976), np.uint32(264977), np.uint32(264978), np.uint32(264979), np.uint32(264980), np.uint32(264981), np.uint32(264982), np.uint32(264983), np.uint32(264984), np.uint32(264985), np.uint32(264986), np.uint32(264987), np.uint32(264988), np.uint32(264989), np.uint32(264992), np.uint32(264993), np.uint32(264994), np.uint32(264995), np.uint32(264996), np.uint32(264997), np.uint32(264998), np.uint32(264999), np.uint32(265000), np.uint32(265001), np.uint32(265002), np.uint32(265003), np.uint32(265004), np.uint32(265005), np.uint32(363822), np.uint32(265006), np.uint32(265007), np.uint32(265008), np.uint32(265009), np.uint32(265010), np.uint32(265011), np.uint32(265012), np.uint32(265013), np.uint32(265014), np.uint32(265015), np.uint32(265016), np.uint32(265017), np.uint32(265018), np.uint32(265020), np.uint32(265021), np.uint32(265534), np.uint32(265535), np.uint32(265022), np.uint32(265023), np.uint32(265024), np.uint32(265025), np.uint32(265026), np.uint32(265027), np.uint32(265028), np.uint32(265029), np.uint32(265030), np.uint32(265031), np.uint32(265032), np.uint32(265033), np.uint32(265034), np.uint32(265035), np.uint32(265036), np.uint32(265037), np.uint32(265038), np.uint32(265039), np.uint32(265040), np.uint32(265041), np.uint32(265042), np.uint32(265043), np.uint32(265044), np.uint32(265045), np.uint32(265046), np.uint32(265047), np.uint32(265048), np.uint32(265049), np.uint32(265050), np.uint32(265051), np.uint32(265052), np.uint32(265053), np.uint32(265054), np.uint32(265055), np.uint32(265056), np.uint32(265057), np.uint32(265058), np.uint32(265059), np.uint32(272737), np.uint32(272738), np.uint32(265063), np.uint32(265064), np.uint32(265065), np.uint32(265066), np.uint32(265067), np.uint32(265068), np.uint32(265069), np.uint32(265070), np.uint32(265071), np.uint32(265072), np.uint32(265073), np.uint32(265074), np.uint32(265075), np.uint32(265076), np.uint32(265077), np.uint32(265078), np.uint32(265079), np.uint32(265080), np.uint32(265081), np.uint32(265082), np.uint32(265083), np.uint32(265084), np.uint32(265085), np.uint32(265086), np.uint32(265087), np.uint32(265088), np.uint32(265089), np.uint32(265090), np.uint32(265091), np.uint32(265092), np.uint32(265093), np.uint32(265094), np.uint32(265095), np.uint32(265096), np.uint32(265097), np.uint32(265098), np.uint32(265099), np.uint32(265100), np.uint32(265101), np.uint32(265102), np.uint32(265103), np.uint32(265104), np.uint32(265105), np.uint32(265106), np.uint32(265107), np.uint32(265108), np.uint32(265109), np.uint32(265110), np.uint32(265111), np.uint32(265112), np.uint32(265113), np.uint32(265114), np.uint32(265115), np.uint32(265116), np.uint32(265117), np.uint32(265118), np.uint32(265119), np.uint32(265120), np.uint32(265121), np.uint32(265122), np.uint32(265123), np.uint32(265124), np.uint32(265125), np.uint32(265126), np.uint32(265127), np.uint32(265128), np.uint32(265129), np.uint32(265130), np.uint32(265131), np.uint32(265132), np.uint32(265133), np.uint32(265134), np.uint32(265135), np.uint32(265136), np.uint32(265137), np.uint32(357840), np.uint32(357841), np.uint32(357842)]
<class 'numpy.uint32'>

[33792, 37121, 33795, 34438, 47754, 22156, 47757, 38416, 96787, 38421, 38424, 46490, 43935, 5539, 43940, 49060, 49061, 49063, 32680, 37164, 32942, 32437, 43835, 9660, 14656, 43841, 46528, 9675, 39883, 38480, 9680, 31314, 45146, 35802, 31071, 39775, 39783, 39784, 6119, 23402, 47854, 12148, 38524, 56063]
<class 'int'>

[94736, 96787]
<class 'int'>

All rupture IDs returned by the filters should be int type

@chrisdicaprio chrisdicaprio added bug Something isn't working solvis LIB labels Jan 17, 2025
chrisbc added a commit that referenced this issue Feb 2, 2025
* made parent fault filter chainable; added support for symmetric difference operation; fixed some small docstring issues; updated changelog;
* remove TODO comment;
* fix for #57 (return int type for polygons);
@chrisbc
Copy link
Member

chrisbc commented Feb 2, 2025

closed by #66

@chrisbc chrisbc closed this as completed Feb 2, 2025
chrisbc added a commit that referenced this issue Feb 27, 2025
* new fault_system_solution_helper module
* a simple rupture grouping algo;
* drop_zero_rate differentiates between FSS and IS;
* refactor subsection filter & tests
* migrate to filter_rupture_ids.for_subsections();
* migrate to filter_rupture_ids.for_parent_fault_ids();
* fixed method names; added doc page for subsection_id_filter;
* refactor filter tests; WIP on DeprecationWarnings; new filter_parent_fault_ids; detox
* fixing many deprecation warnings; updated geopandas, pandas, numpy, pyvista libs; changes to read_csv_dtype configuration; detox
* refactor filters int package; more test cover; implement new filters; migrate old functions and deprecate warn the originals;
* unifying filter methods; improve docstrings & tests;
* implement rate and mag filtering on rupture_id_filter;
* migrate find rupture polygons into filter class; move drop_zero_rates into class init;
* implement ChainableSetBase; migrate FilterRuptureIds to be chainable;
* add set operation support for chaining (join_prior) and test coverage;
* join arguments tidied up; strings and ENUMS are supported;
* fix set operand method names;
* fix set operations return type
* implement set operands for supported set methods; improve docs
* merge 3d geometry changes from @voj; add some testing;
* new participation rate functions; detox
* test 3d surfaces
* migrate participation functions into classes proper; add FSS section_participation;
* make subsection_id_filter chainable;
* added participation methods to fault_system_solution
* simplify FSS participation using rate_weighted_mean; refactor dataframe dtypes; participation performance testing;
* standardise participation functions API and return column;
* fix rate_column; add .all() methods to filter classes;
* add TinyInversionSolution fixture; tune pytest fixture scoping for massive test speed up (~3 times faster);
* doc and docstrings improvements; Better typing in filter package;
* more on rupture_grouping
* add module docstring to inversion_solution_file;
* adding dataframe schema validations with panderas;
* WIP, adding InversionSolutionFile::RuptureRateSchema;
* Feature/52 refactor inversion solution (#53)
* Chore/54 test coverage (#55)
* Chore/59 doc fixes (#61)
* make parent fault filter chainable (#66)
* fix for #57 (return int type for polygons);
* update pytz dep (#69)
* Feature/49 named fault participation (#67)
* Feature: named_fault_participation_rate #49
* Epic Feature: enhanced participation rate options #42
* refactor to remove *Protocol superclasses (#73)
* refactor to remove *Protocol superclasses; migrate and improve docstrings; detox
* Feature/71 scale rupture rates (#74)
* fold in changes suggested by @chrisdicaprio on PR #73;
* fix drop_zero_rates on FilterRuptureIds.for_magnitude(); 
* fix for_parent_fault_ids
* fix test_ruptures_for_subsections
* fix for_rupture_rate
* fix for_polygon ; fix impacted tests;
* Bump version: 0.13.0 → 1.0.0-alpha
* add joint_type arg to relevant FilterRuptureId class methods (#80)
* add joint_type arg to `for_parent_fault_names` *  `for_parent_fault_ids`; add tolist() convenience method;
* refactor for readability/efficiency; add full test coverage for new arg;
* add `join_type` arg to `for_subsection_ids` (working but a little slow); detox;
* rename arg for consistency
* refactoring; new docstrings; named_faults support; detox;
* remove commented line
* changelog entry;
* Bump version: 1.0.0-alpha → 1.0.0-beta
* align version ids
* Chore/82 make docs and api align (#83)
* Bump version: 1.0.0-beta-0 → 1.0.0

---------

Co-authored-by: Chris DiCaprio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LIB solvis
Projects
None yet
Development

No branches or pull requests

2 participants