OpenDrift / opendrift

Open source framework for ocean trajectory modelling
https://opendrift.github.io
GNU General Public License v2.0
247 stars 120 forks source link

Projection:None with lat/lon 2D coordinates #1142

Open simonesammartino opened 1 year ago

simonesammartino commented 1 year ago

Dear all I'm quite new in opendrift and it is literally revolutionizing my research. I love it! I'm using 2D curvilinear gridded current fields from MITgcm, and I'm using the reader_netCDF_CF_generic reader to read them. I had to write my own NetCDF file because the original files returned by the model are propietary binary format. I declared the longitude and latitude coordinate variables as 'longitude'/'latitude' as 'standard_name' and 'degree_east'/'degree_north' as units. When I call the reader, it returned the following:

Projection:
  `None`
Coverage: [pixels]
  xmin: 0.000000   xmax: 989.000000   step: 1   numx: 990
  ymin: 0.000000   ymax: 329.000000   step: 1   numy: 330
  Corners (lon, `lat):`
    ( -4.84,  36.53)  ( -3.97,  36.81)
    ( -4.71,  36.27)  ( -3.90,  36.40)

My first concern is about the "Projection: None", because I can't understand how to intepret it. I assume it is so because of the missing projection in the NetCDF file, but the fact is that I have NOT a projection, and my data are geographical lat/lon coordinates. Moreover, being a curvilinear grid, I have to specify coordinates as 2D matrices. Is this correct? Do I have to worry about the projection? My second concern is about the "Coverage [pixels]" output, because I assume I should read [degrees]. I'm afraid the latter is strictly related with the former. By the way, the size of the grids and its corners are correct. Before to read the reader output I also receive this warning: "No proj string or projection could be derived, using 'fakeproj'. This assumes that the variables are structured and gridded approximately equidistantly on the surface (i.e. in meters). This must be guaranteed by the user. You can get rid of this warning by supplying a valid projection to the reader." I realize it is only a warning, but I would like to understand its meaning and what I can do to avoid it.

On the other hand, in the reader performance log I read:

0:00:00.3  total
         0  preparing
 0:00:00.0  reading
 0:00:00.0  interpolation
 0:00:00.0  interpolation_time
 0:00:00.2  rotating vectors
         0  masking

As my grid is curvilinear, and velocity vectors are oriented along the curved cells of the grid, I had the doubt that the algorithm was trying to rotate velocities to obtain eastwards and northwards components. And, as I rotate them before to write the NetCDF file, I was afraid this could generated an incoherence. It seems not the case, because the vectors are correctly orientated, but, hence, what does "rotating vectors" means? It is the only process in reader performance log that takes some execution time. Can you explain how to interpret this output?

Sorry for the length of my question. Thank you in advance. Simone

knutfrode commented 1 year ago

We are glad that you are finding OpenDrift useful for your work.

Yes, with a curvilinear grid, lon/lat have to be 2D-matrices. The data are then not proiected on a regular grid, but OpenDrift uses bi-linear interpolation internally to map between lon,lat and array indices (row,column), in order to interpolate data to the particle positions. The warning about fakeproj sounds a bit more scary than it is, so we will modify it. Anyway, you can safely neglect it for now.

Regarding rotation of vectors, I believe in fact that vectors are assumed to be oriented along the curvilinear grid, as in your original data. If you use loglevel=0 you should see in the log some message about how many degrees the vectors are rotated to become east/north-oriented. You would like to see 0, as you already rotated your vectors to east/north. But you can then use eastward/northward instead of x/yin the standard_name in your files, e.g. eastward_sea_water_velocityinstead of x_sea_water_velocity, to avoid that vectors should be (erroneously) rotated once more.

simonesammartino commented 1 year ago

Dear knutfrode I'm used to use a lot of free scientific code/softwares/apps, and I'm member of many corresponding help desks/forum, but this is the first time in my life that anyone of the board manager reply to me in such a clear and useful way. Your software is great but your customer care service is even better! Thank you very much. Have a nice summer!