From 4222f74f75cb3979f0557fb918465b93e1b225ac Mon Sep 17 00:00:00 2001
From: Axel Schnitger <axel.schnitger@aei.mpg.de>
Date: Mon, 20 Aug 2018 13:35:45 +0200
Subject: [PATCH] Update the documenation and fix a wrong path.

- Add a shell script to get the example dataset.
- Update documentation: How to get the example data set.
- Fix an absolute path.
---
 README.md                         | 52 ++++++++++++++++++++-----
 continue_gfr_par_from_iteration.m |  2 +-
 get_input_data.sh                 | 63 +++++++++++++++++++++++++++++++
 3 files changed, 107 insertions(+), 10 deletions(-)
 create mode 100755 get_input_data.sh

diff --git a/README.md b/README.md
index 42d6862..852ccd5 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,8 @@
 
 ## Overview
 
-GRACETOOLS is an archive of MATLAB software that can be used for gravity field recovery using GRACE type satellite observations.
+GRACETOOLS is an archive of MATLAB software that can be used for gravity field
+recovery using GRACE type satellite observations.
 
 **Features**
 
@@ -15,15 +16,40 @@ GRACETOOLS is an archive of MATLAB software that can be used for gravity field r
 
 ## Content
 
-- [Usage](#usage)
-- [Features](#features)
-- [Files](#files)
-- [Acknowledgments](#acknowledgments)
-- [Contributors](#contributors)
+<!-- vim-markdown-toc GitLab -->
+
+* [Usage](#usage)
+    * [Example dataset](#example-dataset)
+        * [Linux & Mac](#linux-mac)
+        * [Manually](#manually)
+* [Performance](#performance)
+* [Files](#files)
+* [Acknowledgments](#acknowledgments)
+* [Contributors](#contributors)
+
+<!-- vim-markdown-toc -->
 
 ## Usage
 
-To be able to run the program download the following dataset:
+The main m-files to run are: `gfr_parallel.m` and
+`continue_gfr_par_from_iteration.m`.
+
+### Example dataset
+
+To be able to run these scripts you need an example data-set.
+
+#### Linux & Mac
+
+If you're working with Linux or MacOS simply use the `get_input_data.sh` script
+to get the dataset:
+
+```
+$ ./get_input_data.sh
+```
+
+#### Manually
+
+Download the following dataset:
 
 - [Download dataset](https://seafile.projekt.uni-hannover.de/f/3ee8fef6c6cb485489b4/?dl=1)
 
@@ -70,7 +96,11 @@ input_data
 └── GGM05S.gfc
 ```
 
-The main m-files to run are: `gfr_parallel.m` and `continue_gfr_par_from_iteration.m`.
+
+## Performance
+
+With an older intel i5 (4 cores) a test case with degree and order 10 with 4
+days of observation, each iteration takes about 1h 10min.
 
 ## Files
 
@@ -98,6 +128,7 @@ The main m-files to run are: `gfr_parallel.m` and `continue_gfr_par_from_iterati
 | `plm.m`                         | fully normalized associated Legendre functions for a selected order M.                                                |
 | `plmsp.m`                       | fully normalized associated Legendre functions for all degree and order but in a single points.                       |
 | `readACC.m`                     | Read GRACE ACC1B data                                                                                                 |
+| `readGFC.m`                     | Read gfc files                                                                                                        |
 | `readGNV.m`                     | Read GRACE GNV1B data                                                                                                 |
 | `readKBR.m`                     | Read GRACE KBR1B data                                                                                                 |
 | `readSCA.m`                     | Read GRACE SCA1B data                                                                                                 |
@@ -110,7 +141,10 @@ The main m-files to run are: `gfr_parallel.m` and `continue_gfr_par_from_iterati
 
 - GRACETOOLS is open source software (LICENSE GPLv3).
 - Please reference this article if you use GRACETOOLS:
-- Darbeheshti N., Wöske F., Weigelt M., Mccullough C., Wu H. (2018) GRACETOOLS - GRACE gravity field recovery tools, Geosciences.
+
+```
+Darbeheshti N., Wöske F., Weigelt M., Mccullough C., Wu H. (2018) GRACETOOLS - GRACE gravity field recovery tools, Geosciences.
+```
 
 ## Contributors
 
diff --git a/continue_gfr_par_from_iteration.m b/continue_gfr_par_from_iteration.m
index f116edd..0d559f5 100644
--- a/continue_gfr_par_from_iteration.m
+++ b/continue_gfr_par_from_iteration.m
@@ -45,7 +45,7 @@ ItrNo_max = 12;
 
 % add folder name containing functions and input data (observations, ref.
 % field, initial values...)
-DataFolder='/home/woeske/Matlab/GFR/input_data';
+DataFolder='input_data';
 addpath(genpath(DataFolder));
 
 %% load data from previous iteration
diff --git a/get_input_data.sh b/get_input_data.sh
new file mode 100755
index 0000000..1d637cc
--- /dev/null
+++ b/get_input_data.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+URL="https://seafile.projekt.uni-hannover.de/f/3ee8fef6c6cb485489b4/?dl=1"
+INPUT_DATA=input_data.zip
+
+downloadData(){
+    echo "Downloading data from $URL..."
+    wget --content-disposition "url?raw=1" -U mozilla "$URL" -O $INPUT_DATA
+    echo "Done."
+}
+
+
+setUp(){
+    echo "Start extracting data file..."
+    unzip $INPUT_DATA -d input_data/
+    echo "Done."
+    echo "Removing zip file"
+    rm -f input_data.zip
+    echo "Done."
+}
+
+cleanUp(){
+    echo "Removing subdirectories from input directory."
+    rm -rf input_data/*
+    echo "Done."
+    echo "Removing files from input directory."
+    rm -f input_data/*
+    echo "Done."
+}
+
+getData(){
+    if [[ -d input_data/ ]]; then
+        echo "Directory 'input_data/' already exists."
+        if [[ -f input_data/EGM96.gfc ]]; then
+            echo "There is already data in it."
+            read -r -p "Cleanup and download again? [y/N]" response
+            case $response in
+                [yY][eE][sS]|[yY])
+                    cleanUp
+                    downloadData
+                    setUp
+                    ;;
+                *)
+                    echo "Aborting."
+                    exit
+                    ;;
+            esac
+        else
+            downloadData
+            setUp
+        fi
+    else
+        downloadData
+        setUp
+    fi
+}
+
+
+main(){
+    getData
+}
+
+main
-- 
GitLab