Professional Documents
Culture Documents
EODP Environment R1.0
EODP Environment R1.0
Date: 14/09/2020
Revision: 1.0
Prepared by
Authorised by
Revision Record
Modification Change Description Date
Review
reference
Table of Contents
1. Introduction _____________________________________________________________ 10
2. References ______________________________________________________________ 11
2.1. Applicable Documents __________________________________________________ 11
2.2. Reference Documents __________________________________________________ 11
2.3. Acronyms ____________________________________________________________ 11
3. Setting up the Work Environment. ___________________________________________ 12
3.1. Install Oracle VM Virtualbox _____________________________________________ 12
3.2. Import the Virtual Machine ______________________________________________ 17
3.3. Settings _____________________________________________________________ 23
3.4. Run the Virtual Machine ________________________________________________ 32
3.5. Guest Additions. ______________________________________________________ 34
3.6. Shared folder. Accessing the files in the VM from the host OS. ___________________ 38
3.6.1. Create a folder in the host OS ________________________________________________ 38
3.6.2. Update the shared folder settings in the VM ______________________________________ 39
3.6.3. Mounting the shared folder ___________________________________________________ 42
3.6.4. Mounting the shared folder - script _____________________________________________ 43
3.7. Close the VM _________________________________________________________ 43
3.8. Ubuntu updates _______________________________________________________ 44
3.9. Test COTS installed in the VM ____________________________________________ 45
3.9.1. Dolphin (file explorer) _______________________________________________________ 46
3.9.2. Notepadqq (text editor) _____________________________________________________ 47
3.9.3. Panoply (NetCDF viewer) ____________________________________________________ 49
3.10. Tips for working with a VM. _____________________________________________ 56
3.11. Shrinking the size of the VM ____________________________________________ 57
4. Command Prompt or Terminal. ______________________________________________ 60
4.1. Open a window and new tabs ____________________________________________ 60
4.2. Some basic operations __________________________________________________ 61
4.2.1. Change directory and see contents _____________________________________________ 61
4.2.1.1. ‘cd’ to a directory, ‘ll’ to list contents ________________________________________ 61
4.2.1.2. The ‘.’ and ‘..’ directories _________________________________________________ 61
4.2.1.3. ‘pwd’ see which directory you are in ________________________________________ 62
4.2.2. Making it easier to input a command ___________________________________________ 63
4.2.2.1. Autocomplete with Tab ___________________________________________________ 63
4.2.2.2. Arrows Up and Down for commands ________________________________________ 63
4.2.2.3. Reverse search Ctrl+R ___________________________________________________ 63
4.2.3. Files and Directories ________________________________________________________ 64
List of Tables
Table 2-1: Applicable Documents .................................................................................................. 11
Table 2-2: Reference Documents .................................................................................................. 11
Table 2-3: Acronyms ................................................................................................................... 11
Table 6-1: Some useful Git commands ........................................................................................ 112
List of Figures
Figure 3-1: Download page for VM Virtualbox ................................................................................. 12
Figure 3-2: Save executable for VM Virtualbox ............................................................................... 13
Figure 3-3: Installation of VM Virtualbox ........................................................................................ 13
Figure 3-4: Installation of VM Virtualbox ........................................................................................ 14
Figure 3-5: Installation of VM Virtualbox ........................................................................................ 14
Figure 3-6: Installation of VM Virtualbox ........................................................................................ 15
Figure 3-7: Installation of VM Virtualbox ........................................................................................ 15
Figure 3-8: Installation of VM Virtualbox ........................................................................................ 16
Figure 3-9: Installation of VM Virtualbox ........................................................................................ 16
Figure 3-10: VM Virtualbox .......................................................................................................... 17
Figure 3-11: VM Virtualbox. Import Appliance. ............................................................................... 18
Figure 3-12: VM Virtualbox. Import Appliance. ............................................................................... 19
Figure 3-13: VM Virtualbox. Import Appliance. ............................................................................... 20
Figure 3-14: VM Virtualbox. Import Appliance. ............................................................................... 21
Figure 3-15: VM Virtualbox. Destination folder for the VM. ............................................................... 22
Figure 3-16: VM Virtualbox. Import............................................................................................... 22
Figure 3-17: VM Virtualbox. Import............................................................................................... 23
Figure 3-18: VM settings. ............................................................................................................ 24
Figure 3-19: VM settings. General................................................................................................. 25
Figure 3-20: VM settings. System. ................................................................................................ 26
Figure 3-21: VM settings. System. ................................................................................................ 27
1. INTRODUCTION
This document describes the development environment of Earth Observation Data Processing (EODP).
A Virtual Machine (VM) is provided, to have a common environment for all the participants of EODP.
Instructions are provided on how to install and start working with the VM in § 3.
The guest Operating System (OS) in the VM is Ubuntu. Ubuntu is an easy graphical Linux distribution.
Some basic commands are explained in § 4 (which are common for all Unix based systems).
Section § 5 describes the reference source code, and how to execute it. The EODP code is in two
languages: the Geometry Module is implemented and provided in C++, and the Instrument Module, L1B
and L1C modules are implemented in Python.
Finally, in § 6 the version control that will be used in EODP, Git through GitHub, is described.
2. REFERENCES
2.3. Acronyms
Table 2-3: Acronyms
Acronym Description
AD Applicable Document
GM Geometry Module
OS Operating System
RD Reference Document
TBC To be confirmed
TBD To be defined
TBW To be written
TN Technical Note
UT Unitary Test
VM Virtual Machine
The installation is straightforward, just press Next all the time. Screenshots are provided here as a
guideline:
This opens a menu where you can navigate to the location of the OVA file:
Once the import is finished, the Virtual Machine appears in the main panel of VM Virtualbox:
3.3. Settings
You probably will not have to change the settings, but if you need to, here are several indications. First
right-click on the VM and select ‘Setting’s:
Make sure the clipboard is ‘Bidirectional’. This means that any text (like an URL) that you copy in the host
OS you can past in the VM, or vice versa.
NOTE: the drag-and-drop option is set to ‘Bidirectional’ but we will use another way to access files with a
shared folder, see § 3.6.
The System settings is an important configuration. The Base Memory is how much RAM you allocate to
the VM. The recommendation is to maximise it to the green area. The read area is how much your hows
OS needs (e.g., how much RAM Windows needs). In my laptop I have 32GB, which is more than needed,
so I have allocated 11GB to the VM. Basically, slide the pointer to the end of the green area.
The Display settings should be OK, make sure you have maximum video memory and you have enabled
3D acceleration. Number of monitors is one (one screen).
The shared folder is an important setting, as this is the folder that will be used to transfer files
between the host OS and the VM.
❑ First, create a folder in your host OS (e.g., in this example its called VBox_shared_folder in my user).
❑ You need to modify this shared folder, so double click on it, see Figure 3-23. Update path and name.\
❑ Do not select auto-mount or read-only (its better to manually mount it, see § 3.6). Follow the
configuration in Figure 3-23.
❑ If you want, you can change the name of the shared folder in Linux “my_shared_folder”. Or leave it
as it is.
The rest of the settings should be left by default. They are screenshot here for reference:
If your VM does not maximise to the full screen, go to the next section “Guest Additions”.
Figure 3-34: If the VM does not resize to the monitor, you need to update the Guest Additions.
You are prompted for the superuser password, which you can find in [EODP_GUI] section 5.4. “Superuser
Credentials”.
After that, the installation is complete. However, there is one last step, which is to resize to whatever
your screen resolution is:
Now you should get the VM full screen. It should also automatically resize if you change screen or if you
modify the VM size.
3.6. Shared folder. Accessing the files in the VM from the host OS.
This section details how to create a shared folder, i.e., a folder in your host OS (e.g., Windows) that is
visible in the VM. A shared folder is useful to:
❑ move the reference inputs and source code to the VM
❑ move the outputs generated in the VM to the host OS
❑ to store big files without increasing the size of the VM (see § 3.10).
As you can see, the path in Windows of the shared folder does not match the shared folder I have
created in Figure 3-41, so I need to update it:
Figure 3-43: Shared folder settings in the VM. Need to update the Path in Windows.
Double click on the shared folder and the navigate to ‘Other’ to select your shared folder in the host OS:
Figure 3-44: Shared folder settings in the VM. Need to update the Path in Windows.
NOTE: if you create your own script, remember to give it execution permissions (755)
chmod 755 script
You might need to modify if you have changed the name of the folder in the host OS or the VM.
It will prompt you for superuser credentials that you can find in [EODP_GUI] section 5.4. “Superuser
Credentials”. After that, the folder is mounted.
The example above is a massive update, in general it should only be a couple of MBs. Click on “Install
now”.
You can also update your system via command line with:
sudo apt update
This will parse the system and identify which packets need to be updated.
sudo apt upgrade
This will upgrade the packets, so actually install the packets.
Sudo executes a command as root (“superuser do”), so you will be prompted for the administrator
password, see [EODP_GUI] section 5.4. “Superuser Credentials”.
In the search start typing ‘Dolphin’ until the Dolphin icon appears, and double-click to open it:
This will open the Dolphin window. You can move to any directory and do the typical operations of any
file explorer.
You can also open any file through the file explorer by right-clicking on the file and selecting ‘Open with’:
To launch it you need to run the shell script located in the Panoply folder:
You can run it from any place using a ‘./’. Add an ‘&’ so that you can continue using the window:
Panoply is intuitive to use. You select any NetCDF and open it. Then you can inspect a variable by double-
clicking on it. Another window will open with a viewer for the image, Figure 3-69. You can also inspect
the values of the variable, see Figure 3-70.
Figure 3-70: Panoply. Variable array. Change the format for a higher precision as the default is %.1f
❑ Run the VM, open a terminal, and type (it will prompt you for the superuser password):
sudo dd if=/dev/zero of=/var/tmp/bigemptyfile bs=4096k ; sudo rm /var/tmp/bigemptyfile
❑ Close the VM
❑ In Windows, run the PowerShell as Admin:
❑ Now, run the following command in the Windows PowerShell, substituting the location and name of
the VDI file:
.\VBoxManage.exe modifymedium --compact 'C:\Users\34655\VirtualBox
VMs\EODP_VM\FLEX_VM_Ubuntu_18.04_LTS-disk001.vdi'
And that is it. See how the VM size is reduced by more than 30GB:
You can add new tabs or open more than one window:
Figure 4-2: Open new tabs in the same terminal window or a new terminal
In fact, it is safer to autocomplete. If you press tab and it doesn’t autocomplete, the input path is not
correct.
In case there is more than one option, double-tab will show you the available options.
Figure 4-5: Double tab provides the options. In this example, when we type l1, there are two options
because there are two folders named l1b and l1c
An example. I want to retrieve a commit to avoid having to type all the ‘git commit -m “FLEXFIPSGP-33:
blabla”’. I press Ctrl+R and I start typing ‘git’. The first result I get is this, a git pull, which is not what
I’m interested in.
I continue typing ‘git c’ and when I get there I already have a suggestion of a commit command. I then
press Tab to finish.
mkdir my_directory
NOTE: You need to have write permissions in that folder. See chmod below.
Below is an example where I delete the repository eodp/ (thanks to GitHub there’s no problem). The
hidden .git folder has files that are protected and it warns me against deleting them.
Figure 4-9: Example of permissions. Here I’m removing the eodp repository. There are git files in the .git
folder owned by root, so it ‘complains’ when I try to remove them.
Figure 4-10: By using sudo (superuser), the remove is done without any warning.
Figure 4-12: Example of mv. In this example my_folder1 is moved into my_folder2
For directories, use the -s option. It provides the summary of the size, the total of the directory (if not
used, it will printout the file for each file inside the directory).
du -hs my_directory
Figure 4-15: Example of compressing with tar. Verbose is enabled (the ‘v’), so all the files included in the
TGZ are displayed.
In the following example I create a symbolic link for a binary located in the ut02 folder of the gm test, in
the current directory (‘.’). When you do an ‘ll’, you see the symbolic link in cyan with an arrow showing
where that link is redirected. If I want to execute the binary, I only need to do ‘./FLEX-FIPS-GM_UT02’
and saves me from having to input the whole path.
NOTE: there is a lot of context missing here as executables and scripting is a whole topic. It is out of
scope for this subject.
An example is launching Panoply, see § 3.9.3.
4.2.10. Searching
When you want to look only in a certain type of files, for example the C/C++ source or header files, use:
grep -r “string” --include=*.{cpp,hpp} .
Or for Python scripts:
grep -r “string” --include=*.py .
5.1. Python
For general support with the Python language, and starting with PyCharm (Python development
environment), please refer to [EODP_PY].
This section describes how to run the reference source code, which is the template on which you will
develop the algorithms of data processing.
Figure 5-1: Reference source code. The ISM/L1B/L1C modules have the same structure and are invoked
with the same call.
There are several other folders. The auxiliary/ folder contains input data, like constants, the log
configuration, the ISRF curves.
The common/ folder is a folder for generic Python functions used in the ISM, L1B and L1C. the
common/io/ folder contains folder to “input/output” information, so reading and writing. The
common/plot/ folder contains auxiliary functions to plot functions and images. Finally, the common/src/
folder has other generic functions.
Figure 5-2: Reference source code (not including the modules). Contains the auxiliary data files, common
Python source code, and the configuration of the ISM/L1B/L1C.
5.1.1.1. Configuration
The configuration files are stored in the config/ folder, there is one per module and one global
configuration file, see Figure 5-2.
The configuration files have the default parameters that define the system, the instrument and the
processing.
Figure 5-3: Snapshot of the global and ISM local configuration files.
5.1.1.2. Call
The call to the ISM, L1B and L1C follows the same logic. The modules are initialised with three
directories:
❑ auxdir: the path to the auxiliary/ directory
❑ indir: the path to the module inputs
❑ outdir: the path to the output directory, where you want to save the outputs.
Remember to import the ism class, as shown in the example in the figure below. You can find scripts to
launch the ISM, L1B and L1C standalone in the ism/, l1b/ and l1c/ folders.
The way to call the modules is:
from module.src.module import module
# Define auxdir, indir, outdir
myModule = module(auxdir, indir,outdir)
myModule.processModule()
Where ‘module’ is ‘ism’, ‘l1b’ or ‘l1c’.
The code is structure in “classes” (pseudo-object oriented programming). Below is an example of the
class for the ISM. This class has two methods (i.e., functions), the class constructor __init__ and the
processModule(). The __init__ method is invoked when the class is created. So in Figure 5-4, in myIsm =
ism(auxdir, indir, outdir). The processModule is explicitely called in the following line.
The ISM calls three other classes, for the optical, detection and video phase. Notice how each class is
initialised and the called with the compute() method.
class ism(initIsm):
def processModule(self):
# Read input TOA cube
sgm_toa, sgm_wv = readCube(self.indir, self.globalConfig.scene)
# Detection Stage
myDet = detectionPhase(self.auxdir, self.indir, self.outdir)
toa = myDet.compute(toa, band)
The compute method of these classes will have the calls to each of the functions. For example, here is
the sample code for the video chain phase:
def compute(self, toa, band):
# Digitisation
toa = self.digitisation(toa,
self.ismConfig.bit_depth,
self.ismConfig.min_voltage,
self.ismConfig.max_voltage)
return toa
In EODP, we are going to implement functions that we will add in the opticalPhase.py, detectionPhase.py
and videoChain.py, and we will include the call to these functions in the compute() methods, in order to
create a sequence of processing.
When you call this function in the class, follow this syntax:
toa = self.myFun(toa, var1, var2)
Additionally, you can also save the log by execute the script in the terminal and redirecting the output
with a tee command, see § 5.2.2.
5.2. C++
Figure 5-5: Eclipse IDE. Use the Project Explorer to access different files (left). On the right, you see all
the functions and attributes of the current class. To navigate, for example to initOrbitId(), press
Ctrl+mouse click the function.
Figure 5-6: Eclipse IDE. Use the Project Explorer to access different files (left). On the right, you see all
the functions and attributes of the current class. To navigate, for example to initOrbitId(), press
Ctrl+mouse click the function.
You can run this binary with the following call. Go to the binary folder (you can also run it from a different
directory), and provide after the binary the location of the geometry local configuration file and an
output directory:
./geometry_module ../conf/gm_local_conf.xml output_dir
In a nutshell, after modifying your code in C/C++, you need to compile it, and then run it.
The compilation, explained in very simple terms, first, checks the syntax of your code, and then creates
an object (linking all the dependencies). With this “object” (the binary), you run the code.
You can setup Eclipse to compile the code there. However, I prefer to use the terminal directly to compile
and run. This project already has all the compilation options in the main project CMakeLists.txt (check it
out in the root folder of the project), so you will not need to modify it a priori (unless you want to! :) ).
To compile the code:
❑ Create a build directory in the root folder:
~/EODP/eodp_gm/build/
“2>&1” tells the system to redirect the standard output and error (what is printed in the command line),
and “| tee” duplicates the output so that it is printed in the screen and output to the file.
After that, you see that a log file has been created:
Click on the green button ‘New’ in order to create a new repository. Assign any name that you want,
add a description (optional). Remember to put it as Private and a README:
Notice how the repository is created with one branch, master. We are going to create another branch,
develop. We are going to commit to the develop branch (read about the typical workflow in § 6.7). Click
on the dropdown menu and type in ‘develop’:
Figure 6-7: change directory to where you want to download the repository
You will find the new repository. In this example it is a directory named ‘eodt_test2’, which contains a
.git/ directory and an empty README file:
First thing to notice, we are on the master branch. We will change that in a minute. Second thing, the
repository is up to date, meaning, we are aligned with the origin/master.
NOTE: ‘origin’ means the remote repository, i.e., the repository located at GitHub.
The green branch, master, is the branch you have in your local. The other three branches in red are
located in origin, i.e., the GitHub server.
❑ origin/HEAD points at the main branch which by default is origin/master
❑ origin/master and origin/develop are the two branches we created in the repository, see Figure 6-6.
Do a git branch (or git status) to check that we are currently in develop:
NOTE: (optional) you can enhance the text with markdown. Info in
https://guides.github.com/features/mastering-markdown/.
Notice how the file is marked in red, meaning it has changed from the version in the repository.
Now we will add the file. This notifies Git that this file shall be included in the following commit. The
syntax is the following:
git add pathtofile
Notice how the file is now marked in green. The following step is to commit it:
git commit -m “my commit message”
Now head over to GitHub to see your changes. Open the README.md and check the commit history:
The changes we have done are not in the GitHub repository!! The reason for this is that the changes
are in our local repository. Do a git log to check out the commit history:
Figure 6-21: Git log history – the changes to the README.md are in the local repository but not in the
origin (GitHub server) yet.
We need to push the changes from our local develop branch to the origin/develop branch. This
means we need to upload our changes to the GitHub server. The syntax for this is:
git push origin develop
Figure 6-22: Git push changes from the local/develop to the origin/develop branch.
Now go back to your GitHub account and refresh the README.md and the commit history:
Tips:
❑ Do a git status after every operation
❑ Do small, unitary commits. Do not wait to finish a whole algorithm to commit it. Do many
intermediate commits.
❑ Put meaningful commit messages that will help you in the future in case you need to trace older
versions.
❑ Remember to push to the origin! Assume that the VM can crash any minute (it should not but it is a
good practice).
You can directly download it in the VM through Firefox, or download it to the shared folder in the host OS
(e.g. Windows) and get it from there. Move the sources to the folder of your repository.
This takes to you the destination folder. Select your repository folder, and click on the green button
‘Extract’:
It will ask you whether you want to overwrite or skip the README.md. Press Skip and keep your own
README.md.
It will prompt you again to overwrite the .gitignore. The .gitignore I provide is quite complete so I
recommend that you overwrite it with ‘Replace’:
Press ‘Show the Files’. You can delete the zip file now, or move it somewhere else (you can always
download it again).
Figure 6-37: Once completed, delete the zip file (or move it somewhere else).
Head over to GitHub and check that you can see the newly added sources in your repository in the
develop branch:
Figure 6-43: Git develop and master branches. You will commit to origin/develop. (Optional) you can push
a stable version to master. Source: nvie.com
Moving from develop to master is done directly in GitHub. Go to ‘Pull request’, and click on the green
button ‘New pull request’:
Select base:master and compare:develop. Then click on ‘Create pull request’. You can write a comment
that explains the milestone, or the reason for the pull request.
After that, you should get the option to merge. Click on ‘Merge pull request’:
Once merged, you will find the latest version of develop uploaded to master:
Figure 6-49: Git develop and master branches. You will commit to origin/develop. (Optional) you can push
a stable version to master. Source: nvie.com
A developer works on its own, undisturbed, it their feature branch. He/she will commit to their local
repository and push to the origin/feature branch (upload it to the GitHub feature branch instead of
develop) with (for this example):
git push origin feature/FLEXFIPSGP-33-simplified-scene-generation-implementation
Once a given “feature” is finished, for example a given algorithm has been implemented and unitary
tested, the next step is to merge with develop. This has several steps:
❑ First the developer has to ‘pull’ the origin/develop to its local branch. This means, the latest version
of develop is merged into the local branch. Git does this merge, but it can lead to conflicts that the
developer needs to manually solve.
git pull origin develop
Figure 6-50: Example of “pulling” the origin/develop into the local feature branch.
In the example shown in the figure above, there are luckily no conflicts.
❑ Once the conflicts are solved, the developer needs to commit and push to origin/feature branch.
❑ After this, in GitHub (or wherever the repository is located), the developer performs a pull request.
This means that the developer requests that the changes of the feature branch (which include and are
merged with the latest develop) are introduced in a new version of develop. Another developer or
team member shall review the differences and approve the pull request.
Figure 6-51: A pull request. In this example I’m requesting to merge feature/FLEXFIPSGP-33 branch into
develop.
❑ After the pull request is approved, the developer shall merge the new commits. This way, the develop
is always a clean, stable version. The feature branches are reserved for each developer and they can
have unstable working versions (with frequent intermediate commits so that the work is not lost in
case of a crash).
❑ After a formal delivery of the code, the code is tagged and pushed from develop to master.
Figure 6-52: Git master, develop and “feature” branches. Each developer works in its feature branch. They
will pull the origin/develop branch to their local branch to fetch the latest changes. Afterwards the user
will commit his/her changes to his/her branch, push it to origin/feature branch, and request a pull
request. A different user will approve this request and the changes shall be merged to develop. Source:
researchgate.net
Command Action
git diff file Shows the differences of a given file with the version in the repository.
git checkout file Reverts back to the version in the repository, discards your local changes.
git add --force files If you want to add a file, for example a text file, that is ignored by the .gitignore,
you can force git to add it.
git add -A Adds all of the tracked changes (all the files marked in red).
In the .gitignore file provided with the sources ([EODP_GUI], section 5.2 “EODP Reference Code”), the files
excluded are NetCDF files (.nc), figures (.png), executable (.exe), logs and text (.log, .txt, .csv), etc.
END OF DOCUMENT