NovembreLab / feems

MIT License
15 stars 14 forks source link

polar regions #29

Open steigeec opened 5 months ago

steigeec commented 5 months ago

Hi -

Thank you for developing and maintaining FEEMS!

I'm now hoping to deploy in a polar region, and am struggling to create the spatial graph object correctly. My spatial graph should span the arctic circle, but instead ends up covering only a small polygon to one side of the pole. I am using as input a discrete global grid generated in ddgridR, and initially started with outer coordinates as follows: -65.00 72.00 55.00 72.00 155.00 58.00 -147.00 58.00

I'm curious about whether perhaps I need to modify the source code to specify my projection (projection = ccrs.NorthPolarStereo(central_longitude=0)) earlier, like this? : def prepare_graph_inputs(coord, ggrid, translated, buffer=0, outer=None, projection=None):

... (existing code)

# load_tiles modification to handle projection
tiles2 = load_tiles(ggrid, crs=projection)

I have tried this, as well as playing around with different specifications of the outer coordinates, but so far not managed to make it work, so thought I might check whether you had any advice on how I might deal with this!

Thanks so much! Emma

VivaswatS commented 4 months ago

Hi @steigeec, sorry to hear about that! This issue might be caused by the wrap_america function in utils.py, which was meant to ensure that the American continent (any coordinates past the -40 longitude) was not included in the SpatialGraph.

I would follow the fix issued in https://github.com/NovembreLab/feems/pull/20/files by @karolisr. Let me know if that does not fix the issue.

steigeec commented 4 months ago

Thanks so much, @VivaswatS , for your helpful response -

My grid now spans more of the area I am interested in graph_nodes_250

To obtain my dgg spanning the Arctic, I use dggridr as follows:

grid<-dgconstruct(res=6, projection = "ISEA", aperture = 4, topology = "TRIANGLE", pole_lat_deg = 90) filename <- dgearthgrid(grid, savegrid="world_triangle_res6.shp")

Once I enforce the changes to utils.pyIn preparing graph inputs, I find I get the Assertion Error others have gotten in preparing graph inputs (which I was not previously getting), so I edit that command as suggested:

outer, edges, grid, _ = prepare_graph_inputs(coord=coord, ggrid=grid_path, translated=False, buffer=10, outer=outer)

I should have mentioned that I, both previously and on this occasion, get the PRJ error documented in this issue so have removed the .prj file associated with the shapefile.

Re-examining the example dataset, I tried to close the crescent I plot by repeating the first coordinate set at the end of the outer file:

-65.00 72.00 55.00 72.00 155.00 58.00 -147.00 58.00 -65.00 72.00

(since I turned translation off, also attempted the following, which gets the same result:

295.00 72.00 55.00 72.00 155.00 58.00 213.00 58.00 295.00 72.00

and, for good measure, a very nice and even circle around the poles):

-130 60 -110 60 -90 60 -70 60 -50 60 -30 60 -10 60 10 60 30 60 50 60 70 60 90 60 110 60 130 60 150 60 170 60 -170 60 -150 60

One idea I've had is that the problem occurs near the international date line because of the international date line, and for this reason I cannot use translated=False to good effect-- but rather need to find an alternate solution to the Assertion error. Or perhaps the complete set of edges is not generated due to some aspect of the prepare_graph_inputs function, though I am not yet sure how to check that.

VivaswatS commented 4 months ago

@steigeec do you mind posting a list of coordinates for your samples here? I think it has something to do with the prepare_graph_inputs function and can take a look at how to close the loop

steigeec commented 4 months ago

Yes, of course!

-150.814177, 70.53597 -168.882425, 65.752109 -171.914879, 63.850629 -166.162362, 66.261623 -156.786673, 71.360488 -148.546077, 70.436456 -54.929924, 69.876113 -62.387143, 75.606537 -62.387143, 75.606536 -62.387143, 75.606534 -62.387143, 75.606535 -64.943553, 75.957983 -33.61, 67 -42.59, 61 -32.02, 68 -31.43, 68 -30.2, 68 -42.26, 62 -42.56, 61 -42.37, 61 -42.73, 62 -42.54, 61 -42.65, 61 -43.17, 60 -42.68, 62 -42.82, 62 -29.66, 68 -32.49, 68 -15.281219, 78.27215 -17.557641, 74.127942 -17.558274, 79.485288 -20.370102, 70.498085 -17.031939, 76.705904 -22.641745, 70.337936 -71.776473, 79.059994 -72.01536, 78.83779 -68.787971, 79.453161 -68.244479, 79.521887 -70.262206, 79.751397 -74.168718, 78.343851

Thank you!