Git Product home page Git Product logo

hyoga's People

Contributors

juseg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hyoga's Issues

Add geographic annotations

Add annotation helpers from cartowik, improve them, and document them. Facilitate accurate placement of matplotlib annotations labels, especially on geographic axes.

  • Add annotations with auto label anchor.
  • Add annotations by angle and offset.
  • Add annotations example.
  • Add annotated scatter plot function.
  • Add annotated scatter plot example.

Document opening and plotting model output.

  • Set up documentation with Sphinx
  • Complete docstrings in hyoga.hyoga
  • Complete docstrings in hyoga.open
  • Complete docstrings in hyoga.plot
  • Write a page on opening model output
  • Write a page on plotting model output
  • Upload to readthedocs.io.

Remove cartopy dependence, implement own downloader.

Downloads from multiple sources and potentially formats will be needed in v0.3.0 onward. I think the best way to solve this is object-oriented. With this issue I intend to get a head start on a new downloader, and subclass it for Natural Earth data, so that cartopy is no longer required. I plan to do it in v0.2.x and thereby get readier for v0.3.0.

  • Add generic downloader class.
  • Add Natural Earth downloader.
  • Remove cartopy dependence.

Hide map axes by default.

Most examples contain the following code.

ax.xaxis.set_visible(False)                                                 
ax.yaxis.set_visible(False)

I think we want to hide axes by default instead. The x-coordinate... labels are typically projection coordinates which are hard to read anyway. A scale bar (#16) will be more useful.

Axes interpolation fails on non-cartopy axes.

Interpolation to axes coordinate with ds.hyoga.interp(ax=ax) fails on matplotlib Axes due to an internal call of ax.get_extent() which is only available on cartopy Geoaxes. To reproduce:

import matplotlib.pyplot as plot
import hyoga

ax = plt.axes()
with hyoga.open.example('pism.alps.out.2d.nc') as ds:
    ds = ds.hyoga.interp(hyoga.open.example('pism.alps.vis.refined.nc'), ax=ax)

Profile interpolation crashes on scipy 1.10.0.

Readthedocs builds to fail since latest scipy release.

This is related to scipy/scipy#17718, only affecting scipy==1.10.0 (will be fixed in 1.10.1).

Profile interpolation crashes on mixed precision, for instance mixing float32 PISM output data and float64 profile coordinates. While not an ideal solution for large arrays, the bug can be worked around by upcasting everything to float64.

Add Natural Earth plotting tools

Add Natural Earth functions from cartowik. This is essentially a thin wrapper around cartopy, adding a little convenience, and a lot of speed in some cases.

  • Add shapefile partial plotting and docstring.
  • Add Natural Earth functions and docstrings.
  • Use annotated scatter for custom cities maps.
  • Update examples, cartopy section in docs.
  • New doc page on adding map elements.

Add hyoga logo

I have been working on a logo during early development on Anafi, time to use it.

  • Commit old Anafi logo script.
  • Decide main layout, colours.
  • Other layouts for favicon etc.

Make dataset plot methods available as functions.

Make dataset plot methods Dataset.hyoga.plot.method(self, ...) available as functions hyoga.plot.function(ds, ...).

  • Add dataset plot functions in hyoga.plot.datasets.
  • Add dataset calc functions in hyoga.calc.interp etc.

Use geopandas to plot all vectors

I was looking for a way to combine shapefile geometries in a single artist, decided to give a quick try to GeoPandas and it blew my mind. Here is a quick speed test merging Ehlers et al. LGM global and alps paleoglaciers, removing duplicates, and plotting in Orthographic projection (as in the logo) with:

  • Cartopy BasicReader in 2m41s,
  • Cartopy FionaReader in 2m45s,
  • GeoPandas read_file in 5s!

Besides the increase in speed, GeoPandas will simplify hyoga internals and provide users with more flexible objects for further manipulation or plotting styles. However this will also introduces changes in API. To avoid future breaking change or deprecation warnings, I think I want to get this right before v0.2.

  • Use GeoPandas for Natural Earth.
  • Use GeoPandas for Paleoglaciers.
  • Add hyoga.open.naturalearth?
  • Add hyoga.open.paleoglaciers?
  • Update setup.cfg, doc/environment.yml.

Add altitude and relief colormaps

Add five colormaps from cartowik, document them, and enable them in plot methods.

  • Add altitude and relief shading colormaps.
  • Enable new colormaps in plot methods as imshow.
  • Add color table example as in matplotlib.
  • Add colormap reference as in matplotlib.
  • Document new colormaps on plotting page.

Set aspect ratio equal for maps.

Currently aspect ratios are not set and they are disturbed with every new image plot. Adding a naturalearth() overlay hides this problem, because GeoPandas sets the aspect ratio to 'equal'. Xarray provides an aspect keyword, but this is not satisfactory because it also requires setting size and can't be used with the ax keyword. We probably need wrappers around imshow, contour etc. But at least in the case imshow, ax.set_aspect needs to come after the call to imshow, something like:

def _imshow(self, **kwargs):
    img = var.plot.imshow(**style)
    kwargs.get('ax', plt.gca()).set_aspect('equal')
    return img

I think the wrappers could also hide coordinate ticks and labels, and handle colorbars.

Add shaded relief plot methods

Add shaded relief functions from cartowik, and enable hillshades in either existing, or new, accessor plot methods. Try to keep reasonably low numbers of arguments in plot method.

  • Add hillshade functions from cartowik and docstrings.
  • Rework *_altitude plot methods to include hillshade, or
  • Add {bedrock,surface}_hillshade plot methods.
  • Add mat and shiny shaded relief examples.
  • Include a shaded relief on plotting page.

Propose to rename dataset accessor from hyoga to ice.

I found out that typing hyoga all the time is not so practical (at least on a Swiss keyboard). I am thinking to rename the dataset accessor as ice which is certainly more memorable from v0.2.0. The name may be used in other projects though, I am not sure. The name hyoga would remain usable until at least v0.4.0. If you are watching and have any thoughts about that, feel free to share your opinion.

Consider an alternative approach to masking

Currently masking is achieved using xarray.DataArray.where (in hyoga.hyoga.HyogaDataset.where). Because it uses nans, one drawback with this approach is that there is no "turning back" masked values into non-masked values. This is an issue at least for hyoga.hyoga.HyogaDataset.interp, which needs to refine the mask. An alternative or perhaps complementary masking method would be to use a separate variable (standard name land_ice_area_fraction) and to make sure plotting methods use this variable if it is present (see commit message in 4120b79). Example method names:

  • Add hyoga.hyoga.HyogaDataset.assign_icemask.
  • Add hyoga.hyoga.HyogaDataset.where_icemask.
  • Plotting methods will use the latter xarray.DataArray.where.

A few more tasks before closing this issue.

  • Add hyoga.hyoga.HyogaDataset.assign.
  • Use new mask variable in interp method.
  • Add configurable thickness threshold.
  • Document changes in whatsnew.
  • Update plot examples.

Test plot methods.

Add basic tests for plot methods. This should be quite straightforward now. If plot methods work, there is a good chance the rest of the package works.

Store (and move) downloads into cache subdirectories.

Store files currently stored in root of cache directory (example and paleoglacier data) into subdirectories (just like Natural Earth data). Add code to move old files to their new location so we don't pollute the users' cache with duplicates.

Add plotting examples for gallery

Generic scripts:

  • Plotting with xarray
  • Plotting with cartopy
  • Plotting with cartowik

Hyoga plot presets:

  • Bedrock uplift preset
  • Glacier erosion preset
  • Surface velocity preset
  • Surface streamplot preset

consider using cf_xarray

I saw your tweet and this looks like a cool project.

cf_xarray should help you remove the CF parsing code, it's intended to allow indexing by standard_name etc. I'd be happy to consider changes that would make its use in this project easier.

Add CHELSA elevation data bootstrap source.

With a small change we can make CHELSA input elevation data an option for bootstrapping. This would reduce the need for a separate elevation dataset (i.e. GEBCO) in case the user does not need bathymetry.

  • Add bedrock, surface kwargs to bootstrap.
  • Add 'chelsa', 'gebco' options for both.

Add profile interpolation method

Add profile coordinate builder from cartowik, and implement profile interpolation in new accessor method.

  • Add profile tools from cartowik and docstrings.
  • Add accessor method ds.hyoga.profile.
  • Add demo profile coords, example(s).
  • Add docs, maybe alongside interp.
  • Consider 3D demo data if not too heavy.

Create a separate repository for demo data

Not all hyoga functionality can be demonstrated with the Zenodo data. Besides, these data are already post-processed and thus not ideal to show what happens when opening a raw PISM (or other models) file. Finally, the file is very large, using a lot of resources on read the docs and for anyone who would like to use the demo data. Create and use a separate repository containing:

  • PISM demo boot file
  • PISM demo series file
  • PISM demo gridded file
  • PISM demo interp file

When this is done new examples will be added to

  • Plot bedrock uplift
  • Plot interpolated data

Plotting vectors freezes axes limits.

Hyoga circumvents auto-scaling by freezing axes bounds when plotting global paleoglacier and Natural Earth vectors. A better approach will be to leave auto-scaling on but exclude the vectors using autolim or is_autoscale in future versions of matplotlib and geopandas:

This is the problematic code:

# prevent autoscaling (this is not ideal)
# TODO: open geopandas issue to allow gdf.plot(autolim=False)
kwargs['ax'].set_autoscale_on(False)

# prevent autoscaling (this is not ideal)
# TODO: open geopandas issue to allow gdf.plot(autolim=False)
kwargs['ax'].set_autoscale_on(False)

Add paleoglacier plot methods

Add functions to download, cache, and easily plot global (Last Glacial Maximum) paleoglacier extent datasets.

  • Support plotting broken shapefiles.
  • Add Ehlers & al paleoglaciers.
  • Add Batchelor & al paleoglaciers.

Add domain collections.

Add a class for domain collections with methods to e.g. set their variable resolution or plot themselves on a map, or add such functionality as part of the domain class.

Vector methods are incompatible with rioxarray.

Hyoga v0.3.0 will use rioxarray for geographic transformations. Vector drawing methods currently only recognize a proj4 attribute, but instead should be compatible with rioxarray CRS. Rioxarray's documentation recommends using decode_coords="all" to read mapping attributes in netCDF.

To reproduce (in gebco branch for now, but soon in main too):

ds = hyoga.open.surface('epsg:32632', [150e3, 1050e3, 4820e3, 5420e3])
ds.hyoga.plot.natural_earth()

Projected coordinates not aligned with extent.

The new code produces bootstrapping data where the x and y coordinate values differ from the requested extent. They appear to align instead to the somewhat random coordinates of the NE corner of the clip_box prior to reprojection, which depend on the original grid, and the user-input extent.

This is a problem as data from different sources will project to different grids (e.g. bootstrapping and atmospheric data). I think the workaround is to provide ds.rio.reproject directly with a transform argument instead of crs and resolution.

Fix auto-centering of altitude colormaps.

I realize the documentation are dotted with center=False. This is because xarray defaults to centering any image plot where data span negative and positive values, however this is not really appropriate for glacier-depressed bedrock elevation typically ranging from slightly below sea level to the mountain tops. I can think of two ways to fix this: use sealevel=-120 and possibly the 'Elevational' instead of 'Topographic' colormap, or changing bedrock_altitude() and friends' default behaviour.

  • Implement better defaults for altitude?
  • Remove center=False in docs.
  • Doc changes in whatsnew.

Add Lucazeau heat flow boostrap source.

As far as I understand Lucazeau (2019) provides an update on the similarity method by Goutorbe et al. (2011) which I have used on the Alps, including newer point data and increased resolution of 0.5°. The IHFC provides a nice overview on recent studies.

Consider top-level imports

Current syntax and API reference might be a bit bulky. I am considering to import hyoga.open input functions and the main class HyogaDataset at top level. Perhaps plotting methods can be then documented as HyogaDataset.plot.method.

  • Top-level imports
  • Update api
  • Update examples
  • Update documentation

Document opening online datasets.

I am opening this documentation-only issue to avoid overloading #1 and #3.

  • Document opening online datasets.
  • Add a minimal example for PISM.
  • Perhaps rework datasets chapter outline.

I am thinking to replace opening and masking pages with:

  • Opening datasets
  • Masking and selection
  • Spatial interpolation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.