GeoscienceAustralia / tcrm

A statistical-parametric model for assessing wind hazard from tropical cyclones
http://geoscienceaustralia.github.io/tcrm
Other
81 stars 52 forks source link

Ineffective track filtering in wind filed calculation #124

Closed Wenbo-Duan closed 2 years ago

Wenbo-Duan commented 2 years ago

Hi - when calculating wind field from simulated tracks, it seems that the tracks are not properly filtered by the inRegion function

def inRegion(t, gridLimit, margin):

    """
    :param t: :class:`Track` object
    :returns: True if the track enters the simulation grid, False otherwise
    """

    xMin = gridLimit['xMin'] - margin
    xMax = gridLimit['xMax'] + margin
    yMin = gridLimit['yMin'] - margin
    yMax = gridLimit['yMax'] + margin
    return ((xMin <= t.Longitude.max()) and
            (t.Longitude.min() <= xMax) and
            (yMin <= t.Latitude.max()) and
            (t.Latitude.min() <= yMax))

The filter does not ensure that the track will enter the simulation by only comparing the max value in the array. Am I misunderstanding the intention of the function?

Maybe the following filter can be applied:

return np.size(np.where((xMin <= t.Longitude) &
             (t.Longitude <= xMax) &
             (yMin <= t.Latitude) &
             (t.Latitude <= yMax))) != 0

Thank you in advance.

wcarthur commented 2 years ago

The two filters are functionally the same. By testing the maximum longitude value in the track (t.Longitude.max()) is greater than the minimum bounding longitude (xMin), we check that at least one point of the track is in the simulation domain (or within margin of the edge). This is the same as testing the size of the array of values returned by the np.where clause.