Obtaining dimensions from .nc4 files
-
- Posts: 6
- Joined: Tue Jun 25, 2024 1:33 pm America/New_York
Obtaining dimensions from .nc4 files
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 (91.08 KiB) Not viewed yet
-
- 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 (57.19 KiB) Not viewed yet
Filters:
-
- Subject Matter Expert
- Posts: 16
- Joined: Wed Mar 29, 2023 8:41 am America/New_York
Re: Obtaining dimensions from .nc4 files
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):
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:
-
- Posts: 6
- Joined: Tue Jun 25, 2024 1:33 pm America/New_York
Re: Obtaining dimensions from .nc4 files
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 (279.19 KiB) Not viewed yet
-
- Subject Matter Expert
- Posts: 16
- Joined: Wed Mar 29, 2023 8:41 am America/New_York
Re: Obtaining dimensions from .nc4 files
@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 and click download button, then select "Customize with Harmony" then select service .
To be continued...
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 and click download button, then select "Customize with Harmony" then select service .
To be continued...
-
- Subject Matter Expert
- Posts: 16
- Joined: Wed Mar 29, 2023 8:41 am America/New_York
Re: Obtaining dimensions from .nc4 files
... Then scroll down and click "Edit variables" to select variables:
Selecting what is needed and hit "Download Data" button. After that I got download links to the subset I ordered: .
To be continued...
.Selecting what is needed and hit "Download Data" button. After that I got download links to the subset I ordered: .
To be continued...
-
- Subject Matter Expert
- Posts: 16
- Joined: Wed Mar 29, 2023 8:41 am America/New_York
Re: Obtaining dimensions from .nc4 files
... Here is the list of variables in the files I downloaded
This seems OK, variables "latitude" and "longitude" are linear arrays of 500 elements as they should be in this case .
Please let me know if this sequence of steps leads you to a different result.
.This seems OK, variables "latitude" and "longitude" are linear arrays of 500 elements as they should be in this case .
Please let me know if this sequence of steps leads you to a different result.
-
- Posts: 6
- Joined: Tue Jun 25, 2024 1:33 pm America/New_York
Re: Obtaining dimensions from .nc4 files
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!
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!