ISS LIS Lightning Flash Location Quickview using Python and GIS

The Lightning Imaging Sensor (LIS) onboard the International Space Station (ISS) retrieves optical lightning measurements over most of the 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. 

Data Recipe Type
Visualization
Supporting Software Information
TYPE ACCESS
Python Script ArcMap 10.2+
This data recipe uses the ISS LIS Provisional Science Data, however, this routine may be applied to the other ISS LIS data products offered by GHRC. More information and additional resources about this particular dataset can be accessed here.
 
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 captured lightning from the the 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 4th 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.
 

 

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 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.

Step 6

Within these data files, there are several variables available.  For this data recipes 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.

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.

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

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.

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.

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.

Step 9

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

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.

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.

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

Step 12

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

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”.  Then click “OK” to plot.

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

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.

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.

 

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://ghrc.nsstc.nasa.gov/hydro/?platform[0]=ISS&instrument[0]=LIS.
Dataset Name Non-Quality Controlled Lightning Imaging Sensor (LIS) on International Space Station (ISS) Provisional Science Data
Platform International Space Station (ISS)
Instrument Lightning Imaging Sensor (LIS)
Science Parameter Lightning flash location
Format NetCDF-4
Data Information Data information

 

Variable Description Dimension Units Scale Factor
lightning_flash_lat Latitude coordinate of lightning flash 1D degrees none
lightning_flash_lon Longitude coordinate of lightning flash 1D degrees none

 

Have you used our data? Register for updates