climate-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ibrahim Jarif (JIRA)" <>
Subject [jira] [Created] (CLIMATE-788) : Raises ValueError even when variable is present
Date Mon, 02 May 2016 12:00:16 GMT
Ibrahim Jarif created CLIMATE-788:

             Summary: : Raises ValueError even when variable is present
                 Key: CLIMATE-788
             Project: Apache Open Climate Workbench
          Issue Type: Bug
          Components: data sources
            Reporter: Ibrahim Jarif
            Assignee: Ibrahim Jarif
            Priority: Critical

The *_get_netcdf_variable_name()* function returns *ValueError* even when variable is present
in dataset.

dataset1 = local.load_file('nc/',variable_name='rlon')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/ocw/data_source/", line 243, in load_file
  File "build/bdist.linux-x86_64/egg/ocw/data_source/", line 114, in _get_netcdf_variable_name
ValueError: Unable to locate a single matching variable name from the supplied list of valid
variable names. 

This is the file I'm using to create *Dataset*

In the function *_get_netcdf_variable_name* 
# Check for valid variable names in netCDF variable names
    variables = netcdf.variables.keys()
    vars_lower = [var.encode().lower() for var in variables]

    intersect = set(valid_var_names).intersection(vars_lower)

    if len(intersect) == 1:
        index = vars_lower.index(intersect.pop())
        return variables[index]

*intersect = 2* when {code}valid_var_names=['x', 'rlon', 'rlons', 'lon', 'lons', 'longitude',
'longitudes']{code} and {code}vars_lower=['time', 'rotated_pole', 'rlon', 'lon', 'rlat', 'lat',
'height', 'time_bnds', 'tasmax']{code}

This condition^^ causes the exception to occur.

This message was sent by Atlassian JIRA

View raw message