On Thu, Jun 24, 2010 at 5:15 PM, P Kishor <[email protected]> wrote:
> On Thu, Jun 24, 2010 at 4:58 PM, David Mertens <[email protected]> > wrote: > > On Thu, Jun 24, 2010 at 3:59 PM, P Kishor <[email protected]> wrote: > >> > >> Imagine, I want to end up with a large, 2D piddle $p, whose every > >> element is a 1D piddle $q, so, really, a 3D piddle. But, it is easier > >> to think of it as a 2D piddle, a rectangular grid of piddles. > >> > >> This rectangular piddle is (i x j), say, (2000 x 1500). Each element > >> in this (i x j) piddle has a serial number, starting at coordinates > >> (0,0) at the top left, which is 1, and increasing to the right most > >> edge, then down one row and left, then to the right most edge, and so > >> on. So, in my example 2D (i x j) piddle, the bottom-most, right-most > >> element's coordinates are (1999 x 1499) and its serial number is 3e6. > >> > >> I can get the content of any element in the 2D piddle with $p->at(x, > >> y) where (x, y) is the coordinate pair. Also, thanks to David Mertens, > >> if I know the serial number of an element, I can find its content with > >> $p->flat->at(n), where n is its serial number between 1 and 3e6. > >> > >> Ok. Here's the rub. I don't have all the data. I get the data > >> incrementally. That is, my 2k x 1.5k 2D piddle is really made up like > >> a patchwork quilt, and I get the patches one at a time. Every patch is > >> a series of 1D piddles ($q from my para 1 above) with a unique serial > >> number between 1 and 3e6, so I know, for any set of 1D piddles, which > >> patch they will go to. By the way, is there a PDL method to find the > >> indexes (coordinate pair) of an element in my 2D piddle, given its > >> serial number? I could write one in Perl, but PDL might have one > >> already. > >> > >> So, I want to glue(), which, btw, is really clever method, my patches > >> to each other, one by one, till they end up as the 2000x1500 2D > >> piddle. > >> > >> How do I do the above? > >> > >> > >> -- > >> Puneet Kishor http://www.punkish.org > >> Carbon Model http://carbonmodel.org > >> Charter Member, Open Source Geospatial Foundation http://www.osgeo.org > >> Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor > >> Nelson Institute, UW-Madison http://www.nelson.wisc.edu > >> ----------------------------------------------------------------------- > >> Assertions are politics; backing up assertions with evidence is science > >> ======================================================================= > >> > >> _______________________________________________ > >> Perldl mailing list > >> [email protected] > >> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > > > > Puneet - > > > > If you're going to be building your matrix in a random order, then you'll > > have to pre-allocate it, as far as I can figure. > > > > Right. That sounds like sound advice. So, I create a fake 2D piddle, > and then, as I get my data, replaces each patch worth of slice with > real data, using the serial numbers as a way of "locating" the patches > in the whole fabric. > > > In terms of obtaining the serial address, I think you should probably > just > > write a small function to handle it for you. I don't think there's a > piddle > > method for it. > > Yes, that should be easy. > > > > > > David > > > > -- > > Sent via my carrier pigeon. > > > > > > -- > Puneet Kishor http://www.punkish.org > Carbon Model http://carbonmodel.org > Charter Member, Open Source Geospatial Foundation http://www.osgeo.org > Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor > Nelson Institute, UW-Madison http://www.nelson.wisc.edu > ----------------------------------------------------------------------- > Assertions are politics; backing up assertions with evidence is science > ======================================================================= > I had a revelation on my run about this... To make a concrete example of a 3D data set, suppose you take a recording every minute for 20 days. Then you can consider your data to be a 3D matrix: $data($day, $hour, $min). That seems silly, of course, but it makes it much easier to think about the indexing properly. When you talk about serialization, it sounds like saying that you have every observation from a given hour, but you know the hour from when you started taking data rather than the (day, hour-of-day) pair. In that case, all you need to do is clump the first two dimensions: $data_by_hour = $data->clump(2); Whereas $data had dimensions 20 x 24 x 60, $data_by_hour has dimensions 480 x 60. Now you just do something like this: # get sixty-element 1D piddle from file or somewhere $data_set_for_an_hour = read_data(); # Copy to the (already allocated) hour's data $data_by_hour($serialized_hour, :) .= $data_set_for_an_hour; Does that make sense? David -- Sent via my carrier pigeon.
_______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
