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

modelgrid object will not work in place of spatial_reference object in calc_factors_grid #466

Open
RyanConway91 opened this issue Oct 20, 2023 · 3 comments
Labels

Comments

@RyanConway91
Copy link

I am trying to calculate kriging factors for an mf6 disv. Looks like the method wants a depreciated spatial_reference object instead of a current modelgrid object.

v = pyemu.geostats.ExpVario(contribution=1.0, a=600)#a = 3 times finest PP spacing
gs = pyemu.geostats.GeoStruct(variograms=v,transform="log")
#modify/add cols needed by pyemu
df_pps= df_pps.rename(columns = {'X':'x','Y':'y'})
df_pps['name'] = ['pp_{}'.format(i) for i in range(len(df_pps))]
# hk_pp = df_pps[['name','x','y']]
ok = pyemu.geostats.OrdinaryKrige(geostruct=gs,point_data=df_pps)
f = r"V:\13\80\1006\MF6\recalibration\recal1\Cordova_MF6.dis.grb"
mg = MfGrdFile(f).modelgrid
ok.calc_factors_grid(mg,verbose = True, num_threads = 16)#does not work

error is "Exception: spatial_reference does not have proper attributes:'VertexGrid' object has no attribute 'xcentergrid'"

I have pyemu 1.3.3 and flopy 3.5.0

@RyanConway91
Copy link
Author

Looks like I was using the wrong method. Should be:
df_krig = ok.calc_factors(x =mg.xcellcenters, y = mg.ycellcenters,num_threads = 16, maxpts_interp = 999)#use all data

So I am good, but not going to close because I think the use of the sr class in "calc_factors_grid" is still an issue

@jtwhite79
Copy link
Collaborator

@RyanConway91 that SpatialReference in pyEMU is so we can avoid a direct dependence on flopy, but PstFrom does play nice with flopy's newer modelgrid.

Its still pretty new but we will likely be shifting all things pilot points to pypestutils (https://github.com/pypest/pypestutils) in the near future since it supports both structured and unstructured grids and waaayyyyy faster than pyEMU's kriging

@briochh
Copy link
Collaborator

briochh commented Mar 27, 2024

Sorry @RyanConway91, catching up on things long overdue. I think the confusion comes from the docstring in calc_factors_grid() referencing a flopy.utils.reference.SpatialReference (legacy), it should be pyemu.helpers.SpatialReference (or possibly anything that has attributes [xcentergrid, ycentergrid, nrow, ncol, grid_type, ncpl (only if grid type=='vertex')]). As @jtwhite79 says the SpatialReference in pyemu is pretty stripped down compared to flopys (it was actually a wholesale lifted from flopy's old method). If using pstfrom spatialreference that is passed to calc_factors_grid() is constructed on the fly and can use flopy's modelgrid as an input.

Defo checkout the pypestutils stuff, which is bring all of the wonders of plproc etc into a python accessible form.

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

No branches or pull requests

3 participants