How to Extract Chlorophyll-a data in Level-3 Binned AQUA-MODIS (Netcdf4) Files that are Packed by SCAN Lines of the MODIS instrument #10178
Replies: 1 comment
-
This gave me a chuckle. You're nowhere near the right place to be asking about science things. This is the Discussions area for typescript-eslint, a project in the JavaScript/TypeScript tooling ecosystem. Good luck with your science. 🔬 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Issue
I downloaded AQUA-MODIS netcdf files (total = 3422) for chlorophyll-a from the Earthdata website from 2012 to 2024 for The Northern Red Sea, Egypt.
I need to:
I tried using packages such as ncdf4, terra, raster, and RNetCDF without any success (see my efforts below). I've also tried looking for solutions on Stackoverflow and did some troubleshooting with suggestions from ChatGPT and nothing has worked. I really don't understand how find a solution.
Here's the manifest.txt link to get the data (expires Oct 22nd 2024)
https://oceandata.sci.gsfc.nasa.gov/cgi/getfile/requested_files_2.tar?h=ocdist410&p=/data1/d0703031e30f7f6f/requested_files
Read the files into R:
Loop through all the file paths and the AQUA MODIS netcdf4 files to gain access to them:
Contents of one of the AQUA MODIS files
Attempts to Stack the netcdf files:
Attempt 1:
Error Message
Attempt 2:
Error Message:
Attempt 3:
Error Message
IMPORTANT INFORMATION
I got an answer to my Stackover flow question:
https://stackoverflow.com/questions/79104406/creating-a-spatraster-with-multiple-aqua-modis-netcdf-files-with-the-function
These are "level-3 binned" data. That means that the data are packed by scan lines of the MODIS instrument. Neither terra nor raster will read that, and even ncdf4 reports an error. The only package that I know of that will open the files without error is ncdfCF but even that won't recognise the data set contained in each file. You can, however, read out the raw data and then process it yourself.
library(ncdfCF)
(chl <- open_ncdf(files))
AQUA_MODIS.20030101.L3b.DAY.CHL
Resource : /my_data_dir/AQUA_MODIS.20030101.L3b.DAY.CHL.nc
Format : netcdf4
Conventions: CF-1.6 ACDD-1.3
Keep open : FALSE
Has groups : TRUE
(vars <- chl$root$unused())
I KEEP ON GETTING AN ERROR WHEN I RUN THIS LINE OF CODE AND THIS IS WHERE I'M STUCK
Error: attempt to apply non-function
Many thanks in advance if anyone can help
Desired Output from the answer in my Stackoverflow question:
$
level-3_binned_data.BinList
[0] BinList
Group : /level-3_binned_data
Data type : binListType
Dimension ids: 0
$
level-3_binned_data.chlor_a
[1] chlor_a
Group : /level-3_binned_data
Data type : binDataType
Dimension ids: 1
$
level-3_binned_data.BinIndex
[2] BinIndex
Group : /level-3_binned_data
Data type : binIndexType
Dimension ids: 2
Reading the data
library(RNetCDF)
d <- var.get.nc(vars[[1]]$group$handle, vars[[1]]$name)
str(d)
List of 5
$ bin_num : num [1:2402743(1d)] 260315 262125 262126 263933 263934 ...
$ nobs : num [1:2402743(1d)] 1 2 2 7 6 9 3 1 1 3 ...
$ nscenes : num [1:2402743(1d)] 1 1 1 2 3 3 3 1 1 1 ...
$ weights : num [1:2402743(1d)] 1 1.41 1.41 3.73 4 ...
$ time_rec: num [1:2402743(1d)] 3.16e+08 6.31e+08 6.31e+08 2.21e+09 1.89e+09 ...
Beta Was this translation helpful? Give feedback.
All reactions