home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 836857104

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/5276#issuecomment-836857104 https://api.github.com/repos/pydata/xarray/issues/5276 836857104 MDEyOklzc3VlQ29tbWVudDgzNjg1NzEwNA== 11815787 2021-05-10T15:41:56Z 2021-05-10T15:43:04Z NONE

I was able to generate a small code to re-produce the error. ```python import numpy as np import xarray as xr from copy import deepcopy import random import os import logging log = logging.getLogger(name)

def generate_data(xpath, m=10000,n=900,k=601): """

:param m:
:param n:
:param k:
:return:
"""
coord1=dict(dim1=range(m), dim2=range(n))
for mat in range(k):
    a = np.random.rand(m,n)
    file_name = "{:04d}.nc".format(mat)
    full_file_name = os.path.join(xpath, file_name)
    coord1['maturity'] = [mat]
    a = np.reshape(a,[m,n,1])
    ar = xr.DataArray(a, dims=['dim1', 'dim2', 'maturity'], coords=coord1)
    ar.to_netcdf(full_file_name)

def func(xpath, spec): log.debug("xpath=%s, spec=%s", xpath, spec)

doc = deepcopy(spec)

with xr.open_mfdataset(xpath + "/*.nc", concat_dim='maturity') as data:
        var_name=  list(data.data_vars)[0]
        ar = data[var_name]
        maturity = spec['maturity']
        ann = ar.cumsum(dim='maturity')
        ann = ann - 1
        ar1 = ann.sel(maturity=maturity)
        doc['data'] = ar1.load().values
return doc

def repeat_access_data_generate_error(xpath, k=601, l=1000): """ Dummy to generate error :return: """ spec={} dum=0.0 for _l1 in range(l): try: spec['maturity'] = np.random.randint(0,k,1)[0] doc = func(xpath, spec) #do dummy operation with doc dum = (dum + np.sum(doc['data']))/2.0 except Exception as err: log.error("spec=%s, err=%s", spec, err, exc_info=True)

return dum

if name == "main": FORMAT = '%(asctime)-15s, %(levelname)s %(process)d, %(filename)s:%(lineno)s - %(funcName)20s(), %(message)s' log_file_name = "errors.log" logging.basicConfig(filename=log_file_name, filemode='a+', level=logging.DEBUG, format=FORMAT) xpath="/home/ubuntu/runs/xrdata/" # folder to hold files # change values of m,n,k to re-produce the error generate_data(xpath,m=1000) repeat_access_data_generate_error(xpath)

```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  878481461
Powered by Datasette · Queries took 157.276ms · About: xarray-datasette