DG0 functions are plotted with reversed axes

Bug #1154133 reported by Timothée Lecomte
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DOLFIN
New
Undecided
Unassigned

Bug Description

Dear Dolfin developpers,

I think I have found a behaviour that looks like a bug to me.

I was trying to import data from a tiff image to a DG0 function. I was struggling to get the axes' orientation in agreement with he rest of my functions, when I realized that plotting a DG0 function produces a plot with its reversed compared to the same function projected on a CG1 space... Both x and y axis are reversed. I don't know about z, since I look at 2D data.

Here is a little piece of code, to be run with the attached image. Am I doing something wrong ? Isn't the DG0 image reversed ?
Thanks in advance for your help.

(This is on Dolfin 1.1.0 compiled with Dorsal on MacOS X 10.6.8)

import numpy
import dolfin
import Image

#input filename
file_im = 'image.png'

# input image
IM = Image.open(file_im)

# convert to numpy array
im = numpy.array(IM.getdata()).reshape(IM.size[1], IM.size[0]).astype(numpy.double)

# image size
Ly = 1e0
Lx = Ly*IM.size[0]/IM.size[1]
Ny, Nx = im.shape

# create mesh
mesh = dolfin.RectangleMesh (0, 0, Lx, Ly, Nx, Ny)

# load numpy array in DG0 image
V_DG0 = dolfin.FunctionSpace(mesh, "DG", 0)
I_DG0 = dolfin.Function(V_DG0)
I_DG0.vector()[:] = im[::-1,::].flatten().repeat(2) # repeat because we have two triangles per pixel

# project on CG1
V_CG1 = dolfin.FunctionSpace(mesh, "CG", 1)
I_CG1 = dolfin.project(I_DG0, V_CG1)

# plot => axes are reversed
dolfin.plot(I_DG0, title="DG0", axes=True)
dolfin.plot(I_CG1, title="CG1", axes=True)

dolfin.interactive()

Revision history for this message
Timothée Lecomte (timothee-lecomte-5) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.