[Matplotlib-users] Area averaged

2014-02-23 Thread Fadzil Mnor
Hi, I just started using Python for the last few weeks, and previously been using GrADS for around 4 years. I have trouble looking for a simplest way to calculate area average, let say I need to calculate a SST over a region of 20S-10N and 130E-170E. I know how to get one point values of SST vs

Re: [Matplotlib-users] Area averaged

2014-02-23 Thread Alex Goodman
Hi Fadzil, All you actually need to do is use numpy.average(), which is numpy's implementation of the weighted average. It can be shown geometrically that using the cosine of the latitude as the weights in the weighted average would give you approximately the area average, though if your SST data

[Matplotlib-users] Two Scales - twinx()

2014-02-23 Thread Stephen George
Hi, I was wanting to use dual scales on my plot and was just running the example code from http://matplotlib.org/examples/api/fahrenheit_celsius_scales.html I subsequently changed the function Tc to read def Tc(Tf): return Tf Fully expecting the two scales to track each other

Re: [Matplotlib-users] Area averaged

2014-02-23 Thread Fadzil Mnor
Thanks Alex for the reply. So, that script calculates the global SST. What if when we want to calculate for only in specific box? For example, SST over this area only: --- 10 N | | |

Re: [Matplotlib-users] Area averaged

2014-02-23 Thread Alex Goodman
Hi Fadzil, Ah sorry, I glossed over that part of your question. There are actually two solutions to this, one would be to actually find the indices where the latitudes and longitudes are within your desired bounds using numpy.where(). However I generally prefer to use numpy's built-in fancy

Re: [Matplotlib-users] grid of subplot

2014-02-23 Thread Paul Hobson
You're not adding your subplot to an existing figure, so a new one is created. put fig = plt.figure(...) at the top of your script and replace axii = plt.subplot(numalp, numobs, axisNum) with axii = fig.add_subplot(numalp, numobs, axisNum) On Sat, Feb 22, 2014 at 5:28 PM, Gabriele Brambilla