LANCE NRT AMSR2 L2B Global Swath Rain Ocean Data Quickview using Python and GIS

The LANCE Near Real-Time (NRT) AMSR2 Level 2B Global Swath Rain Ocean Data include surface precipitation, wind speed over ocean, water vapor over ocean, and cloud liquid water over ocean retrieved from measurements of the Advanced Microwave Scanning Radiometer 2 (AMSR2) instrument on the Global Change Observation Mission - Water 1 (GCOM-W1). These rain and ocean products were created using the Goddard Space Flight Center (GSFC) PROFiling algorithm (GPROF) 2010 version 2 by the Land Atmosphere Near real-time Capability for EOS (LANCE) at the AMSR Science Investigator-led Processing System (AMSR SIPS). This Python-based data recipe steps the user through code that compiles information from a series of NRT AMSR2 Swath data files and generates a CSV file containing surface precipitation rates with locations to enable use with other software. For this data recipe, the CSV file will be used to plot surface precipitation rates in ESRI ArcMap.

Data Recipe Type
Data Format ConversionData Visualization
Supporting Software Information
TYPE ACCESS
Python Script Open Source
ArcMap 10.2+ Restricted, license required

This data recipe uses the LANCE NRT AMSR2 L2B Global Swath Rain Ocean Data. 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 under Python 2.7, please install the following Python package: numpy, tables, and csv.

Step 1

Follow the location link on this page to access the GHRC DAAC data-recipe GitLab folder and obtain the LANCE NRT AMSR2 L2B Global Swath Quickview Python script titled “LANCE_NRT_AMSR2_SurfacePrecip_Quickview.py

You can preview the script by clicking the file name. To download, select the  “Download” button located on the top right side of the webpage to download the script as a 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 it 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 LANCE NRT AMSR2 L2B Global Swath Rain Ocean data in HDF-EOS5 format directly here.  Simply follow this link to enter your account information, select and download the data files of your choice.  Save these data files to a desired location on your computer.

Step 4

Navigate to the folder on your computer where you saved the LANCE NRT AMSR2 L2B Global Swath Rain Ocean data files. From the address bar copy the file path and paste the file path within the quotation marks for the variable “dataDir”.  For Python, the backslashes need to be changed to forward slashes.  At the end of the file path, make sure to add a “/”. A Python list of strings named 'files' is created with the data file name(s). Multiple data files can be used. For this data recipe, we use one single data file (‘AMSR_2_L2_RainOcean_R00_201812312341_D.he5’) which represents a swath data collected on December 31, 2018.

Step 5

Within these data files, there are several variables available. For this data recipe we use the ‘surfacePrecipitation’, ‘QualityFlag’, ‘pixelStatus’, ‘Latitude’, and ‘Longitude’. All these variables are organized in two-dimensional data arrays (n_track, n_xtrack), where the first dimension ‘n_track’ is the number of pixels in the along-track direction, and ‘n_xtrack’ the number of pixels in the cross-track direction. This script goes to the file directory where the LANCE NRT AMSR2 L2B Global Swath Rain Ocean data files are stored, loops through each file, and pulls out these variables.

Step 6

Then this script checks the ‘QualityFlag’ and ‘pixelStatus’ values for each data pixel. If QualityFlag = 0 (good retrieval), pixelStatus = 0 (valid pixel), and surfacePrecipitation > 0, we create a three-key dictionary (‘lon’,’lat’,’sfc_precip’) and add this dictionary to the list ‘dict_list’:

Step 7

Once these values are extracted, the next portion of the code generates the CSV file of surface precipitate rates with location information to use within ArcMap or other software. For the variable “output_csv_file”, 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 8

Once the Python code is run, navigate to the folder 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 surface precipitation rates in ArcMap or other software. For this data recipe we will demonstrate plotting it in ArcMap. Close the CSV file.

Step 9

Open ArcMap 10.2 on your computer. First, you will have to define the coordinate system to use for your plot. In the “Table of Contents” window on the left side of your screen you will see a “Layers” icon which represents the data frame that you are working in.

Right-click this icon and select “Properties” at the bottom of the dropdown list. Navigate to the “Coordinate System” tab in the “Data Frame Properties” window.

Here is where you can select your coordinate system. Click the “+” sign next to the coordinate system folder, navigate to the desired system, select it, and click “OK”. In this example, we used the Geographic Coordinate System “WGS 1984”

Step 10

Now that you have a coordinate system, you can begin to plot the points from the CSV file. Select the Add Data button   on the taskbar located at the top of the window. This will open the “Add Data” dialog box. Here, you can select the files that you would like to add to your map. When first accessing a folder, you will have to create a path for it. Select the “Connect To Folder” button  and navigate to the folder containing the “AMSR2_NRT_L2B_swath_20181231.csv” file that you created earlier. After you select the folder, a path is created and you can now access the files within the folder.

Step 11

Inside the folder, you should see your CSV file. After selecting this file, click the “Add” button. The CSV file will now show up as a map layer in the “Table of Contents” window.

Step 12

Now it is time to plot the points on your map. To begin, right-click the CSV layer and select “Display XY Data”.

A dialog box will open where the user can select which columns of the CSV file will function as the x, y, and z fields to be plotted on the map.  Here is where you will input latitude and longitude as the x and y-coordinates for location and the surface precipitation as the z-coordinate, indicating the precipitation value at that point.

Step 13

Match each field to the following settings using the dropdown menus located to their right: for “X Field” select the “lon” column,  for “Y Field” select the “lat” column, and for “Z Field” select the “sfc_precip” column.

Click “OK” to plot. You will get a popup message notifying you that your table does not include an “Object-ID” field, so you will not have functionalities like selecting or querying the points as features. You can click “OK” for now since you are just plotting the points but steps on how to export this layer to a shapefile will be shown later in this recipe.

You will now see the points plotted in the window, as shown in the image below, and the title of this layer “AMSR2_NRT_L2B_swath_20181231.csv Events” will be displayed in the “Table of Contents” pane.

Step 14

You can add a basemap underneath your plotted points to provide a reference for the point locations. Click the dropdown arrow on the “Add Data” button  and select “Add Basemap”. Select the basemap style that you prefer. Here, we chose the “Light Gray Canvas” style. Lastly, click the the “Add” button to add this layer to the map. The final plot should appear like the image shown below.

Step 15

You can view the attribute table for the layer by right-clicking the layer titled “AMSR2_NRT_L2B_swath_20181231.csv Events” and selecting “Open Attribute Table” near the top of the drop down menu.

Here you can view the latitude, longitude, and surface precipitation value for each point.

The “AMSR2_NRT_L2B_swath_20181231.csv Events” layer is displayed, but it has not been saved. There are a few options to save including saving it as a layer file or exporting the data as a shapefile or feature class. Here, we will show you how to export the data as a shapefile.

Step 16

First, right click the “AMSR2_NRT_L2B_swath_20181231.csv Events” layer and navigate down to “Data” in the dropdown menu. In the “Data” dropdown menu, select “Export Data” as seen below.

This will open the “Export Data” dialog box where you can select which coordinate system you would like the shapefile to have and the output path.

Here, we chose to use the same coordinate system as “the data frame”.

Step 17

To create the file path and name, click the “Browse” icon . In the “Look in:” dropdown menu, make sure the correct path is set to save your file to. Next, in the “Save as type:” dropdown menu near the bottom of the window, select “Shapefile” as the type. Lastly, enter the name that you would like to give the shapefile and click “Save”.

This will bring you back to the “Export Data” window where you can click “OK” to create the shapefile.
You now have a shapefile that includes all of the data for your points. In the shapefile’s attribute table (right click the shapefile and select “Open Attribute Table”) each of the points now has a unique identifier (FID). This allows for more functionality like selecting specific points using the “Select Features” tool   as shown below.

Dataset Name NRT AMSR2 L2B Global Swath GSFC Profiling Algorithm 2010: Surface Precipitation, Wind Speed over Ocean, Water Vapor over Ocean and Cloud Liquid Water over Ocean
Platform Global Change Observation Mission - Water 1 (GCOM-W1)
Instrument Advanced Microwave Scanning radiometer 2 (AMSR2)
Science Parameter Surface Precipitation, Wind Speed over Ocean, Water Vapor over Ocean, Cloud Liquid Water over Ocean
Format HDF-EOS5
Data Information Data information

 

Variable Description Data Type Units NoData Value
Latitude Latitude Float32 degrees north N/A
Longitude Longitude Float32 degrees east N/A
SurfacePrecipitation The instantaneous total precipitation rate at the surface for each pixel. Check pixelStatus for a valid retrieval. Float32 mm hr-1 -9999.9
QualityFlag

Indicates the generalized quality of the retrieved pixel. Valid values include:

0 - High quality (retrieval is good);

1 - Medium quality (use with caution);

2 - Low quality (recommended qualitative use only)

Int8 N/A -99
PixelStatus

If there is a retrieval at a given pixel, variable explains:

0 - Valid Pixel;

1 - Boundary error in land mask;

2 - Boundary error in sea-ice check;

3 - Boundary error in sea surface temperature;

4 - Invalid time;

5 - Invalid latitude/longitude;

6 - Invalid brightness temperature;

7 - Invalid sea surface temperature;

8 - No retrieval due to sea-ice over water;

9 - No retrieval due to sea-ice over coast;

10 - Land/coast screens not able ot be applied;

11 - Failure in ocean rain - no match with database profile TBs

Int8 N/A N/A

 

Have you used our data? Register for updates