Skip to content

Converting WRF field to an iris dataset fails #26

@kelcyno

Description

@kelcyno

What happened?

When using Xarray's to iris:

field_iris=field_in.to_iris()

the following error is thrown: ValueError: [UT_SUCCESS] Failed to parse unit

A work around is to drop 'XTIME' and 'Times' from field_in. This allows to_iris to pick up on the cf-compliant 'Time'.

Minimal Complete Verifiable Example

vars = ['COMDBZ']
files = sorted(glob.("wrf2dout_d02_2021*.nc"))
def preprocess(ds):
    return ds[vars]

ds = xr.open_mfdataset(
    files,
    engine="xwrf",
    parallel=True,
    concat_dim="Time",
    combine="nested",
    preprocess=preprocess,
    chunks={'Time': 1},decode_times=False
)
#Time originally has an integer, while Times is a datetime.  
#I need the datetime
ds['Time'] = ds['Times'] 
comdbz = ds['COMDBZ']
comdbz = comdbz.drop('XTIME')
comdbz = comdbz.drop('Times')
field_iris=comdbz.to_iris()
data_time=field_iris.slices_over('Time')

Relevant log output

No response

Version

main

Which Python version are you using?

3.8

Anything else we need to know?

This isn't a direct bug so much as a way to use wrf data with the Xarray to_iris functionality.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions