Closed DaniJonesOcean closed 3 years ago
Hi Dan,
I would recommend adding a new "key" to the function edit_mask in make_domain.py, to make custom changes for your domain. Within the if statement for that key, add the line
bathy = np.amax(bathy, -6000)
that should fill everything deeper than 6000m.
I'd be happy to have your key in the master branch if that's easiest for you, just submit a pull request. And the python3 update will be coming soon(ish) - it's on my list! but there are many other things on my list!
That's a good suggestion, thanks! :)
I will do that. If we could leave this issue open for now please, I'll link it to the pull request once I create it. You can "assign" this issue to me, if you want.
Apologies for the delay on this - I hope to get back to it soon!
Hi @knaughten. For some reason, when I add my key and run this function, nothing changes. Here's what I added to the make_domain.py
file:
elif key == 'SO-WISE-GYRE':
# SO-WISE (gyre configuration)
# Block out everything west of South America
omask = mask_box(omask, lon_2d, lat_2d, xmin=-85.0, xmax=-70.0, ymin=-45.0, ymax=-30.0)
# Fill in everything deeper than 6000 m
bathy = np.amax(bathy, -6000)
And I run the command:
edit_mask('topo_v02/sowise_gyre_bathy.nc', 'topo_v02/sowise_gyre_bathy_edited.nc', key='SO-WISE-GYRE')
It returns
Fields updated successfully. The deepest bathymetry is now 7933.9877905 m.
And there is no difference between the edited and non-edited files. I'm running this in iPython on BAS HPC. Any idea what could be going on?
EDIT: Update. Just needed to restart my iPython kernel, apparently.
A small update: the np.amax
command above returns an error, but this function works:
bathy[bathy<-6000] = -6000
I've noticed that if you pass the edit_mask
function a nonsense key, it still executes. It doesn't use the default mask in that instance. I might suggest a little error-catching statement that warns you if the key wasn't recognised, if that's okay?
Oh! And I just needed to restart my iPython kernel to incorporate the changes. It seems like the file editing is working now. (That still confuses me about Python - you have to restart the kernel to change your functions and things? Am I missing something?)
Oh good, glad you figured it out. I think instead of np.amax, np.maximum is what you want. But your fix is just as good.
Python is annoying that way, I think there is a way to re-import all your modules but I usually don't bother - I copy and paste the modified function or block of code using %paste in ipython, and then work interactively for testing purposes.
Dr Kaitlin Naughten | Ocean-Ice Modeller | British Antarctic Survey
High Cross, Madingley Road, Cambridge CB3 0ET
Email: @.**@.>
From: Dan Jones @.> Sent: 19 March 2021 10:59 To: knaughten/mitgcm_python @.> Cc: Kaitlin Naughten - UKRI BAS @.>; Mention @.> Subject: Re: [knaughten/mitgcm_python] Feature request: function to fill bathymetry below a certain depth level (#4)
A small update: the np.amax command above returns an error, but this function works:
bathy[bathy<-6000] = -6000
I've noticed that if you pass the edit_mask function a nonsense key, it still executes. It doesn't use the default mask in that instance. I might suggest a little error-catching statement that warns you if the key wasn't recognised, if that's okay?
Oh! And I just needed to restart my iPython kernel to incorporate the changes. It seems like the file editing is working now. (That still confuses me about Python - you have to restart the kernel to change your functions and things? Am I missing something?)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/knaughten/mitgcm_python/issues/4#issuecomment-802741436, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC45IKDKJA4MTOJOJO5IYBTTEMVAJANCNFSM4YC53DBA.
This email and any attachments are intended solely for the use of the named recipients. If you are not the intended recipient you must not use, disclose, copy or distribute this email or any of its attachments and should notify the sender immediately and delete this email from your system. UK Research and Innovation (UKRI) has taken every reasonable precaution to minimise risk of this email or any attachments containing viruses or malware but the recipient should carry out its own virus and malware checks before opening the attachments. UKRI does not accept any liability for any losses or damages which the recipient may sustain due to presence of any viruses. Opinions, conclusions or other information in this message and attachments that are not related directly to UKRI business are solely those of the author and do not represent the views of UKRI.
Done! Issue closed with this pull request:
Hi Kaitlin,
For my domain, I effectively want to fill in a couple kilometres of the South Sandwich Trench. Is there a function that will allow me to fill the bathymetry below a chosen depth level (e.g. 6000 m)? I didn't see one, but perhaps I missed it.
Could that be added? Where would it fit in the workflow of this code?
Thanks! Dan