-
Notifications
You must be signed in to change notification settings - Fork 363
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
Enable writing of 3-D netCDF data cubes from greenspline and grdinterpolate #4581
Conversation
Thus, the work on writing a 3-D cube calls to gmt_write_nc_cube in gmt_nc.c
Alternatively, no -Q is needed for grdinfo and grd2xyz since we could presumably check if a given netCDF file is a grid or cube, and then take action. As for xyz2grd one has to specify -Rw/e/s/n -Idx/dy, but if a cube this needs to be -Rw/e/s/n/z0/z1 -Idx/dxy/dz so perhaps there is no need for -Q there either. What do you think, @joa-quim ? |
What is the interest of this? Why care to convert a 4-D to xyzt and back? |
|
Yes, > 20 years ago when people still wrote grids manually. I fail to see why spending time coding a 4D analog |
OK, we can wait to see if there is any demand. What about grdinfo for cubes? |
src/gmt_nc.c
Outdated
|
||
/* Depending on row_order, write y-coordinate array bottom-to-top or top-to-bottom */ | ||
if (HH->row_order == k_nc_start_south) { | ||
for (row = 0; row < header->n_rows; row++) xy[row] = (double) gmt_M_col_to_x (GMT, row, header->wesn[YLO], header->wesn[YHI], header->inc[GMT_Y], 0.5 * header->registration, header->n_rows); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please break line. Lines like these are an horror to debug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, done in my workspace - not ready to commit yet.
|
This does not work since registration is a problem. Now done in grdinterpolate instead.
Pinging @remkos to have a look if he has time. In addition to the email I sent, also see the issue with lack of assigning variable names and units a few posts above. |
I was looking at your proposal for units. As far as I remember (but I may have done that in other programs), if one adds "[m]" to the x-name then "m" is used as the unit. This should also hold for y-name, z-name and any other specified units, of course. But yes, this would be rather "hidden" way of doing things and probably a more direct way of specifying the units, as you suggested above would be better. Or maybe support both. Indeed, there was no way to specify the variable name. It was always x and y, unless the projection was geographical and lon and lat where used. This is not required by COARDS, but I have seen applications react to it appropriately, even without the units like degrees_east, degrees_north or the appropriate standard_name. Still, what is required by COARDS is that the dimensions and the coordinate axes are called the same. So the dimensions and the coordinate arrays are called lon and lat, consistently. Now checking the code:
|
It is great that name [unit] is parsed like that - I guess I thought it was a special thing for [degrees_longitude] etc. and not general. So we can improve the docs on that for sure. |
In the process, change greenspline -D to -Z but backwards compatible so that it and grdinterpolate can take -Dinformation to set the various grid/cube variables. Updated scripts using -D and ensure the "name [unit]" parsing works for x,y,z, and d. Renamed +zsunit to +ddataunit for both grids and cube but this is backwards compatible for grids of course.
Since (re-)discovering the ability to specify the name of a dimension or data and add the unit in brackets, the proposal above has been simplified, and implemented. We now have, via the -Dinfo setting, these new things:
With that I think we are good. I updated gspline_4.sh to use -D (which I added to greenspline) via the command
and now
So, the -Dinfo was added to both greenspline and grdinterpolate. Since greenspline already used -D I moved that option to -Z but we handle this with backwards compatibility. All tests work fine - I think this PR is now good to be approved and merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests pass for me too.
Description of proposed changes
This PR completes the gmt_write_nc_cube coding to enable the writing of 3-D layers (with layers an unlimited dimension). It is WIP because I want to complete what GMT_Read_Data with CONTAINER_ONLY should do for cubes, and update gspline_4.sh to no longer write lots of 2-D grids.
Related question whose solution can be separate PR is: