Coder Social home page Coder Social logo

resample returns meaningless dates about esmlab HOT 1 CLOSED

ncar avatar ncar commented on July 18, 2024
resample returns meaningless dates

from esmlab.

Comments (1)

andersy005 avatar andersy005 commented on July 18, 2024

@matt-long, with #133, I added a new optional argument, method to allow users to control how they want the time values to be computed:

By default, midpoint values are computed:

dsm = esmlab.resample(ds, freq='mon')
dsm.time
<xarray.DataArray 'time' (time: 12)>
array([cftime.DatetimeNoLeap(2000, 1, 16, 12, 0, 0, 0, 6, 16),
       cftime.DatetimeNoLeap(2000, 2, 15, 0, 0, 0, 0, 1, 46),
       cftime.DatetimeNoLeap(2000, 3, 16, 12, 0, 0, 0, 2, 75),
       cftime.DatetimeNoLeap(2000, 4, 16, 0, 0, 0, 0, 5, 106),
       cftime.DatetimeNoLeap(2000, 5, 16, 12, 0, 0, 0, 0, 136),
       cftime.DatetimeNoLeap(2000, 6, 16, 0, 0, 0, 0, 3, 167),
       cftime.DatetimeNoLeap(2000, 7, 16, 12, 0, 0, 0, 5, 197),
       cftime.DatetimeNoLeap(2000, 8, 16, 12, 0, 0, 0, 1, 228),
       cftime.DatetimeNoLeap(2000, 9, 16, 0, 0, 0, 0, 4, 259),
       cftime.DatetimeNoLeap(2000, 10, 16, 12, 0, 0, 0, 6, 289),
       cftime.DatetimeNoLeap(2000, 11, 16, 0, 0, 0, 0, 2, 320),
       cftime.DatetimeNoLeap(2000, 12, 16, 12, 0, 0, 0, 4, 350)], dtype=object)
Coordinates:
  * time     (time) object 2000-01-16 12:00:00 ... 2000-12-16 12:00:00
Attributes:
    bounds:   time_bnds
dsm = esmlab.resample(ds, freq='mon', method='left')
dsm.time
<xarray.DataArray 'time' (time: 12)>
array([cftime.DatetimeNoLeap(2000, 1, 1, 12, 0, 0, 0, 5, 1),
       cftime.DatetimeNoLeap(2000, 2, 1, 12, 0, 0, 0, 1, 32),
       cftime.DatetimeNoLeap(2000, 3, 1, 12, 0, 0, 0, 1, 60),
       cftime.DatetimeNoLeap(2000, 4, 1, 12, 0, 0, 0, 4, 91),
       cftime.DatetimeNoLeap(2000, 5, 1, 12, 0, 0, 0, 6, 121),
       cftime.DatetimeNoLeap(2000, 6, 1, 12, 0, 0, 0, 2, 152),
       cftime.DatetimeNoLeap(2000, 7, 1, 12, 0, 0, 0, 4, 182),
       cftime.DatetimeNoLeap(2000, 8, 1, 12, 0, 0, 0, 0, 213),
       cftime.DatetimeNoLeap(2000, 9, 1, 12, 0, 0, 0, 3, 244),
       cftime.DatetimeNoLeap(2000, 10, 1, 12, 0, 0, 0, 5, 274),
       cftime.DatetimeNoLeap(2000, 11, 1, 12, 0, 0, 0, 1, 305),
       cftime.DatetimeNoLeap(2000, 12, 1, 12, 0, 0, 0, 3, 335)], dtype=object)
Coordinates:
  * time     (time) object 2000-01-01 12:00:00 ... 2000-12-01 12:00:00
Attributes:
    bounds:   time_bnds
dsm = esmlab.resample(ds, freq='mon', method='right')
dsm.time
<xarray.DataArray 'time' (time: 12)>
array([cftime.DatetimeNoLeap(2000, 1, 31, 12, 0, 0, 0, 0, 31),
       cftime.DatetimeNoLeap(2000, 2, 28, 12, 0, 0, 0, 0, 59),
       cftime.DatetimeNoLeap(2000, 3, 31, 12, 0, 0, 0, 3, 90),
       cftime.DatetimeNoLeap(2000, 4, 30, 12, 0, 0, 0, 5, 120),
       cftime.DatetimeNoLeap(2000, 5, 31, 12, 0, 0, 0, 1, 151),
       cftime.DatetimeNoLeap(2000, 6, 30, 12, 0, 0, 0, 3, 181),
       cftime.DatetimeNoLeap(2000, 7, 31, 12, 0, 0, 0, 6, 212),
       cftime.DatetimeNoLeap(2000, 8, 31, 12, 0, 0, 0, 2, 243),
       cftime.DatetimeNoLeap(2000, 9, 30, 12, 0, 0, 0, 4, 273),
       cftime.DatetimeNoLeap(2000, 10, 31, 12, 0, 0, 0, 0, 304),
       cftime.DatetimeNoLeap(2000, 11, 30, 12, 0, 0, 0, 2, 334),
       cftime.DatetimeNoLeap(2000, 12, 31, 12, 0, 0, 0, 5, 365)], dtype=object)
Coordinates:
  * time     (time) object 2000-01-31 12:00:00 ... 2000-12-31 12:00:00
Attributes:
    bounds:   time_bnds

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.