Computing an average over some novel area.

2 views
Skip to first unread message

David Jones

unread,
Dec 16, 2010, 4:07:23 AM12/16/10
to ccc-giste...@googlegroups.com
On 15 December 2010 19:01, Clearscience <clearsc...@gmail.com> wrote:
>
> I believe I am currently (nearly at least) at the stage where I am
> ready to begin trying to figure out how to specify the algorithm for
> specific lats and longs. Any advice?
>

Right. I hope you've read
http://code.google.com/p/ccc-gistemp/source/browse/trunk/doc/overview.txt
.

As I understand from our previous conversation you'd like to produce a
temperature change series for a particular area. As previously
mentioned this is easiest if the area is a rectangle on a lat/long
grid.

I'm planning on changing the code in the future so that this is much
easier. But until then, you'll need to change some of the code.

Step 5 (as implemented in code/step5.py) is what you'll need to change.

(referring to http://code.google.com/p/ccc-gistemp/source/browse/trunk/code/step5.py?r=644
which is the most recent version of this file as I write)

I recommend you edit the function step5() and replace the call to the
function SBBXtoBX (and all the subsequent code) with a call to your
own function that takes the same subboxes argument.

The subboxes argument is an iterator, the first item is metadata, and
the following 8000 items are the 8000 cells. Each cell comes as a
triple of (landweight, landseries, oceanseries).

Each landseries is an instance of the Series class (defined in
code/giss_data.py) and will have a box attribute that describes the
bounds of the cell.

Something like this code should then capture all the series that are
withing a rectangle defined by (lonsouth, lonnorth, latwest, lateast).

def myarea(subboxes):
meta = subboxes.next() # take, then ignore this
areaseries = []
for weight, land, ocean in subboxes:
lat,lon = eqarea.centre(land.box)
if latwest <= lat < lateast and lonsouth <= lon < lonnorth:
areaseries.append(land)


You then need to combine all the series in areaseries to produce your
final average. Again, this is trickier than it needs to be and the
code could do with cleaning up:

areaseries.sort(key=len, reverse=True)
average = list(areaseries[0])
weight = [a != MISSING for a in average]
for cell in areaseries[1:]:
series.combine(average, weight, cell, 1, 0, len(average)//12,
parameters.box_min_overlap)

Your final series in then in average (which is a list). Do try and
catch me on chat if you get brave enough to code this up. :)

Good luck!

drj

Reply all
Reply to author
Forward
0 new messages