This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
> Hi, > > Sorry for pinging you so much about this ... allow me to try to explain > my goal more clearly: > > I am writing a utility class that will > 1. Read a specified source data file (e.g. a NetCDF file) > 2. Extract a subset of this data according to caller-defined parameters > (e.g. an arbitrary path or corridor through the source data) > 3. Return to the caller an Object - perhaps a GeoGrid, or a > NetcdfDataset - which contains the extracted subset. > > So: > (GeoGrid or NetcdfDataset) subset = > utilityClass_instance.extractSubset( [Source data file], [subset > parameters] ); > > Thus far I am able to extract the subset data from the source file, and > write out the subset data as a new NetCDF file, using a > NetcdfFileWriteable. But I do not want the subset to be written to > disk. I want the subset to be returned in memory, as an Object. > > An IOSP is designed to take data from a RandomAccessFile and dump it > into a submitted NetcdfFile. An IOSP just has to satisfy the contract of IOServiceProvider. It doesnt matter how it gets satisfied. You can create an IOSP any way you want - its an interface. If you don't need the RandomAccessFile, you can ignore it. Use memory-resident data, a random-number generator, etc to fill the data. You can create a NetcdfFile with the protected constructor, and pass in your IOSP: protected NetcdfFile(IOServiceProvider spi, RandomAccessFile raf, String location, CancelTask cancelTask); // need access to protected constructor class MyNetcdfFile extends NetcdfFile { MyNetcdfFile (IOServiceProvider spi, String name) { super(spi, null, name, null); } } Once you have a NetcdfFile, you can build a NetcdfFile, NetcdfDataset, GridDataset, etc, and use all the mechanism of subsetting already there. Ultimately those call your IOSP, and you must return the data correctly. Ticket Details =================== Ticket ID: VSP-832015 Department: Support netCDF Java Priority: Critical Status: Closed