Beispiel #1
0
    sciopen_netcdf = sciget_int_dimension = sciget_float = None
    _HAS_SCIENTIFIC_PYTHON = False

try:
    from pynetcdf.NetCDF import NetCDFFile as pynNetCDFFile
    pynopen_netcdf = lambda name, mode: pynNetCDFFile(name, mode)
    pynget_int_dimension = lambda obj, name: obj.dimensions[name]
    pynget_float = lambda obj, name: obj.variables[name].getValue()
    _HAS_PYNETCDF = True
except ImportError:
    pynopen_netcdf = pynget_int_dimension = pynget_float = None
    _HAS_PYNETCDF = False

try:
    from scipy.io.netcdf import netcdf_file as spNetCDFFile
    spopen_netcdf = lambda name, mode: spNetCDFFile(name, mode)
    spget_int_dimension = lambda obj, name: obj.dimensions[name]
    spget_float = lambda obj, name: obj.variables[name].getValue()
    _HAS_SCIPY_NETCDF = True
except ImportError:
    spopen_netcdf = spget_int_dimension = spget_float = None
    _HAS_SCIPY_NETCDF = False

HAS_NETCDF = (_HAS_NC4 or _HAS_SCIENTIFIC_PYTHON or 
              _HAS_PYNETCDF or _HAS_SCIPY_NETCDF)

def _coerce_to_string(string, encoding='ascii'):
    """
    Decodes input to a string with the specified encoding if it is a bytes
    object. Otherwise, it just returns the input string.
    """
Beispiel #2
0
    sciopen_netcdf = sciget_int_dimension = sciget_float = None
    _HAS_SCIENTIFIC_PYTHON = False

try:
    from pynetcdf.NetCDF import NetCDFFile as pynNetCDFFile
    pynopen_netcdf = lambda name, mode: pynNetCDFFile(name, mode)
    pynget_int_dimension = lambda obj, name: obj.dimensions[name]
    pynget_float = lambda obj, name: obj.variables[name].getValue()
    _HAS_PYNETCDF = True
except ImportError:
    pynopen_netcdf = pynget_int_dimension = pynget_float = None
    _HAS_PYNETCDF = False

try:
    from scipy.io.netcdf import netcdf_file as spNetCDFFile
    spopen_netcdf = lambda name, mode: spNetCDFFile(name, mode)
    spget_int_dimension = lambda obj, name: obj.dimensions[name]
    spget_float = lambda obj, name: obj.variables[name].getValue()
    _HAS_SCIPY_NETCDF = True
except ImportError:
    spopen_netcdf = spget_int_dimension = spget_float = None
    _HAS_SCIPY_NETCDF = False

HAS_NETCDF = (_HAS_NC4 or _HAS_SCIENTIFIC_PYTHON or 
              _HAS_PYNETCDF or _HAS_SCIPY_NETCDF)

def _coerce_to_string(string, encoding='ascii'):
    """
    Decodes input to a string with the specified encoding if it is a bytes
    object. Otherwise, it just returns the input string.
    """
Beispiel #3
0
    _HAS_NC4 = False

try:
    from Scientific.IO.NetCDF import NetCDFFile as sciNetCDFFile
    sciopen_netcdf = lambda name, mode: sciNetCDFFile(name, mode)
    sciget_int_dimension = lambda obj, name: obj.dimensions[name]
    sciget_float = lambda obj, name: obj.variables[name].getValue()
    _HAS_SCIENTIFIC_PYTHON = True
except ImportError:
    sciopen_netcdf = sciget_int_dimension = sciget_float = None
    _HAS_SCIENTIFIC_PYTHON = False

try:
    from scipy.io.netcdf import netcdf_file as spNetCDFFile
    spopen_netcdf = lambda name, mode: \
            spNetCDFFile(name, mode, mmap=False, version=2)
    spget_int_dimension = lambda obj, name: obj.dimensions[name]
    spget_float = lambda obj, name: obj.variables[name].getValue()
    _HAS_SCIPY_NETCDF = True
except ImportError:
    spopen_netcdf = spget_int_dimension = spget_float = None
    _HAS_SCIPY_NETCDF = False

HAS_NETCDF = (_HAS_NC4 or _HAS_SCIENTIFIC_PYTHON or _HAS_SCIPY_NETCDF)

def _coerce_to_string(string, encoding='ascii'):
    """
    Decodes input to a string with the specified encoding if it is a bytes
    object. Otherwise, it just returns the input string.
    """
    try: