/** * Create a new Array by copying this Array to a new one with given shape * * @param shape the new shape * @return the new Array * @throws IllegalArgumentException new shape is not conformable */ public Array reshape(int[] shape) { Array result = factory(this.getDataType(), shape); if (result.getSize() != getSize()) throw new IllegalArgumentException("reshape arrays must have same total size"); Array.arraycopy(this, 0, result, 0, (int) getSize()); return result; }
/** * Create a new Array by copying this Array to a new one with given shape * * @param shape the new shape * @return the new Array * @throws IllegalArgumentException new shape is not conformable */ public Array reshape(int[] shape) { Array result = factory(this.getElementType(), shape); if (result.getSize() != getSize()) throw new IllegalArgumentException("reshape arrays must have same total size"); result.setUnsigned( isUnsigned()); Array.arraycopy(this, 0, result, 0, (int) getSize()); return result; }
/** * Create a new Array by copying this Array to a new one with given shape * * @param shape the new shape * @return the new Array * @throws IllegalArgumentException new shape is not conformable */ public Array reshape(int[] shape) { Array result = factory(this.getElementType(), shape); if (result.getSize() != getSize()) throw new IllegalArgumentException("reshape arrays must have same total size"); result.setUnsigned(isUnsigned()); Array.arraycopy(this, 0, result, 0, (int) getSize()); return result; }
Array.arraycopy(varData, 0, sectionData, destPos, (int) varData.getSize()); destPos += varData.getSize();
runIdx, timeIdx, mainv.getFullName(), result.getSize(), destPos, allData.getSize()); Array.arraycopy(result, 0, allData, destPos, (int) result.getSize()); destPos += result.getSize();
@Override protected Array read(DatasetOuterDimension dset, NetcdfFile ncfile) throws IOException { Array data = getData(dset.getId()); if (data != null) return data; Attribute att = ncfile.findGlobalAttribute(gattName); if (att == null) throw new IllegalArgumentException("Unknown attribute name= " + gattName); data = att.getValues(); if (dtype == null) dtype = DataType.getType(data); if (dset.ncoord == 1) // LOOK ?? putData(dset.getId(), data); else { // duplicate the value to each of the coordinates Array allData = Array.factory(dtype, new int[]{dset.ncoord}); for (int i = 0; i < dset.ncoord; i++) Array.arraycopy(data, 0, allData, i, 1); // LOOK generalize to vectors ?? putData(dset.getId(), allData); data = allData; } return data; }
public Array reallyRead(CancelTask cancelTask) throws IOException { Variable orgVar = ncd_2dtime.findVariable(mainv.getFullNameEscaped()); int[] orgVarShape = orgVar.getShape(); // calculate shape - wants it "all" (we dont seem to have access to the derived variable, so must construct) int rank = orgVar.getRank()-1; int[] varShape = new int[rank]; varShape[0] = invList.size(); System.arraycopy(orgVarShape, 2, varShape, 1, rank - 1); Array allData = Array.factory(mainv.getDataType(), varShape); int destPos = 0; Section section = new Section(orgVar.getRanges()); // loop over inventory for (Inventory inv : invList) { Array varData; try { section.setRange(0, new Range(inv.run, inv.run)); section.setRange(1, new Range(inv.time, inv.time)); varData = orgVar.read(section); } catch (InvalidRangeException e) { logger.error("read failed", e); throw new IllegalStateException(e.getMessage()); } Array.arraycopy(varData, 0, allData, destPos, (int) varData.getSize()); destPos += varData.getSize(); if ((cancelTask != null) && cancelTask.isCancel()) return null; } return allData; }
System.out.printf("%d reallyRead %s %d bytes start at %d total size is %d%n", timeIdx, mainv.getFullName(), result.getSize(), destPos, allData.getSize()); Array.arraycopy(result, 0, allData, destPos, (int) result.getSize()); destPos += result.getSize();
@Override protected Array read(DatasetOuterDimension dset, NetcdfFile ncfile) throws IOException { Array data = getData(dset.getId()); if (data != null) return data; Attribute att = ncfile.findGlobalAttribute(gattName); if (att == null) throw new IllegalArgumentException("Unknown attribute name= " + gattName); data = att.getValues(); if (dtype == null) dtype = DataType.getType(data.getElementType()); if (dset.ncoord == 1) // LOOK ?? putData(dset.getId(), data); else { // duplicate the value to each of the coordinates Array allData = Array.factory(dtype, new int[]{dset.ncoord}); for (int i = 0; i < dset.ncoord; i++) Array.arraycopy(data, 0, allData, i, 1); // LOOK generalize to vectors ?? putData(dset.getId(), allData); data = allData; } return data; }
Array.arraycopy(varData, 0, allData, resultPos, nelems); resultPos += nelems;
@Override protected Array read(DatasetOuterDimension dset, NetcdfFile ncfile) throws IOException { Array data = getData(dset.getId()); if (data != null) return data; Attribute att = ncfile.findGlobalAttribute(gattName); if (att == null) throw new IllegalArgumentException("Unknown attribute name= " + gattName); data = att.getValues(); if (dtype == null) dtype = DataType.getType(data.getElementType()); if (dset.ncoord == 1) // LOOK ?? putData(dset.getId(), data); else { // duplicate the value to each of the coordinates Array allData = Array.factory(dtype, new int[]{dset.ncoord}); for (int i = 0; i < dset.ncoord; i++) Array.arraycopy(data, 0, allData, i, 1); // LOOK generalize to vectors ?? putData(dset.getId(), allData); data = allData; } return data; }
Array.arraycopy(varData, 0, allData, resultPos, nelems); resultPos += nelems;
Array.arraycopy(varData, index.srcPos, allData, index.resultPos, index.nelems); } catch (RuntimeException e) { System.out.println(index.toString());
Array.arraycopy(varData, index.srcPos, allData, index.resultPos, index.nelems); } catch (RuntimeException e) { System.out.println(index.toString());
Array.arraycopy(varData, index.srcPos, allData, index.resultPos, index.nelems); } catch (RuntimeException e) { System.out.println(" tiledSection: " + tiledSection);
System.out.printf("%d reallyRead %s %d bytes start at %d total size is %d%n", timeIdx, mainv.getFullName(), result.getSize(), destPos, allData.getSize()); Array.arraycopy(result, 0, allData, destPos, (int) result.getSize()); destPos += result.getSize();
Array.arraycopy(varData, index.srcPos, allData, index.resultPos, index.nelems); } catch (RuntimeException e) { System.out.println(index.toString());
runIdx, timeIdx, mainv.getFullName(), result.getSize(), destPos, allData.getSize()); Array.arraycopy(result, 0, allData, destPos, (int) result.getSize()); destPos += result.getSize();
Array.arraycopy(varData, index.srcPos, allData, index.resultPos, index.nelems); } catch (RuntimeException e) { System.out.println(" tiledSection: " + tiledSection);
Array.arraycopy(varData, index.srcPos, allData, index.resultPos, index.nelems); } catch (RuntimeException e) { System.out.println(" tiledSection: " + tiledSection);