Skip to content

FieldList.select_by_ncvars throws an error #76

@cjroberts

Description

@cjroberts

I get the following error (using cf-python 3.4.0) when trying to use FieldList.select_by_ncvars to select a field by netCDF variable name:

In [1]: import cf                                                                                                                                                                                 
 
In [2]: fl = cf.read('ESACCI-OC-L3S-IOP-MERGED-5D_DAILY_4km_GEO_PML_OCx_QAA-20010101-fv4.2.nc')                                                                                                   
 
In [3]: fl.select_by_ncvar('atot_412')                                                                                                                                                            
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-3-0069b9e04a8b> in <module>
----> 1 fl.select_by_ncvar('atot_412')
 
~/miniconda3/envs/cci/lib/python3.7/site-packages/cf/fieldlist.py in select_by_ncvar(self, *rank)
   1044 
   1045         '''
-> 1046         return type(self)(f for f in self if f.match_by_ncvar(*ncvars))
   1047 
   1048     def select_by_property(self, *mode, **properties):
 
~/miniconda3/envs/cci/lib/python3.7/site-packages/cf/fieldlist.py in __init__(self, fields)
     54                 self.append(fields)
     55             else:
---> 56                 self.extend(fields)
     57 
     58     def __call__(self, *identities):
 
~/miniconda3/envs/cci/lib/python3.7/site-packages/cf/fieldlist.py in <genexpr>(.0)
   1044 
   1045         '''
-> 1046         return type(self)(f for f in self if f.match_by_ncvar(*ncvars))
   1047 
   1048     def select_by_property(self, *mode, **properties):
 
NameError: name 'ncvars' is not defined

I tried this too:

In [6]: fl.select_by_ncvar(ncvars='atot_412')                                                                                                                                                     
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-37ac3193cda2> in <module>
----> 1 fl.select_by_ncvar(ncvars='atot_412')
 
TypeError: select_by_ncvar() got an unexpected keyword argument 'ncvars'

Please would you be able to help?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions