CodeRunner Help

CodeRunner Help

CodeRunner is an online utility for sharing, writing and running code. This tool

  • simplifies data analysis by eliminating the need to download data and process it locally
  • encourages contributions of post-processing routines with its ability to make code public
  • enables data processing and code development to be conducted from anywhere with an Internet connection

Currently, MathWorks MATLAB is supported.

Getting Started

Understanding the CodeRunner WorkSpace

Creating a Simple Package

  1. Right-click on MATLAB and select 'Create Package.'
  2. Give your package a name (e.g., MyFirstPackage).
  3. Expand your package by clicking the '+.' Right click on 'codes' and select 'Create File.'
  4. Enter a name for this file (e.g., myfirstfile.m). An empty file will automatically be opened in the code development section at right.
  5. Enter a simple Matlab statement (e.g., a=1:10)
  6. Save your script by selecting the Save icon.
  7. Run your script by selecting the Run icon.
  8. Wait to see the output of your script appear below.

To learn how to begin accessing NEPTUNE Canada data, see Using Public Packages.

Using Public Packages

Public packages provide a continually expanding resource for getting started on your data analysis and taking advantage of pre-existing code. To access these scripts, choose the 'Public' tab at upper left in the CodeRunner environment. There are two main subdivisions: NEPTUNE CANADA and COMMUNITY.

  • NEPTUNE Canada packages are meant to provide templates for accessing the data and metadata from our database, and other basic functionality.The ScalarDataTemplates package is a recommended starting point.
  • COMMUNITY are contributions from the user community. (If you would like to share code that you have developed, see the Contributing a Package section below.)

Package details are shown by placing your cursor over a package in the tree menu. All public packages are versioned. While older versions remain available, it is recommended that you use the most recent package for best results.

To use a package, right click and choose one of:

  • Save As New Package: This will import a copy of the package into your Private workspace. At that point, you can peruse the contents and make any changes that you wish. The changes will not affect the public version.
  • Import To ...> Existing Package: This will import a copy of the package as a subfolder to a package that already exists in your Private workspace.

Contributing a Package 

To contribute a package that you have developed to the wider community:

  1. Select your package.
  2. Right-click and select 'Publish'.
  3. Complete the form in the panel that appears. Try to make the name and description informative as this will be the main means for other users to browse public packages. 
  4. Click Submit
  5. Check that your package now appears under the Public tab Community section.

Please ensure that your code is well-documented and functioning before you contribute your code. Future changes will not be automatically be made public, but you can publish again with the same name and a new version number.

Creating Results - Useful tips

Plots: When saving plots with the MATLAB print command, -dpng and -djpeg are recommended inputs if opening them (double-click on the file or right-click and select 'Open') within the web browser is desirable. For alternative image formats, you can right-click on the result, select 'Download' and open in your desktop application of choice. The MATLAB saveas function can be used to create the MATLAB figure format, which can be opened in your desktop MATLAB software.

Subdirectories: Subdirectories can be created within your MATLAB code. A simple example is:

x=1:100;
y=x.^3+5*x.^2-40;

datname='subfoldertest/simplefn.mat';
mkdir('subfoldertest');
save(datname,'x','y');

plotname='subfoldertest/simplefn';
print('-dpng','-r71',plotname)

Access: Files in the results folder can be accessed from within your code. For example (assuming the above code has already been run):

load('../results/subfoldertest/simplefn.mat');
x(50:55)

MATLAB

Here are details of the MathWorks MATLAB software that is currently implemented for CodeRunner.

Release: R2011a
Toolboxes: Database, Statistics, Signal Processing, Image Processing, Wavelet

Matlab is running in a LINUX environment, meaning that certain Windows-only commands are not available (e.g., memory function).

NEPTUNE Toolbox functions

Functions in the NEPTUNE Toolbox are meant to facilitate accessing information from the NEPTUNE Canada system while working in the Code Runner MATLAB environment.

getADfiles

  • adfiles=getADfiles(deviceid) returns cell of AD filename strings for deviceid within last 24 hours.
  • adfiles=getADfiles(deviceid,startdate,enddate) returns cell of AD filename strings for deviceid between startdate (datenum) and enddate (datenum).

AD files refer to the archived log files containing raw data from instruments.

getData

  • neptune,meta,nd=getData(neptune,startdate,enddate,deviceid) returns all data for neptune(i).sensorids of deviceid between startdate and enddate ('dd-mmm-yyyy HH:MM:SS PM').
  • neptune,meta,nd=getData(neptune,startdate,enddate,deviceID,subsampletype,subsampleperiod) returns subsampled data for neptune(i).sensorids of deviceid between startdate and enddate ('dd-mmm-yyyy HH:MM:SS PM'). Options for subsampletype: 1=Averaged Data, 2=Decimated Data, 3=Min/Max Data. subsampleperiod options (seconds): 60 for minute, 3600 for hourly, 86400 for daily, 604800 for weekly

This function returns neptune (a structure array containing the data for each sensor), meta (a structure containing basic metadata), and nd (a boolean which will be 1 if there is time-series data, and 0 otherwise).

getDeviceSensorIDs

  • sensorid=getDeviceSensorIDs(deviceid) returns sensorids, for which data is available, for a given deviceid

getSamplePeriod

  • samplingPeriod=getSamplePeriod(deviceid) returns sampling period, in seconds, for the current date and time
  • samplingPeriod=getSamplePeriod(deviceid,startdate) returns sampling period, in seconds, for a given startdate (datenum)

getSite

  • lat,lon,depth,deviceHeading,sitename,locationname,siteid,locationid=getSite(deviceid) returns current site details for deviceid
  • lat,lon,depth,deviceHeading,sitename,locationname,siteid,locationid=getSite(deviceid,startdate) returns site details for deviceid at startdate (datenum)

Site details include lat (latitude, degrees North), lon (longitude, degrees East), depth (deployment depth, m), deviceHeading (degrees), sitename, location name, siteid, locationid. All directional values are with respect to true North.

Coming Soon downloadHydrophoneWAVFiles

  • fnames=downloadHydrophoneWAVFiles returns files available for deviceid 11207 from the last 15 minutes
  • fnames= downloadHydrophoneWAVFiles(deviceid) returns files available for provided deviceid from the last 15 minutes
  • fnames= downloadHydrophoneWAVFiles(deviceid,startdate) returns files available for provided deviceid from last 15 minutes since startdate (datenum)
  • fnames= downloadHydrophoneWAVFiles(deviceid,startdate,enddate) returns files available for provided deviceid from startdate (datenum) to enddate (datenum) (up to 1 hour of data).

Other Toolboxes

A number of popular toolboxes from the wider community are being integrated into the available functions on the classpath. If there's a toolbox that you'd recommend for inclusion, please let us know.

T_Tide Harmonic Analysis Toolbox

  • TIP: Call the t_readme function to display a synopsis of this toolbox in the lower code output panel
  • Includes minor modifications to output generated plots as a PNG, so that they will be available in the CodeRunner 'results' folder. Plots are named after the function that generated them, appended by the timestamp at time of generation.

Gibbs SeaWater (GSW) Oceanographic Toolbox of TEOS-10

Read MiniSEED M-File

  • Refer to the license for usage conditions.

Waveform Suite

  • Refer to the license for usage conditions.
  • Visit http://www.giseis.alaska.edu/Seis/EQ/tools/GISMO/ for additional background information.
  • Includes minor modifications to output generated plots in specgram,specgram2 and plot functions as a PNG, so that they will be available in the CodeRunner 'results' folder. Plots are named after the function that generated them, appended by the timestamp at time of generation.
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.