New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding projection to ROMS native reader #1130
Comments
Hi, Inserting projection information inside the reader code will have uncontrolled implication, and here leads to error. I believe instead the problem is that the Note that the LCS/FTLE methods are quite experimental, and should probably be moved outside of OpenDrift, as a wrapper/postprocessor functionality. |
Hi @knutfrode If used "as is" the reader will use the
In our case ROMS grid is provided as 2D arrays (like the example netcdf file) If grid cell dimensions are NOT consistent across the grid, it seems we cant actually provide a projection to the ROMS reader even if we wanted to. Passing
Keen to hear your thoughts |
Hi, I believe this is fine for all practical purposes. |
Thanks for the clarification @knutfrode |
@knutfrode I'm still confused about whether I should be inputting a proj4 string to the ROMS reader. It looks like if I were to do this, then it would save time calculating the "interpolator for lon,lat to x,y conversion", which I would like to avoid doing to save time, if possible. However, I cannot input "proj4" to the ROMS reader. Should I add this as an optional input to the ROMS reader or was it intentionally removed as an option? |
According to the docstring it seems one can provide proj4-string to the reader, but this is a recent mistake when the docstring was copied from reader_netCDF_CF_generic: If a proj4-string were to be used, the file would also need to contain X- and Y-coordinates. But I believe in this case it would anyway be better to use Note that there is some legacy and historical mess in the ROMS native reader. One day it will hopefully be merged with the generic reader. |
@knutfrode Thanks for the info. I do have lon/lat arrays as well as x/y arrays for each grid. What do you think is the best way to use these in the ROMS reader so they don't have to be calculated? I understand now that using |
@knutfrode Alternatively, I thought I could alter the projection code in |
@knutfrode Ok it turns out I can pickle the interpolators you already have in there to save time. I made changes to this effect in a new PR (I'm about to submit). One question though: the "proj" error says that the grid points should be approximately equidistant — is that true? In |
Yes, curvilinear should be just fine, grid points are then "approximately equidistant", and there should be only very minor (insignificant) numerical errors in interpolation compared to a regular grid (which anyway only strictly applies to a map projection approximation). This warning might sound a bit more scary than it is, and should perhaps be removed or "mildened". What do you think @gauteh ? |
@knutfrode Sorry to keep pushing on this, but given that LinearNDInterpolator accepts the lon/lat values from the model and they can have whatever spacing between them, doesn't that mean that the interpolators are accurately representing the conversion between lon/lat and index space for the model grid (at least up to the accuracy of the Qhull representation calculated in LinearNDInterpolator)? |
Hi there,
I am trying to calculate LCS's from a ROMS simulation and am running into a bit of an issue. Using the native reader "as is" the fakeproj correctly returns the corners of my domain, but only places one particle in it.
===========================
Reader: roms native
Projection:
None
Coverage: [pixels]
xmin: 0.000000 xmax: 793.000000 step: 1 numx: 794
ymin: 0.000000 ymax: 361.000000 step: 1 numy: 362
Corners (lon, lat):
(199.67, 55.23) (213.36, 63.39)
(206.19, 52.26) (220.02, 59.70)
[...]
09:27:29 INFO opendrift.models.basemodel:1701: All points are in ocean
09:27:29 INFO opendrift.models.basemodel:2870: 2016-08-02 16:00:00 - step 1 of 120 - 1 active elements (0 deactivated)
09:27:29 INFO opendrift.models.basemodel:2870: 2016-08-02 15:50:00 - step 2 of 120 - 1 active elements (0 deactivated)
Consequently, no ftles can be calculated. From a previous thread (issue #783) I gathered that I need to add a projection to the reader and did so in opendrift.readers.basereader.variables line 14:
class ReaderDomain(Timeable):
"""
Projection, spatial and temporal domain of reader.
"""
name = None
Using print(reader) I get this:
===========================
Reader: roms native
Projection:
+proj=lcc +lat_1=55 +lat_2=60 +lon_0=265 +units=m
Coverage: [degrees]
xmin: -3531750.000000 xmax: -2342250.000000 step: 1500 numx: 794
ymin: -3003750.000000 ymax: -2462250.000000 step: 1500 numy: 362
Corners (lon, lat):
(-111.88, -15.26) (-106.32, -14.12)
(-111.27, -17.62) (-105.91, -16.57)
and finally particles are placed on the grid
17:00:50 INFO opendrift.models.basemodel:2762: Backwards simulation, starting at time of last seeded element
17:01:45 INFO opendrift.models.basemodel:1689: Using existing reader for land_binary_mask
17:01:45 INFO opendrift.models.basemodel:1701: All points are in ocean
17:01:45 INFO opendrift.models.basemodel:2870: 2016-08-02 16:00:00 - step 1 of 120 - 644980 active elements (0 deactivated)
17:01:53 INFO opendrift.models.basemodel:2870: 2016-08-02 15:50:00 - step 2 of 120 - 644980 active elements (0 deactivated)
The problem is that the corners of my domain as displayed by print(reader) are not correct (compare to using fakeproj above). How do I fix this? Do I need to provide the projection info somewhere else?
Thank you!
The text was updated successfully, but these errors were encountered: