Java Code Examples for ucar.nc2.dataset.NetcdfDataset#Enhance
The following examples show how to use
ucar.nc2.dataset.NetcdfDataset#Enhance .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Aggregation.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Add a dataset scan * * @param crawlableDatasetElement defines a CrawlableDataset, or null * @param dirName scan this directory * @param suffix filter on this suffix (may be null) * @param regexpPatternString include if full name matches this regular expression (may be null) * @param dateFormatMark create dates from the filename (may be null) * @param enhanceMode how should files be enhanced * @param subdirs equals "false" if should not descend into subdirectories * @param olderThan files must be older than this time (now - lastModified >= olderThan); must be a time unit, may ne * bull */ public void addDatasetScan(Element crawlableDatasetElement, String dirName, String suffix, String regexpPatternString, String dateFormatMark, Set<NetcdfDataset.Enhance> enhanceMode, String subdirs, String olderThan) { datasetManager.addDirectoryScan(dirName, suffix, regexpPatternString, subdirs, olderThan, enhanceMode); this.dateFormatMark = dateFormatMark; if (dateFormatMark != null) { isDate = true; if (type == Type.joinExisting) type = Type.joinExistingOne; // tricky DateExtractor dateExtractor = new DateExtractorFromName(dateFormatMark, true); datasetManager.setDateExtractor(dateExtractor); } }
Example 2
Source File: AggDataset.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected AggDataset(MFile mfile, @Nullable Object spiObject, @Nullable Element ncmlElem) { this.mfile = mfile; this.cacheLocation = mfile.getPath(); Set<NetcdfDataset.Enhance> wantEnhance = (Set<NetcdfDataset.Enhance>) mfile.getAuxInfo(); this.enhance = (wantEnhance == null) ? NetcdfDataset.getEnhanceNone() : wantEnhance; this.id = null; this.reader = null; this.spiObject = spiObject; this.ncmlElem = ncmlElem; }
Example 3
Source File: Aggregation.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Add a dataset scan * * @param crawlableDatasetElement defines a CrawlableDataset, or null * @param dirName scan this directory * @param suffix filter on this suffix (may be null) * @param regexpPatternString include if full name matches this regular expression (may be null) * @param dateFormatMark create dates from the filename (may be null) * @param enhanceMode how should files be enhanced * @param subdirs equals "false" if should not descend into subdirectories * @param olderThan files must be older than this time (now - lastModified >= olderThan); must be a time unit, may ne * bull */ public void addDatasetScan(Element crawlableDatasetElement, String dirName, String suffix, String regexpPatternString, String dateFormatMark, Set<NetcdfDataset.Enhance> enhanceMode, String subdirs, String olderThan) { datasetManager.addDirectoryScan(dirName, suffix, regexpPatternString, subdirs, olderThan, enhanceMode); this.dateFormatMark = dateFormatMark; if (dateFormatMark != null) { isDate = true; if (type == Type.joinExisting) type = Type.joinExistingOne; // tricky DateExtractor dateExtractor = new DateExtractorFromName(dateFormatMark, true); datasetManager.setDateExtractor(dateExtractor); } }
Example 4
Source File: DecoderWrapper.java From sis with Apache License 2.0 | 5 votes |
/** * Returns all grid geometries (related to coordinate systems) found in the netCDF file. * This method returns a direct reference to an internal array - do not modify. * * @return all grid geometries, or an empty array if none. * @throws IOException if an I/O operation was necessary but failed. */ @Override @SuppressWarnings({"ReturnOfCollectionOrArrayField", "null"}) public Grid[] getGrids() throws IOException { if (geometries == null) { List<CoordinateSystem> systems = null; if (file instanceof NetcdfDataset) { final NetcdfDataset ds = (NetcdfDataset) file; final EnumSet<NetcdfDataset.Enhance> mode = EnumSet.copyOf(ds.getEnhanceMode()); if (mode.add(NetcdfDataset.Enhance.CoordSystems)) { /* * Should not happen with NetcdfDataset opened by the constructor expecting a filename, * because that constructor already enhanced the dataset. It may happen however if the * NetcdfDataset was given explicitly by the user. We try to increase the chances to * get information we need, but it is not guaranteed to work; it may be too late if we * already started to use the NetcdfDataset before this point. */ ds.enhance(mode); } systems = ds.getCoordinateSystems(); /* * If the UCAR library does not see any coordinate system in the file, verify if there is * a custom convention recognizing the axes. CSBuilderFallback uses the mechanism defined * by Apache SIS for determining variable role. */ if (systems.isEmpty() && convention() != Convention.DEFAULT) { final CSBuilderFallback builder = new CSBuilderFallback(this); builder.buildCoordinateSystems(ds); systems = ds.getCoordinateSystems(); } } geometries = new Grid[(systems != null) ? systems.size() : 0]; for (int i=0; i<geometries.length; i++) { geometries[i] = new GridWrapper(systems.get(i)); } } return geometries; }
Example 5
Source File: Aggregation.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected Dataset(MFile mfile) { this.mfile = mfile; this.cacheLocation = mfile.getPath(); this.enhance = (Set<NetcdfDataset.Enhance>) mfile.getAuxInfo(); }
Example 6
Source File: AggregationOuterDimension.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected Dataset makeDataset(String cacheName, String location, String id, String ncoordS, String coordValueS, String sectionSpec, EnumSet<NetcdfDataset.Enhance> enhance, ucar.nc2.util.cache.FileFactory reader) { return new DatasetOuterDimension(cacheName, location, id, ncoordS, coordValueS, enhance, reader); }
Example 7
Source File: AggregationTiled.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected Dataset makeDataset(String cacheName, String location, String id, String ncoordS, String coordValueS, String sectionSpec, EnumSet<NetcdfDataset.Enhance> enhance, ucar.nc2.util.cache.FileFactory reader) { return new DatasetTiled(cacheName, location, id, sectionSpec, enhance, reader); }
Example 8
Source File: NcMLReaderNew.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * parse a netcdf JDOM Element, and add contents to the targetDS NetcdfDataset. * <p/> * This is a bit tricky, because it handles several cases When targetDS == refds, we are just modifying targetDS. When * targetDS != refds, * we keep them seperate, and copy from refds to newds. * <p/> * The user may be defining new elements or modifying old ones. The only way to tell is by seeing if the elements * already exist. * * @param ncmlLocation NcML URL location, or may be just a unique name for caching purposes. * @param builder add the info to this one * @param netcdfElem JDOM netcdf element * @param cancelTask allow user to cancel the task; may be null * @throws IOException on read error */ private void readNetcdf(String ncmlLocation, NetcdfDataset.Builder builder, Element netcdfElem, @Nullable CancelTask cancelTask) throws IOException { this.location = ncmlLocation; // log messages need this // detect incorrect namespace Namespace use = netcdfElem.getNamespace(); if (!use.equals(ncNSHttp) && !use.equals(ncNSHttps)) { String message = String.format("Namespace specified in NcML must be either '%s' or '%s', but was '%s'.", ncNSHttp.getURI(), ncNSHttps.getURI(), use.getURI()); throw new IllegalArgumentException(message); } if (ncmlLocation != null) { builder.setLocation(ncmlLocation); } builder.setId(netcdfElem.getAttributeValue("id")); builder.setTitle(netcdfElem.getAttributeValue("title")); Element aggElem = netcdfElem.getChild("aggregation", ncNS); if (aggElem != null) { Aggregation agg = readAgg(aggElem, ncmlLocation, builder, cancelTask); builder.setAggregation(agg); agg.build(cancelTask); // LOOK seems like we should add the agg metadata here, so that it can be modified. } // read the root group and recurse readGroup(builder, null, null, netcdfElem); String errors = errlog.toString(); if (!errors.isEmpty()) { throw new IllegalArgumentException("NcML had fatal errors:" + errors); } // enhance means do scale/offset and/or add CoordSystems Set<NetcdfDataset.Enhance> mode = parseEnhanceMode(netcdfElem.getAttributeValue("enhance")); if (mode != null) { // cant just set enhance mode if (DatasetEnhancer.enhanceNeeded(mode, null)) { DatasetEnhancer enhancer = new DatasetEnhancer(builder, mode, cancelTask); enhancer.enhance(); builder.setEnhanceMode(mode); } } /* * LOOK optionally add record structure to netcdf-3 * String addRecords = netcdfElem.getAttributeValue("addRecords"); * if ("true".equalsIgnoreCase(addRecords)) * targetDS.sendIospMessage(NetcdfFile.IOSP_MESSAGE_ADD_RECORD_STRUCTURE); */ }
Example 9
Source File: AggregationOuter.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected AggDataset makeDataset(String cacheName, String location, String id, String ncoordS, String coordValueS, String sectionSpec, EnumSet<NetcdfDataset.Enhance> enhance, ucar.nc2.util.cache.FileFactory reader) { return new AggDatasetOuter(this, cacheName, location, id, ncoordS, coordValueS, enhance, reader); }
Example 10
Source File: TestAggDatasetIsCached.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void showModes(Set<NetcdfDataset.Enhance> modes) { for (NetcdfDataset.Enhance mode : modes) { System.out.printf("%s,", mode); } System.out.printf("%n"); }
Example 11
Source File: Aggregation.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 3 votes |
/** * Dataset constructor. * With this constructor, the actual opening of the dataset is deferred, and done by the reader. * Used with explicit netcdf elements, and scanned files. * * @param cacheLocation a unique name to use for caching * @param location attribute "location" on the netcdf element * @param id attribute "id" on the netcdf element * @param enhance open dataset in enhance mode, may be null NOT USED * @param reader factory for reading this netcdf dataset; if null, use NetcdfDataset.open( location) */ protected Dataset(String cacheLocation, String location, String id, EnumSet<NetcdfDataset.Enhance> enhance, ucar.nc2.util.cache.FileFactory reader) { this.mfile = MFileOS.getExistingFile(location); this.cacheLocation = cacheLocation; this.id = id; // this.enhance = enhance; // LOOK why ?? this.reader = reader; }
Example 12
Source File: AggregationTiled.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 3 votes |
/** * Dataset constructor. * With this constructor, the actual opening of the dataset is deferred, and done by the reader. * Used with explicit netcdf elements, and scanned files. * * @param cacheName a unique name to use for caching * @param location attribute "location" on the netcdf element * @param id attribute "id" on the netcdf element * @param sectionSpec attribute "sectionSpec" on the netcdf element * @param enhance open dataset in enhance mode * @param reader factory for reading this netcdf dataset; if null, use NetcdfDataset.open( location) */ protected DatasetTiled(String cacheName, String location, String id, String sectionSpec, EnumSet<NetcdfDataset.Enhance> enhance, ucar.nc2.util.cache.FileFactory reader) { super(cacheName, location, id, enhance, reader); this.sectionSpec = sectionSpec; try { section = new Section(sectionSpec); } catch (InvalidRangeException e) { throw new IllegalArgumentException(e); } }
Example 13
Source File: Aggregation.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Dataset factory, so subclasses can override * * @param cacheName a unique name to use for caching * @param location attribute "location" on the netcdf element * @param id attribute "id" on the netcdf element * @param ncoordS attribute "ncoords" on the netcdf element * @param coordValueS attribute "coordValue" on the netcdf element * @param sectionSpec attribute "sectionSpec" on the netcdf element * @param enhance open dataset in enhance mode NOT USED * @param reader factory for reading this netcdf dataset * @return a Aggregation.Dataset */ protected Dataset makeDataset(String cacheName, String location, String id, String ncoordS, String coordValueS, String sectionSpec, EnumSet<NetcdfDataset.Enhance> enhance, ucar.nc2.util.cache.FileFactory reader) { return new Dataset(cacheName, location, id, enhance, reader); // overridden in OuterDim, tiled }
Example 14
Source File: Aggregation.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Dataset factory, so subclasses can override * * @param cacheName a unique name to use for caching * @param location attribute "location" on the netcdf element * @param id attribute "id" on the netcdf element * @param ncoordS attribute "ncoords" on the netcdf element * @param coordValueS attribute "coordValue" on the netcdf element * @param sectionSpec attribute "sectionSpec" on the netcdf element * @param enhance open dataset in enhance mode NOT USED * @param reader factory for reading this netcdf dataset * @return a Dataset */ protected AggDataset makeDataset(String cacheName, String location, String id, String ncoordS, String coordValueS, String sectionSpec, EnumSet<NetcdfDataset.Enhance> enhance, ucar.nc2.util.cache.FileFactory reader) { return new AggDataset(cacheName, location, id, enhance, reader, spiObject, ncmlElem); // overridden in OuterDim, // tiled }