I'm working with ERA-Interim data from ECMWF, where the variables I need are spread over multiple files. How can I add a variable from one file to an existing file so that, in the end, I have one file with all the variables I need?
I've tried the append(), concatenate() and merge functions so far and nothing has worked.
p_data = anapath1+'/'+yyyy+'/'+mm+'/'+'P'+date
b_data = anapath1+'/'+yyyy+'/'+mm+'/'+'B'+date
g_data = anapath1+'/'+yyyy+'/'+mm+'/'+'G'+date
#Open/Read netCDF files
inpcst = xr.open_dataset(cstfile)
inp1 = xr.open_dataset(p_data)
inp2 = xr.open_dataset(b_data)
inp3 = xr.open_dataset(g_data)
These are some of the data files that I'm using. I loaded them into python.
cdo merge inp1 inp2 inp
I tried this method to combine two data files but get the following error:
File "<ipython-input-12-667af80d1ae4>", line 49
cdo merge inp1 inp2 inp
^
SyntaxError: invalid syntax
I've seen this code exactly like that on here before, so I don't know why there is a syntax error. It's very easy in Matlab since you can just do this:
inp = inp1
inp.a = inp2.a
inp.b = inp3.b
where a and b are the variables from inp2 and inp3 that I want to add to inp
I simply want to copy certain variables from one file to another