inlabru-org / inlabru

inlabru
https://inlabru-org.github.io/inlabru/
73 stars 21 forks source link

Support barrier in spherical and global meshes #168

Open samroyston opened 1 year ago

samroyston commented 1 year ago

Related to issues #42 and #166

In inla.mesh.2d, the spherical or global models are (currently) supported by supplying 3D coordinates (inla.mesh.2d(loc = ...)), resulting in a S2 mesh. My understanding is the barrier model currently requires inla.mesh.2d(boundary = ...) to be provided as sp:: Spatial* object type with CRS. Ideally a 2S mesh would be supported to which a boundary can be added.

finnlindgren commented 1 year ago

Thanks, good point. There are several aspects of the barrier model interface that needs to be updated. But the current code is supposed to handle Spatial* object bundaries with CRS info if the mesh itself also has a CRS (fm_CRS("sphere") I think is the appropriate one, and then fm_spTransform() should be used; recent gdal/proj by itself doesn't want to transform between planets of different radii...). However, there may be special handling inside the barrier code (that I didn't write) that doesn't use the information fully, or a bug elsewhere (in code I did write) A reprex would be really helpful for this!

finnlindgren commented 1 year ago

One may need to convert the Spatial* polygon to inla.mesh.segment first, but if the code that uses the information is in the barrier code itself that probably won't help, if it uses it for inside/outside information. I identified that part of the barrier code as being in the need of a conceptual overhaul a while back.

finnlindgren commented 1 year ago

inlabru now supports spherical meshes and also sf objects, see fm_transform and fm_crs, for example, including for integration. The INLA barrier code still needs fixing.

finnlindgren commented 10 months ago

The INLAspacetime package, https://github.com/eliaskrainski/INLAspacetime, has a new implementation of the barrier models, but I think it doen't fully support spherical meshes yet. Once we sort out the transition to the new fmesher (https://github.com/inlabru-org/fmesher) package that should become easier to fix.