Intial supersensor files

Add file for creating the supersensor, and
one for associated tests, with initial code.
Refactor calculation of sensor drift

Move the method that calculated drift timeseries
from the Radiometric drift module to libtools, so
we can use it in the supersensor module too. Also
move the associated unit test.

At the same time, change so that instead of just
reference/target, it calculates (target-reference)/reference
and simplify to use a list comprehension instead of
a loop with several lines.
Fit polynomial to doublets

- Loop through sensors to be recalibrated
- Loop through the reference sensor bands
- If the current recalibration sensor includes
  this band:
     - Read reflectance data for both sensors
     - Find doublets
     - Calculate timeseries of:
       (calibration TOA - reference TOA)/reference TOA
     - Fit polynomial to this timeseries and
       return the coefficients
Add recalibration

First refactor code to change reference to the
"calibration sensor(s)" to "target sensor(s)"
to avoid confusion.

Add method to recalibrate the target sensor
at all dates, using the polynomical that was
calculated from the doublets. This is
effectively saying "given this target sensor
measurement, what measurement would we have
got from the reference sensor?"

Also add a unit test for the new method
Update outdated docstrings

Some docstring updates to reflect
changes to method argument parameters
Combine recalibrated data

After looping through all the target sensors,
and doing the recalibration, combine the
data such that each sensor now has the same
number of bands (any bands that weren't present
for that sensor are filled with None).

This is because we can't include band info
in geotiff files, and the database models only
take a single set of wavlengths per sensor. So
we want all the supersensor datasets to cover
the same bands, regardless of which original
sensor they were from.

Add a new method to do the combining, and also
add a unit test for it.
Changes for geotiff and database entry

Make some changes to get ready for making the
geotiffs, and adding to database:

- In get_metadata, we need to store some additional
  information (coordinates, angles etc)

- Refactor the recombining method so that it returns
  a dictionary of dictionaries (1st key = sensor,
  then 2nd key = band). This is because we will use
  array2raster from the image ingestion code, and
  that expects a dictionary as input
  Also change the unit test to reflect the change.
Add initial make_geotiffs method

Add first iteration of a method to create
geotiffs of the recalibrated data.

It loops through the target sensors, then
loops through the list of images (ie the
different dates) and saves as geotiff.

Bands that weren't present in the original
file are padded as an array of nans, so that
all the geotiffs contain the same number of
bands, regardless of which sensor they came
from.

Files are saved in a subdirectory following
the naming convention of the normal sensors,
where the sensor name is SUPER_REF_[reference]

We name the geotiffs like this:
super_[target]_ref_[reference]_YYYY-MM-DD[_direction].tif
('_nadir' or '_fward' is added if it was present
in original filename)

Still to do: think of way to provide the root
of the save directory (currently hardwired).

Also, currently falls over if trying to loop through
MERIS images, as the originals are not all exactly
the same size (one pixel different). Nit sure why
this is.
Add test for make_geotiffs
Changes to API and Query tools

Update the query tools library so that the
main database url is in get() rather than
spread out elsewhere. Then other methods just
pass in the resource they are querying
(eg image, or instrument) and that is appended
to the url.

Add a post method to posting new items to the
database. It returns the URI that was created
(if the API is set to include it)

Add authorization field to the resources we want
to post to (NB no security yet!)

We need the resource API in order to reference
any foreign key objects when posting a new
object (eg, to post a new image we need a
reference to an instrument, region and
measurement type). This requires us to change
include_resource_uri from False to True in a
the required resources so that we can retrieve
the URI from a query.
Add "get or post" method

Add a new method to simulate the
"get or create" django method - it
does a get to see if an object already
exists with the search parameters, and
if not posts a new object. In either
case the URI for the found/created
object is returned (or None if the
resource API doesn't return the URI)

If get returns more than one object,
an exception is raised.

NOTE currently only works for simple
models, not ones that refer to
foreign keys (since the way those are
searched is different in post and get
syntax)
Add supersensor images to database

New method to add the recalibrated images
to the database, under a new supersensor
instrument.

We use libquery.Querydb to post the data,
instead of using the django commands so that
it is not dependant on always using django
for the database.

Note that currently there is no mechanism to
stop multiple duplicate images being posted
(instrument uses Querydb.get_or_post which
prevents duplicates, but it can't currently
cope with foreign key fields)
Bug fix for image size

Supersensor code was falling over when going
through a series of images, because the grid
size (for the geotiff) was only calculated
once per sensor, but some images are one or
two grid points different in size.

(This is because when the region of interest
is extracted, the grid size is calculated
from the original image size)

Move the calculation of grid size inside the
loop for each image, so it is calculated
separately each time. Code now runs ok.

Also, remove some unneeded print commands
that were for debugging.
Update supersensor tests

Amend unit test to include the sun and
viewing azimuth angles in metadata
extraction.
Update docs

Update a couple of docstrings, and rebuild
the webdocs to include the supersensor code.
Merge 'supersensor' branch into master

Merge in the changes for the supersensor tool.
It recalibrates any number of given target
sensors to the reference sensor, and creates a
new instrument and images in the database.