#-------------------------------------------------------------------------------
#Unless stated otherwise, all data in the OATH Dataset is licensed under a
#Creative Commons 4.0
#Attribution License (CC BY 4.0) and the accompanying source code is
#licensed under a
#BSD-2-Clause License.
#In particular, all actual image data included in the tarball are modified from
#the
#THEMIS all-sky imagers .
#
#We thank H. Frey for giving us permission to include these data.
#Copyright for these data remains with NASA.
#
#We acknowledge NASA contract NAS5-02099 and V. Angelopoulos for use of data
#from the THEMIS Mission. Specifically: S. Mende and E. Donovan for use of the
#ASI data, the CSA for logistical support in fielding and data retrieval from
#the GBO stations, and NSF for support of GIMNAST through grant AGS-1004736.
#-------------------------------------------------------------------------------
#===============================================================================
#
# This archive contains all necessary data and programs for replicating the
# results of
# Clausen, L. B. N., & Nickisch, H. (2018). Automatic classification of auroral
# images from the Oslo Auroral THEMIS (OATH) data set using machine learning.
# Journal of Geophysical Research: Space Physics, 123,
# https://doi.org/10.1029/2018JA025274
#
# 13 Apr 2018: Version 1.0, initial release
# 26 Oct 2018: Version 1.1, some bug fixes in ridge.py and rotate.sh
#
#===============================================================================
# Here follow the commands to execute the training and classification
# tested on fresh install of
# Gubuntu 17.10 (Artful Aardvark)
# Kernel 4.13.0-37 generic
# x86_64
# 4 core Intel Core i7-3520-M CPU (2.9 GHz)
# make sure Python3, git, wget, and imagemagick are installed
sudo apt install python3 git wget imagemagick
# install several Python3 packages for tensorflow
sudo apt install python3-pip python3-dev python3-h5py python3-contextlib2
# install several Python3 packages for machine learning
sudo apt install python3-matplotlib python3-pandas python3-sklearn
# get tensorflow
mkdir ~/tensorflow/
cd ~/tensorflow
pip3 install tensorflow
git clone https://github.com/tensorflow/models/
cd models/research/slim
sudo python3 setup.py install
# get pre-trained model
cd ~/tensorflow
mkdir tmp
cd tmp
wget http://download.tensorflow.org/models/inception_v4_2016_09_09.tar.gz
tar xf inception_v4_2016_09_09.tar.gz
mkdir ../checkpoints
mv inception_v4.chpt ../checkpoints
# get TF_FeatureExtraction
cd ~/tensorflow
git clone https://github.com/tomrunia/TF_FeatureExtraction
# rotate the images
cd ~/oath/code
chmod a+x rotate.sh
./rotate.sh
# run feature extraction, assuming the cropped, scaled, and rotated images
# are in the folder ~/oath/images/cropped_scaled_rotated
cd ~/tensorflow/TF_FeatureExtraction
# this is one long command
python3 example_feat_extract.py --network inception_v4 --checkpoint ../checkpoints/inception_v4.ckpt --image_path ~/oath/images/cropped_scaled_rotated/ --out_file ~/oath/features/auroral_feat.h5 --layer_names Logits
# train the ridge classifier
cd ~/oath/code
python3 ridge.py