1. Jupyter Notebook Basics#

Bioscape

BioSCape, the Biodiversity Survey of the Cape, is NASA’s first biodiversity-focused airborne and field campaign that was conducted in South Africa in 2023. BioSCape’s primary objective is to study the structure, function, and composition of the region’s ecosystems, and how and why they are changing.

BioSCape’s airborne dataset is unprecedented, with AVIRIS-NG, PRISM, and HyTES imaging spectrometers capturing spectral data across the UV, visible and infrared at high resolution and LVIS acquiring coincident full-waveform lidar. BioSCape’s field dataset is equally impressive, with 18 PI-led projects collecting data ranging from the diversity and phylogeny of plants, kelp and phytoplankton, eDNA, landscape acoustics, plant traits, blue carbon accounting, and more

This workshop will equip participants with the skills to find, subset, and visualize the various BioSCape field and airborne (imaging spectroscopy and full-waveform lidar) data sets. Participants will learn data skills through worked examples in terrestrial and aquatic ecosystems, including: wrangling lidar data, performing band math calculations, calculating spectral diversity metrics, machine learning and image classification, and mapping functional traits using partial least squares regression. The workshop format is a mix of expert talks and interactive coding notebooks and will be run through the BioSCape Cloud computing environment.

Date: October 9 - 11, 2024 Cape Town, South Africa

Host: NASA’s Oak Ridge National Laboratory Distributed Active Archive Center (ORNL DAAC), in close collaboration with BioSCape, the South African Environmental Observation Network (SAEON), the University of Wisconsin Madison (Phil Townsend), The Nature Conservancy (Glenn Moncrieff), the University of California Merced (Erin Hestir), the University of Cape Town (Jasper Slingsby), Jet Propulsion Laboratory (Kerry Cawse-Nicholson), and UNESCO.

Instructors:

  • In-person contributors: Anabelle Cardoso, Erin Hestir, Phil Townsend, Henry Frye, Glenn Moncrieff, Jasper Slingsby, Michele Thornton, Rupesh Shrestha

  • Virtual contributors: Kerry Cawse-Nicholson, Nico Stork, Kyle Kovach

Audience: This training is primarily intended for government natural resource management agency representatives and field technicians in South Africa, as well as local academics and students, especially those connected to the BioSCape Team.

1.1. Overview#

This short tutorial introduces workshop participants to basic Jupyter Notebook functionality and creates a persistent NASA Earthdata login in each participant’s managed Hub environment.

1.1.1. This block is an example of Markdown#

  • double click on this cell to expose the markdown

  • Run a code block with shift enter, or the > symbol above

  • notice the single # that marks the Title

  • notice the markup around the # that adds formatting

  • add new lines with starting with ## and ### and see what happens

1.1.2. The next blocks are examples of running code. Hint, to run the code block, click the run arrow or SHIFT ENTER#

# here is a code block that runs a simple line of python
# print statements
print('Hello World')
Hello World
# assign a variable and print
num = 10
print(num)
10
num2 = 2
print(num + num2)
12

1.1.3. Import python modules#

1.1.3.1. Importing python modules is often a first step to scripting in the Python language.#

NumPy is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays.

# import python modules and libraries
import numpy as np
# create a basic array
arr = np.array([1, 2, 3, 4, 5])
print(arr)
print(type(arr))
[1 2 3 4 5]
<class 'numpy.ndarray'>

1.1.4. Earthaccess#

earthaccess is a python library that searches for and downloads or streams NASA Earth science data with just a few lines of code.

Bioscape

  • Here, We’ll use earthaccess to create a persistent login for your NASA Earthdata Login. Earthaccess is very helpful for accessing data in NASA Earthdata with a few lines of code.

import earthaccess 
# ask for EDL credentials and persist them in a .netrc file
earthaccess.login(strategy="interactive", persist=True)
<earthaccess.auth.Auth at 0x7f5647e8ea80>
# your earthdata login credentials will persist in the Hub where you created it

1.1.5. We’ll use earthaccess a few throughout the workshop#