Skip to content

iris.analysis.stats.pearsonr metadata error #4786

Closed Answered by rcomer
EnergyResearcher asked this question in Q&A
Discussion options

You must be logged in to vote

I assume you do some subsetting so that the time dimensions are the same length. The problem resolve is flagging is that your time coordinates have different units. You could fix this with something like

import cf_units

# Make sure both cubes have the same calendar, otherwise convert_units doesn't work.
new_unit = cf_units.Unit(cube2.coord("time").units.origin, calendar="gregorian")
cube2.coord("time").units = new_unit

cube2.convert_units(cube1.coord("time"))

However, you will still get an error if the time coordinate points and bounds don't match, so it may be easier to replace the whole coordinate:

cube2.remove_coord("time")
cube2.add_dim_coord(cube1.coord("time"), 0)

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@EnergyResearcher
Comment options

Comment options

You must be logged in to vote
5 replies
@EnergyResearcher
Comment options

@rcomer
Comment options

rcomer Jun 9, 2022
Collaborator

@EnergyResearcher
Comment options

@pp-mo
Comment options

pp-mo Jun 9, 2022
Maintainer

@EnergyResearcher
Comment options

Answer selected by EnergyResearcher
Comment options

You must be logged in to vote
0 replies
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