Open Jinta0Li opened 3 months ago
Hi Jintao,
From the print of the file contents it is clear that the axes of the data sets are reversed from the recommendations in the CF Metadata Conventions. While the file does not claim to adhere to the CF conventions, most software for reading netCDF files does. That apparently includes GDAL library, which reads the file for terra
. It does manage to identify the axes for variables mask
and twsa_baseline
, probably by their names, but the 3D variables twsa
and uncertainty
have a time
dimension which is apparently complicating things too much.
It does not stop there. The unit of degrees
for the longitude
and latitude
dimensions should not be used, but rather degrees_east
and degrees_north
, respectively, as per the CF conventions.
The time unit of Modified Julian Date
is also not standard and not described in the readme.txt
file. The values obviously represent days from some baseline date but beyond that it's a mystery. Successive data points are mostly around 30 days apart, but it ranges from 11 to 370! From the readme.txt
file it is clear that these are months but what are "the 216 valid months when official GRACE(-FO) products are avaliable"?
You can load the data into terra
by using ncdf4
to read the arrays of the variables, transpose and flip the arrays as required, and then do terra::rast()
on each array. For the time
dimension I would suggest that you reach out to the authors of the data set to understand how to map the dimensions values to the "216 valid months".
Hello,
I have encountered an issue with the
terra
package while trying to read a NetCDF file. The file in question can be downloaded from the following link: https://doi.org/10.3929/ethz-b-000648738.When using
terra::rast()
to read the NetCDF file, the function does not correctly interpret the file's structure. Specifically:**1.
terra::rast()
identifies only 2 variables in the file, whereas thencdf4::nc_open()
function correctly identifies 4 variables.ncdf4::nc_open()
shows that the file includes a time dimension, butterra::rast()
does not recognize the time dimension at all.**For your reference, here is the code I used to read the file with both packages:
and here are the results:
Could you please investigate this issue or provide guidance on how to correctly read this NetCDF file using the
terra
package?Thank you for your attention and assistance.
Best regards,
Jintao