Difference between revisions of "Interferometry in ISCE with ALOS Imagery"

From CUOSGwiki
Jump to navigationJump to search
Line 13: Line 13:
   
 
Please follow the link below to register for an Earth Data account now, or verify that you are registered:<br>
 
Please follow the link below to register for an Earth Data account now, or verify that you are registered:<br>
<center>'''Create an Earth Data Account:''' https://earthdata.nasa.gov/</center><br>
+
<center>'''Create an Earth Data Account:''' https://earthdata.nasa.gov/</center>
 
Once you have verified your account, you will be able to automatically download the data for this tutorial by running the getTutorialData.py script included in the GitHub repo. A copy of the script has been included below.
 
Once you have verified your account, you will be able to automatically download the data for this tutorial by running the getTutorialData.py script included in the GitHub repo. A copy of the script has been included below.
   
Line 24: Line 24:
 
</code>
 
</code>
 
This creates a .netrc file that stores your user credentials with special permissions so that they may only be accessed by certain methods. To learn more about this step, follow this [https://wiki.earthdata.nasa.gov/display/EL/How+To+Access+Data+With+cURL+And+Wget link].
 
This creates a .netrc file that stores your user credentials with special permissions so that they may only be accessed by certain methods. To learn more about this step, follow this [https://wiki.earthdata.nasa.gov/display/EL/How+To+Access+Data+With+cURL+And+Wget link].
  +
  +
<syntaxhighlight lang="python">
  +
# This script downloads the data from the Alaska Satellite Facility webpage that
  +
# be used in the "Interferometry in ISCE with ALOS Imagery" tutorial
  +
# author@allyplourde created on 12-08-2020 10:40:00
  +
  +
import os
  +
import isce_xml_configurations as getxmls
  +
  +
# setup the working directory:
  +
home_dir = os.path.join(os.getenv("HOME"), "Tutorial")
  +
PROCESS_DIR = os.path.join(home_dir, "Hawaii_ALOS1")
  +
DATA_DIR = os.path.join(PROCESS_DIR, "data")
  +
  +
  +
# read EarthData credentials from ~/.netrc file
  +
if (os.path.exists(os.path.join(os.getenv("HOME"), ".netrc"))):
  +
netrc_path = os.path.join(os.getenv("HOME"), ".netrc")
  +
count = len(open(netrc_path).readlines( ))
  +
if count == 1:
  +
file = open(os.path.join(os.getenv("HOME"), ".netrc"), "r")
  +
contents = file.read().split(" ")
  +
ASF_USER = contents[3]
  +
ASF_PASS = contents[5]
  +
file.close()
  +
else:
  +
ASF_USER = np.loadtxt(os.path.join(os.getenv("HOME"), ".netrc"), skiprows=1, usecols=1, dtype=str)[0]
  +
ASF_PASS = np.loadtxt(os.path.join(os.getenv("HOME"), ".netrc"), skiprows=1, usecols=1, dtype=str)[1]
  +
else:
  +
print("WARNING: The ASF USER pass needs to be included in ~/.netrc file.")
  +
print(" The ~/.netrc file does not exixt or is not setup properly.")
  +
print("Follow this link for instructions on setting up your ~/.netrc file")
  +
print("""If you wish to download the data from ASF please make sure:
  +
1) you have valid earthdata login and password stored in your ~/.netrc file
  +
2) make sure that you have logged into ASF vertex page and have accepted the EULA agreement.""")
  +
print("Without further actions you will still be able to run this notebook using already available data on S3 bucket.")
  +
print("Using data on S3 bucket ...")
  +
  +
# set up internal directories to keep data organized
  +
if not os.path.exists(PROCESS_DIR):
  +
print("create ", PROCESS_DIR)
  +
os.makedirs(PROCESS_DIR)
  +
else:
  +
print(PROCESS_DIR, " already exists!")
  +
  +
if not os.path.exists(DATA_DIR):
  +
print("create ", DATA_DIR)
  +
os.makedirs(DATA_DIR)
  +
else:
  +
print(DATA_DIR, " already exists!")
  +
  +
# change working directory to data directory to
  +
# prepare for file downloads
  +
os.chdir(DATA_DIR)
  +
  +
cmd = "wget https://datapool.asf.alaska.edu/L1.0/A3/ALPSRP265743230-L1.0.zip --user={0} --password={1}".format(ASF_USER, ASF_PASS)
  +
if not os.path.exists(os.path.join(DATA_DIR, "ALPSRP265743230-L1.0.zip")):
  +
os.system(cmd)
  +
else:
  +
print("ALPSRP265743230-L1.0.zip already exists")
  +
  +
cmd = "wget https://datapool.asf.alaska.edu/L1.0/A3/ALPSRP272453230-L1.0.zip --user={0} --password={1}".format(ASF_USER, ASF_PASS)
  +
if not os.path.exists(os.path.join(DATA_DIR, "ALPSRP272453230-L1.0.zip")):
  +
os.system(cmd)
  +
else:
  +
print("ALPSRP272453230-L1.0.zip already exists")
  +
</syntaxhighlight>
   
 
== Installation ==
 
== Installation ==

Revision as of 12:40, 8 December 2020

The Interferometric synthetic aperture radar Scientific Computing Environment (ISCE).

Note that this tutorial is only compatible with Linux and MacOS. ISCE is not currently supported on a Windows environment.

ISCE does not offer a Graphical User Interface([1]), which may be intimidating for some users. Although it is not necessary, some experience with the following tasks is recommended:

  1. Using the Command Line (Terminal)
  2. Setting up a Conda environment
  3. Writing and executing scripts in Python


Download the Data

ALOS is the "Advanced Land Observation Satellite" developed by JAXA. It has three remote sensing instruments on board, one of which is the Phased Array type L-band Synthetic Aperture Radar (PALSAR). Imagery from this sensor can be obtained freely from the Alaska Satellite Facility (ASF) with an Earth Data account.

Please follow the link below to register for an Earth Data account now, or verify that you are registered:

Create an Earth Data Account: https://earthdata.nasa.gov/

Once you have verified your account, you will be able to automatically download the data for this tutorial by running the getTutorialData.py script included in the GitHub repo. A copy of the script has been included below.

To run some of the function in ISCE, you will need a file on your computer that stores your Earth Data Account credentials. To do this, run the following commands, replacing YOURUSERNAME and YOURPASSWORD with your Earth Data login information:

 cd ~
 touch .netrc
 echo "machine urs.earthdata.nasa.gov login YOURUSERNAME password YOURPASSWORD " > .netrc
 chmod 0600 .netrc

This creates a .netrc file that stores your user credentials with special permissions so that they may only be accessed by certain methods. To learn more about this step, follow this link.

# This script downloads the data from the Alaska Satellite Facility webpage that
# be used in the "Interferometry in ISCE with ALOS Imagery" tutorial
# author@allyplourde created on 12-08-2020 10:40:00

import os
import isce_xml_configurations as getxmls

# setup the working directory:
home_dir = os.path.join(os.getenv("HOME"), "Tutorial")
PROCESS_DIR = os.path.join(home_dir, "Hawaii_ALOS1")
DATA_DIR =  os.path.join(PROCESS_DIR, "data")


# read EarthData credentials from ~/.netrc file
if (os.path.exists(os.path.join(os.getenv("HOME"), ".netrc"))):
    netrc_path = os.path.join(os.getenv("HOME"), ".netrc")
    count = len(open(netrc_path).readlines(  ))
    if count == 1:
        file = open(os.path.join(os.getenv("HOME"), ".netrc"), "r")
        contents = file.read().split(" ")
        ASF_USER = contents[3]
        ASF_PASS = contents[5]
        file.close()
    else:
        ASF_USER = np.loadtxt(os.path.join(os.getenv("HOME"), ".netrc"), skiprows=1, usecols=1, dtype=str)[0]
        ASF_PASS = np.loadtxt(os.path.join(os.getenv("HOME"), ".netrc"), skiprows=1, usecols=1, dtype=str)[1]
else:
    print("WARNING: The ASF USER pass needs to be included in ~/.netrc file.")
    print(" The ~/.netrc file does not exixt or is not setup properly.")
    print("Follow this link for instructions on setting up your ~/.netrc file")
    print("""If you wish to download the data from ASF please make sure: 
             1) you have valid earthdata login and password stored in your ~/.netrc file
             2) make sure that you have logged into ASF vertex page and have accepted the EULA agreement.""")
    print("Without further actions you will still be able to run this notebook using already available data on S3 bucket.")
    print("Using data on S3 bucket ...")

# set up internal directories to keep data organized
if not os.path.exists(PROCESS_DIR):
    print("create ", PROCESS_DIR)
    os.makedirs(PROCESS_DIR)
else:
    print(PROCESS_DIR, " already exists!")

if not os.path.exists(DATA_DIR):
    print("create ", DATA_DIR)
    os.makedirs(DATA_DIR)
else:
    print(DATA_DIR, " already exists!")

# change working directory to data directory to
# prepare for file downloads
os.chdir(DATA_DIR)

cmd = "wget  https://datapool.asf.alaska.edu/L1.0/A3/ALPSRP265743230-L1.0.zip --user={0} --password={1}".format(ASF_USER, ASF_PASS)
if not os.path.exists(os.path.join(DATA_DIR, "ALPSRP265743230-L1.0.zip")):
    os.system(cmd)
else:
    print("ALPSRP265743230-L1.0.zip already exists")

cmd = "wget  https://datapool.asf.alaska.edu/L1.0/A3/ALPSRP272453230-L1.0.zip --user={0} --password={1}".format(ASF_USER, ASF_PASS)
if not os.path.exists(os.path.join(DATA_DIR, "ALPSRP272453230-L1.0.zip")):
   os.system(cmd)
else:
   print("ALPSRP272453230-L1.0.zip already exists")

Installation

A Conda environment will be used to manage software dependencies so the user must only be concerned with having Anaconda installed on their computer. Click here for instructions on installing Anaconda. Once Anaconda is installed, open a new terminal and enter the command:

conda init

this sets up a base Anaconda environment that will allow you to access certain commands and libraries directly from the command line.


Download the Conda environment: ISCE-2 has a number of dependencies and highly is susceptible to versioning conflicts. By using a virtual environment, the packages (and their versions) will be uploaded to a separate space on your computer rather than in the root file. An environment configured for ISCE-2 has been uploaded to the Anaconda cloud, to create this environment locally, execute the following command:

conda env create allyplourde/ISCE2

Shortly after running the command, you should see packages beginning to be installed one by one.

01-createEnvironment.jpg

This step may take a while to complete. While waiting, here is something interesting to look at... something interesting here

Once the installation is complete, the environment must be activated.

02-createEnvironment.jpg

After sending the following command

conda activate ISCE-2

you can observe that the <ISCE-2> environment is pre-pended to your working directory path.

03-activateEnvironment.jpg

Creating the ISCE-2 Conda environment has already taken care of its installation as well as setting some global variables. To confirm ISCE-2 has been successfully installed, use this echo command:

echo $ISCE_HOME

This should output the path to the folder where isce-2 has been installed

04-homeVariable.jpg

Finally, to test the installation, run the following command: python $ISCE_HOME/applications/stripmapApp.py --help This will output information about the stripmapApp python application including a description and configuration guidelines.