[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trying to clip a multi-array
- Subject: Re: Trying to clip a multi-array
- Date: Mon, 01 Feb 1999 09:10:45 -0700
> Date: Mon, 01 Feb 1999 00:30:55 -0800
> From: Scottie Swenson <address@hidden>
> To: address@hidden, address@hidden,
> address@hidden, address@hidden
> Subject: Re: Trying to clip a multi-array
Hi Scottie,
> I have made significant progress into understanding the ucar classes. In fact
> I
> have things pretty well under wraps.
>
> But, I just hit a bug that I am unsure how to properly patch. I am trying to
> such out a clipped array from a larger MultiArray.
>
> The error message is this:
...
> debug: java.lang.NullPointerException
> debug: at
> ucar.multiarray.MultiArrayImpl.numberOfElements(MultiArrayImpl.java:58)
> debug: at ucar.multiarray.MultiArrayProxy.toArray(MultiArrayProxy.java:309)
> debug: at ucar.multiarray.MultiArrayProxy.toArray(MultiArrayProxy.java:283)
> debug: at
> cellworks.footprints.FinniganMS_NETCDF.makeCast(FinniganMS_NETCDF.java:238)
> debug: at cellworks.moulage.Footprint.run(Footprint.java:964)
> debug: at java.lang.Thread.run(Thread.java)
>
> The offending chunk of code on my side is this:
> Variable scan_index = cdf.get("scan_index");
> Variable point_count = cdf.get("point_count");
> Variable mass_values = cdf.get("mass_values");
>
> int[] gi = new int[] {0};
> [...]
> scanOffset = scan_index.getInt(gi);
> scanCount = point_count.getInt(gi);
>
> // limit the scope of the copy to the range of a the next scan
> ClipMap cm = new ClipMap(0,scanOffset,scanCount);
>
> // Now get the clipped MultiArray for the masses
> MultiArray mass = new MultiArrayProxy(mass_values, cm);
>
> double[] masses = (double[])(mass.toArray());
Thanks for reporting this bug. The appended patch to
src/multiarray/MultiArrayProxy.java should fix the problem. Please let us
know if it doesn't, or if you find any more bugs.
--Russ
diff -r1.10 MultiArrayProxy.java
309c309
< final int length = MultiArrayImpl.numberOfElements(shape,
---
> final int length = MultiArrayImpl.numberOfElements(shp,
312c312
< final MultiArrayImpl data = new MultiArrayImpl(shape, products,
---
> final MultiArrayImpl data = new MultiArrayImpl(shp, products,
314c314
< AbstractAccessor.copyO(this, origin, data, shape);
---
> AbstractAccessor.copyO(this, origin, data, shp);