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

Projections and Secondaries don't get along #1965

Open
chaosphere2112 opened this issue May 10, 2016 · 0 comments
Open

Projections and Secondaries don't get along #1965

chaosphere2112 opened this issue May 10, 2016 · 0 comments

Comments

@chaosphere2112
Copy link
Contributor

I'm playing with a technique to do a polar 1D plot in VCS, and I ran into some issues along the way. The biggest issue is that attempting to use a projection on a secondary object (which is something the API supports) doesn't really work, at all.

A simple test case:

import vcs
line = vcs.createline()
line.projection = "polar"
line.worldcoordinate = [-180, 180, -90, 90]
line.viewport = [.25, .75, .25, .75]
line.x = [-180, 180]
line.y = [90, 90]
canvas = vcs.init()
canvas.plot(line)

which gives you a blank canvas.

This seemed odd to me, since we do essentially that exact line when plotting a polar plot of a 2D variable (via the template.box1 attribute).

import vcs, cdms2
f = cdms2.open(vcs.sample_data + '/clt.nc')
s = f('clt')
canvas = vcs.init()
boxfill = vcs.getboxfill("polar")
empty_template = vcs.createtemplate()
empty_template.blank()
empty_template.box1.priority = 1
canvas.plot(s, empty_template, boxfill)

circle

I inserted some code to dump the attributes of the line object being generated for that template, and got this:

 ----------Line (Tl) member (attribute) listings ----------
secondary method = Tl
name = __line_591065525709696
type = ['solid']
width = [1.0]
color = [1]
priority = 1
viewport = [0.2766584621956789, 0.7233415266284211, 0.259999990463, 0.860000014305]
worldcoordinate = [-180.3333333325, 179.6666666625, -90.0, 90.0]
x = [[-180.3333333325, 179.6666666625], [-180.3333333325, 179.6666666625]]
y = [[90.0, 90.0], [-90.0, -90.0]]
projection = polar
colormap = None

I tried assigning those exact values to a line and plotting it, but it still failed to produce any output.

I dug into the VTK objects actually being assembled, iterated across all of the points created, and still, everything was the same for both ways. After a bunch of spelunking through misc. VTK objects, I discovered the the bounds on the actors were set differently.

It turns out that the plot function will try and grab a "vtk_backend_grid" and pass it to this code in fitToViewport; when we plot the template, vtk_backend_grid is passed as a kwarg, but when we plot the line straight-up, we use the Xrg and Yrg values derived from the worldcoordinate attribute on the line object.

We definitely need to be able to correctly project stuff without plotting a variable as part of the process, so this is in the "bug" category.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant