Skip to content

netcdf time:units issues, get around problems using preprocess? #7144

Answered by kmuehlbauer
durack1 asked this question in Q&A
Discussion options

You must be logged in to vote

@durack1 It might be easier than anticipated.

Just open like this:

def fixTime(ds):
    print("fix time:units")
    ds.time.encoding["units"] = "days since 2001-01-01"
    return xr.decode_cf(ds)

# make it a one-liner :-)
ds = xr.open_dataset("sic_O1.nc", decode_times=False).pipe(fixTime)

Update: refactor code

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@keewis
Comment options

@kmuehlbauer
Comment options

@durack1
Comment options

@keewis
Comment options

@durack1
Comment options

Answer selected by durack1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants