Initial commit for toolbox library

Add a new directory to hold all the tools, and add
the abstract base class that they will have to subclass.

Also add initial unit tests.
Order images by time

Add ordering to the Image api so we can order by
date, returning a timeseries.
Add intial brdf routines

Add first stages of BRDF tool, based on the
ToolBase class. Methods mMostly taken from
Dan's dimitripy code.

Also add a tool for performing database queries
and use that to return database entries.
(though in final product the web interface should
do this instead)
Add InstrumentWavelength resource

Add InstrumentWavelengthResource to the api, and
add a corresponding url so we can query the
database for all the wavelengths for a given sensor.
Intermediate work on BRDF tool

Refactor run method so it just takes a json format
object as returned from database query.

Add a main() method to test the tool, while we don't
have the web interface ready.

BRDF tool now extracts reflectance arrays from
the returned list of files, and plots a timeseries
with one line per band.

Add new method to libquerydb to perform a query for
the instrument wavelengths, given an instrument to
search for. We use the returned wavelengths to
label the BRDF plot.

libbrdfroujean now
Add time binning

Move the plotting stuff to a new method, and bin
the data in time chunks before calculating BRDF.
Default bin is 5 days (same as DIMITRI).

Also, fix the relative azimuth angle calculation
so it stays in range 0-180
Calculate error estimates

Add calculation of error estimates to the timeseries
method. Then just return the result arrays, and split
out the plotting to a separate method.
Return mean dates from the binned timeseries

Instead of storing the mid point of the bin,
calculate the mean date of the included images.
Do this by converting to unix timestamp, so
they are just integers which we can average.

This gave an error when the bin size was such
that we had some bins with no images found,
leading to an empty timestamps list. So add a
check that we found some images before doing
any of the brdf calculations.
Improve the timeseries plot

Tidy up the plot a bit:
- Make the figure window bigger
- Add (optional) title, xlabel and ylabel
  arguments, and use instrument and region
  in our title.
- Move the legend box outside the plot area,
  and add a title to it
Add some tests for the BRDF code
Write BRDF output to csv file

Add method to write the BRDF output arrays
to a csv file. File name includes the sensor
name, region and the date range.

The arrays are written with dates along the
columns, and with all bands for first variable
as rows, then all bands for next variable etc
(following DIMITRI output format)
Add more unit tests for BRDF module
Update tools documentation

Update the docstrings in the tools libraries,
and add a new page to the web documentation to
display them.
BRDF updates

- k coefficients only calculated once, for some given
  date range. Then these values are used to calculate
  BRDF for the entire timeseries.
  (If no date range given, it defaults to using the
   whole timeseries)

- Plot (reflectance - BRDF)/BRDF * 100 (ie the error
  as a percentage of modelled BRDF)

- Before plotting, remove (by setting to nan) values
  that are more than two standard deviations away from
  mean

- Add option to save the plot, if a filename is passed
  to plot_timeseries(). Amend the plot unit test so that
  no file is created there.

- Add measured reflectance to the output csv file. This
  means also re-sampling into the time bins as with BRDF.

- Re-build the html docs to reflect the changes
Merge in BRDF branch

Adds new "tools" folder which we will use to
hold all the tools libraries.

Set up an abstract base class which the tools
will subclass (and must override the "run"
method.)

Add first tool to compute Roujean BRDF and create
a plot and csv file. Also add a library for
database queries (but we should use the user
interface instead when it's ready.

Update html docs to include a new page for the
tools
Refactor tools directory

Do some refactoring of the tools directory ahead
of working on radiometric drift:

- Have one unit test file per library, and put
  these all in a "tests" subfolder to keep things
  tidier

- Create a new libtools.py for holding functions
  that will be useful in several tools (such as
  reading reflectance from the geotiffs).

- Move get_angles and read_reflectance from the
  BRDG library into this new shared tools file.
  (And move unit tests to the appropriate new
  test file too)

- Create skeleton file for new radiometric drift
  library and associated test file.
Merge in bug fix from add_images branch
Extract data fields

Start the radiometric drift routine, by reading
data fields from the two JSON object inputs and
storing in dictionaries.

Perform a check to make sure that both datasets
are for the same region of interest (might want
to add other checks here later?)

Also add unit tests for new methods
Add doublet checking methods

Add functions to libtools for checking doublets:
- calc_amc calculates the AMC value for given
  viewing angles

- calc_amc_threshold calculates the AMC value
  corresponding to given angular differences,
  to be used as a threshold value

- check_doublet takes a pair of images and
  tests whether they meet all the matching
  criteria (AMC below threshold value, dates
  within threshold offset, ROI coverage at
  least threshold value)

- Also add a helper tool slice_dictionary to
  enable taking a slice across all keys in a
  dictionary (ie as if doing something like
  dic[:][index])

Also add tests for these new functions
Add some new general functions

Add some new functions to libtools, for use by
the other tools:

- mean_date: return the mean of a list of dates
  (in python datetime format). This was previously
  coded in libbrdf_reoujean, so change that to
  call this libtools function instead.

- get_reflectance_band: Read 2d reflectance array
  from a list of files, but only for a particular
  raster band.
  Also change the name of get_reflectance to
  get_reflectance_mean so the distinction is clear.

Add units tests for these too