Skip to main content

Description

The Lightning Imaging Sensor onboard the International Space Station (ISS LIS) retrieves optical lightning measurements over most of Earth. This Python-based data recipe steps the user through code that compiles information from a series of ISS LIS datafiles in a directory and generates a gridded heat map plot of lightning flash locations and a CSV file containing the location coordinates. This data recipe enables the visualization of lightning flash locations across several user-selected ISS LIS swath data files, accumulates flashes within a Python plot, and creates a CSV file with locations to enable use with other software. For this data recipe, the CSV file will be used to plot lightning flash locations in ESRI ArcMap. 

How to Use

This data recipe uses the ISS LIS Provisional Science Data. However, this routine may be applied to the other ISS LIS data products. Note that Non-Quality Controlled Lightning Imaging Sensor (LIS) on International Space Station (ISS) Provisional Science Data have been retired now that science data are available.
 
This data recipe is available as a Python script. To run the Python script, please install the following Python package: numpy, matplotlib, basemap and netCDF4.

Step 1

Follow the location link on this page to access the GHRC DAAC data-recipe GitLab folder and obtain the ISS LIS Lightning Flash Location Quickview Python script titled "ISS_LIS_FlashLoc_Quickview.py"
 
You can preview the script by clicking the file name. To download, select the green “Clone or download” button located on the right side of the webpage to download the script as a zipped file or to open on your desktop. Save the file to a desired folder location on your computer. You may also directly copy the script from the GitHub preview and paste in within your Python environment.

Step 2

Open the Python environment installed on your computer and make sure the required Python packages outlined in the “How to Use” section are installed. 

Navigate to the location on your computer where the data recipe Python file is saved and open the file within your Python environment. If you have copied the script, paste it within a new Python file.

Step 3

To download the data needed for this data recipe, a free NASA Earthdata user account is required. If you do not have an account, you will first need to create one.

Once your NASA Earthdata account has been created, you can download the ISS LIS netCDF-4 data files directly here.  Simply follow this link to enter your account information, select and download the data files of your choice. Save these files to a desired location on your computer.
 
For this data recipe, we focus on January 4, 2018, because the data capture lightning from a bombogenesis winter weather event along the U.S. East coast. Since ISS LIS data files represent individual swaths collected within a day, all data files generated for January 4 were downloaded for this data recipe (shown in the image below). This Python code can handle plotting one data file, or many collected over a time period of your choosing.
list of data files
Image Caption

ISS LIS data files generated for January 4, 2018.

Step 4

Navigate to the folder on your computer where you saved the ISS LIS netCDF-4 data files. From the address bar copy the file path as shown below.
 
Paste the file path within the quotation marks for the variable “dataDir” highlighted in blue below. For Python, the backslashes need to be changed to forward slashes. At the end of the file path, make sure to add a “/”.
step 4 computer code

Step 5

This data recipe will also generate a CSV file of lightning flash locations to use within other software. For the variable “csvfile”, define the full file path to where you want to save this file on your computer along with its associated name. This Python script will create a file in this directory using the name you defined.

string of computer code

Step 6

Within these data files, there are several variables available. For this data recipe we use the “lightning_flash_lat” and “lightning_flash_lon” variables, which contain the the latitude and longitude coordinates of ISS LIS detected lightning flash locations. This script goes to the file directory where the ISS LIS data files are stored, loops through each file, and pulls out the latitude and longitude flash location coordinates. These values are appended or added onto two arrays (flash_lat and flash_lon) so that all lightning flash locations are collected within one location, not spread across several files. The image below shows the code section that performs this task.

string of Python code for ghrc recipe
Image Caption

If you would like to augment the code and extract other variables, you can change the data variables shown in red.

Step 7

Once these values are extracted, the next portion of the code generates the CSV file. If you do not want to generate a file, simply comment out this portion of the code as shown.

image of python code

To change the header names of the columns, change the text highlighted in blue below to a header name of your choosing.

image of python code

The next line of code defines what data variables will be included in the CSV file. For this example we use the flash_lat and flash_lon array containing the extracted flash location coordinates.

image of python code

Step 8

The last section of the code formats a hexagrid heat map plot of flash locations. In this example, a hexbin is used to identify all flash locations that fall within a user defined hexgrid size. In the final plot, each hexgrid represent a total count of flashes occurring within a specific “area” or bin size. To adjust the hexgrid size, simply adjust the the gridsize highlighted below.

lines of python code

Take special note to remember to rename the “plt.title” and “cbar.set_label” variables in the lines highlighted in blue below to insure you are representing the plot and variable units appropriately.

lines of python code

Step 9

To plot the image, simply run the code and the generated plot shown below should appear.

step 9 global image with colors indicating lighting strikes

Step 10

Once the code is run, navigate to the file on your computer where the CSV file was created. In Excel, the CSV file should look similar to the image below.

step 10 table with numbers

This file may be used to plot the flash locations in other software. For this data recipe we will demonstrate plotting it in ArcMap. Close the CSV file.

Step 11

Open your ArcMap Desktop application. For this tutorial, ArcMap 10.2 was used. Click the add data button to add the CSV file as shown.

screenshot of arc gis interface

Navigate to the location on your computer where the CSV file is stored. Double click the file to add it as a table layer.

screenshot of files in a program

Step 12

To plot the coordinates in the file, right click the flash location table layer and select “Display XY Data”.

screenshot of file path

A “Display XY Data” window will open. The “X Field” and “Y Field” should auto populate. Double check the fields and use the drop downs to set the “X Field”  to “flash_lon” and the “Y Field” to “flash_lat”.  Click “OK” to plot.

screenshot of data interface

A window will pop up that reads “Table Does Not Have Object-ID Field”.  Click “OK”.

screenshot of box saying table does not have image object

The points should show up plotted in ArcMap.

Step 13

To save the flash locations as a shapefile, right click on the flash location data layer then select “Export Data” and save out the file to a desired location.

screenshot showing file path

The ISS LIS lighting flash locations should plot similar to the below map. You may then use these points for other types of analysis and map making.

global map with orange dots indicating lighting strikes
This Python script may be reused and altered as needed to plot additional data variables not used in this example.  
 
The following GHRC ISS LIS data products in netCDF-4 format may be used with this data recipe: https://search.earthdata.nasa.gov/portal/ghrc/search?fi=LIS!ISS&as[instrument][0]=ISS.

Details

Last Updated

Published on

Data Centers

Global Hydrometeorology Resource Center DAAC (GHRC DAAC)