I have a very large dataset in NetCDF4 format. Normally I would just read the variables I need and pass them as attributes to my custom class so I can create new methods for post processing. Since this dataset is so large, this is not an option as it throws a memory error. So I want to extend the attributes of the NetCDF4 Dataset instead. The following code illustrates what I'm trying to do:
import netCDF4
class output(NetCDF4.Dataset):
def __init__(self, path):
super(NetCDF4.Dataset, self).__init__(path)
print(self.variables) # Prints successfully
def my_new_method(self):
print(self.variables) # AttributeError: 'output' object has no attribute 'variables'