modelgrid object will not work in place of spatial_reference object in calc_factors_grid
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
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
@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
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.