Open rsignell-usgs opened 4 years ago
cc @hdsingh
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).
@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.
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.
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.
In summary, I think this is a reasonable request that we can allow, when someone makes the effort to implement it.
It would be nice to allow
xrviz
to handle ametpy
-generatedcartopy_crs
passed as part of theinitial_params
forxrviz
.hvplot
handles it just fine, but using it in theinitial_params
returnsTypeError: getattr(): attribute name must be string
. See:https://nbviewer.jupyter.org/gist/rsignell-usgs/56d8ff54708a95b45bb46f55a0677ab0