-
Notifications
You must be signed in to change notification settings - Fork 10
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
ROMS.jl/src /create_grid.jl produces incorrect x_rho, y_rho, x_psi, x_u, x_v, etc. #16
Comments
This is not very elegant but I believe this is a pseudocode (matlab) solution that preserves the grid spacing of lon_rho, lat_rho, etc. Please check that you agree:
|
I just fixed the scaling issue. Reading thought the seagrid code, it seems that these x/y are expressed in the Mercator projection (or other conformal projection). Apparently, in the "official" c_grid.m, these variables x_/y_ are no longer written for spherical grids I just tested that indeed ROMS runs just fine without these variables. In future we might decide to just drop these variables for spherical grids. |
Okay. I think the scaling is still incorrect. |
Can you explain what you mean? Your proposed code gives the following grid: For the code: lonv = 0.:2:50
latv = 0.:2:60
lon = [x_ for x_ in lonv, y_ in latv]
lat = [y_ for x_ in lonv, y_ in latv]
xshift = yshift = 0
dlat_m = 110.574e3
dlon_m = 111.320e3 .* cosd.(lat)
y = 0 .* lat;
for j = 2:size(lon,2)
y[:,j] = dlat_m .* (lat[:,j]-lat[:,j-1]) + y[:,j-1];
end
y = y .+ yshift .* (y[:,2]-y[:,1]);
x = 0 .* lon;
for i = 2:size(lon,1)
x[i,:] = dlon_m[i,:].* (lon[i,:]-lon[i-1,:]) + x[i-1,:];
end
x = x .+ xshift * (x[2,:]-x[1,:])'
using PyPlot
clf()
plot(x,y,"k-")
plot(x',y',"k-") The projected grid is no-longer orthogonal. Even if the distance between direct cell neighbors (along x and y axis) is correct in your projection, the distance between e.g. the points i,j and i+1,j+1 is not. The Mercator projection preserve angles and but distances have to be interpreted using a scaling function. For reference here is what pyroms does: The projection can be chosen by the user. I think it will implemented that. (it would be easier for me if you can just share julia code in future, thanks!). |
I was comparing dx and dy between adjacent points to 1/pm and 1/pn to check equivalence. I did not realize most users optimize for planar orthogonality and apply a scaling function to the data to recover the correct scale. I tried to implement a preservation of scale using these two modifications: which resulted in this grid that preserves the distance found between points on the spherical grid. I think it is okay due to spherical orthogonality (e.g. #11) but could be wrong. |
the spacing of grids x_rho, y_rho, x_psi, x_u, x_v is inconsistent (e.g ~20 times smaller) than that of lon_rho, lat_rho, etc.
The text was updated successfully, but these errors were encountered: