Skip to content
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

Allow passing of cartopy_crs #47

Open
rsignell-usgs opened this issue Oct 8, 2019 · 6 comments
Open

Allow passing of cartopy_crs #47

rsignell-usgs opened this issue Oct 8, 2019 · 6 comments

Comments

@rsignell-usgs
Copy link
Collaborator

rsignell-usgs commented Oct 8, 2019

It would be nice to allow xrviz to handle a metpy-generated cartopy_crs passed as part of the initial_params for xrviz.
hvplot handles it just fine, but using it in the initial_params returns
TypeError: getattr(): attribute name must be string. See:

https://nbviewer.jupyter.org/gist/rsignell-usgs/56d8ff54708a95b45bb46f55a0677ab0

@martindurant
Copy link
Member

cc @hdsingh

@hdsingh
Copy link
Member

hdsingh commented Oct 8, 2019

As of now initial_params's values are only in the form of strings and not the form of custom objects such as cartopy.crs. It is a good idea to also allow passing the values for projection options directly in the form of these objects. Values in the form of string will also be allowed.

I will look into this issue after 11Oct (exams now).

@hdsingh
Copy link
Member

hdsingh commented Oct 8, 2019

@rsignell-usgs (for now you can directly pass it in the form of string such as "LambertConformal"). Initially our idea was to pass the initial params with a YAML file, so only values in the form of strings were allowed.

@hdsingh
Copy link
Member

hdsingh commented Oct 11, 2019

This is how I think it could be done:

import cartopy.crs as ccrs
crs = ccrs.LambertConformal(central_longitude=40.,
                            central_latitude=60.,
                            globe=ccrs.Globe(ellipse='WGS84',
                                             semimajor_axis=None,
                                             ))

Lets say this is the crs object parsed by metpy. If we want to pass just the name of this object it could be done by crs.__class__.__name__. However, this object can't be passed directly to hvplot because we also need to display its properties in the crs params.
So the values of default parametes (along with globe's parameters) need to be extracted from this object, for display in crs params.
This could be done with the help of keys/values from crs.proj4_params. This data has to be converted to dictionary and is to be passed to crs.value textbox for display.

@martindurant
Copy link
Member

However, this object can't be passed directly to hvplot

well, it could, but would be an alternate code path. This could be very OK, you can use the passed-in CRS object or you can set your own parameters. Extracting out the parameters from a passed-on object and populating the fields would only ever be on a best-attempt basis, because there are many options we cannot surface in the interface.

@martindurant
Copy link
Member

In summary, I think this is a reasonable request that we can allow, when someone makes the effort to implement it.

@jsignell jsignell self-assigned this Oct 24, 2019
@jsignell jsignell removed their assignment Nov 27, 2019
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

No branches or pull requests

4 participants