[Matplotlib-users] Compass patch

2013-10-03 Thread Stephane Raynaud
Hi,

I would like to make Patch class (a compass) and be able to set its size in
points and its position finally interpeted in data coordinates once the
patch is added add to axes.
I tried start from a mix of existing patch classes (Patch, Polygon,
Shadow), but they all deal with transforms in a different way.

So, how to code it in a proper way ?

Thank for your help.

-- 
Stephane Raynaud
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Insert image on current plot without deformation

2015-07-27 Thread Stephane Raynaud
 Hi,

In matplotlib, what is the most appropriate way to plot an image with its
native aspect ratio, and optionally its native size, inside existing axes
at a specific data location?

For instance:

from matplotlib.pyplot import plotfrom matplotlib.image import
imreadfrom matplotlib.cbook import get_sample_data

plot([50,60],[1000,2000])
im = imread(get_sample_data("grace_hopper.png", asfileobj=False))

Now I want to plot im for instance centered at coordinates (57,1200) with
some scaling or a max height and without deformation.
Thanks for the help.



-- 
Stephane Raynaud
--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Basemap: GEOS_ERRORs

2009-07-02 Thread Stephane Raynaud
Hi (Jeff),


I recently performed updates to matplotlib and basemap.
>From this time, I have a random and reccurent error when I create a
Basemap instance.
Here is one example :

>>> from mpl_toolkits.basemap import Basemap
>>> Basemap(**{'lon_0': -4.5250263598141309, 'urcrnrlat': 49.140154231678416, 
>>> 'projection': 'cyl', 'llcrnrlon': -7.268048710144, 'lat_ts': 
>>> 47.468781818043126, 'urcrnrlon': -1.7500559147572474, 'area_thresh': 0.1, 
>>> 'llcrnrlat': 45.797409404407844, 'resolution': 'i', 'lat_0': 
>>> 47.468781818043126})

GEOS_ERROR: TopologyException: found non-noded intersection between
8.67583 4.66292, 8.70206 4.66997 and 8.71039 4.67664, 8.67708 4.64997
8.70205 4.66997

It depends on the area and the resolution (polygons).

I have version '0.99.3' of basemap.

Any idea?
-- 
Stephane Raynaud

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap: GEOS_ERRORs

2009-07-02 Thread Stephane Raynaud
Yep, the same library (physical, on our network)  fails depending only
the computer, thus on its own internal libraries called by GEOS.


By the way, I tried basemap with geos 3.0.4, and saw the "simplify()"
method working. That's funny!


On Thu, Jul 2, 2009 at 2:08 PM, Jeff Whitaker wrote:
> Stephane Raynaud wrote:
>>
>> Hi (Jeff),
>>
>>
>> I recently performed updates to matplotlib and basemap.
>> >From this time, I have a random and reccurent error when I create a
>> Basemap instance.
>> Here is one example :
>>
>>
>>>>>
>>>>> from mpl_toolkits.basemap import Basemap
>>>>> Basemap(**{'lon_0': -4.5250263598141309, 'urcrnrlat':
>>>>> 49.140154231678416, 'projection': 'cyl', 'llcrnrlon': -7.268048710144,
>>>>> 'lat_ts': 47.468781818043126, 'urcrnrlon': -1.7500559147572474,
>>>>> 'area_thresh': 0.1, 'llcrnrlat': 45.797409404407844, 'resolution': 'i',
>>>>> 'lat_0': 47.468781818043126})
>>>>>
>>
>> GEOS_ERROR: TopologyException: found non-noded intersection between
>> 8.67583 4.66292, 8.70206 4.66997 and 8.71039 4.67664, 8.67708 4.64997
>> 8.70205 4.66997
>>
>> It depends on the area and the resolution (polygons).
>>
>> I have version '0.99.3' of basemap.
>>
>> Any idea?
>>
>
> Stephane:  I'd say it's an issue with your geos library installation that
> basemap is linking to.  I don't see that error using your example for geos
> 2.2.3 or geos 3.0.3.
>
> I'd suggest rebuilding the geos library, then recompiling basemap.
>
> -Jeff
>



-- 
Stephane Raynaud

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap: Mask the ocean [SEC=UNCLASSIFIED]

2009-11-02 Thread Stephane Raynaud
Ross,


one way is to mask (or remove) ocean points using the _geoslib module
provided with basemap.
When you create a Basemap instance, you can retrieve all its polygons land
(continents and islands) with "mymap.coastpolygons".
Thay are stored as numpy arrays, and you can convert them to
_geoslib.Polygon objects :

poly = _geoslib.Polygon(N.asarray(coastalpoly).T)

Then you loop over all Polygons and all (x,y) points and test :

good_point = _geoslib.Point((x,y)).within(poly)

Thanks to this method, you can choose you optimal resolution.
You can even compute the intersection of you hexagons with coastal polygons
using .intersection() and .area (instead of simply checking if the center is
inside) and then reject points depending the fraction of the cell covered by
land (or ocean).

On Mon, Nov 2, 2009 at 8:07 AM,  wrote:

> Listers,
>
> I'm using basemap to plot randomly sampled values (x,y,z) through hexbin.
>  This produces a very nice result. Some sample code is:
> --
> import numpy as np
> from numpy.random import seed
> import matplotlib.pyplot as plt
> from mpl_toolkits.basemap import Basemap
> from matplotlib.mlab import griddata
>
> ll_lat = -38.39477  # extent of area of interest
> ll_lon = 144.54767
> ur_lat = -37.51642
> ur_lon = 145.67144
>
> num_points = 100# sample points
>
> # create random sampling over the area of interest
> seed(0)
> data = np.ones((3, num_points))
> data[0,:] *= ll_lon + np.random.random((num_points))*(ur_lon-ll_lon)
> data[1,:] *= ll_lat + np.random.random((num_points))*(ur_lat-ll_lat)
> data[2,:] *= np.random.random((num_points))*1
>
> # plot the data
> fig = plt.figure()
> ax = fig.add_subplot(111)
> m = Basemap(projection='cyl', llcrnrlat=ll_lat, urcrnrlat=ur_lat,
>llcrnrlon=ll_lon, urcrnrlon=ur_lon, resolution='f',
>suppress_ticks=False, area_thresh=0.5)
> plt.hexbin(data[0,:], data[1,:], data[2,:], zorder=3)
> m.fillcontinents(color=(0.8,0.8,0.8,0), zorder=1)
> m.drawcoastlines(linewidth=0.25, color='k', zorder=2)
> plt.show()
> --
>
> This contrived example shows a sparse set of hexagons on both land and
> ocean.  I would like the hexagons over the ocean to be hidden.  I can make
> the ones on land disappear by changing the 'zorder' parameter of .hexbin()
> to 0.  However I have found no way of doing the inverse and hiding hexagons
> over the ocean.
>
> Using drawlsmask() is too crude at a 5-minute resolution.
>
> Any ideas?
>
> Thanks,
> Ross
>
>
> --
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Stephane Raynaud
--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap: Mask the ocean [SEC=UNCLASSIFIED]

2009-11-04 Thread Stephane Raynaud
Maybe using path clipping you can plot only over land like this :

--
import numpy as np
from mpl_toolkits.basemap import Basemap
import pylab as plt
import matplotlib.patches as patches
import matplotlib.transforms as transforms

ll_lat = -38.10  # extent of area of interest
ll_lon = 145.06
ur_lat = -38.00
ur_lon = 145.16

# create data points all on land
fudge = ((ll_lon+0.05,  ur_lat-0.00,   1000),
(ll_lon+0.05,  ur_lat-0.01,   2000),
(ll_lon+0.05,  ur_lat-0.02,   3000),
(ll_lon+0.05,  ur_lat-0.03,   4000),
(ll_lon+0.04,  ur_lat-0.025,  1000),
(ll_lon+0.043, ur_lat-0.036,  1),
(ll_lon+0.047, ur_lat-0.041,  2),
(ll_lon+0.07,  ur_lat-0.07,   4000),
(ll_lon+0.08,  ur_lat-0.08,   3000),
(ll_lon+0.09,  ur_lat-0.09,   2000),
(ll_lon+0.10,  ur_lat-0.10,   1000))

data = np.ones((3, len(fudge)))
for (i, (lon, lat, val)) in enumerate(fudge):
   data[0,i] = lon
   data[1,i] = lat
   data[2,i] = val

# plot the data
fig = plt.figure()
m = Basemap(projection='cyl', llcrnrlat=ll_lat, urcrnrlat=ur_lat,
  llcrnrlon=ll_lon, urcrnrlon=ur_lon, resolution='f')

# +CHANGES
coll = plt.hexbin(data[0,:], data[1,:], data[2,:], gridsize=5)
ax = plt.gca()
for n, poly in enumerate(m.coastpolygons):
type = m.coastpolygontypes[n]
if type in [1,3]:
p = patches.Polygon(np.asarray(poly).T)
p.set_color('none')
ax.add_patch(p)
m.set_axes_limits(ax=ax)
coll.set_clip_path(p)
# -CHANGES

plt.show()
--

On Wed, Nov 4, 2009 at 1:17 AM,  wrote:

>
>
> -Original Message-
> From: Jeff Whitaker [mailto:jsw...@fastmail.fm]
> Sent: Tuesday, 3 November 2009 02:53
> To: Stephane Raynaud
> Cc: Wilson Ross; matplotlib-users@lists.sourceforge.net
> Subject: Re: [Matplotlib-users] basemap: Mask the ocean [SEC=UNCLASSIFIED]
>
> Stephane Raynaud wrote:
> > Ross,
> >
> >
> > one way is to mask (or remove) ocean points using the _geoslib module
> > provided with basemap.
> > When you create a Basemap instance, you can retrieve all its polygons
> > land (continents and islands) with "mymap.coastpolygons".
> > Thay are stored as numpy arrays, and you can convert them to
> > _geoslib.Polygon objects :
> >
> > poly = _geoslib.Polygon(N.asarray(coastalpoly).T)
> >
> > Then you loop over all Polygons and all (x,y) points and test :
> >
> > good_point = _geoslib.Point((x,y)).within(poly)
> >
> > Thanks to this method, you can choose you optimal resolution.
> > You can even compute the intersection of you hexagons with coastal
> > polygons using .intersection() and .area (instead of simply checking
> > if the center is inside) and then reject points depending the fraction
> > of the cell covered by land (or ocean).
>
> Following Stephane's excellent suggestion, here's a prototype Basemap
> method that checks to see if a point is on land or over water.  Ross -
> if you find it useful I'll include it in the next release.  Note that it
> will be slow for lots of points or large map regions.
>
> -Jeff
> --
>
> Yes, Stephane's approach is nice and Jeff has nicely encapsulated the
> approach. I'll put that into my bag of tricks!
>
> However it doesn't quite do what I want.  My data does not have any points
> in the ocean; the hex binning creates hexagonal patches that extend out into
> the ocean. As a physicist I say "that's a representation artifact" and leave
> it at that, but my end-users want that 'bleed' into the ocean removed.  My
> argument that they are losing data falls on deaf ears.
>
> Here's an even more contrived example that improves on my poor previous
> attempt to explain the problem:
> 
> import numpy as np
> import matplotlib.pyplot as plt
> from mpl_toolkits.basemap import Basemap
>
> ll_lat = -38.10  # extent of area of interest
> ll_lon = 145.06
> ur_lat = -38.00
> ur_lon = 145.16
>
> # create data points all on land
> fudge = ((ll_lon+0.05,  ur_lat-0.00,   1000),
> (ll_lon+0.05,  ur_lat-0.01,   2000),
> (ll_lon+0.05,  ur_lat-0.02,   3000),
> (ll_lon+0.05,  ur_lat-0.03,   4000),
> (ll_lon+0.04,  ur_lat-0.025,  1000),
> (ll_lon+0.043, ur_lat-0.036,  1),
> (ll_lon+0.047, ur_lat-0.041,  2),
> (ll_lon+0.07,  ur_lat-0.07,   4000),
> (ll_lon+0.08,  ur_lat-0.08,   3000),
> (ll_lon+0.09,  ur_lat-0.09,   2

[Matplotlib-users] Cross axis arrows

2009-12-03 Thread Stephane Raynaud
Hi,

how to make this arrow not disappear below the right plot?
Here is the code :


from matplotlib.patches import *
import matplotlib.pyplot as P

P.figure(figsize=(5, 3))
ax1 = P.subplot(121)
P.plot([0, 1])
ax2 = P.subplot(122)
P.plot([0, 1])


patch = ConnectionPatch((.5, .5), (.7, .3), 'data', 'data', axesA=ax1,
axesB=ax2,
zorder=100, arrowstyle='fancy',clip_on=False, connectionstyle='Angle3',
mutation_scale=100)
ax1.add_patch(patch)

P.savefig('cross_arrow.png')
P.show()
--------




-- 
Stephane Raynaud
<>--
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] quiver + dates

2010-02-08 Thread Stephane Raynaud
Hi Filipe,

you can fist use the quiver() function in the classic way for stick plots,
then use gca().xaxis_date().

Here is a simple example :

import pylab as P
# t may be generated using date2num()
t = P.arange(100,110,.1)
u = P.sin(t)
v = P.cos(t)
P.quiver([t],[[0]*len(t)],u,v)
P.gca().xaxis_date()
P.show()


On Sun, Feb 7, 2010 at 6:11 PM, Filipe Pires Alvarenga Fernandes <
ocef...@gmail.com> wrote:

> Hello list,
>
> I'm trying to create a stick-plot figure using the quiver function from
> matplotlib. However, I'm failing miserably to plot dates in the x-axis. Has
> anyone done this before? Also, is there an effort to create a stickplot
> function?
>
> Thanks, Filipe
>
> *
> Filipe Pires Alvarenga Fernandes
>
> University of Massachusetts Dartmouth
> 200 Mill Road - Fairhaven, MA
> Tel: (508) 910-6381
> Email: falvarengafernan...@umassd.edu
>  ocef...@yahoo.com.br
>  ocef...@gmail.com
>
> http://ocefpaf.tiddlyspot.com/
> *
>
>
> --
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the
> business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>


-- 
Stephane Raynaud
--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Basemap.pyproj: towgs84

2009-01-16 Thread Stephane Raynaud
Hi,

it seems that pyproj.Proj does not take into account the "towgs84" optional
parameter.
Here is what I simply tried:

from mpl_toolkits.basemap import *
lonref = -3.
latref = 47.

kwproj  = dict(proj="lcc",  a=6378249.2, b=6356515., x_0=60.,
y_0=20.,
lon_0="2d20'14.025", lat_0="46d48'",  lat_1="45d53'56.108",
lat_2="47d41'45.652")
print pyproj.Proj(**kwproj)(lonref, latref)

kwproj.update(towgs84="-168,-60,+320")
print pyproj.Proj(**kwproj)(lonref, latref)

Both transforms give the same result.

Try the same parameters with "cs2cs" changes the results as expected.
Did I miss something?

--
Stephane Raynaud
--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib.mlab PCA analysis

2009-02-10 Thread Stephane Raynaud
Hi Marjolaine,

On Tue, Feb 10, 2009 at 12:31 PM, Marjolaine Rouault wrote:

> Hi,
>
> I am struggling to do a PCA analysis on a masked array. Anybody has
> suggestions on how to deal with masked array when doing PCAs?



You need to remove missing values at each time step.
This means that your missing data are always at the same place.
Maybe something like this can work :

# Let's say we analyse myfullvar(nt,ny,nx)
mask = myfullvar[0]
ns = numpy.count(~mask)
myvar = numpy.zeros(nt,ns)
for it in xrange(nt):
  myvar[it] = myfullvar[it].compressed()

# Then you make a PCA decomposition of myvar and you get back your EOFs
myeofs(neof,ns)
myfulleofs = numpy.ma.zeros(neof,ny,nx)+numpy.ma.masked
for ieof in xrange(neof):
  myfulleofs[~mask.flat] = myeofs[ieof]



>
> Best regards, Marjolaine.
>
>
>
> --
> This message is subject to the CSIR's copyright terms and conditions,
> e-mail legal notice, and implemented Open Document Format (ODF) standard.
> The full disclaimer details can be found at
> http://www.csir.co.za/disclaimer.html.
>
> This message has been scanned for viruses and dangerous content by
> MailScanner,
> and is believed to be clean.  MailScanner thanks Transtec Computers for
> their support.
>
>
>
> --
> Create and Deploy Rich Internet Apps outside the browser with
> Adobe(R)AIR(TM)
> software. With Adobe AIR, Ajax developers can use existing skills and code
> to
> build responsive, highly engaging applications that combine the power of
> local
> resources and data with the reach of the web. Download the Adobe AIR SDK
> and
> Ajax docs to start building applications today-
> http://p.sf.net/sfu/adobe-com
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Stephane Raynaud
--
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib.mlab PCA analysis

2009-02-12 Thread Stephane Raynaud
On Wed, Feb 11, 2009 at 8:00 PM, Marjolaine Rouault wrote:

> Hi,
>
> Thanks a lot for your comments.  I did try earlier on to remove the bad
> points but came across some problems when re-ordering my array. I will try
> out the method sent to me and check the reference.


Yep, the compacting/reordering method is appropriate for fixed missing
values (typically a grid mask) but not approriate for randomly placed
missing values.

I didn't read these references, but a simple approach you can implement in
python (using for example numpy.linalg.eig applied to you covariance matrix
to compute your eofs, and then your pcs) consist in a interative method to
fill your missing value and let converge your EOF/PC.
0) first save your mask once: mask = data.mask.copy()
1) fill the missing values with the mean data.filled(data.mean())
2) make a reconstruction of your data (EOF[1:10] . PC[1:10]) after your PCA
analysis using a limited number of modes (met's say 10) : datarec
3) replace you original missing data with your reconstructed field: data =
numpy.where(mask, datarec, data)
4)  restart from 1) a number of time you can fixe or detect with a criteria
based for example on the eigenvalues
5) the finally, you can use you EOFs et PCs, and has a bonus, you filled
your data!



>
>
> Regards, Marjolaine.
>
>
>
> >>> > 02/11/09 4:06 PM
> >>>
> Marjolaine,
>
> I am assuming your masked array entries are missing data.  Multivariate
> analysis with missing data can be handled in several standard ways, however
> these methods don't appear in most Python libraries.
>
> Here are some references on the topic that will help you:
>
> [1] P.R.C. Nelson and J.F. MacGregor, 1996, "Missing data methods in PCA
> and PLS: Score calculations with incomplete observations", Chemometrics and
> Intelligent Laboratory Systems, v35, p 45-65.
>
> [2] F. Arteaga and A. Ferrer, 2002, "Dealing with missing data in MSPC:
> several methods, different interpretations, some examples", Journal of
> Chemometrics, v16, p408-418.
>
> Paper [1] deals with building a model with missing data, while paper [2]
> looks at applying an existing PCA model to new data that contains missing
> entries.
>
> Hope these help,
> Kevin
>
> Marjolaine Rouault wrote:
> >
> > Hi,
> >
> > I am struggling to do a PCA analysis on a masked array. Anybody has
> > suggestions on how to deal with masked array when doing PCAs?
> >
> > Best regards, Marjolaine.
> >
>
> Quoted from:
> http://www.nabble.com/matplotlib.mlab-PCA-analysis-tp21932808p21932808.html
>
>
>
> --
> This message is subject to the CSIR's copyright terms and conditions,
> e-mail legal notice, and implemented Open Document Format (ODF) standard.
> The full disclaimer details can be found at
> http://www.csir.co.za/disclaimer.html.
>
> This message has been scanned for viruses and dangerous content by
> MailScanner,
> and is believed to be clean.  MailScanner thanks Transtec Computers for
> their support.
>
>
>
> --
> Create and Deploy Rich Internet Apps outside the browser with
> Adobe(R)AIR(TM)
> software. With Adobe AIR, Ajax developers can use existing skills and code
> to
> build responsive, highly engaging applications that combine the power of
> local
> resources and data with the reach of the web. Download the Adobe AIR SDK
> and
> Ajax docs to start building applications today-
> http://p.sf.net/sfu/adobe-com
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Stephane Raynaud
--
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Input data types and pure numpy.ma

2007-12-19 Thread Stephane Raynaud
Hi,

when matplotlib processes variables, it makes sure to handle masked
variables (numpy.ma) by converting them using "soft "
numpy.ma.asarray. So, when a subclass instance of numpy.ma is used as
a variable, it keeps properties and methods in this operation that can
be conflicting with future processing.

An example of problematic input variable can be cdms variable (from
CDAT - cdat.sourceforge.net/). Such a variable is like a numpy.ma with
axes (like time, longitude, latitude, etc) and attributes (like
missing value, name, units). A problem for example is that it cannot
handle "newaxis" slicings (var[:,newaxis]) that matplotlib uses to be
sure that a variable has a suitable rank. In addition, other
properties of cdms variable ares not interesting for matplotlib
processing.

Therefore, it may be useful to strictly convert input variables to
pure numpy.ma using something like numpy.ma.array(var,copy=0).
Is it feasible?

-- 
Stephane Raynaud

-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] clabel Formatter

2008-02-22 Thread Stephane Raynaud
Hi,

what is the best way to use a Formatter for contour labels (clabel)
instead of using simple formatting ('%g')?
Should we derive a class from ContourLabeler and do things by hand?

It would be useful for example for showing labels from
power(10.,level) and you plot logarithmic values.

Thanks for the help.

-- 
Stephane Raynaud

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] locale and Qt

2008-02-28 Thread Stephane Raynaud
Hi,

when I set the locale to a value (let's say 'en_US.UTF-8' different
from my that of environement ('fr_FR'), it is automatically switched
back to 'fr_FR.UTF-8' after the first figure is created when the
backend is dervied from Qt (no problem with Agg only).

Any idea how to prevent from that?

-- 
Stephane Raynaud

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] locale and Qt

2008-02-29 Thread Stephane Raynaud
On Fri, Feb 29, 2008 at 2:52 PM, Michael Droettboom <[EMAIL PROTECTED]> wrote:
> Can you describe how you are changing the locale?  It could be that Qt
>  is reverting it to your system value every time a new figure window is
>  created.  Maybe you could set it somehow "deeper", like in an
>  environment variable.

I simply perform a locale.setlocale(locale.LC_ALL, 'en_US.UTF-8').

A simple way to avoid this problem is to set the environement variable
at the same time :
os.environ['LANG'] = 'en_US.UTF-8'
but it's not a clean way.

I guess, a MPL solution would be to check if locale.getlocale()
returns something else than (None,None) at the beginning of
new_figure_manager() and to set it back at the end.

>
>  Cheers,
>  Mike
>
>
>
>  Stephane Raynaud wrote:
>  > Hi,
>  >
>  > when I set the locale to a value (let's say 'en_US.UTF-8' different
>  > from my that of environement ('fr_FR'), it is automatically switched
>  > back to 'fr_FR.UTF-8' after the first figure is created when the
>  > backend is dervied from Qt (no problem with Agg only).
>  >
>  > Any idea how to prevent from that?
>  >
>
>  --
>  Michael Droettboom
>  Science Software Branch
>  Operations and Engineering Division
>  Space Telescope Science Institute
>  Operated by AURA for NASA
>



-- 
Stephane Raynaud

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Basemap cache

2008-03-06 Thread Stephane Raynaud
Hi

Jeff: how about introducing a cache system for Basemap objects?

You recently gave me the idea of using cPickle on Basemap objects, so
I implement a very simple cache system that try to check if map has
already been serialized and dumped to a cache file, before trying to
create it from scratch. Checking is performed on file name which
contains bounds and resolution of the map.

Do you think that it can be managed directly (and in a better way) in
Basemap(), let's say using the cache keyword set to False by default?
A cache directory in ~/.matplotlib/basemap can be used for that.


-- 
Stephane Raynaud

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap scalebar

2008-03-06 Thread Stephane Raynaud
orizontalalignment='center',\
>verticalalignment='bottom',\
>fontsize=9)
>
> # setup of basemap ('lcc' = lambert conformal conic).
> # use major and minor sphere radii from WGS84 ellipsoid.
> m =
> Basemap2(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
>  rsphere=(6378137.00,6356752.3142),\
>  resolution='l',area_thresh=1000.,projection='lcc',\
>  lat_1=50.,lon_0=-107.)
> # draw coastlines and political boundaries.
> m.drawcoastlines()
> m.fillcontinents()
> # draw parallels and meridians.
> # label on left, right and bottom of map.
> m.drawparallels(arange(0.,80,20.),labels=[1,1,0,1])
> m.drawmeridians(arange(10.,360.,30.),labels=[1,1,0,1])
> # draw a line from x1,y to x2,y and label it with distance in km.
> length = 3000 #kilometers
> x1,y1 = 0.25*m.xmax, 0.25*m.ymax
> lon1,lat1 = m(x1,y1,inverse=True)
> m.drawscale(lon1,lat1,length)
> title('a fancy map scale')
> show()
>
>
>
>
> --
> Michael Hearne
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> (303) 273-8620
> USGS National Earthquake Information Center
> 1711 Illinois St. Golden CO 80401
> Senior Software Engineer
> Synergetics, Inc.
> --
>
>
>
>
>
> --
> Jeffrey S. Whitaker Phone : (303)497-6313
> NOAA/OAR/CDC  R/PSD1FAX   : (303)497-6449
> 325 Broadway    Boulder, CO, USA 80305-3328
>
>
>
>
>
> --
> Michael Hearne
> [EMAIL PROTECTED]
> (303) 273-8620
> USGS National Earthquake Information Center
> 1711 Illinois St. Golden CO 80401
> Senior Software Engineer
> Synergetics, Inc.
> --
>
>
> -
>  This SF.net email is sponsored by: Microsoft
>  Defy all challenges. Microsoft(R) Visual Studio 2008.
>  http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> ___
>  Matplotlib-users mailing list
>  Matplotlib-users@lists.sourceforge.net
>  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>



-- 
Stephane Raynaud

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap scalebar

2008-03-06 Thread Stephane Raynaud
On Thu, Mar 6, 2008 at 6:15 PM, Jeff Whitaker <[EMAIL PROTECTED]> wrote:
> Stephane Raynaud wrote:
>  > Hi,
>  >
>  > this scalebar is a really good idea!
>  >
>  > However, I suggest that all parameters must be optional:
>  > - The position could be by default somewhere in the lower left corner
>  > (for example). It may be interesting to find a "best" position using
>  > the algo of legend.
>  > - Then length could be estimated from automatically from the map 
> coordinates.
>  >
>  >
>  >
>  Stephane:  While I agree it would be nice to be able to just say 'give
>  me a scalebar', I don't think having Basemap choose a default location
>  and size would be very useful.  You want the scalebar to be where there
>  is nothing else drawn on the map, and this will be different in every
>  case.

Sure, but the algorithm used by legend tries to put the legend where
there is nothing drawn.


> Plus, you probably want the length to be a nice round number, not
>  an arbitrary fraction of the map domain.

I was not thinking about a simple fraction, but a nice length taken
within values derived from a Locator scaled by a fraction on the map
domain.


>
>  -Jeff
>
>
> > On Tue, Mar 4, 2008 at 3:47 PM, Michael Hearne <[EMAIL PROTECTED]> wrote:
>  >
>  >>  Jeff - I think the way GMT does it would be okay - they have a latitude 
> of
>  >> true scale, which I usually choose as the center latitude of the map.
>  >>
>  >> I was thinking we should allow people to choose the "simple" or "fancy"
>  >> options.  Do you think it will be okay to have the height of the bar and 
> the
>  >> text offset be relative to the length of it?  I suppose if the height
>  >> becomes a problem, people could use the yoffset keyword...
>  >>
>  >> --Mike
>  >>
>  >>
>  >> On Mar 4, 2008, at 6:05 AM, Jeff Whitaker wrote:
>  >>
>  >> Michael Hearne wrote:
>  >> Jeff - That would replicate the "simple" scale-bar from GMT.  Below is my
>  >> not-complete attempt at replicating the "fancy" scale bar.  It would need
>  >> some options for specifying different units (miles, nautical miles, etc.)
>  >> and perhaps some more attention to spacing of the text from the scale bar
>  >> and tick marks...
>  >>
>  >> --Mike
>  >>
>  >> Mike:  Very nice!  Do you want the scale to show the true distance on the
>  >> earth (in which case the labels will vary depending on where the label is
>  >> placed), or the distance in map projection coordinates (in which case the
>  >> labels are constant)?  Or perhaps a lat/lon value could be given to 
> specify
>  >> where the scale is true?
>  >>
>  >> -Jeff
>  >>
>  >> from numpy import *
>  >> from matplotlib.toolkits.basemap import Basemap, pyproj
>  >> from pylab import *
>  >> # add drawscale method to Basemap class.
>  >> class Basemap2(Basemap):
>  >>def drawscale(self,lon,lat,length,yoffset=None):
>  >>"""draw a fancy map scale from lon-length/2,lat-yoffset to
>  >>lon-length/2,lat-yoffset, label it with actual distance in km"""
>  >>length = length*1000 #input length is km
>  >>
>  >>#we need 5 sets of x coordinates (in map units)
>  >>#center of scale
>  >>xc,yc = self(lon,lat)
>  >>#left edge of scale
>  >>lon1,lat1 = self(xc-length/2,yc,inverse=True)
>  >>x1,y1 = self(lon1,lat1)
>  >>#quarter scale
>  >>lon2,lat2 = self(xc-length/4,yc,inverse=True)
>  >>x2,y2 = self(lon2,lat2)
>  >>#three quarter scale
>  >>lon3,lat3 = self(xc+length/4,yc,inverse=True)
>  >>x3,y3 = self(lon3,lat3)
>  >>#right edge of scale
>  >>lon4,lat4 = self(xc+length/2,yc,inverse=True)
>  >>x4,y4 = self(lon4,lat4)
>  >>   if yoffset is None: yoffset = 0.1*length
>  >>
>  >>#plot top line
>  >>ytop = yc+yoffset/2
>  >>ybottom = yc-yoffset/2
>  >>ytick = ybottom - yoffset/2
>  >>ytext = ytick - yoffset/2
>  >>m.plot([x1,x4],[ytop,ytop],color='k')
>  >>#plot bottom line
>  >>m.plot([x1,x4],[ybottom,ybottom],color='k')
>  >>#plot left edge
>  >>m.plot([x1,x1]