Skip to content

Add risk index outcome for navigation in ice-covered waters #968

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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

torotorotaxi
Copy link

@torotorotaxi torotorotaxi commented Jul 11, 2023

This adds a new analysis task to compute the risk index outcome (rio) from sea-ice concentration and (floe) thickness, as outlined in the International Maritime Organization (IMO) document (https://www.imorules.com/GUID-2C1D86CB-5D58-490F-B4D4-46C057E1D102.html).

@torotorotaxi
Copy link
Author

Plots need to be refined (mostly labels and titles). Probably some commits will need to be squashed before merging.

@torotorotaxi
Copy link
Author

From Milena: @xylar, I helped Gennaro with this one. Hopefully, everything should be almost ready to go, but please let us know if you see anything amiss. Thanks. We'll post an example plot as soon as I can find it (we are in Italy right now, so same time zone as you).

@torotorotaxi
Copy link
Author

Here is an example output for this task:
https://portal.nersc.gov/project/m1199/milena/E3SMv2.1B60to10rA02/Years96-100/sea_ice/index.html

@proteanplanet: it would also be great if you could take a look and comment here. It would be nice if we could get rid of the rio>30 noisy results (darkest blue), but the things the we tried didn't work.

@torotorotaxi torotorotaxi changed the title Add sea-ice risk index outcome Add risk index outcome for navigation in ice-covered waters Jul 11, 2023
@milenaveneziani
Copy link
Collaborator

@xylar, @proteanplanet, @stephenprice: in case you missed this since it came from a different username, I am pinging you again. No rush, just making sure you see it.

@proteanplanet
Copy link

I would like to suggest that rather than putting this into MPAS-Analysis, or perhaps in addition to putting this into MPAS-Analysis, we create an analysis member directly in MPAS-SeaIce that outputs the risk index.

@xylar
Copy link
Collaborator

xylar commented Jul 15, 2023

@milenaveneziani, I'll be back from vacation on Tuesday and will take a look as soon as I can after that.

@milenaveneziani
Copy link
Collaborator

sounds good. Thanks @xylar.
There is one last thing to add to the title of the plot: a parameter value that comes from the config file, so that is super easy to do.

Copy link
Collaborator

@xylar xylar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@torotorotaxi and @milenaveneziani, this looks promising!

I have a few suggested changes, most minor. The only more significant one would be to move the hard-coded arrays to a data file.

It would be nice if we could get rid of the rio>30 noisy results (darkest blue), but the things the we tried didn't work.

I think the problem is that things are either fractionally above or fractionally below 30.0, depending on machine roundoff. I would move the upper bound to either 30.01 or 29.99 so 30.0 is consistently on one side or the other.

Comment on lines 248 to 269
# this are labels that should appear in the plot, to indicate the Polar Class of the vessel (included here for the moment)
# pic = ["PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "IA Super",\
# "IA", "IB", "IC", "Not Ice Strengthened"]

# reference floe thicknesses for calculation of Risk Index Values
# (this values were agreed upon by Elizabeth Hunke, Andrew Roberts,
# and Gennaro D'Angelo based on literature and IMO description)
h_riv = np.array([0.5, 10, 15, 30, 50, 70, 100, 120, 170, 200, 250]) * 0.01
# table of Risk Index Values (defined by IMO)
riv = np.array([[ 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1 ],\
[ 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 0 ],\
[ 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 0,-1 ],\
[ 3, 3, 3, 3, 2, 2, 2, 2, 1, 0,-1,-2 ],\
[ 3, 3, 3, 3, 2, 2, 1, 1, 0,-1,-2,-2 ],\
[ 3, 2, 2, 2, 2, 1, 1, 0,-1,-2,-3,-3 ],\
[ 3, 2, 2, 2, 1, 1, 0,-1,-2,-3,-3,-3 ],\
[ 3, 2, 2, 2, 2, 1, 0,-1,-2,-3,-4,-4 ],\
[ 3, 2, 2, 2, 1, 0,-1,-2,-3,-4,-5,-5 ],\
[ 3, 2, 2, 1, 0,-1,-2,-3,-4,-5,-6,-6 ],\
[ 3, 2, 1, 0,-1,-2,-3,-4,-5,-6,-7,-8 ],\
[ 3, 1, 0,-1,-2,-3,-4,-5,-6,-7,-8,-8 ]])

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty opposed to having arrays like this in the code, so it would be better to have all of this in a NetCDF or csv data file (with a date stamp). The file would also ideally be on the LCRC server and not part of the code. This would also allow us to update the data file with a new date stamp as needed.

# sea-ice concentration conversion from range [0,1] to range [0,10]
scale_factor = 10
# polar class array index should be in the range [0,11], but not checked!
pc = self.config.getint(self.taskName, 'polarClass') - 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It there a reason not to produce plots for all 12 classes? If yes, could there be a desire to produce plots for more than one class, in which case polarClass should become a list of polarClasses?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xylar: should we put this file in a folder inside observations/SeaIce? If so, I need to figure out how to call it (will look at another task for reference) and remind myself how I update the documentation so that it's reflected in https://mpas-dev.github.io/MPAS-Analysis/develop/users_guide/observations.html#sea-ice-observations.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milenaveneziani, please add information about your observations to the bottom of the sea-ice section of this XML file:
https://github.com/MPAS-Dev/MPAS-Analysis/blob/develop/mpas_analysis/obs/observational_datasets.xml#L1700
(before the icebergs section). You should be able to see what is expected from the other observations there.
Yes, please put your observations on LCRC under /lcrc/group/e3sm/public_html/diagnostics/observations/SeaIce in an appropriate subdirectory and, if it helps you with testing, you can make another copy under /lcrc/group/e3sm/diagnostics/observations/SeaIce. (Diagnostics get synced from public_html to that location as well as to other supported machines as part of E3SM-Unified testing and deployment.)

Comment on lines 4018 to 4902
# Polar Class of vessel according to IMO. Range is 1 to 12 (increments of 1).
polarClass = 6
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be documented a bit more to list the 12 polar classes, as is done in the code.

Comment on lines 4021 to 4915
# reference lat/lon for sea ice plots in the northern hemisphere
minimumLatitude = -50
referenceLongitude = 180
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the comment need to be updated, since you have a minimum, rather than a reference, latitude.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this is for the southern hemisphere.

Comment on lines 3987 to 4845
# Polar Class of vessel according to IMO. Range is 1 to 12 (increments of 1).
polarClass = 6
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be documented a bit more to list the 12 polar classes, as is done in the code.

Comment on lines 3990 to 4858
# reference lat/lon for sea ice plots in the northern hemisphere
minimumLatitude = 50
referenceLongitude = 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the comment need to be updated, since you have a minimum, rather than a reference, latitude.

@xylar
Copy link
Collaborator

xylar commented Jan 17, 2025

@milenaveneziani and @torotorotaxi, what would it take to get this finished and merge? it's been stale for about a year an a half so it's time to either push it through or let it go, I would say.

@proteanplanet
Copy link

My two cents worth - calculating the RIO as an MPAS-SeaIce analysis member has been on our list, and would provide a more accurate assessment of risk because it would access the sea ice thickness distribution in run time. I suggest dropping this PR and together pursuing the RIO output directly from MPAS-SeaIce instead.

@milenaveneziani
Copy link
Collaborator

@xylar, @proteanplanet: we actually need this for two projects with @stephenprice, so please do not close it. @torotorotaxi and I will discuss the best way forward for this PR shortly. Thanks.

@stephenprice
Copy link
Contributor

@xylar -- Would it be possible for us to keep this PR open for a bit longer? We have an internal (LANL) project ongoing right now (winter-spring '25) that is working with/on this. Our assumption is that it will be in a position to merge following a bit more work during this time period. Thanks.

@xylar
Copy link
Collaborator

xylar commented Jan 31, 2025

@stephenprice, I'm fine to leave this up. I was just checking a couple weeks back because it seemed abandoned.

@milenaveneziani
Copy link
Collaborator

I rebased and addressed a few minor comments about documentation in the config file. We are testing this now on chicoma

@MPAS-Dev MPAS-Dev deleted a comment from torotorotaxi Feb 4, 2025
@milenaveneziani
Copy link
Collaborator

milenaveneziani commented Mar 16, 2025

@xylar: for some reason Gennaro is unable to push to his own fork (permission issue..), which is weird, but in any case these are all his changes, which can be summarized as follows:

  • as per your request, the table with the RIV values has been moved to file. I decided to put it into the observations/SeaIce/RIO directory: let me know if you would prefer a different location.
  • the RIO calculation per se has been updated, adding an option to calculate RIO from the ice concentration categories. Plots have also been updated.

Things that for sure are left to do for this PR are: 1) add the RIV file to the public repo; 2) add something in the documentation that describes the RIV file.

@milenaveneziani
Copy link
Collaborator

One last thing that we need to decide with @stephenprice is whether we want to add something related to a specific route. I feel like there are two ways of doing it: 1) use the remapped RIO climatology that is calculated here and save the RIO-on-route information to file. This would require a simple addition to this PR; or 2) do it separately as a separate script using MPAS native fields (similarly to how I handle transect time series or vertical sections along a transect).
We can talk about this again after spring break.

@milenaveneziani
Copy link
Collaborator

Here are some sample plots. Using aggregated sea ice concentration:
image
image

@milenaveneziani
Copy link
Collaborator

and using the ice categories:
image
image

@milenaveneziani
Copy link
Collaborator

@xylar: an update on this. We have decided against adding anything else related to specific routes, so this PR should be almost ready to go (after resolving the conflicts).

The only things left are these:

  1. add the RIV file to the public repo; 2) add something in the documentation that describes the RIV file.

Could you please remind me how to do the documentation update? (I will also take a look at the documentation for developers)

@xylar
Copy link
Collaborator

xylar commented Mar 27, 2025

Here's the gist:
https://mpas-dev.github.io/MPAS-Analysis/develop/tutorials/dev_add_task.html#adding-documentation
Let me know if you have questions there.

@xylar
Copy link
Collaborator

xylar commented Mar 27, 2025

For the RIV (which count as "obs", I think), I would appreciate an entry in https://github.com/MPAS-Dev/MPAS-Analysis/blob/develop/mpas_analysis/obs/observational_datasets.xml. Let me know if you don't think that's appropriate.

@milenaveneziani
Copy link
Collaborator

yes, that was my idea as well (to count them as obs)

@milenaveneziani
Copy link
Collaborator

@xylar: I followed the steps for adding documentation (plus I also added two list entries to docs/users_guide/analysis_tasks.rst, which was not mentioned in the developers documentation), but I don't think I can see the tasks listed in my test build of the docs. You'll probably know why right away..
I also added these files to the public repo:

pwd
/lcrc/group/e3sm/public_html/diagnostics/observations/SeaIce
chrlogin2:ac.milena/lcrc/.../SeaIce> ll RIV
total 3.5K
drwxrwsr-x 2 ac.milena E3SM 4.0K Mar 31 17:16 ./
drwxrwsr-x 9 ac.milena E3SM 4.0K Mar 31 15:28 ../
-rw-r-xr-- 1 ac.milena E3SM  633 Mar 31 17:13 obs.bib*
-rw-r-xr-- 1 ac.milena E3SM  874 Mar 31 17:16 README.md*
-rw-rw-r-- 1 ac.milena E3SM  681 Mar 31 15:30 riv_MSC.1_Circ.1519_6_June_2016.csv

Copy link
Collaborator

@xylar xylar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xylar: I followed the steps for adding documentation

Sounds good!

(plus I also added two list entries to docs/users_guide/analysis_tasks.rst, which was not mentioned in the developers documentation)

Sorry about that!

but I don't think I can see the tasks listed in my test build of the docs.

I build the docs locally and see the tasks fine. Maybe something went wrong in your build?

You'll probably know why right away..

I only see a few very minor issues, which I flagged below.

I also added these files to the public repo:

-rw-r-xr-- 1 ac.milena E3SM 633 Mar 31 17:13 obs.bib*
-rw-r-xr-- 1 ac.milena E3SM 874 Mar 31 17:16 README.md*

Could you chmod those two files to be group writable but not group executable? Not a big thing but presumably the intention.

Comment on lines 3 to 4
climatologyMapRiskIndexOutcomeNH
=======================================
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
climatologyMapRiskIndexOutcomeNH
=======================================
climatologyMapRiskIndexOutcomeNH
================================

Comment on lines 3 to 4
climatologyMapRiskIndexOutcomeSH
=======================================
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
climatologyMapRiskIndexOutcomeSH
=======================================
climatologyMapRiskIndexOutcomeSH
================================

Comment on lines +83 to +88
Example Result
--------------
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Example Result
--------------
Observations
------------
:ref:`imo_riv`
Example Result
--------------

Comment on lines +83 to +88
Example Result
--------------
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Example Result
--------------
Observations
------------
:ref:`imo_riv`
Example Result
--------------

@milenaveneziani
Copy link
Collaborator

I build the docs locally and see the tasks fine. Maybe something went wrong in your build?

it's possible. I'm glad you can see them just fine.

Could you chmod those two files to be group writable but not group executable?

yep, done.

I only see a few very minor issues, which I flagged below

I also just fixed these.

Not sure why there are conflicts in sea_ice/__init__.py: should I click on the web editor as suggested?

@milenaveneziani
Copy link
Collaborator

I think I have rebased successfully my local branch to origin/develop and solved the conflicts. I haven't pushed yet though, in case you prefer to handle things differently to preserve the commit history. Let me know what you think.

@xylar
Copy link
Collaborator

xylar commented Apr 1, 2025

A rebase is my preferred way so go ahead.

@milenaveneziani milenaveneziani force-pushed the add_risk_index_outcome branch from 8b56fcb to 5295bbb Compare April 1, 2025 04:04
@milenaveneziani
Copy link
Collaborator

This is ready to go on my side, @xylar. Let me know if there is anything else that should be done.

@xylar
Copy link
Collaborator

xylar commented Apr 1, 2025

@milenaveneziani, I'm going to run my test suite and make sure I don't see any bugs.

One more question for you all. My reading is that this would be on by default and doesn't require any special analysis member or anything like that to be present in the simulation. I just want to make sure that we do want the new analysis on my default without users having to set any config options. (It wouldn't make it into the Unified release that might happen today or tomorrow, it's just too late for that, so it would start showing up in E3SM simulation results in 6 months or so.)

@xylar
Copy link
Collaborator

xylar commented Apr 1, 2025

@milenaveneziani
Copy link
Collaborator

milenaveneziani commented Apr 1, 2025

My reading is that this would be on by default and doesn't require any special analysis member or anything like that to be present in the simulation

exactly. This only needs default sea ice output to run.

No problem about making it to e3sm-unified. We have our developer mpas conda builds that we can use for analysis.

And yes, the documentation also looks good.

@xylar
Copy link
Collaborator

xylar commented Apr 1, 2025

I didn't think to sync the diagnostics fields before I ran my test suite, and my tests failed because the file is missing. It seems like others may run into a similar problem. Let me figure out why that's crashing MPAS-Analysis and not just causing the analysis task to fail.

Copy link
Collaborator

@xylar xylar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milenaveneziani and @torotorotaxi, I'm afraid I'm going to have to ask for some restructuring. It won't work to read the CSV file like you're doing in the constructor. The danger that this makes MPAS-Analysis as a whole unusable is just too high.

As an example, you can see how the Antarctic melt observations are read from a CSV file in run_task():
https://github.com/MPAS-Dev/MPAS-Analysis/blob/develop/mpas_analysis/ocean/climatology_map_antarctic_melt.py#L631

polarclass = np.int_(polarclass) - 1

# read in table of Risk Index Values
#riv_csv = 'riv_MSC.1_Circ.1519_6_June_2016.csv'
Copy link
Collaborator

@xylar xylar Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a bit of suggested clean-up:

Suggested change
#riv_csv = 'riv_MSC.1_Circ.1519_6_June_2016.csv'

Comment on lines +108 to +109
IceClassLabels = np.genfromtxt(riv_csv, delimiter=',', skip_header=1,
dtype=str, usecols=(0,))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here is that if riv_csv is missing, MPAS-Analysis will crash completely. That's not a good state to be in. This file needs to be read and used in a run_task() method, not in a constructor. As this is currently written, even if someone tries to disable this analysis, they are required to have this CSV file in order to run other analysis.

@xylar
Copy link
Collaborator

xylar commented Apr 1, 2025

I can help with these changes if you need me to, but I'd be grateful if you could give it the first go.

@milenaveneziani
Copy link
Collaborator

hmm, not sure if I have the bandwidth to try this, definitely not this week.
Do you suppose a raise IOError could work in this case?

@xylar
Copy link
Collaborator

xylar commented Apr 1, 2025

Do you suppose a raise IOError could work in this case?

That is what will happen if the file is missing anyway and what will crash all of MPAS-Analysis. The problem is that opening a diagnostics file that may or may not exist is simply not a safe thing to do in the constructor of an analysis task. You could have a try/except to catch this but then you would need to gracefully handle the case that the file doesn't exist. I think you would just ideally not be loading the file at all at construction time.

@xylar
Copy link
Collaborator

xylar commented Apr 2, 2025

@milenaveneziani, I looked into it a bit more and there isn't a clean way to reorganize in the way I was hoping (so the file only gets read when the task gets run) but it's easy enough to just do nothing if the file is missing. I have some suggested clean up and a fix on my branch here:
https://github.com/xylar/MPAS-Analysis/tree/add_risk_index_outcome
Specifically, take a look at this addition:
xylar@e8355cd

Here's the clean-up I'd recommend:
xylar@947ba5d

If you're happy with both, please cherry-pick them (or hard-reset to my branch and force push).

@xylar
Copy link
Collaborator

xylar commented Apr 2, 2025

We're getting there but the main vs. ctrl differences don't quite look right:
image

Comment on lines +4821 to +4828
# colormap for model/observations
colormapNameResult = RdYlBu
# whether the colormap is indexed or continuous
colormapTypeResult = indexed
# color indices into colormapName for filled contours
colormapIndicesResult = [0, 56, 85, 170, 198, 227, 241, 248, 255, 255]
# colormap levels/values for contour boundaries
colorbarLevelsResult = numpy.linspace(-10., 30., 9)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to define a colormap for the differences for main vs. control runs. (for NH and SH).

@xylar
Copy link
Collaborator

xylar commented Apr 2, 2025

Here's an alternative approach I would recommend, in which the CSV file is stored in the python package instead of the diagnostics data. I realize I said above that the file would ideally be on the LCRC server. It seems like that approach isn't working out very well and that it needs to be in code to avoid issues when the data isn't found.

fcd818ada

@xylar
Copy link
Collaborator

xylar commented Apr 3, 2025

I tested the alternative approach above. I had to make a small bug fix so I've updated the commit hash in the link. The results of my test suite with this approach look good:
https://web.lcrc.anl.gov/public/e3sm/diagnostic_output/ac.xasay-davis/analysis_testing/chrysalis/add_risk_index_outcome/

@milenaveneziani
Copy link
Collaborator

Sounds great!
So, I need to remove the files from the obs directory at LLRC and also the changes to the docs related to the obs part, right?

Will try to do this later this afternoon.
Thanks @xylar!

@xylar
Copy link
Collaborator

xylar commented Apr 4, 2025

I think it would avoid confusing if we remove the LCRC RIV directory, yes. And, yes, please update the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants