开发者

Showing error in fname and working directory even after importing os in jupyter notebook, Python 3.9

I am cu开发者_如何学Crrently working with TROPOMI data. To explore the intricate parts (metadata, QA etc) of data. Run this code for import libraries in Jupyter notebook in Windows.

#Block 1: Import libraries
#Library to perform array operations
import numpy as np
#Library for accessing files in the directory
import os
#Library to read in netCDF files
from netCDF4 import Dataset
#Block 2: Open a TROPOMI netCDF4 data file

#Select TROPOMI product ('CO' or 'NO2')
data_product = 'CO'

#Enter file name
file_path = os.getcwd()
if data_product == 'CO':
    file_name = 'S5P_OFFL_L2__CO_____20181101T072905_20181101T091035_05447_01_010200_20181107T065627.nc'
if data_product == 'NO2':
    file_name = 'S5P_OFFL_L2__NO2____20181101T072905_20181101T091035_05447_01_010200_20181107T092435.nc'
    fname = [file_path + file_name]

#Set the file name to read
file_id = Dataset(fname)

Output:

NameError                                 Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_16108\271847607.py in <module>
     13 
     14 #Set the file name to read
---> 15 file_id = Dataset(fname)

NameError: name 'fname' is not defined

Even after importing libraries, why it does not read the working directory?

I saved these S5P files in the Current working directory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜