Skip to content

coordinates.lon_bounds can give a range larger than 360 degrees #858

@ChrisFairless

Description

@ChrisFairless

The climada.util.coordinates.lon_bounds method returns a normalised range for the provided longitudes.

I've run into an edge case where the returned range is > 360 degrees:

lon_bounds(np.concatenate([[-179.99], np.arange(-179.7, 179.9, 0.2), [179.99]]), buffer = 0.1)

returns (179.91, 540.09)

I happens only when

  1. there is a non-zero buffer,
  2. the normalised lowest/highest longitude is within one buffer distance of the 180 degree meridian,
  3. the longitudes cover the 360 degree longitude range without a gap (lon_diff_max) of more than 2 degrees,
  4. but with a gap greater than double the buffer

In this case the longitudes either side of 180 degrees are taken as the min and max, the buffer applied, and you get a range like the (179.91, 540.09) above.

We can fix this by updating the value of lon_diff_max when we decide that we will split across the antimeridian rather than at the location of the largest gap in the longitude data (line 200).

I'll submit a pull request for it later today.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions