我有netCDF4格式的高度计卫星数据,我需要将数据中存在的所有变量导出为csv格式。
我尝试使用pandas库。但是我的代码无法正常工作
import netCDF4
import pandas as pd
nc_file = 'F:/data/JASON 3/2016/00 11.11.16/JA3_GPR_2PTP000_166_20160213_230539_20160214_000152.nc'
nc = netCDF4.Dataset(nc_file, mode='r')
#print(nc)
nc.variables.keys()
range_ku=nc.variables['range_ku'][:]
range1=((range_ku*0.001)+1300000.0)
mean_sea_surface=nc.variables['mean_sea_surface'][:]
mean_sea_surf_scaled=(mean_sea_surface*0.0001)
mean_topography=nc.variables['mean_topography'][:]
mean_topo_scaled=(mean_topography*0.0001)
model_dry_tropo_corr=nc.variables['model_dry_tropo_corr'][:]
topo_cr=(model_dry_tropo_corr*0.0001)
rad_wet_tropo_corr=nc.variables['rad_wet_tropo_corr'][:]
wet_topo_cr=(rad_wet_tropo_corr*0.0001)
iono_corr_alt_ku=nc.variables['iono_corr_alt_ku'][:]
iono_cr=(iono_corr_alt_ku*0.0001)
sea_state_bias_ku=nc.variables['sea_state_bias_ku'][:]
sea_state_bias_cr=(sea_state_bias_ku*0.0001)
lat = nc.variables['lat'][:]
lon = nc.variables['lon'][:]
time_var = nc.variables['time']
dtime = netCDF4.num2date(time_var[:],time_var.units)
ssha= nc.variables['ssha'][:]
ssha1=(ssha*0.001)
alt = nc.variables['alt'][:]
alt1=((alt*0.001)+1300000.0)
print(dtime)
print(lat)
print(lon)
print(alt1)
print(range1)
print(mean_sea_surface)
print(mean_topography)
print(model_dry_tropo_corr)
print(rad_wet_tropo_corr)
print(iono_corr_alt_ku)
print(sea_state_bias_ku)
nc_ts = pd.Series(lat, lon,alt1,range1,mean_sea_surface,mean_topography,model_dry_tropo_corr,rad_wet_tropo_corr,iono_corr_alt_ku,sea_state_bias_ku,dtime)
nc_ts.to_csv('data.csv',index=False, header=True)
File "F:/untitled3.py", line 50, in <module>
nc_ts = pd.Series(lat, lon,alt1,range1,mean_sea_surface,mean_topography,model_dry_tropo_corr,rad_wet_tropo_corr,iono_corr_alt_ku,sea_state_bias_ku,dtime)
TypeError: __init__() takes from 1 to 7 positional arguments but 12 were given