Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative timesteps after .to_netcdf with long time periods? #545

Closed
cwerner opened this issue Aug 21, 2015 · 3 comments
Closed

Negative timesteps after .to_netcdf with long time periods? #545

cwerner opened this issue Aug 21, 2015 · 3 comments

Comments

@cwerner
Copy link

cwerner commented Aug 21, 2015

Hi.

I discovered that I get negative times on the time dimension for long intervals (years 1700-2013, monthly timestep).

import xray
import numpy as np
import pandas as pd

years = range(1700,2014)
LATS = np.arange(-89.75, 90.0, 0.5)
LONS = np.arange(-179.75, 180.0, 0.5)

tlist = pd.date_range('%d-01-01' % years[0], periods=12*len(years), freq='M')

da = xray.DataArray(np.ones((12*len(years), 360, 720))*-9999, \
            [('time', tlist), ('latitude',  LATS), ('longitude', LONS) ])

# i then fill the dataarray with info from a text file (using read_csv from pandas)
# eventually I dump to netcdf

ds = xray.Dataset({"mgpp": da})
ds.to_netcdf('test_%d-%d.nc' % (years[0], years[-1]))

If I "ncdump -c mgpp_1700-2013.nc I get:

netcdf mgpp_1700-2013 {
dimensions:
    latitude = 360 ;
    time = 3768 ;
    longitude = 720 ;
variables:
    float latitude(latitude) ;
    float mgpp(time, latitude, longitude) ;
        mgpp:units = "gCm-2" ;
    float longitude(longitude) ;
    float time(time) ;
        time:units = "days since 1700-01-31 00:00:00" ;
        time:calendar = "proleptic_gregorian" ;
data:

time = 0, 28, 59, 89, 120, 150, 181, 212, 242, 273, 303, 334, 365, 393, 424, 
    454, 485, 515, 546, 577, 607, 638, 668, 699, 730, 758, 789, 819, 850, 
    880, 911, 942, 972, 1003, 1033, 1064, 1095, 1123, 1154, 1184, 1215, 1245, 
    1276, 1307, 1337, 1368, 1398, 1429, 1460, 1489, 1520, 1550, 1581, 1611, 
    1642, 1673, 1703, 1734, 1764, 1795, 1826, 1854, 1885, 1915, 1946, 1976, 
    2007, 2038, 2068, 2099, 2129, 2160, 2191, 2219, 2250, 2280, 2311, 2341, 
    2372, 2403, 2433, 2464, 2494, 2525, 2556, 2584, 2615, 2645, 2676, 2706, 
    2737, 2768, 2798, 2829, 2859, 2890, 2921, 2950, 2981, 3011, 3042, 3072, 
    3103, 3134, 3164, 3195, 3225, 3256, 3287, 3315, 3346, 3376, 3407, 3437, 
    3468, 3499, 3529, 3560, 3590, 3621, 3652, 3680, 3711, 3741, 3772, 3802, (...)

and eventually:

  (...) 106435, 106466, 106497, 106527, 106558, 106588, 106619, 106650, 106679, 
    106710, 106740, -106732.982337963, -106702.982337963, -106671.982337963, 
    -106640.982337963, -106610.982337963, -106579.982337963, 
    -106549.982337963, -106518.982337963, -106487.982337963, 
    -106459.982337963, -106428.982337963, -106398.982337963, 
    -106367.982337963, -106337.982337963, -106306.982337963, 
    -106275.982337963, -106245.982337963, -106214.982337963, 
    -106184.982337963, -106153.982337963, -106122.982337963, 
    -106094.982337963, -106063.982337963, -106033.982337963, 
    -106002.982337963, -105972.982337963, -105941.982337963, 
    -105910.982337963, -105880.982337963, -105849.982337963, (...)

Not sure if I can inflence that at "dump" time with to_netcdf? I know about the time limitation, but my years should be non-critical, no?

@shoyer shoyer added the bug label Aug 21, 2015
@shoyer
Copy link
Member

shoyer commented Aug 21, 2015

This looks like some sort of integer overflow bug. Oddly, the times actually roundtrips fine back into xray (but probably not other programs that read netCDFs).

@stale
Copy link

stale bot commented Feb 1, 2019

In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity
If this issue remains relevant, please comment here; otherwise it will be marked as closed automatically

@stale stale bot added the stale label Feb 1, 2019
@spencerkclark
Copy link
Member

This is the same issue as #2272, which was fixed in #2519.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants