This page lists examples of SPECCHIO API uses for common use cases.

Use Case

Scheduled Data Loading

Scenario A spectroradiometer system mounted on a tower records data during daylight hours.
The data are sent from the spectroradiometer control system to a file server at regular intervals.
Ideally, as data are sent to the file server they are put into folders per day, months and year to keep them tidy.
The spectral files generated by the spectroradiometer are supported by the SPECCHIO file readers.

Goal SPECCHIO loads the new data automatically into the SPECCHIO database.
  • The SPECCHIO application already contains methods to load campaign data from a specified path
  • New files are loaded automatically while ignoring the ones loaded previously (Delta-Loading Capability)

  • Required code:
  • A Matlab code that uses the SPECCHIO API to call the loading method for a campaign
  • A shell script calling Matlab
  • Crontab scheduling of shell script to be called periodically using cron (Unix systems like Linux or macOS)
Source Code and Scripts
  • Matlab script for the actual data loading:

  • AutoloadingExample.m

  • Shell script (autoloading_example.sh) to open Matlab from the command line, execute the auto loading and exit again:

  • #!/bin/sh
    cd /SPECCHIO_Project/MatlabIntegration_V3
    /Applications/MATLAB_R2015b.app/bin/matlab -nodisplay -nosplash -r "AutoloadingExample;exit;"

  • Defining a cron job:

  • Enter the job in your crontab using the crontab function: env EDITOR=nano crontab -e

    To carry out a loading every minute add: */1 * * * * ~/autoloading_example.sh