/** * Promote a global attribute to a variable * * @param varName name of agg variable * @param orgName name of global attribute, may be different from the variable name */ void addVariableFromGlobalAttribute(String varName, String orgName) { cacheList.add(new PromoteVar(varName, orgName)); }
@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; }
protected void promoteGlobalAttributes(DatasetOuterDimension typicalDataset) throws IOException { for (CacheVar cv : cacheList) { if (!(cv instanceof PromoteVar)) continue; PromoteVar pv = (PromoteVar) cv; Array data = pv.read(typicalDataset); pv.dtype = DataType.getType(data.getElementType()); VariableDS promotedVar = new VariableDS(ncDataset, null, null, pv.varName, pv.dtype, dimName, null, null); /* if (data.getSize() > 1) { // LOOK case of non-scalar global attribute not delat with Dimension outer = ncDataset.getRootGroup().findDimension(dimName); Dimension inner = new Dimension("", (int) data.getSize(), false); //anonymous List<Dimension> dims = new ArrayList<Dimension>(2); dims.add(outer); dims.add(inner); promotedVar.setDimensions(dims); } */ ncDataset.addVariable(null, promotedVar); promotedVar.setProxyReader( this); promotedVar.setSPobject(pv); } }
protected void promoteGlobalAttributes(DatasetOuterDimension typicalDataset) throws IOException { for (CacheVar cv : cacheList) { if (!(cv instanceof PromoteVar)) continue; PromoteVar pv = (PromoteVar) cv; Array data = pv.read(typicalDataset); if (data == null) throw new IOException("cant read "+typicalDataset); pv.dtype = DataType.getType(data.getElementType()); VariableDS promotedVar = new VariableDS(ncDataset, null, null, pv.varName, pv.dtype, dimName, null, null); /* if (data.getSize() > 1) { // LOOK case of non-scalar global attribute not delat with Dimension outer = ncDataset.getRootGroup().findDimension(dimName); Dimension inner = new Dimension("", (int) data.getSize(), false); //anonymous List<Dimension> dims = new ArrayList<Dimension>(2); dims.add(outer); dims.add(inner); promotedVar.setDimensions(dims); } */ ncDataset.addVariable(null, promotedVar); promotedVar.setProxyReader( this); promotedVar.setSPobject(pv); } }
@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; }
@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; }
protected void promoteGlobalAttributes(DatasetOuterDimension typicalDataset) throws IOException { for (CacheVar cv : cacheList) { if (!(cv instanceof PromoteVar)) continue; PromoteVar pv = (PromoteVar) cv; Array data = pv.read(typicalDataset); if (data == null) throw new IOException("cant read "+typicalDataset); pv.dtype = DataType.getType(data); VariableDS promotedVar = new VariableDS(ncDataset, null, null, pv.varName, pv.dtype, dimName, null, null); /* if (data.getSize() > 1) { // LOOK case of non-scalar global attribute not delat with Dimension outer = ncDataset.getRootGroup().findDimension(dimName); Dimension inner = new Dimension("", (int) data.getSize(), false); //anonymous List<Dimension> dims = new ArrayList<Dimension>(2); dims.add(outer); dims.add(inner); promotedVar.setDimensions(dims); } */ ncDataset.addVariable(null, promotedVar); promotedVar.setProxyReader( this); promotedVar.setSPobject(pv); } }
/** * Promote a global attribute to a variable * * @param varName name of agg variable * @param orgName name of global attribute, may be different from the variable name */ void addVariableFromGlobalAttribute(String varName, String orgName) { cacheList.add(new PromoteVar(varName, orgName)); }
/** * Promote a global attribute to a variable * * @param varName name of agg variable * @param orgName name of global attribute, may be different from the variable name */ void addVariableFromGlobalAttribute(String varName, String orgName) { cacheList.add(new PromoteVar(varName, orgName)); }