Ibrahim Jarif created CLIMATE-788:
-------------------------------------

             Summary: load_file.py : Raises ValueError even when variable is 
present
                 Key: CLIMATE-788
                 URL: https://issues.apache.org/jira/browse/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.

{code}
dataset1 = 
local.load_file('nc/AFRICA_KNMI-RACMO2.2b_CTL_ERAINT_MM_50km_1989-2008_tasmax.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/local.py", line 243, in 
load_file
  File "build/bdist.linux-x86_64/egg/ocw/data_source/local.py", line 114, in 
_get_netcdf_variable_name
ValueError: Unable to locate a single matching variable name from the supplied 
list of valid variable names. 
{code}

This is the file I'm using to create *Dataset*
!http://i.imgur.com/UvAISLS.png!

In the function *_get_netcdf_variable_name* 
{code}
# 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]
{code}

*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
(v6.3.4#6332)

Reply via email to