-
Notifications
You must be signed in to change notification settings - Fork 53
WIP: Add antarctic melt time series #228
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
Conversation
Climatology now includes functions to support ncclimo (and update climatology bounds based on a list of available input files). streamfunctionMOC has been updated ot use ncclimo to compute the annual climatology of velocity.
This merge adds a config option ncclimoParallelMode in the execute section. The default is "serial", but it can also be set to "bck" on machines with enough RAM to handle the 12 background processes for computing monthly climatologies simultaneously. This should be tested on different machines and for different run sizes, and the machine-specific config files should be updated accordingly.
This arg is not needed in update_start_end_year_from_file_names
With this merge, xarray data sets can be written out with finite _FillValue using the shared.io.write_netcdf function. By default, the fill values are the defaults from the netCDF4 package. All climatologies have been updated to use write_netcdf. ncremap is now called with the --renormalize flag so that only non fill values are used in the resulting output.
Climatologies are never overwritten, and should be deleted manually instead.
We decided that it was difficult to keep this flag updated and that, in most cases, this information is avialable through GitHub.
Instead, have a link to a directory with existing mapping files, and require that all mapping files follow the MPAS-Analysis naming conventions. If no mapping directory is supplied or mapping files are not found in the supplied directory, create them in the mappingSubdirectory of the output directory.
The switch to ncclimo makes it difficult to accommodate the variable name mapping required to support older ACME versions (before beta1). The simplest solution is to not support these older versions any longer and to move away from mapping (which is confusing to developers). The new G-QU240 run is small and helpful for debugging MPAS-Analysis.
This flag has just been added in nco v. 4.6.8-alpha06
Each analysis task now has a list of prerequisite tasks that must run before it can be run. In addition to supporting caching times, in the future this functionality could be used to build tasks out of multiple subtasks (e.g. one to compute the climatology and one to do the plotting). This would be particularly useful if multiple tasks depend on the same climatology (which is not currently the case). A little bit of clean up has been done on some __init__.py files and on shared.io.utility
This allows a call to create_tasks for a given class to generate not just one but multiple tasks. This could be useful for tasks that can be broken into multiple subtasks (each of which can be an AnalysisTask). It is also useful for analysis involving a number of independent plots (e.g. multiple seasons or depths) that can be handled by separate tasks in parallel.
This leads to a less redunadant, more intuitive calling structure.
Switch all tasks with climatologies to use an instance of MpasClimatology to compute climatologies with ncclimo. Divide up seasonal climatology map tasks into one task per season Divide sea ice map plotting tasks into one task per field, season, hemisphere and observations source for better parallelization.
Rather than doing hyperslabbing (via iselValues) after a climatology has been computed on the full 3D variable, this commit passes the flags needed ot do hyperslabbing in ncclimo. This should save time and disk space for high res and/or long climatologies.
In the LatLonGridDescriptor, determine if the grid is local based on whether longitude covers the full 360 degrees.
SST, SSS and MLD can be plotted on this grid by adding 'antarctic' to the comparisonGrids list. A plotting routine for data on a ploar grid has also been added, including support for both index and norm color maps (the latter will be used for melt rates and Antarctic temperatures at various depths).
This function in MpasClimatology allows derived classes to make additions or modifications to the climatology before remapping. This can be helpful for performing masking.
The name of the mask file is constructed automatically from the mesh name.
Plot of melt rate and total melt flux are performed for each chosen ice shelf or group of ice shelves.
This script requires a mesh file, the iceShelves.geojson file produced in the geometric_features repo, and the MpasMaskCreator.x from the MPAs-Tools repo.
These now point to the correct mask directory and have also had a list of major ice shelves and regions added to the melt time series plots.
7273d73 to
c12f276
Compare
|
@stephenprice, I rebased this branch onto add_sose_T_S after making some small fixes to the Edison config files. If you've already made your own fork of this branch, you might want to rebase or reset --hard to pick up my changes. |
|
Will do @xylar. Thanks - |
| totalMeltFlux = constants.sec_per_year * \ | ||
| (cellMasks*areaCell*freshwaterFlux).sum(dim='nCells') | ||
|
|
||
| totalArea = (cellMasks*areaCell).sum(dim='nCells') |
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.
@xylar -- I did some spot checking here of places where either melt flux or average melt rate from our simulations roughly agrees with Rignot et al. One or the other is close in a few places, but never both, and this appears to be because the shelf areas based on the cellMasks are too large in all cases I've checked (by 30-50%). Overall, the total shelf area estimate for all of Antarctica is ~2.7x too large relative to Rignot et al. I can imagine how this could be if we are always treating a grid cell as floating if any part of it is partially floating. Is that the case? This problem will get better at higher resolution, but it may make comparing modeled and obs. melt rates difficult for our lower-res. simulations. It's possible there is some other bug here as well, but I thought I'd get your thoughts before digging too deep on this. Thanks.
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.
Sorry, @stephenprice, I am missing a factor here. freshwaterFlux should be multiplied by landIceFraction, since many cells are only partly covered by land ice. I'll make a note of this here and fix it momentarily.
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 noticed that the numbers seemed weird but I didn't realize how bad the problem was or what the cause was until your comment.
| 'iceShelvesToPlot') | ||
|
|
||
| dsRestart = xarray.open_dataset(self.restartFileName) | ||
| areaCell = dsRestart.areaCell |
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 should be changed to:
areaCell = dsRestart.landIceFraction.isel(Time=0)*dsRestart.areaCellThere 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, great! Well that was an easy fix (I didn't know landIceFraction even existed). I'll give this a try and report back.
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.
At first glance this looks much better. I'll do some more careful checks on the reported areas later this morning.
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.
With this change, the area of the indiv. shelves I checked are within ~5% and the total ice shelf area of the AIS is within ~7% (relative to the values reported in Rignot et al.). This seems reasonable to me considering the coarse res. of the 60to30 mesh. Also, all of the modeled shelf areas are biased too-small which also seems reasonable when you consider the fractal nature of coastlines.
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.
Great! I don't recall the exact algorithm I used to get landIceFraction but there's definitely some smoothing involved. I think there's also something that says, if a cell has more than 50% grounded ice, it's grounded, so that would likely account for the bias toward less ice-shelf area. This should decrease with higher res but stay biased in the same direction.
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.
@xylar -- FYI, I am making code updates and pushing them to my fork now, so you don't have to make these same changes on your fork anymore if you don't want to.
|
Ok, thanks. Yeah, I remember that Ross and FR did not actually look to bad in these runs. But there were still huge biases elsewhere. |
|
@xylar -- I'd like your opinion on next steps in terms of comparing melt rate time series from indiv. shelves to observations. The easy thing to do would be to make lookup tables (dictionaries) of the Rignot et al. melt rates and uncertainties (ditto for Depoorter and other estimates) for each shelf and then use those for plotting against modeled values (either as a mean and unc. bounds on the melt time series plots, or as some kind of bar chart like you suggested from Timmermann and Hellmer). The harder (and more costly) version would be to re-grid the obs. data onto the relevant ocean mesh and re-calculate the "observed" values that we are comparing with. The downside to that would be that 1) we're actually changing the reported obs. values that we are comparing with and 2) the reported unc. loose a bit of their meaning. I think we'll want the the harder version at some point (e.g. for comparing spatial patterns of melt). But that is a different exercise with different goals than this one. Note also that for some obs. datesets (like Depoorter et al.) there isn't really an option to remap reported values onto our grids. |
Yes, this is the first step. I would put the Rignot and Depoorter values (best estimate and uncertainties) into a .csv file (a simple spreadsheet format) within the Melt observations directory. csv files are really easy to read into numpy arrays in python, and I'm sure it's easy to take one column as dictionary keys and another as values so you could make this a dictionary. I'm hesitant to hard-code a dictionary of observations into the code itself. |
I think we could do this if we want to cross-correlate melt patterns. It would be easy to add this to the analysis that performs plots of melt fields, particularly if a climatology instead of a time series is what's needed.
Yes, I think this is a different analysis than we're currently working on. |
|
Thanks for the feedback on this @xylar. I'm going to start w/ a short csv file w/ only one or two shelves in it. Once that is working I can update to include more. If there are any examples of were you currently use .csv files (or other tabular values) as inputs for analysis, let me know. Otherwise, I'll see what I can find on my own. |
|
Here's stackoverflow post that might help you get started with csv: from ..shared.io.utility import build_config_full_path
...
observationsDirectory = build_config_full_path(config, 'oceanObservations', 'meltSubdirectory')
obsFileName = '{}/Rignot_2013_melt_rates.csv'.format(observationsDirectory)We haven't had any need for csv file so far, so there aren't any examples in MPAS-Analysis yet. |
|
By the way, there's an Excel file as part of the supplementary material for Rignot 2013 that you can convert to csv. So no need to do that work yourself, just download the example. You might have to modify a few ice-shelf names but that shouldn't be hard. |
|
Following up on the stackoverflow example, the code might look like: observationsDirectory = build_config_full_path(config, 'oceanObservations', 'meltSubdirectory')
obsFileName = '{}/Rignot_2013_melt_rates.csv'.format(observationsDirectory)
obsFile = csv.reader(obsFileName)
rignotDict = {}
for line in obsFile:
shelfName = line[1]
meltFlux = line[2]
melFluxUncertainty = line[3]
meltRate = line[4]
meltRateUncertainty = line[5]
rignotDict[shelfName] = {'meltFlux': meltFlux,
'meltFluxUncertainty': meltFluxUncertainty,
'meltRate': meltRate,
'meltRateUncertainty': meltRateUncertainty}Then, you could access the values later as: print 'The melt flux from Thwaites is', rignotDict['Thwaites']['meltFlux']Again, I hope that helps. |
|
By the way, a few recommendations for actually writing python code:
This will give you warnings (orange bullets on the left) when you're not following the so-called PEP8 conventions for code formatting. We try to follow that standard pretty strictly. If this is a lot of bother, no worries. We can always do a "reformatting" commit at the end. |
|
Thanks for all these tips. I'll let you know how it goes. |
|
I've got the full Rignot csv file reading into a dictionary now in a little test script. And while the original xls file is going to require some massaging first for this to work in practice, it is at least working in principle. Thanks for the suggestions. |
|
Sounds great! |
|
The i/o portion of this is working now (at NERSC). I'll spare you the further play-by-play, but just so you know, further devel. is happening on my fork at: https://github.com/stephenprice/MPAS-Analysis/commits/add_antarctic_melt_time_series |
|
@xylar - I've gotten to a point where I can pull the obs values for melt flux / melt rate (or other values from the csv file) into the figures, but I'm not sure what the right syntax is for plotting them. Right now, I'm just pushing them onto the axis label. Can you point me to an example for how this is done for some other time series? E.g., I know sea ice plots against obs. values in their timeseries plots. I've pushed the code to my fork if you want to take a look. Right now, it only works for select ice shelves because of name conflicts between our regions and the Rignot file. That will take a bit of work to fix, as some names / areas / values will need to be combined in the Rignot file first. But for now, if you just specify a few select ice shelves ('Totten', 'Getz', 'Abbot', 'Amery') in your config file it will work. Lastly, should we be moving this discussion away from this page and over to something associated w/ my fork? |
|
@stephenprice, I'm going to close this PR. Why don't you do a work-in-progress PR like this one but from your branch and we'll continue the discussion there. We can make a note that discussion started here. |
|
Ok, will do. I suppose this is just a normal PR but w/ the specification in the description that it is a work-in-progress (and add don't merge tag,etc)? |
|
Yes, exactly. Start the title with WIP and add a "don't merge" tag. |
This is a work-in-progress PR describing the addition of an analysis task for plotting time series of melt rates under individual ice shelves and groups of ice shelves.