首页 > > 详细

调试R语言、R设计辅导、调试R编程、R编程调试

.NC
library(readxl)
nc-soilmoist = read_excel("E:/R/RDATA/2006.nc.xlsx", sheet = 6)
soilmiost1= nc-soilmoist [:,2]
soilmiost2= nc-soilmoist [:,3]
soilmiost3= nc-soilmoist [:,4]
nc-soilheat= read_excel("E:/R/RDATA/2006.nc.xlsx", sheet = 7)
soil-h-f1= nc-soilheat[:,2]
soil-h-f2= nc-soilheat[:,3]
soil-h-f3= nc-soilheat[:,4]
nc-soiltemp = read_excel("E:/R/RDATA/2006.nc.xlsx", sheet = 8)
soiltemp1= nc-soiltemp[:,2]
soiltemp2= nc-soiltemp[:,3]
soiltemp3= nc-soiltemp[:,4]
nc-time= read_excel("E:/R/RDATA/2006.nc.xlsx", sheet = 11)
year0= nc-time [:,3]
month0= nc-time [:,4]
dom0= nc-time [:,5]
start_hr0= nc-time [:,6]
psurf0= nc-time [:,7]
co20= nc-time[:,8]
wind0= nc-time[:,9]
wind_ux0= nc-time[:,10]
wind_uy0= nc-time[:,11]
wind_uz0= nc-time[:,12]
Rn0= nc-time[:,13]
Rn-short0= nc-time[:,14]
Rn-long0= nc-time[:,15]
Solar_rad0= nc-time[:,16]
Fc_wpl 0= nc-time[:,17]
LE_wpl 0= nc-time[:,18]
HS0= nc-time[:,19]
Rain0= nc-time[:,20]
Tcanopy0= nc-time[:,21]
Qcannopy0= nc-time[:,22]
PAR0= nc-time[:,23]

lon <- ncdim_def(“lon”, “degreesE”, vals =116.252 )
lat<- ncdim_def( “lan”, “degreesN”, vals =39.537 )
depth <- ncdim_def( “depth”, “cm”, vals =1, 2, 3 )
time<- ncdim_def(“time”, “hours since 2009-1-1 00:00”, calendar=365_day )

lon<- ncvar_def(“lon”, “ degreesE”, dim=’ lon’, longname=’longitude’)
lat<- ncvar_def(“lat”, “ degreesN”, dim=’ lat’, longname=’latitude’)
year<- ncvar_def(“year”, dim=’ time’, longname=’year’)
month<- ncvar_def(“month”, dim=’ time’, longname=’month’)
dom<- ncvar_def(“dom”, dim=’ time’, longname=’day-of-month’)
start-hr <- ncvar_def(“start -hr”, dim=’ time’, longname=’hour’)
Psurf<-ncvar_def(“psurf”, units=’hpa’,dim=’ time’, longname=’Surface pressure’)
CO2 <-ncvar_def(“CO2”, units=’ppm’, dim=’ time’, longname=’Surface [CO2]’)
Wind<-ncvar_def(“wind”, units=’m/s’, dim=’ time’, longname=’Surface wind speed’)
Wind_ux<-ncvar_def(“wind_ux”, units=’m/s’, dim=’ time’, longname=’Surface wind speed in x direction’)
Wind_uy<-ncvar_def(“wind_uy”, units=’m/s’, dim=’ time’, longname=’Surface wind speed in y direction’)
Wind_uz<-ncvar_def(“wind_uz”, units=’m/s’, dim=’ time’, longname=’Surface wind speed in z direction’)
Rn<- ncvar_def(“rn”, units=’ W/m2’, dim=’ time’, longname=‘Net radiation’)
Rn-short<- ncvar_def(“rn-short”, units=’ W/m2’, dim=’ time’, longname=‘Short wave net radiation’)
Rn-long<- ncvar_def(“rn-long”, units=’ W/m2’, dim=’ time ’, longname=‘Long wave net radiation’)
Solar_rad<- ncvar_def(“Solar radaition”, units=’W/m2’, dim=’ time ’, longname=‘Solar radaition’)
Fc_wpl<- ncvar_def(“Carbon dioxide flux”, units=’mg/m2/s’, dim=’ time ’, longname=‘Carbon dioxide flux’)
LE_wpl<- ncvar_def(“LE_wpl”, units=’ W/m2’, dim=’ time ’, longname=‘Latent heat flux’)
HS<- ncvar_def(“HS”, units=’ W/m2’, dim=’ time ’, longname=‘Sensible heat flux’)
Rain<- ncvar_def(“Rain”, units=’ W/m2’, dim=’ time ’, longname=‘Rain’)
Tcanopy<- ncvar_def(“Tcanopy”, units=’degreesC’, dim=’ time’, longname=‘Air temperature’)
Qcannopy<- ncvar_def(“Qcannopy”, units=’percentage’, dim=’ time’’, longname=‘Relative humidity’)
PAR<- cvar_def(“PAR”, units=’percentage’, dim=’ time’’, longname=‘Relative humidity’)
Soilmoist<- ncvar_def(name=’”Soilmoist-depth1”, “Soilmoist-depth2”, “Soilmoist-depth3”’, units=’ percentage’, dim=’
time’ ‘depth’, longname=‘Rain’)
Soilheat<- ncvar_def(name= “Soilheat-depth1” “Soilheat-depth2” “Soilheat-depth3”, units=’ W/m2’, dim=’ time’ ‘depth ’,
longname=‘Soil heat flux’)
Soiltemp<- ncvar_def(name= “Soilheat-depth1” “Soilheat-depth2”“Soiltemp-depth3”, units=’degreesC’, dim=’ time’
‘depth’, longname=‘Soil temperature’)

#,
2006datanc<- nc_create(filename = '2006data.nc', vars=lon, lat, year, month, dom, start-hr, Psurf, CO2,
Wind, Wind_ux, Wind_uy, Wind_uz, Rn, Rn-short, Rn-long, Solar_rad, Fc_wpl, LE_wpl HS, Rain, Soilmoist, Soilheat,
Soiltemp, Airtemp, RH ,force_v4=TURE)


#
year<-ncvar_put(nc=2006datanc, varid = year, vals =year0)
month<-ncvar_put(nc=2006datanc, varid = month, vals =month0)
dom<-ncvar_put(nc=2006datanc, varid = dom, vals =dom0)
start-hr <-ncvar_put(nc=2006datanc, varid = start-hr, vals = start-hr 0)
Wind <-ncvar_put(nc=2006datanc, varid = Wind, vals = Wind 0)
Wind_ux <-ncvar_put(nc=2006datanc, varid = Wind_ux, vals = Wind_ux 0)
Wind_uy <-ncvar_put(nc=2006datanc, varid = Wind_uy vals = Wind_uy 0)
Wind_uz <-ncvar_put(nc=2006datanc, varid = Wind_uz, vals = Wind_uz 0)
Rn <-ncvar_put(nc=2006datanc, varid = Rn, vals = Rn 0)
Rn-short <-ncvar_put(nc=2006datanc, varid = Rn-short, vals = Rn-short 0)
Rn-long <-ncvar_put(nc=2006datanc, varid = Rn-long, vals = Rn-long 0)
Solar_rad <-ncvar_put(nc=2006datanc, varid = Solar_rad, vals = Solar_rad 0)
Fc_wpl <-ncvar_put(nc=2006datanc, varid = Fc_wpl, vals = Fc_wpl 0)
LE_wpl <-ncvar_put(nc=2006datanc, varid = LE_wpl, vals = LE_wpl 0)
HS <-ncvar_put(nc=2006datanc, varid = HS, vals = HS 0)
Rain <-ncvar_put(nc=2006datanc, varid = Rain, vals = Rain 0)
Tcanopy <-ncvar_put(nc=2006datanc, varid = Tcanopy, vals = Tcanopy 0)
Qcannopy <-ncvar_put(nc=2006datanc, varid = Qcannopy, vals = Qcannopy 0)
PAR <-ncvar_put(nc=2006datanc, varid = PAR, vals = PAR0)
Soilmoist-depth1 <-ncvar_put(nc=2006datanc, varid = PAR, vals = soilmiost1)
Soilmoist-depth2<-ncvar_put(nc=2006datanc, varid = PAR, vals = soilmiost2)
Soilmoist-depth3<-ncvar_put(nc=2006datanc, varid = PAR, vals = soilmiost3)
Soilheat-depth1 <-ncvar_put(nc=2006datanc, varid = PAR, vals = soil-h-f1)
Soilheat-depth2<-ncvar_put(nc=2006datanc, varid = PAR, vals = soil-h-f2)
Soilheat-depth3<-ncvar_put(nc=2006datanc, varid = PAR, vals = soil-h-f3)
Soiltemp-depth1<-ncvar_put(nc=2006datanc, varid = PAR, vals = soiltemp1)
Soiltemp-depth2<-ncvar_put(nc=2006datanc, varid = PAR, vals = soiltemp2)
Soiltemp-depth3<-ncvar_put(nc=2006datanc, varid = PAR, vals = soiltemp3)
nc_close(2006datanc)

#,
nc <- nc_open(‘ 2006datanc.nc')
print(nc)
nc_close(nc)





 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!