Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _rename_and_clean_coords(ds, add_lon_lat=True):
ds = ds.rename({'lon': 'x', 'lat': 'y'})
ds = maybe_swap_spatial_dims(ds)
if add_lon_lat:
ds = ds.assign_coords(lon=ds.coords['x'], lat=ds.coords['y'])
return ds