Skip to content

AttributeError: 'numpy.float32' object has no attribute 'name' when trying to modify Zarr V2 _FillValue #813

@norlandrhagen

Description

@norlandrhagen

Hey @tomwhite,

I'm trying to change the default _FillValue for an Xarray dataset and then write it to Zarr V2. When I call to_zarr, I get: AttributeError: 'numpy.float32' object has no attribute 'name'.

I don't have a reproducer yet, but the variable encoding looks like:

{
  "chunks": {},
  "preferred_chunks": {},
  "compressors": [
    "Zlib(level=1)"
  ],
  "filters": [],
  "shards": None,
  "_FillValue": "-9999.0",
  "dtype": "float32"
}

Any ideas? Sorry in adv if this is a duplicate!

Traceback:

  File "/Users/nrhagen/Documents/carbonplan/OCR/ocr_pyramid/.venv/lib/python3.13/site-packages/xarray/core/duck_array_ops.py"
, line 422, in fillna
    return where(notnull(data), data, other)
  File "/Users/nrhagen/Documents/carbonplan/OCR/ocr_pyramid/.venv/lib/python3.13/site-packages/xarray/core/duck_array_ops.py"
, line 409, in where
    return xp.where(condition, *as_shared_dtype([x, y], xp=xp))
           ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nrhagen/Documents/carbonplan/OCR/ocr_pyramid/.venv/lib/python3.13/site-packages/cubed/array_api/searching_functions.py"
, line 105, in where
    return elemwise(nxp.where, condition, x1, x2, dtype=dtype)
  File "/Users/nrhagen/Documents/carbonplan/OCR/ocr_pyramid/.venv/lib/python3.13/site-packages/cubed/core/ops.py"
, line 575, in elemwise
    return blockwise(
        func,
    ...<2 lines>...
        dtype=dtype,
    )
  File "/Users/nrhagen/Documents/carbonplan/OCR/ocr_pyramid/.venv/lib/python3.13/site-packages/cubed/core/ops.py"
, line 302, in blockwise
    chunkss, arrays = unify_chunks(*args)
                      ~~~~~~~~~~~~^^^^^^^
  File "/Users/nrhagen/Documents/carbonplan/OCR/ocr_pyramid/.venv/lib/python3.13/site-packages/cubed/core/ops.py"
, line 1504, in unify_chunks
    nameinds.append((a.name, ind))
                     ^^^^^^
AttributeError: 'numpy.float32' object has no attribute 'name'
Raised while encoding variable 'tasmax' with value <xarray.Variable (y: 512, x: 512)> Size: 1MB
cubed.Array<array-038, shape=(512, 512), dtype=float32, chunks=((256, 256), (256, 256))>
Attributes:
    cell_measures:  area: areacella
    cell_methods:   area: mean time: maximum
    comment:        maximum near-surface (usually, 2 meter) air temperature (...
    history:        2019-05-02T08:38:27Z altered by CMOR: Treated scalar dime...
    long_name:      Daily Maximum Near-Surface Air Temperature
    original_name:  STMX
    standard_name:  air_temperature
    units:          K

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions