У меня есть следующий код:
import netCDF4
from netCDF4 import Dataset
import numpy as np
import sys
import time
import calendar
import datetime as dt
import pandas as pd
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
def print_var_recursively(grp):
for varname in list(grp.variables.keys()):
var=grp.variables[varname]
dims=var.dimensions
if not ('scanline' in dims and 'ground_pixel' in dims and 'time' in dims):
continue
if 'corner' in dims or varname=='time_utc':
continue
print(dims['time'])
print(varname,dims)
print(var)
def ncdump(nc_fid, verb=True):
'''
ncdump outputs dimensions, variables and their attribute information.
The information is similar to that of NCAR's ncdump utility.
ncdump requires a valid instance of Dataset.
Parameters
----------
nc_fid : netCDF4.Dataset
A netCDF4 dateset object
verb : Boolean
whether or not nc_attrs, nc_dims, and nc_vars are printed
Returns
-------
nc_attrs : list
A Python list of the NetCDF file global attributes
nc_dims : list
A Python list of the NetCDF file dimensions
nc_vars : list
A Python list of the NetCDF file variables
'''
def print_ncattr(key):
"""
Prints the NetCDF file attributes for a given key
Parameters
----------
key : unicode
a valid netCDF4.Dataset.variables key
"""
#=====================================================
try:
fileList=open('fileList.txt','r')
except:
print('Did not find a text file containing file names (perhaps name does not mathc)')
sys.exit()
else:
for FILE_NAME in fileList:
FILE_NAME=FILE_NAME.strip()
user_input=input('\nWould you like to process\n'+FILE_NAME+'\n\n(Y/N)')
if(user_input=='N' or user_input=='n'):
print('Skipping...')
continue
else:
nc_file=Dataset(FILE_NAME,'r')
nc_attrs,nc_dims,nc_vars=ncdump(nc_file)
print_var_recursively(nc_file.groups['PRODUCT'])
nc_file.close()
#=====================================================
если я запускаю код, я получаю сообщение:
'TypeError: cannot unpack non-iterable NoneType object'
Может кто-нибудь просветить меня?