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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

dtype of regridded cube changes after realizing the data #238

Closed
schlunma opened this issue Feb 20, 2023 · 6 comments 路 Fixed by #239
Closed

dtype of regridded cube changes after realizing the data #238

schlunma opened this issue Feb 20, 2023 · 6 comments 路 Fixed by #239
Assignees
Labels
New: Issue Highlight a new community raised "generic" issue Type: Bug

Comments

@schlunma
Copy link

馃悰 Bug Report

After regridding a cube with dtype=float32 using regrid_unstructured_to_rectilinear and realizing the data the output cube's dtype is float64. If the data is saved and re-loaded before realizing the data, the dtype does not change.

How To Reproduce

import numpy as np

import iris
from iris.coords import DimCoord
from iris.cube import Cube
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD

import esmf_regrid
from esmf_regrid.experimental.unstructured_scheme import regrid_unstructured_to_rectilinear

print("iris version:", iris.__version__)
print("iris-esmf-regrid version:", esmf_regrid.__version__)

path = iris.sample_data_path('mesh_C4_synthetic_float.nc')
with PARSE_UGRID_ON_LOAD.context():
    cube = iris.load_cube(path)
    print("dtype input cube:", cube.dtype)

lat = DimCoord([10, 20, 30], standard_name='latitude', units='degrees_north')
lon = DimCoord([10, 20, 30], standard_name='longitude', units='degrees_east')
lat.guess_bounds()
lon.guess_bounds()
target = Cube(np.ones((3, 3)), dim_coords_and_dims=[(lat, 0), (lon, 1)])

regridded_cube = regrid_unstructured_to_rectilinear(cube, target)
print("dtype regridded cube before cube.data:", regridded_cube.dtype)

# If the following lines are added, the dtype is still float32 after realizing
# the data
# from pathlib import Path
# x = Path.home() / 'test.nc'
# iris.save(regridded_cube, x)
# regridded_cube = iris.load_cube(x)

regridded_cube.data
print("dtype regridded cube after cube.data:", regridded_cube.dtype)

prints

iris version: 3.4.0
iris-esmf-regrid version: 0.5.0
dtype input cube: float32
dtype regridded cube before cube.data: float32
dtype regridded cube after cube.data: float64

Expected behaviour

The dtype should be float32 for the regridding cube even after realizing the data.

Environment

  • OS and version: Red Hat Enterprise Linux 8.5 (Ootpa)
  • esmf_regrid version: 0.5.0
@schlunma schlunma added New: Issue Highlight a new community raised "generic" issue Type: Bug labels Feb 20, 2023
@bjlittle
Copy link
Member

Thanks @schlunma for raising this.

@stephenworsley is on the case and will dip into this asap, cheers 馃憤

@github-actions
Copy link
Contributor

@SciTools-incubator/esmf-regrid-devs This issue is stale due to a lack of activity in the last 90 days. Remove stale label or comment, otherwise this issue will close automatically in 7 days time.

@github-actions github-actions bot added the Stale: Closure warning This stale issue or pull-request has been marked for closure label May 24, 2023
@schlunma
Copy link
Author

still relevant

@github-actions github-actions bot removed the Stale: Closure warning This stale issue or pull-request has been marked for closure label May 25, 2023
@trexfeathers trexfeathers linked a pull request Jun 21, 2023 that will close this issue
@github-actions
Copy link
Contributor

@SciTools-incubator/esmf-regrid-devs This issue is stale due to a lack of activity in the last 90 days. Remove stale label or comment, otherwise this issue will close automatically in 7 days time.

@github-actions github-actions bot added the Stale: Closure warning This stale issue or pull-request has been marked for closure label Aug 24, 2023
@stephenworsley stephenworsley removed the Stale: Closure warning This stale issue or pull-request has been marked for closure label Aug 24, 2023
Copy link
Contributor

@SciTools-incubator/esmf-regrid-devs This issue is stale due to a lack of activity in the last 180 days. Remove stale label or comment, otherwise this issue will close automatically in 14 days time.

@github-actions github-actions bot added the Stale: Closure warning This stale issue or pull-request has been marked for closure label Feb 21, 2024
@schlunma
Copy link
Author

still relevant

@stephenworsley stephenworsley removed the Stale: Closure warning This stale issue or pull-request has been marked for closure label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New: Issue Highlight a new community raised "generic" issue Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants