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

PySCHISM: TypeError in fgrid.py: 'sjoin() got an unexpected keyword argument 'op'' #130

Closed
mansurjisan opened this issue Aug 15, 2024 · 1 comment · Fixed by #131
Closed
Assignees

Comments

@mansurjisan
Copy link

mansurjisan commented Aug 15, 2024

PySCHISM: TypeError in fgrid.py: 'sjoin() got an unexpected keyword argument 'op''

I encountered a TypeError in fgrid.py when trying to use the modify_by_region method in PySCHISM. The error message indicates that sjoin() got an unexpected keyword argument 'op'. This issue seems to be caused by a change in the geopandas API, where the op parameter has been replaced by predicate.

Steps to Reproduce

  1. Run the following code:
from pyschism.mesh.hgrid import Hgrid
from pyschism.mesh.fgrid import DragCoefficient

if __name__ == '__main__':

    hgrid=Hgrid.open('hgrid.gr3', crs='epsg:4326')

    depth1=-1.0
    depth2=-3.0
    bfric_river=0.0025
    bfric_land=0.025

    fgrid=DragCoefficient.linear_with_depth(hgrid, depth1, depth2, bfric_river, bfric_land)

    regions=['region1.reg', 'region2.reg']
    values=[0.001, 0.0]
    flags=[1, 0] 

    for reg, value, flag in zip(regions, values, flags):
        fgrid.modify_by_region(hgrid, f'./{reg}', value, depth1, flag)

    fgrid.write('drag.gr3', overwrite=True)
  1. The error occurs on this line in fgrid.py:
gdf_in = gpd.sjoin(gdf2, gdf1, op="within")

Proposed Fix

The issue can be fixed by replacing op with predicate:

gdf_in = gpd.sjoin(gdf2, gdf1, predicate="within")

Additional Information

PySCHISM version: 0.1.15
Geopandas version: 1.0.1
Python version: 3.9.19

@mansurjisan mansurjisan changed the title TypeError in fgrid.py: 'sjoin() got an unexpected keyword argument 'op'' PySCHISM: TypeError in fgrid.py: 'sjoin() got an unexpected keyword argument 'op'' Aug 15, 2024
@SorooshMani-NOAA SorooshMani-NOAA self-assigned this Aug 16, 2024
@SorooshMani-NOAA
Copy link
Contributor

@mansurjisan can you test the update in PR and see if it resolves the issues. Unfortunately pyschism doesn't yet have any automated tests, so we need manual testing to confirm it works. See #131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants