Skip to content

Conversation

@leouieda
Copy link
Member

Fixes #109

Changes proposed in this pull request

Implement the infrastructure needed to make and use GMT color palettes (CPTs).

Creating a CPT:

  1. Create a virtual file for output of type GMT_IS_PALETTE
  2. Call makecpt using the virtual file as output
  3. Create an empty Palette structure
  4. Copy the GMT_PALETTE from the virtual file into the Palette

Using a CPT:

  1. Pass in a Palette structure generated using the above.
  2. Open a virtual file for input and pass in the Palette as 'data' (cast to
    void pointer)
  3. Use the virtual file in the -C/cmap option

For all this to work, need Python wrappers for the GMT_PALETTE structure. This
is mostly because the creation of the CPT is done in a different session (when
running makecpt). So we can't use the GMT allocated CPT as a void pointer like
we do for the rest of the data. We need a structure which Python controls the
memory.

Wrap the GMT_PALETTE structure and 2 others that are used inside it.
No tests for them yet.
@leouieda
Copy link
Member Author

Turns out that copying the CPT from GMT allocated memory to Python memory will be a lot of work. I'll leave this open for now and implement an easier workaround using temp files instead. Once that is working, I'll substitute the inner workings with the ctypes structures from this PR.

weiji14 added a commit to weiji14/deepbedmap that referenced this pull request Sep 18, 2019
Managed to get back the square 250x250km tiles, reduce the tile edge artifacts in the full mosaic, and get a pretty PyGMT map out! Solution to the GPU memory limitation was to have chainer disable the 'backprop' setting that means we don't save the memory hungry computational graph during inference, and we're also making sure to use cudnn's deterministic mode here. The 'whole of Antarctica' inference script now uses the a dataclass (>Python 3.7 feature) that has a namedtuple-like 'y' and 'x' accessor to make it harder to mess things up, especially important with all the extra padding and clipping we're doing to remove the tile edge artifacts. Also removed the 10km grounding line clip as the ocean predictions doesn't look too bad now (though they're not exactly 'valid'). Also waiting on GenericMappingTools/pygmt#126 so that we can use color palettes properly in PyGMT.
@leouieda
Copy link
Member Author

Closing as things have changed too much since this was opened.

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.

how to build a colorbar

2 participants