/** * Add all; replace old if has same name */ public void addAll(Iterable<Attribute> atts) { for (Attribute att : atts) addAttribute(att); }
private void addAttributes(Group g, DodsV dodsV) { List<DODSAttribute> atts = dodsV.attributes; for (Attribute ncatt : atts) { g.addAttribute(ncatt); } }
/** * Add an attribute to a group. * * @param parent add to this group. If group is null, use root group * @param att add this attribute * @return the attribute that was added */ public Attribute addAttribute(Group parent, Attribute att) { if (immutable) throw new IllegalStateException("Cant modify"); if (parent == null) parent = rootGroup; parent.addAttribute(att); return att; }
/** * Add an attribute to a group. * * @param parent add to this group. If group is null, use root group * @param att add this attribute * @return the attribute that was added */ public Attribute addAttribute(Group parent, Attribute att) { if (immutable) throw new IllegalStateException("Cant modify"); if (parent == null) parent = rootGroup; parent.addAttribute(att); return att; }
/** * Add an attribute to a group. * * @param parent add to this group. If group is null, use root group * @param att add this attribute * @return the attribute that was added */ public Attribute addAttribute(Group parent, Attribute att) { if (immutable) throw new IllegalStateException("Cant modify"); if (parent == null) parent = rootGroup; parent.addAttribute(att); return att; }
private void addAttribute(Object parent, ucar.nc2.Attribute att) { if (parent instanceof Group) ((Group) parent).addAttribute(att); else if (parent instanceof Variable) ((Variable) parent).addAttribute(att); }
private void addAttribute(Object parent, ucar.nc2.Attribute att) { if (parent instanceof Group) ((Group) parent).addAttribute(att); else if (parent instanceof Variable) ((Variable) parent).addAttribute(att); }
private void addAttribute(Object parent, ucar.nc2.Attribute att) { if (parent instanceof Group) ((Group) parent).addAttribute(att); else if (parent instanceof Variable) ((Variable) parent).addAttribute(att); }
/** * Add optional String attribute to a group. * * @param parent add to this group. If group is null, use root group * @param name attribute name, may not be null * @param value attribute value, may be null, in which case, do not addd * @return the attribute that was added */ public Attribute addAttribute(Group parent, String name, String value) { if (immutable) throw new IllegalStateException("Cant modify"); if (value == null) return null; if (parent == null) parent = rootGroup; Attribute att = new Attribute(name, value); parent.addAttribute(att); return att; }
/** * Copy attributes from src to target, skip ones that already exist (by name) * @param src copy from here * @param target copy to here */ static public void transferGroupAttributes(Group src, Group target) { for (Attribute a : src.getAttributes()) { if (null == target.findAttribute(a.getShortName())) target.addAttribute(a); } }
/** * Copy attributes from src to target, skip ones that already exist (by name) * @param src copy from here * @param target copy to here */ static public void transferGroupAttributes(Group src, Group target) { for (Attribute a : src.getAttributes()) { if (null == target.findAttribute(a.getShortName())) target.addAttribute(a); } }
/** * Copy attributes from src to target, skip ones that already exist (by name) * @param src copy from here * @param target copy to here */ static public void transferGroupAttributes(Group src, Group target) { for (Attribute a : src.getAttributes()) { if (null == target.findAttribute(a.getShortName())) target.addAttribute(a); } }
/** * Rename a global Attribute. Must be in define mode. * @param oldName existing Attribute has this name * @param newName rename to this * @return renamed Attribute, or null if not found */ public Attribute renameGlobalAttribute(String oldName, String newName) { if (!defineMode) throw new UnsupportedOperationException("not in define mode"); Attribute att = findGlobalAttribute(oldName); if (null == att) return null; rootGroup.remove(att); att = new Attribute( newName, att.getValues()); rootGroup.addAttribute( att); return att; }
/** * Rename a global Attribute. Must be in define mode. * @param oldName existing Attribute has this name * @param newName rename to this * @return renamed Attribute, or null if not found */ public Attribute renameGlobalAttribute(String oldName, String newName) { if (!defineMode) throw new UnsupportedOperationException("not in define mode"); Attribute att = findGlobalAttribute(oldName); if (null == att) return null; rootGroup.remove(att); att = new Attribute( newName, att.getValues()); rootGroup.addAttribute( att); return att; }
/** * Rename a global Attribute. Must be in define mode. * @param oldName existing Attribute has this name * @param newName rename to this * @return renamed Attribute, or null if not found */ public Attribute renameGlobalAttribute(String oldName, String newName) { if (!defineMode) throw new UnsupportedOperationException("not in define mode"); Attribute att = findGlobalAttribute(oldName); if (null == att) return null; rootGroup.remove(att); att = new Attribute( newName, att.getValues()); rootGroup.addAttribute( att); return att; }
public void augmentDataset(NetcdfDataset ds, CancelTask cancelTask) throws IOException { String start_date = ds.findAttValueIgnoreCase(null, "start_date", null); SimpleDateFormat df = new SimpleDateFormat("yyyy.DDD.HH.mm.ss"); // "2006.105.00.00.00" DateFormatter dfo = new DateFormatter(); Date start = null; try { start = df.parse(start_date); } catch (ParseException e) { throw new RuntimeException("Cant read start_date="+start_date); } Variable v = ds.findVariable("time_offset"); v.addAttribute(new Attribute( CDM.UNITS, "seconds since "+dfo.toDateTimeString(start))); Group root = ds.getRootGroup(); root.addAttribute(new Attribute( CDM.CONVENTIONS, "Suomi-Station-CDM")); ds.finish(); }
private void addGroup(NetcdfFile ncfile, Group parent, GribCollectionImmutable.GroupGC group, GribCollectionImmutable.Type gctype, boolean useGroups) { Group g; if (useGroups) { g = new Group(ncfile, parent, group.getId()); g.addAttribute(new Attribute(CDM.LONG_NAME, group.getDescription())); try { ncfile.addGroup(parent, g); } catch (Exception e) { logger.warn("Duplicate Group - skipping"); return; } } else { g = parent; } makeGroup(ncfile, g, group, gctype); }
public void augmentDataset(NetcdfDataset ds, CancelTask cancelTask) throws IOException { String start_date = ds.findAttValueIgnoreCase(null, "start_date", null); if (start_date == null) return; SimpleDateFormat df = new SimpleDateFormat("yyyy.DDD.HH.mm.ss"); // "2006.105.00.00.00" DateFormatter dfo = new DateFormatter(); Date start; try { start = df.parse(start_date); } catch (ParseException e) { throw new RuntimeException("Cant read start_date="+start_date); } Variable v = ds.findVariable("time_offset"); v.addAttribute(new Attribute( CDM.UNITS, "seconds since "+dfo.toDateTimeString(start))); Group root = ds.getRootGroup(); root.addAttribute(new Attribute( CDM.CONVENTIONS, "Suomi-Station-CDM")); ds.finish(); }
private void convertGroup(Group g, Group from) { for (EnumTypedef et : from.getEnumTypedefs()) g.addEnumeration(et); for (Dimension d : from.getDimensions()) g.addDimension(new Dimension(d.getShortName(), d)); for (Attribute a : from.getAttributes()) g.addAttribute(a); for (Variable v : from.getVariables()) g.addVariable(convertVariable(g, v)); for (Group nested : from.getGroups()) { Group nnested = new Group(this, g, nested.getShortName()); g.addGroup(nnested); convertGroup(nnested, nested); } }
private void convertGroup(Group g, Group from) { for (EnumTypedef et : from.getEnumTypedefs()) g.addEnumeration(et); for (Dimension d : from.getDimensions()) g.addDimension(new Dimension(d.getShortName(), d)); for (Attribute a : from.getAttributes()) g.addAttribute(a); for (Variable v : from.getVariables()) g.addVariable(convertVariable(g, v)); for (Group nested : from.getGroups()) { Group nnested = new Group(this, g, nested.getShortName()); g.addGroup(nnested); convertGroup(nnested, nested); } }