Coder Social home page Coder Social logo

"regrid" drops dataset attributes about dodola HOT 8 CLOSED

brews avatar brews commented on June 30, 2024
"regrid" drops dataset attributes

from dodola.

Comments (8)

brews avatar brews commented on June 30, 2024

Using something like xr.set_options(keep_attrs=True) might get the behavior we need from xesmf. I'm not sure though. I'm not up to date on attrs behavior in xarray.

from dodola.

dgergel avatar dgergel commented on June 30, 2024

It looks like what we need is keep_attrs=True in the call to the xesmf regridder. The default is false for some reason.

e.g.

return regridder(x).astype(astype)
would be

if astype:
        return regridder(x, keep_attrs=True).astype(astype)
    return regridder(x)

from dodola.

brews avatar brews commented on June 30, 2024

@dgergel I think that's for the old xesmf from a few years back and not the pangeo-supported fork...?

Edit: My rough fix for getting attrs merged from ds to out_ds has been

out_ds.attrs |= ds.attrs
for k, v in ds.variables.items():
    if k in out_ds:
        out_ds[k].attrs |= v.attrs

from dodola.

dgergel avatar dgergel commented on June 30, 2024

@brews I took a look at the source code for the pangeo-supported fork of xesmf and it still has that keep_attrs=True option in applying the regridder (and the default is false), see here: https://github.com/pangeo-data/xESMF/blob/fa07fa6a7d382c8298261170e4e9df894d8f7cb6/xesmf/frontend.py#L382

from dodola.

brews avatar brews commented on June 30, 2024

@dgergel Huh! You're right! I'll see if that arg does the trick. Thanks.

from dodola.

dgergel avatar dgergel commented on June 30, 2024

@brews we fixed this, correct? So we can go ahead and close?

from dodola.

brews avatar brews commented on June 30, 2024

@dgergel good question. It's a bit of a stale issue but I say we should keep this open. Right now we have a hackish workaround. It works but I'd like to try the solution you recommend before we close this.

from dodola.

dgergel avatar dgergel commented on June 30, 2024

Got it - let's keep it open for now then.

from dodola.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.