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

Concatenated cubes lose their derived coordinate #2478

Closed
pelson opened this issue Apr 6, 2017 · 8 comments · Fixed by #5096
Closed

Concatenated cubes lose their derived coordinate #2478

pelson opened this issue Apr 6, 2017 · 8 comments · Fixed by #5096

Comments

@pelson
Copy link
Member

pelson commented Apr 6, 2017

I'm pretty deep into some code, and it looks like cube.concatenate is throwing away my derived coordinates. Apologies I can't provide a SSCCE currently (happy for this issue to simply be recorded until I get a chance to look into it).

@duncanwp
Copy link
Contributor

duncanwp commented May 2, 2017

I've hit this too, do you have an easy workaround?

@duncanwp
Copy link
Contributor

duncanwp commented May 2, 2017

Just adding one of the original aux factories to the concatenated Cube seems to work.

duncanwp added a commit to duncanwp/cis_plugins that referenced this issue May 2, 2017
@bjlittle bjlittle self-assigned this May 3, 2017
@bjlittle
Copy link
Member

bjlittle commented May 3, 2017

I'll take a peek ...

@bjlittle
Copy link
Member

bjlittle commented May 3, 2017

Yup, it's a known TODO, ever since concatenate was first written, see https://github.com/SciTools/iris/blob/v1.12.x/lib/iris/_concatenate.py#L40

@schlunma
Copy link
Contributor

schlunma commented Jan 14, 2020

I just encountered the same problem in the latest version. Here is a working example:

import iris
print(iris.__version__)
print("")


# Load sample data
path = iris.sample_data_path('hybrid_height.nc')
cube_0 = iris.load(path)[0]

# Copy cube
cube_0.remove_coord('time')
cube_0 = iris.util.new_axis(cube_0)
cube_1 = cube_0.copy()
time_coord_0 = iris.coords.DimCoord([1],
                                    bounds=[0, 2],
                                    var_name='time',
                                    standard_name='time',
                                    long_name='time',
                                    units='days since 2000-01-01')
time_coord_1 = time_coord_0.copy([3], bounds=[2, 4])
cube_0.add_dim_coord(time_coord_0, 0)
cube_1.add_dim_coord(time_coord_1, 0)

print("Cubes have derived coordinate:")
print(cube_0)
print(cube_1)
print("")

# Concatenate
cubes = iris.cube.CubeList([cube_0, cube_1])
new_cube = cubes.concatenate_cube()
print("Cube does not have derived coordinate:")
print(new_cube)

which gives

2.3.0
Cubes have derived coordinate:
air_potential_temperature                    (time: 1; model_level_number: 15; grid_latitude: 100; grid_longitude: 100)
     Dimension coordinates:
          time                                    x                      -                  -                    -
          model_level_number                      -                      x                  -                    -
          grid_latitude                           -                      -                  x                    -
          grid_longitude                          -                      -                  -                    x
     Auxiliary coordinates:
          atmosphere_hybrid_height_coordinate     -                      x                  -                    -
          sigma                                   -                      x                  -                    -
          surface_altitude                        -                      -                  x                    x
     Derived coordinates:
          altitude                                -                      x                  x                    x
     Scalar coordinates:
          forecast_period: 0.0 hours
          forecast_reference_time: 2009-09-09 17:10:00
     Attributes:
          Conventions: CF-1.5
          STASH: m01s00i004
          source: Data from Met Office Unified Model 7.04
air_potential_temperature                    (time: 1; model_level_number: 15; grid_latitude: 100; grid_longitude: 100)
     Dimension coordinates:
          time                                    x                      -                  -                    -
          model_level_number                      -                      x                  -                    -
          grid_latitude                           -                      -                  x                    -
          grid_longitude                          -                      -                  -                    x
     Auxiliary coordinates:
          atmosphere_hybrid_height_coordinate     -                      x                  -                    -
          sigma                                   -                      x                  -                    -
          surface_altitude                        -                      -                  x                    x
     Derived coordinates:
          altitude                                -                      x                  x                    x
     Scalar coordinates:
          forecast_period: 0.0 hours
          forecast_reference_time: 2009-09-09 17:10:00
     Attributes:
          Conventions: CF-1.5
          STASH: m01s00i004
          source: Data from Met Office Unified Model 7.04

Cube does not have derived coordinate:
air_potential_temperature                    (time: 2; model_level_number: 15; grid_latitude: 100; grid_longitude: 100)
     Dimension coordinates:
          time                                    x                      -                  -                    -
          model_level_number                      -                      x                  -                    -
          grid_latitude                           -                      -                  x                    -
          grid_longitude                          -                      -                  -                    x
     Auxiliary coordinates:
          atmosphere_hybrid_height_coordinate     -                      x                  -                    -
          sigma                                   -                      x                  -                    -
          surface_altitude                        -                      -                  x                    x
     Scalar coordinates:
          forecast_period: 0.0 hours
          forecast_reference_time: 2009-09-09 17:10:00
     Attributes:
          Conventions: CF-1.5
          STASH: m01s00i004
          source: Data from Met Office Unified Model 7.04

I would be really nice of someone could take a look at this. Thanks! @bjlittle

@github-actions
Copy link
Contributor

In order to maintain a backlog of relevant issues, we automatically label them as stale after 500 days of inactivity.

If this issue is still important to you, then please comment on this issue and the stale label will be removed.

Otherwise this issue will be automatically closed in 28 days time.

@github-actions github-actions bot added the Stale A stale issue/pull-request label Aug 10, 2021
@schlunma
Copy link
Contributor

Still an important issue for me (and ESMValTool development team).

@schlunma
Copy link
Contributor

schlunma commented Dec 7, 2022

Just opened a PR that fixes this: #5096

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants