Skip to content
Gordon Maclean edited this page Oct 7, 2020 · 23 revisions

Some R code for ISS, initially a couple of functions to read and plot spectra. You can use a built version of R-iss on EOL servers, or clone and build your own.

To use a built version on EOL servers

The functions that read the NetCDF files use the eolts package from R-eol, which is installed on EOL servers barolo and tikal.

Set the RCODE environment variable, which is used below to load the compiled functions into an R session.

bash:

export RCODE=~maclean/git/R-iss/R/.RData

csh:

setenv RCODE ~maclean/git/R-iss/R/.RData

To clone and build R-iss

R-iss can be run on Linux or Macs, assuming R and the eolts R package have been installed. See Installing-and-Using-the-R-EOL-packages.

Once that is done, do:

cd my_git_place
git clone https://github.com/ncareol/R-iss.git

Build it

cd R-iss/R
make

Set RCODE environment variable

bash:

export RCODE=$PWD/.RData

csh:

setenv RCODE $PWD/.RData

set NETCDF_DIR environment variable

This is the directory containing the spectral NetCDF files, which are read by the plotspec function.

cd my_netcdf_dir

bash:

export NETCDF_DIR=$PWD

csh:

setenv NETCDF_DIR $PWD

Spectra and Fuzzy plots with R

R
attach(Sys.getenv("RCODE"))     # attach the built code

options(time.zone="UTC")
# choose a 1 minute time period
dpar(start=utime("2019 10 1 23:47"),lenmin=1)

# generate all spectra plots on interactive window
# The default input spcfile is "%d-%b-%Y_%H-%M-%S.spc.nc",
# and the default input moments is "moments_%Y%m%d.nc"
plotspec()          # default parameters
plotspec(ndev=2)    # use two windows for plots
plotspec(dB=TRUE)   # plot spectra in dB, 10*log10(x)
plotspec(xzoom=2, dB=TRUE)   # zoom in by factor of 2 in velocity

# longer time period, more spectra
dpar(start=utime("2019 10 1 23:47"),lenmin=5)
plotspec(layout=c(3,2))    # 3 columns of plots, 2 rows on a page
plotspec(layout=c(3,2), ndev=3)  # same layout, use at most 3 windows

# create plots in a PDF
pdf(file="/tmp/mapr_spec.pdf",width=8,height=10.5)
plotspec()
dev.off()           # close pdf, it can now be viewed

# to see the arguments to plotspec
args(plotspec)

# plot one of the fuzzy variables, choose from "clutter", "doppler", "rfi":
plotfuzzy(vars="clutter")

# quit (everything in R is a function)
q()
# then generally enter "y" to save history and objects