【发布时间】:2017-11-05 16:35:40
【问题描述】:
我正在尝试使用 Python 将 netCDF 文件转换为 CSV 或文本文件。我已经阅读了this post,但我仍然缺少一步(我是 Python 新手)。它是一个包含纬度、经度、时间和降水数据的数据集。
这是我目前的代码:
import netCDF4
import pandas as pd
precip_nc_file = 'file_path'
nc = netCDF4.Dataset(precip_nc_file, mode='r')
nc.variables.keys()
lat = nc.variables['lat'][:]
lon = nc.variables['lon'][:]
time_var = nc.variables['time']
dtime = netCDF4.num2date(time_var[:],time_var.units)
precip = nc.variables['precip'][:]
我不知道如何从这里开始,但我知道这是用 pandas 创建数据框的问题。
【问题讨论】:
标签: python csv text netcdf netcdf4