Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
kvalobs:kvoss:system:qc2:8hdk376snf09zj37dk82s92:ncdf [2009-06-20 22:40:08]
paule
kvalobs:kvoss:system:qc2:8hdk376snf09zj37dk82s92:ncdf [2022-05-31 09:29:32] (current)
Line 15: Line 15:
   $ R CMD INSTALL ncdf   $ R CMD INSTALL ncdf
   $ history   $ history
 +  ...
 +  ...
 +  # there are perhaps even easier ways to do this:
 +
 +  $ install.packages("gplots", dependencies = TRUE)
 +
 +  # no source was linked ... but the mirror choose automatically opens
 +  # and one just selects a site and the install happens!
 +  ...
 +  $ 
 </code> </code>
  
Line 21: Line 31:
 <code> <code>
   $ R   $ R
-  library(ncdf) +   Method='unspecified' 
-  > nd = open.ncdf("interpolations.nc"+   Shortname='outfile' 
-  > x=get.var.ncdf(nd,"Original"+   library(ncdf) 
-  > y=get.var.ncdf(nd,"Interpolations"+   nd = open.ncdf("interpolations.nc"
-  > v <- array(x, length(x)) +   x=get.var.ncdf(nd,"Original"
-  > w <- array(y, length(y)) +   y=get.var.ncdf(nd,"Interpolations"
-  > xx=x[!is.na(x) & x>=0 & x < 100] +   x[x==-1]=0 
-  > yy=y[!is.na(x) & x>=0 & x < 100] +   v <- array(x, length(x)) 
-  > yyy=yy[!is.na(xx) & xx>=0 & xx < 100] +   w <- array(y, length(y)) 
-  > plot(xxx,yyy) +   xx=x[!is.na(x) & x>=0 & x < 100] 
-  > cor(xxx,yyy)+   yy=y[!is.na(x) & x>=0 & x < 100] 
 +   yyy=yy[!is.na(yy) & yy>=0 & yy < 100] 
 +   xxx=xx[!is.na(yy) & yy>=0 & yy < 100] 
 +   jpeg(filename=paste(Shortname,'jpg',sep='.')) 
 +   plot(xxx,yyy,pch=46,xlab='Original Value',ylab='Interpoltion',main=Method
 +   XC=cor(xxx,yyy
 +   ff <- lm(xxx ~ yyy) 
 +   ff$coefficients[1] 
 +   ff$coefficients[2] 
 +   z=ff$coefficients[1]*xxx + ff$coefficients[2] 
 +   #lines(xxx,z) 
 +   text(0,95,"Linear Regression",pos=4) 
 +   text(0,90,paste("Gradient =",format(ff$coefficients[1],digits=5)),pos=4) 
 +   text(0,85,paste("Intercept =",format(ff$coefficients[2],digits=5)),pos=4) 
 +   text(0,75,paste("Correlation coefficient =",format(XC,digits=5)),pos=4) 
 +   dev.off()
  
-  > ff <- lm(yyy ~ xxx) 
-  > z=ff$coefficients[1]*xxx + ff$coefficients[2] 
 </code> </code>
 +
 +Alternatively, place the code in a file and run from the command line:
 +<code>
 + $ Rscript plot_netcdf.R "Test Plot" OUTPUT
 +</code>
 +that will produce the file OUTPUT.jpg with the plot title "Test Plot".
 +  * {{kvalobs:kvoss:system:qc2:8hdk376snf09zj37dk82s92:plot_netcdf.pdf|plot_netcdf.R}}
 +
 +
  • kvalobs/kvoss/system/qc2/8hdk376snf09zj37dk82s92/ncdf.1245537608.txt.gz
  • Last modified: 2022-05-31 09:23:18
  • (external edit)