0

I want to read a particular parameter from multiple nc files using xarrays in python. I want to make time as an another dimension using xarray. How to do it? Could you please resolve my issue?

Edit: I have a nc files of subdaily data

import xarray as xr

ds = xr.open_mfdataset('/home/atmosphere/data/gridsat/GRIDSAT-B1.2013.07.01.*.v02r01.nc',engine='netcdf4', concat_dim='Time')

But I am getting an error

ValueError: arguments without labels along dimension 'Ngeo' cannot be aligned because they have different dimension sizes: {6, 7}

There are few more dimensions with a name Ngeo on the dataset, which I don't need to use (I don't want to import whole parameters from the file, my required parameter to be imported is irwin_cdr along with lat and lon).

2
  • Provide some code and an example problem please. Commented Dec 3, 2019 at 22:53
  • 2
    When loading multiple files, the data must all have identical dimension sizes (other than the one you are concatenating on - in this case 'time'). You are getting the error since it's finding different sized 'Ngeo' dimensions in different files. You can try using the argument `drop_vars = ' with the variables you don't need (that have the odd dim sizes). If that doesn't work you'll need to manually pull the variables you want and concatenate them together. Commented Dec 4, 2019 at 18:49

1 Answer 1

1

As bwc suggested, 'drop_vars=' did very well. So I could ignore the parameters having different dimension name like 'Ngeo' Hence the line I used is,

ds=xr.open_mfdataset(fname,drop_variables=('satlat','satlon','satrad','satname')

Thanks bwc

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.