GithubHelp home page GithubHelp logo

Comments (11)

andersy005 avatar andersy005 commented on August 18, 2024

@alperaltuntas, which esmlab version are you using? For the time being, I recommend installing esmlab from source (master branch). There are some changes that are not available in the latest release.

from esmlab.

alperaltuntas avatar alperaltuntas commented on August 18, 2024

Here is my esmlab version: esmlab==2019.1.0+27.g2b992eb

from esmlab.

andersy005 avatar andersy005 commented on August 18, 2024

The latest stable is version 2019.2.0 (https://pypi.org/project/esmlab/). You probably need to upgrade to this version: pip install esmlab --upgrade

from esmlab.

andersy005 avatar andersy005 commented on August 18, 2024

For latest features, bug fixes, I highly recommend installing from source for now. The next stable release is scheduled for next week.

from esmlab.

alperaltuntas avatar alperaltuntas commented on August 18, 2024

I just switched to master, and it looks like it is still not working:

traceback:

Traceback (most recent call last):
  File "/glade/work/altuntas/scripts/mncPy/mavg2.py", line 41, in <module>
    main()
  File "/glade/work/altuntas/scripts/mncPy/mavg2.py", line 37, in main
    compute_mon_climatology(dset)
  File "/gpfs/fs1/work/altuntas/ncar_pylib_20190118/lib/python3.6/site-packages/esmlab/climatology.py", line 75, in compute_mon_climatology
    computed_dset[tb_name] - computed_dset[tb_name][0, 0]
  File "/gpfs/fs1/work/altuntas/ncar_pylib_20190118/lib/python3.6/site-packages/xarray/core/dataset.py", line 970, in __getitem__
    return self._construct_dataarray(key)
  File "/gpfs/fs1/work/altuntas/ncar_pylib_20190118/lib/python3.6/site-packages/xarray/core/dataset.py", line 899, in _construct_dataarray
    self._variables, name, self._level_coords, self.dims)
  File "/gpfs/fs1/work/altuntas/ncar_pylib_20190118/lib/python3.6/site-packages/xarray/core/dataset.py", line 74, in _get_virtual_variable
    ref_var = variables[ref_name]
KeyError: 'time_bound'

interactive debugging

(Pdb) 'time_bound' in dset
True
(Pdb) 'time_bound' in dset.drop(static_variables)
True
(Pdb) 'time_bound' in dset.drop(static_variables).groupby(time_dot_month).mean(time_coord_name)
False

from esmlab.

andersy005 avatar andersy005 commented on August 18, 2024

Okie dokie.. let me look into it. I will get back to you

from esmlab.

andersy005 avatar andersy005 commented on August 18, 2024

@alperaltuntas, I can confirm that this is a bug.

Ccing @matt-long

from esmlab.

andersy005 avatar andersy005 commented on August 18, 2024

Would you be interested in submitting a PR to fix it? @alperaltuntas

from esmlab.

alperaltuntas avatar alperaltuntas commented on August 18, 2024

Would you be interested in submitting a PR to fix it? @alperaltuntas

Sure, I'll work on this.

from esmlab.

matt-long avatar matt-long commented on August 18, 2024

@alperaltuntas, @andersy005: I was not able to reproduce this error.

Here's what I did.

from glob import glob
import xarray as xr
import esmlab

files = sorted(glob('/glade/scratch/altuntas/archive/g.e20.GIAF.T62_g37.test_d2m.001/ocn/hist/g.e20.GIAF.T62_g37.test_d2m.001.pop.h.0001-*.nc'))

ds = xr.open_mfdataset(files, decode_times=False, decode_coords=False)
ds_monclim = esmlab.climatology.compute_mon_climatology(ds)

Works fine.

version = 'v2019.1.0+42.g4c2339c'

So that's a bit of mystery. @alperaltuntas, you have confirmed that you are still getting the error?

I think it's important to note, however, independent of this error, that the function is not doing the right thing for these data. Since you are averaging 5-day data to monthly bounds, we should really consider the portion of the time_bound window that overlaps with each month and compute a weighted mean of the values, apportioning the weights for data points overlapping 2 months appropriately. This is a limitation of the current framework and might be characterized as a bug.

from esmlab.

alperaltuntas avatar alperaltuntas commented on August 18, 2024

Thanks, @matt-long. Apparently, adding decode_times=False argument in open_mfdataset call fixes the issue with time_bound.

from esmlab.

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.