ISS LIS Lightning Flash Location Quickview using Python 2.7 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 |
TYPE | ACCESS | ||
---|---|---|---|
Python 2.7 Script | ArcMap 10.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.
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.
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.
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.
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.
To plot the image, simply run the code and the generated plot shown below should appear.
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.
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.
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.
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.
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 |