Plotting a time-temperature graph using netCDF file and txt in R

Hey everyone,
I am new to RStudio and I want to plot a time-temperature graph. I want to compare the temperatue of a .txt file and a .nc file in one plot. My problem is that the length differs. I have 288 measurement points, but the temperature of the netcdf has a length of 14450. Why do I have 14450 of temperature, but only 288 time stamps?

> ncin=nc_open("augs_test13_av_3d_N02.koe_reinhardt.nc")

> print(ncin)
> t <- ncvar_get(ncin, "time",start = 144 ,count = 288) 
> origin_time=ncatt_get( ncin, varid=0, attname="origin_time",
                       verbose=FALSE )$value 
> origin_time_short=substr(origin_time,1,19) 
> torigin=as.POSIXct(origin_time_short,format="%Y-%m-%d %H:%M:%S",tz="GMT")
> tposix=as.POSIXct(t, format="%Y-%m-%d %H:%M:%S",
                  origin=torigin,tz="GMT")

> head(tposix)
[1] "2019-06-26 00:00:00 GMT" "2019-06-26 00:05:00 GMT" "2019-06-26 00:10:00 GMT"
[4] "2019-06-26 00:15:00 GMT" "2019-06-26 00:20:00 GMT" "2019-06-26 00:25:00 GMT"

###Temp 
> ncin$var$theta$dim[[4]]$name
 [1] "time"
> tempK <- ncvar_get(ncin , varid="theta", start = c(1, 1, 1, 144), count = c(1,1,1,288))
> temp_withoutNAs <- temp[,,4:5,]

The structure of temp_withoutNAs is: num [1:5, 1:5, 1:2, 1:288] 21.9 21.9 21.9 22 22.1 ...

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.