Re: Data manipulation

Hi Tennessee-

Bill Hibbard wrote:
Will this copy the (x_ocean, y_ocean) data, or re-use the existing data
structures? I have to be memory conscious as some of these data sets get
very large. This looks like a useful function, but I can mimic the same
behaviour myself and make sure that I'm not wasting memory if I need to.


Look for method signatures with 'boolean copy' arguments.
Setting copy = false causes it not to make a copy, if
possible.

If you use the strategy for creating separate fields that I
outlined in my previous message, you will save on
memory because it will be using individual FileFlatFields
(which don't get instantiated until necessary) for each
of the parameters.  Just perusing the code quickly, the
extract(int) method will create the new FieldImpl with
setSamples(false) which will not make a copy. If you don't
use the separate field strategy, I think you'll end up
with a copy of the data because the extract method will
have to actually read in the data for all variables before
it can separate them out.

In general, a getSample(int) call on a FieldImpl will not make a copy
of the data, since FieldImpls are immutable and contain Data objects
in their Ranges.  However, on a FlatField, you will always
get a memory expansion because it will convert the backing
float/double arrays to a Data object (Tuple/RealTuple).

That said, take Bill's advice and use copy == false if you
don't want to increase memory when you call setSample()/setSamples()
when possible.

I didn't write domainFactor() and don't know. Maybe
someone else does.

domainFactor on the individual FlatFields will do a copy.
It makes a getValues() call on the FlatField to get the
data.  Then it has to break it apart and create a new
structure for the data.  So, in this case you end up
with two copies of the data.  I think this could be
modified to call getValues(false) since it will create
a new float[][] array and set the individual values, not
doing this by array.  That would halve the memory used.
Also, right now it calls setSamples on the new FlatField
with copy == true which is another copy of the data.
I think that could be changed as well. (Tom/Bill, does this
seem right to you at lines 1800/1815 in FieldImpl?)

Don
*************************************************************
Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307
http://www.unidata.ucar.edu/staff/donm
"There's someone in my head, but it's not me"    Roger Waters
*************************************************************