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

Indice mismatch in VectorWind when using daily data but not seasonally averaged data #83

Closed
MicrMc opened this issue Mar 20, 2017 · 7 comments

Comments

@MicrMc
Copy link

MicrMc commented Mar 20, 2017

Hi Andrew
I am using VectorWind to calculate divergence and absolute vorticity in model runs. Both work fine when using seasonal U and V data however when I switched to daily data extracting season of interest, DJF, it cannot calculate the VectorWind, crashing at u.transpose(apiorder) in source code and producing the error IndexError: Indice mismatch. Indices must have the same length.

My data is:

In [45]: print ctl_uwnd
x_wind / (m s-1)                    (time: 5220; latitude: 144; longitude: 192)
     Dimension coordinates:
          time                           x               -               -
          latitude                       -               x               -
          longitude                      -               -               x
     Auxiliary coordinates:
          clim_season                    x               -               -
          forecast_period                x               -               -
          month                          x               -               -
          year                           x               -               -
     Scalar coordinates:
          forecast_reference_time: 1981-09-01 00:00:00
          pressure: 200.0 hPa
     Attributes:
          Conventions: CF-1.5
          STASH: m01s15i243
          source: Data from Met Office Unified Model
          um_version: 8.4
     Cell methods:
          mean: time (1 hour)

In [46]: print ctl_vwnd
y_wind / (m s-1)                    (time: 5220; latitude: 144; longitude: 192)
     Dimension coordinates:
          time                           x               -               -
          latitude                       -               x               -
          longitude                      -               -               x
     Auxiliary coordinates:
          clim_season                    x               -               -
          forecast_period                x               -               -
          month                          x               -               -
          year                           x               -               -
     Scalar coordinates:
          forecast_reference_time: 1981-09-01 00:00:00
          pressure: 200.0 hPa
     Attributes:
          Conventions: CF-1.5
          STASH: m01s15i244
          source: Data from Met Office Unified Model
          um_version: 8.4
     Cell methods:
          mean: time (1 hour)

With the seasonal data the same lat and lon dimensions but only 58 timesteps.
What would the error be in using daily data as opposed to seasonally averaged data for VectorWind?

@ajdawson
Copy link
Owner

Please provide the full traceback for the error you are seeing.

@MicrMc
Copy link
Author

MicrMc commented Mar 21, 2017 via email

@ajdawson
Copy link
Owner

Weird. Seems to be having a problem actually loading the data within iris rather than being a problem in windspharm. Can you try putting the following line before the call to windspharm (line 107 in your script):

ctl_vwnd.data
ctl_w = VectorWind(ctl_uwnd, ctl_vwnd)

This will force iris to load the data for the ctl_vwind cube, and I'm wondering if this will trigger the same error.

@MicrMc
Copy link
Author

MicrMc commented Mar 21, 2017 via email

@ajdawson
Copy link
Owner

Its Andrew, and yes I think this is a problem with iris, but may be raised because windspharm makes a copy of a cube with deferred data then in-place transposes it (however you seem to be running an older version of iris, I'm not sure this would happen in the most recent version).

You should read up on the deferred loading in iris, but basically when you load a netcdf file (or other format) iris reads the metadata, but doesn't load any data values into memory, it only does this when it needs it. You can force iris to load the data by accessing the .data attribute as we did here. This makes sense for windspharm, which needs to load all the data anyway so it can be passed to a Fortran library.

@ajdawson
Copy link
Owner

I forgot, iris cubes have a method has_lazy_data() that you can call to see if data is still deferred.

@MicrMc
Copy link
Author

MicrMc commented Mar 21, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants