Obtaining dimensions from .nc4 files

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
shrinidhin9
Posts: 6
Joined: Tue Jun 25, 2024 1:33 pm America/New_York
Answers: 0

Obtaining dimensions from .nc4 files

by shrinidhin9 » Mon Aug 05, 2024 12:25 pm America/New_York

I have been working with the subsetted .nc4 files for NO2 data from TEMPO, last downloaded from NASA Earthdata on 08/01/2024. I selected the region I wanted data for, but when I download and extract the data the dimensions just show up as arrays of integers from 0 to 68 and 0 to 42 (latitude and longitude, respectively). I would like to know how to access the latitude and longitude coordinates that I've selected, and if I'm missing an important step when subsetting or accessing this data. I've attached a few screenshots from NASA Earthdata and the opened file in VSCode via Python.
Attachments
Screenshot 2024-08-05 at 9.12.50 AM.png
Screenshot 2024-08-05 at 9.12.50 AM.png (91.08 KiB) Not viewed yet
Screenshot 2024-08-05 at 9.12.42 AM.png
Screenshot 2024-08-05 at 9.12.42 AM.png (128.12 KiB) Not viewed yet
Screenshot 2024-08-05 at 9.11.59 AM.png
Screenshot 2024-08-05 at 9.11.59 AM.png (57.19 KiB) Not viewed yet

Filters:

ASDC - alexrad71
Subject Matter Expert
Subject Matter Expert
Posts: 16
Joined: Wed Mar 29, 2023 8:41 am America/New_York
Answers: 0

Re: Obtaining dimensions from .nc4 files

by ASDC - alexrad71 » Tue Aug 06, 2024 1:15 pm America/New_York

Hello shrinidhin9, the confusing part of your question is in variable selection. I believe that group/variable tree should look differently. Here is what I see (I played with both V01 and V03 versions on TEMPO_NO2_L2 product, they look the same with this respect):
Clipboard_08-06-2024_01.jpg
Clipboard_08-06-2024_01.jpg (317.92 KiB) Not viewed yet
You need to open "geolocation" group (folder) and select latitude, longitude, and whatever else is necessary. Here is how the outcome of my subset looks like in HDFView:
Clipboard_08-06-2024_02.jpg
Clipboard_08-06-2024_02.jpg (76.11 KiB) Not viewed yet

shrinidhin9
Posts: 6
Joined: Tue Jun 25, 2024 1:33 pm America/New_York
Answers: 0

Re: Obtaining dimensions from .nc4 files

by shrinidhin9 » Tue Aug 06, 2024 1:25 pm America/New_York

I can't see the images you've attached, but when I open the geolocation folder to select variables, the only ones I see are relative_azimuth_angle, solar_zenith_angle solar, and viewing_zenith_angle. I've attached a screenshot of my variables options below. Thus I'm not sure what's wrong with the way I'm accessing the data.
Attachments
Screenshot 2024-08-06 at 10.23.52 AM.png
Screenshot 2024-08-06 at 10.23.52 AM.png (279.19 KiB) Not viewed yet

ASDC - alexrad71
Subject Matter Expert
Subject Matter Expert
Posts: 16
Joined: Wed Mar 29, 2023 8:41 am America/New_York
Answers: 0

Re: Obtaining dimensions from .nc4 files

by ASDC - alexrad71 » Tue Aug 06, 2024 4:00 pm America/New_York

@shrinidhin9, it was not clear from your original post that you are using L3 (gridded) data. The structure of the L3 data differs from that of L2 I used. That is why you do not see latitudes and longitudes in geolocation group.

Going back to the issue. I search for TEMPO_NO2_L3_V03 collection in the EarthData and select the following region (rectangle) of interest: 30N to 40N, 120W to 110W, here is the https://search.earthdata.nasa.gov/search/granules?p=C2930763263-LARC_CLOUD!C2930763263-LARC_CLOUD&pg[1][a]=3185429511!3185378095!LARC_CLOUD&pg[1][v]=t&pg[1][gsk]=-start_date&q=TEMPO_NO2_L3_V03&sb[0]=-120%2C30%2C-110%2C40&tl=1722966442!3!!&lat=35.14745390128212&long=-122.85193328481526&zoom=5.
Picking up first two granules
Clipboard_08-06-2024_03.jpg
Clipboard_08-06-2024_03.jpg (373.23 KiB) Not viewed yet
and click download button, then select "Customize with Harmony"
Clipboard_08-06-2024_04.jpg
Clipboard_08-06-2024_04.jpg (72.96 KiB) Not viewed yet
then select service
Clipboard_08-06-2024_05.jpg
Clipboard_08-06-2024_05.jpg (134.72 KiB) Not viewed yet
.
To be continued...

ASDC - alexrad71
Subject Matter Expert
Subject Matter Expert
Posts: 16
Joined: Wed Mar 29, 2023 8:41 am America/New_York
Answers: 0

Re: Obtaining dimensions from .nc4 files

by ASDC - alexrad71 » Tue Aug 06, 2024 4:11 pm America/New_York

... Then scroll down and click "Edit variables" to select variables:
Clipboard_08-06-2024_06.jpg
Clipboard_08-06-2024_06.jpg (102.72 KiB) Not viewed yet
.
Selecting what is needed
Clipboard_08-06-2024_07.jpg
Clipboard_08-06-2024_07.jpg (82.19 KiB) Not viewed yet
and hit "Download Data" button. After that I got download links to the subset I ordered:
Clipboard_08-06-2024_09.jpg
Clipboard_08-06-2024_09.jpg (92.51 KiB) Not viewed yet
.
To be continued...

ASDC - alexrad71
Subject Matter Expert
Subject Matter Expert
Posts: 16
Joined: Wed Mar 29, 2023 8:41 am America/New_York
Answers: 0

Re: Obtaining dimensions from .nc4 files

by ASDC - alexrad71 » Tue Aug 06, 2024 4:21 pm America/New_York

... Here is the list of variables in the files I downloaded
Clipboard_08-06-2024_10.jpg
Clipboard_08-06-2024_10.jpg (73.83 KiB) Not viewed yet
.

This seems OK, variables "latitude" and "longitude" are linear arrays of 500 elements as they should be in this case
Clipboard_08-06-2024_11.jpg
Clipboard_08-06-2024_11.jpg (138.41 KiB) Not viewed yet
.

Please let me know if this sequence of steps leads you to a different result.

shrinidhin9
Posts: 6
Joined: Tue Jun 25, 2024 1:33 pm America/New_York
Answers: 0

Re: Obtaining dimensions from .nc4 files

by shrinidhin9 » Thu Aug 08, 2024 11:06 am America/New_York

I was able to access the latitude and longitude when I didn't specify the group when opening the .nc4 file.

So I did

no2obj1 = 'TEMPO_NO2_L3_V03_20240708T151622Z_S007_subsetted.nc4'
no2data1 = xr.open_dataset(no2obj1, group = 'product')
no2data1 = no2data1['vertical_column_troposphere'].values

no2coords1 = xr.open_dataset(no2obj1)
lat = no2coords1.coords['latitude'].values
lon = no2coords1.coords['longitude'].values

Opening the file twice seemed to be the most straightforward solution for me to access the latitude and longitude values. Thank you for your help!

Post Reply