[Python] multidimensional coordinate transform with xarray

Discussão em 'Python' iniciado por Stack, Maio 12, 2025.

  1. Stack

    Stack Membro Participativo

    How to convert multidimensional coordinate to standard coordinate in order to unify data when using xarray for nc data:

    import xarray as xr

    da = xr.DataArray(
    [[0, 1], [2, 3]],
    coords={
    "lon": (["ny", "nx"], [[30, 40], [40, 50]]),
    "lat": (["ny", "nx"], [[10, 10], [20, 20]]),
    },
    dims=["ny", "nx"],
    )



    except:

    xr.DataArray(
    [[0, 1, np.nan],
    [np.nan, 2, 3]],
    coords={
    "lat": [10, 20],
    "lon": [30, 40, 50],
    })

    Continue reading...

Compartilhe esta Página