-
Notifications
You must be signed in to change notification settings - Fork 237
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
MITgcmutil update #727
base: master
Are you sure you want to change the base?
MITgcmutil update #727
Conversation
... and linebreaks for lines longer than 79 characters
When I include
This is from the doc in the python function and seems to be triggered by the preceding
When I move |
My previous (first) comment got scrapped, so I repeat what I can remember of it: @dramauh Thanks for this contribution. I took the liberty to make small changes to make the doc-work. Not sure if I did it correctly ( @jahn ?). Please check if it works for you and please add missing documentation. When I tried, I ran into the problem described above. |
@mjlosch is fine, I should have tried to compile the document before commiting. That error catched me by surprised Thank for correcting the problem |
small bugged in density.py
I fixed a small flag in the density.py. I also corrected documentation adding utils and tests. I did not get any error @mjlosch, and I wrote exactly the same code that you use..very strange |
Thanks, I can now also compile the readthedocs without error messages. It may have to do with the infamous DOS eol characters (^M) that I saw in a few places (e.g., the utils.py file is a DOS file, something you may want to change). |
fantastic. I hope everything is clear. Let me know if there is anything that needs further developement. |
@dramauh I am sorry, I was wrong. The problem described above remains. The docstring sections in utils.gen_blanklist and utils.timecmap starting with "Test" lead to the above error message. I don't know what this is. |
- add __all__ to tests/__init__.py - remove second code block, as it does not seem to be allowed
The docs were not rendering correctly for both MacOS and Linux (my MacOS implementation gave a warning, see above, the Linux version didn't). Apparently, only one block of code is allowed. |
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.
This looks good. I didn't test everything thoroughly, but I did find a small problem in diagnostics.readstats, which I took the liberty to fix. @dramauh please check, if it still works for you. I also changed back the files modes to 644 (rw-r--r--) for all regular files (except the script gluemncbic).
The tests with the large (1MB) bathy_test.bin only work, if one is in the tests directory. Maybe that can be made more foolproof (e.g. by specifying a path to the file?). I am not sure. Maybe @jahn has an opinion about this.
The automodule documentation seems to work now.
utils/python/MITgcmutils/CHANGES.txt
Outdated
@@ -1,3 +1,33 @@ | |||
Version 0.5, 2023-04-17 |
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.
I have no feelings about this., but the next step would be 0.2, wouldn't it?
gravity = -9.810000e+00 | ||
rhoConst = 1.027500e+03 | ||
eosRefP0 = 1.013250e+05 |
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.
These parameters are a matter of choice and as such they should be defaults, but not constants.
One can also imagine making gravity a function of latitude (see UNESCO Tech. Pap. in Mar. Sci., 1983, eq 27):
grav = 9.780318 * (1.0 + (5.2788e-3 + 2.36e-5 * sin^2(lat)) * sin^2(lat))
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.
I agree with you. We could add those constant as default input parameters in the function. Also I have been thinking to remove that minus and move it to the equation..It does not make much sense there. I try to correct it tomorrow.
I have included suggestions in conversion and test utils. Also, I fixed a small bug in density
I added @mjlosch suggestions. Now, you can add latitude to the function pfromz. I also added paths to locate the binaries that are used in the tests. |
I added mds to init because it is not called by default in linux. I cleaned conversion module to accept different dimensions for lat
@jahn when you find the time, it would be great if you have a quick look at this. I think this is good to merge. |
I have deleted the bathy_test.bin and added bathy data to test_utils.py.
I removed the bathy file and included a portion in the test_utils.py to save some space. I wonder if the code looks untidy because of this. @mjlosch may you take a look, please? I can always change the file back and add a separate data file (~20kb). |
I am fine with that, no more large bathymetry file! I would probably for the plots of |
I deleted the figure and font size properties and fixed a few things |
I'm taking a look at this at the moment. I'll have a review by the end of the week. Updates soon. |
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.
These are great additions to the package. I've left a few comments about things to improve or change. I haven't yet had a chance to actually use the new functions on some data, so the comments are, for now, focused on testing frameworks and coding style.
I'll try and make time to point the functions at some data and actually try them out before ocean sciences, but I might not manage it.
This Python package includes a number of helpful functions and scripts for | ||
dealing with MITgcm output. You can install it from the model repository (in | ||
directory :filelink:`utils/python/MITgcmutils`) or from the Python Package | ||
Index: |
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.
The line jitter in this file is a bit annoying. It's not really a problem, but the file history and pull request would both be cleaner if removed.
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.
I think this was done by another author. I decided to leave it as it is part of the readocs
|
||
Notes | ||
----- | ||
AUTHOR: Martin Losch 2002-08-09 (mlosch@mit.edu) |
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.
Really? I'm skeptical that @mjlosch wrote this routine in 2002. It looks like this comment has been copy/pasted into the new doc strings.
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.
I guess at that time, I wrote a Matlab version of this (did I even know that python existed?), see utils/matlab/dens*.m
, which was later converted to python.
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.
As Martin said, some of these routines came from Matlab scripts and others from the MITgcm source code. I tried to keep the author comments.
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.
👍
I think that's a great approach in general.
I queried this one because I wasn't aware that the TEOS-10 routines existed in any format in 2002. But, it's before my time, so I don't actually know.
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.
hhahah, I have just noticed it..I will correct those time travel typos
""" | ||
Computes in-situ density of sea water | ||
|
||
Density of Sea Water using TEOS 48-polynomial. |
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.
Change to "TEOS-10"
@@ -1,222 +0,0 @@ | |||
# | |||
# created by mlosch on 2002-08-09 | |||
# converted to python by jahn on 2010-04-29 |
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.
Only half of this provenance has been kept in the new doc string.
bathy=np.array(bathy).astype('f4').reshape([60,60]) | ||
|
||
def test_blanklist(): | ||
"""Test blanklist generator |
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.
As written, I don't think it's possible for these tests to fail under python's pytest
framework.
We need an assert
statement or a comparison with blessed output that can fail in order for this to be an automated test.
Once that exists, we can add some code to the automated testing (.github/workflows/build_testing.yml
) to run them every time.
|
||
|
||
def hfac(depth,rF,hFacMin=0.3,hFacMinDr=50,htype='C'): | ||
""" |
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.
I can't find a test for this function.
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.
I add a new example for this function
return tuple(hfac_dic[i] for i in htype) | ||
|
||
def readbin(fname, ndims, dataprec='float32', machineformat='b'): | ||
""" |
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.
We could have a circular test for the read and write binary functions. Make an array, write it to binary, read it back in, and then assert that the original array is identical to the one that has been through both functions.
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.
I did not add it to prevent making dummy files. I prefer to wait for more complex functions before using circular tests.
do not modify salinity (to be debated)
@jahn and I went through the file I also have a suggestion for the "tests": as they are not unit or regression tests, but rather a useful illustration of |
I have just taken a a look to it. I think it is much cleaner now. Thanks for your help. About the tests, I have not preference. I can change the name of those functions. The aim of that folder was to collect all test and/or examples as the library becomes bigger |
|
||
fig = plt.figure() | ||
ax = fig.add_subplot(111) | ||
ax.pcolor(mland,cmap=cmap_lm) |
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.
here and elsewhere: is there any reason to prefer pcolor
over the (in my experience) much faster pcolormesh
?
I tried pcolormesh
and the figures look the same.
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.
I changed this as you suggested
I did some more cleanup. utils.py still needs a bit of attention. Another issue is that before this PR, one could import MITgcmutils without having matplotlib installed, as long as one didn't explicitly import cs or llc. Now everything is imported automatically and plotting and non-plotting capabilities are more mixed up. |
The test folder was renamed examples and their functions to eg_... There is a new function in examples to compute the vertical mask grid. Lastly, I edited a few comments and replace pcolor to pcolormesh
What changes does this PR introduce?
I have updated the python package MITgcmutils including new modules
What is the current behaviour?
The current version lacks of basic python functions to open and manipulate binary output from MITgcm
What is the new behaviour
(if this is a feature change)?
The updated library has converted MATLAB functions such gen_blanklist, readbin and writebin. It also includes all the density profiles in MITgcm, and a function to convert depth to dbar following MITgcm. Finally, there are some new functions in utils.py for tile visualization and/or debugging.
Does this PR introduce a breaking change?
(What changes might users need to make in their application due to this PR?)
The documentation needs a slight update to include the new functions and the changes in the old ones
Other information:
I wrote a symbolic version of 0.5. I let the developers decide the most suitable version number
Suggested addition to
tag-index
(To avoid unnecessary merge conflicts, please don't update
tag-index
. One of the admins will do that when merging your pull request.)