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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added fix for WACCM ua time coordinate #200

Closed
wants to merge 4 commits into from
Closed

added fix for WACCM ua time coordinate #200

wants to merge 4 commits into from

Conversation

hb326
Copy link
Contributor

@hb326 hb326 commented Aug 6, 2019

Time was not monotonic for a WACCM ua file, so we fixed it.
Fixing the bounds did not work. We assume because iris.guess_bounds() does not work for coordinate time.

@hb326 hb326 added the fix for dataset Related to dataset-specific fix files label Aug 6, 2019
@hb326 hb326 self-assigned this Aug 6, 2019
@bouweandela bouweandela removed their request for review August 23, 2019 14:38
@bouweandela
Copy link
Member

@jvegasbsc can you please review this?



def test_ua_fix_metadata(ua_cubes):
expected_coord = iris.coords.AuxCoord(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expected_coord = iris.coords.AuxCoord(
expected_coord = iris.coords.DimCoord(

[1.0, 2.0, 3.0], standard_name='time', units='days since 1850-01-01',
bounds=None)
expected_cube = iris.cube.Cube([7.0, 9.0, 8.0], var_name='ua',
aux_coords_and_dims=[(expected_coord, 0)])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
aux_coords_and_dims=[(expected_coord, 0)])
dim_coords_and_dims=[(expected_coord, 0)])

idx_sorted = np.argsort(coord.points)
coord.points = coord.points[idx_sorted]
coord.bounds = None
# coord.guess_bounds('time') # fails for coordinate 'time'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is failing exactly?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @bouweandela question. @hb326, note that coord already refers to time, so I am not sure why there is another mention of time in the args. Certainly guess_bounds works with time coordinates in general.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like time could be only AuxCoord in some cases and the time points are mangled - but if the data has enough dimensions to account for a (pseudo)time coordinate then what's in DimCoords that replaces time?

@JaroCamphuijsen
Copy link
Contributor

@hb326 can you have a look at the comments above? Then we can probably merge this.

@bouweandela bouweandela changed the base branch from development to master January 3, 2020 12:12
Co-authored-by: Bouwe Andela <[email protected]>
@valeriupredoi
Copy link
Contributor

valeriupredoi commented Feb 8, 2021

OK I started committing stuff that @bouweandela suggested (I know, I'm nasty - changing code in a PR that has nothing to do with meself heh, but was trying to see if we can get this through to the 2.2 release) but I stopped coz it looks like we really need @hb326 to have a look and comment/commit 👍

@hb326
Copy link
Contributor Author

hb326 commented May 4, 2021

OK I started committing stuff that @bouweandela suggested (I know, I'm nasty - changing code in a PR that has nothing to do with meself heh, but was trying to see if we can get this through to the 2.2 release) but I stopped coz it looks like we really need @hb326 to have a look and comment/commit 👍

I am looking at it now. Sorry, took a while. Hopefully we can get it sorted for release 2.3!

@valeriupredoi
Copy link
Contributor

cool stuff! just ping me here if you need a review 🍺

@hb326
Copy link
Contributor Author

hb326 commented May 4, 2021

@valeriupredoi: it seems like the problem vanished! I just now ran a recipe where I try to read the WACCM data without any fix, in different variations (historical, amip, piControl), and it seems like everything is read correctly. Could you please check if you can read the following data, no need for a script, just reading the data with the ESMValTool:

  • {dataset: CESM2-WACCM, project: CMIP6, mip: day, exp: historical, grid: gn, ensemble: r1i1p1f1, start_year: 1960, end_year: 2014}

Maybe some update to the Core has fixed the problem without the dataset fix?

@hb326
Copy link
Contributor Author

hb326 commented May 4, 2021

@valeriupredoi: it seems like the problem vanished! I just now ran a recipe where I try to read the WACCM data without any fix, in different variations (historical, amip, piControl), and it seems like everything is read correctly. Could you please check if you can read the following data, no need for a script, just reading the data with the ESMValTool:

* {dataset: CESM2-WACCM,  project: CMIP6,  mip: day,  exp: historical,  grid: gn, ensemble: r1i1p1f1,  start_year: 1960,  end_year: 2014}

Maybe some update to the Core has fixed the problem without the dataset fix?

I should add that I am using the current master branch for the ESMValTool and the ESMValCore for this test.

@hb326
Copy link
Contributor Author

hb326 commented May 6, 2021

@valeriupredoi: did you check yet if WACCM would run for you without fix as well?

@hb326
Copy link
Contributor Author

hb326 commented May 11, 2021

@valeriupredoi: this was one of the PR I wanted you to check on.

Copy link
Contributor

@valeriupredoi valeriupredoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hb326 I understand the special case but I think it's best you add a note (in-line comment) about this particular case (it was visible to me from the test case, cheers for adding it!). But my question is - what sort of DimCoord does the cube have to account for the time axis, if time itself is an AuxCoord

idx_sorted = np.argsort(coord.points)
coord.points = coord.points[idx_sorted]
coord.bounds = None
# coord.guess_bounds('time') # fails for coordinate 'time'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like time could be only AuxCoord in some cases and the time points are mangled - but if the data has enough dimensions to account for a (pseudo)time coordinate then what's in DimCoords that replaces time?

ta_cube = iris.cube.Cube([1.0], var_name='ta')
time_coord = iris.coords.AuxCoord(
[1.0, 3.0, 2.0], standard_name='time', units='days since 1850-01-01',
bounds=[[0.5, 1.5], [2.5, 3.5], [1.5, 2.5]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes, this is accounted for in this test case @bouweandela and @zklaus

@valeriupredoi
Copy link
Contributor

@hb326 could you pls do a mergy merge of master into this, some bits are causing age-related issues, and fix the conflicts as well pls (lemme know if you need help with that) 🍺

@hb326
Copy link
Contributor Author

hb326 commented May 11, 2021

@hb326 could you pls do a mergy merge of master into this, some bits are causing age-related issues, and fix the conflicts as well pls (lemme know if you need help with that) 🍺

@valeriupredoi, my thinking is that we can just forget this pull request since it seems to me that some change in the ESMValCore actually fixed the problem for which I had written the fix. Did you try to read in the WACCM ua data with the current master branch of ESMValCore and ESMValTool? Because for me it works like a charm, WITHOUT using the fix.

@valeriupredoi
Copy link
Contributor

@hb326 could you pls do a mergy merge of master into this, some bits are causing age-related issues, and fix the conflicts as well pls (lemme know if you need help with that) beer

@valeriupredoi, my thinking is that we can just forget this pull request since it seems to me that some change in the ESMValCore actually fixed the problem for which I had written the fix. Did you try to read in the WACCM ua data with the current master branch of ESMValCore and ESMValTool? Because for me it works like a charm, WITHOUT using the fix.

I'll have a looksee now 👍

@valeriupredoi
Copy link
Contributor

the file on JASMIN which is version 27-Feb-2019 I get after a raw CMOR check (just by importing the checker and running it):

esmvalcore.cmor.check.CMORCheckError: There were errors in variable ua:
lon: units should be degrees_east, not degrees
 lat: units should be degrees_north, not degrees
 in cube:
eastward_wind / (m s-1)             (time: 1980; air_pressure: 19; latitude: 192; longitude: 288)

so all fine, no issues with time 👍
Up to you if you just wanna nuke the PR, Birgit 🍺

@hb326
Copy link
Contributor Author

hb326 commented May 11, 2021

Ok, it does seem like the problem that this PR was supposed to fix was fixed with an update to the ESMValCore recently. So this PR is redundant.

@hb326 hb326 closed this May 11, 2021
@valeriupredoi
Copy link
Contributor

fairly sure it's the data that got updated @hb326

@bouweandela
Copy link
Member

Can the branch be deleted?

@hb326
Copy link
Contributor Author

hb326 commented May 11, 2021

Can the branch be deleted?

@bouweandela, I would say yes, it can be deleted.

@valeriupredoi valeriupredoi deleted the waccm_ua_fix branch May 11, 2021 15:57
@valeriupredoi
Copy link
Contributor

brancho deletado, cheers @hb326

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix for dataset Related to dataset-specific fix files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants