sededu / rivers2stratigraphy

educational activity for teaching how rivers become stratigraphy
MIT License
7 stars 4 forks source link

slows down significantly after a small period... #18

Closed amoodie closed 6 years ago

amoodie commented 6 years ago

Might need to look into creating a new class ChannelBody that merges a series of channels into a single convex (or concave ideally...) hull object to plot as a single shape.

amoodie commented 6 years ago

Maybe use the old approach with calculating unions to simplify geometry of body after avulsion?

old code:

# method 2 -- unions
        # # do somethign with if dx is too large, then splice a couple more
        # # channels in between to ensure it is a single polygon?!
        # chanActShp_un = so.unary_union([chanActShp, newActShp])
        # n_split = 0 # number of times the distance has been spaced

        # # while chanActShp_un.type == 'MultiPolygon':
        # #     print("is multi")
         # #     n_split += 1
         # if chanActShp_un.type == 'Polygon':
        #     chanActShp = chanActShp_un
        # elif chanActShp_un.type == 'MultiPolygon':
        #     chanActPtList = geom.concave_hull(sg.mapping(chanActShp), sg.mapping(newActShp), dx)
        #     chanActShp = sg.Polygon(chanActPtList)
        # chanActPoly = Polygon(np.transpose((*[chanActShp.exterior.xy])))
         chanList = np.vstack((chanList, chanAct))
        chanListPoly.append(chanActPoly)
amoodie commented 6 years ago

PR #19 seems to fix the slow down (mostly) but when the memory leak (see #1) becomes significant, the entire process really bogs down.