Page 1 of 1
Obtaining dimensions from .nc4 files
Posted: Mon Aug 05, 2024 12:25 pm America/New_York
by shrinidhin9
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.
Re: Obtaining dimensions from .nc4 files
Posted: Tue Aug 06, 2024 1:15 pm America/New_York
by ASDC - alexrad71
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 (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 (76.11 KiB) Not viewed yet
Re: Obtaining dimensions from .nc4 files
Posted: Tue Aug 06, 2024 1:25 pm America/New_York
by shrinidhin9
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.
Re: Obtaining dimensions from .nc4 files
Posted: Tue Aug 06, 2024 4:00 pm America/New_York
by ASDC - alexrad71
@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 (373.23 KiB) Not viewed yet
and click download button, then select "Customize with Harmony"

- Clipboard_08-06-2024_04.jpg (72.96 KiB) Not viewed yet
then select service

- Clipboard_08-06-2024_05.jpg (134.72 KiB) Not viewed yet
.
To be continued...
Re: Obtaining dimensions from .nc4 files
Posted: Tue Aug 06, 2024 4:11 pm America/New_York
by ASDC - alexrad71
... Then scroll down and click "Edit variables" to select variables:

- Clipboard_08-06-2024_06.jpg (102.72 KiB) Not viewed yet
.
Selecting what is needed

- 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 (92.51 KiB) Not viewed yet
.
To be continued...
Re: Obtaining dimensions from .nc4 files
Posted: Tue Aug 06, 2024 4:21 pm America/New_York
by ASDC - alexrad71
... Here is the list of variables in the files I downloaded

- 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 (138.41 KiB) Not viewed yet
.
Please let me know if this sequence of steps leads you to a different result.
Re: Obtaining dimensions from .nc4 files
Posted: Thu Aug 08, 2024 11:06 am America/New_York
by shrinidhin9
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!