Krishnaap
Krishnaap

Reputation: 302

How to import a particular parameter from multiple nc files into xarray in python

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).

Upvotes: 0

Views: 675

Answers (1)

Krishnaap
Krishnaap

Reputation: 302

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

Upvotes: 1

Related Questions