Project

General

Profile

how to import data from numpy arrays (without input files)

Added by Juanma Sancho almost 12 years ago

It is clear how to obtain the CDO output as a numpy array avoiding output files, like in the following example:

data = cdo.timmean(input = ifile,options = '-f nc',returnCdf=True)
v1 = data.variables['var1'][:]

I am also interested in importing data directly from numpy arrays whithout using any input file (ifile). This would permit to use cdo operators in Python scripts without requiring any input or output files, just numpy arrays.
Is it possible?

Thanks in advance,


Replies (1)

RE: how to import data from numpy arrays (without input files) - Added by Ralf Mueller almost 12 years ago

Juanma Sancho wrote:

It is clear how to obtain the CDO output as a numpy array avoiding output files, like in the following example:

data = cdo.timmean(input = ifile,options = '-f nc',returnCdf=True)
v1 = data.variables['var1'][:]

I am also interested in importing data directly from numpy arrays without using any input file (ifile). This would permit to use cdo operators in Python scripts without requiring any input or output files, just numpy arrays.
Is it possible?

No, CDO needs input files to operate on, numpy can only be returned by the python module cdo.py. But you can use the full list of NumPy Methods or PyGSL to work on the numpy arrays.

    (1-1/1)