Class NetCDFOutputAdapter
java.lang.Object
net.simplace.sim.io.FWSimIOAdapter
net.simplace.sim.io.output.FWSimOutputAdapter
net.simplace.sim.io.output.adapter.NetCDFOutputAdapter
- All Implemented Interfaces:
FWSimFieldContainer
Output adapter writing the output of an
FWSimOutput to a NetCDF-3 file (NetCDFInterface). The file
has the dimensions time (unlimited, days since 1970-01-01), simulationid (number of
simulations from the interface) and stringlength (64); every output variable becomes a NetCDF variable
over time and simulation, arrays get an additional dimension count<n>. Missing numbers are
written as -999, missing texts, booleans and arrays are not written (fill value).
The adapter needs the first three columns to be project id, current date and simulation id (no
clean="true" header, no CAL frequency); otherwise the output is not written. If the file name depends
on the project (e.g. ${projectid}), each project gets its own file (see
updateFile(FWSimVarMap)).
- Author:
- Andreas Enders
-
Nested Class Summary
Nested classes/interfaces inherited from class FWSimIOAdapter
FWSimIOAdapter.FREQUENCE -
Field Summary
Fields inherited from class FWSimOutputAdapter
iCacheSize, iQueueFields inherited from class FWSimIOAdapter
iArrayMode, iFieldcount, iFrequence, iHeaderVariables, iInterface, iJexlRule, iKeyMap, iName, iOrderNumber, iProcessTime, iResourceElement, iSession, iSourceKey -
Constructor Summary
ConstructorsConstructorDescriptionNetCDFOutputAdapter(String aFile, String aName, String aDivider, int aOrderNumber, FWSimIOAdapter.FREQUENCE aFrequence, String aCacheSize, ProcessTime aProcessTime, FWSimSession aSession) Creates the adapter with its own NetCDF interface.NetCDFOutputAdapter(FWSimOutputAdapter aOldAdapter, FILEInterface aInterface) Copy constructor used when the interface is replaced.NetCDFOutputAdapter(org.jdom2.Element aResourceElement, int aOrderNumber, FWSimVarMap aVarMap) Creates the adapter from anoutputelement. -
Method Summary
Modifier and TypeMethodDescriptionvoidfinalize()Closes the file pool and the NetCDF writer.protected voidinit(FWSimVarMap aVarMap) Creates the NetCDF file with its dimensions, one variable per output variable (with units, description and aggregation mode as attributes) and global attributes describing solution, project and output.voidupdateFile(FWSimVarMap aVarMap) Determines the output file for the current project; if it differs from the current file, the current file is closed and a new file is created.protected voidwriteData(FWSimQueueObjectMap aObjectToWrite) Writes an output line to the NetCDF file (in the writer thread): a new date or simulation id is added to its dimension first, then each value (from the fourth column on) is written at its time and simulation index.Methods inherited from class FWSimOutputAdapter
createAdapter, createOutputFromObservable, getContentType, getInputVariables, getInterface, getOutputVariables, getQueueLenth, getResetScript, getStatistics, getStatisticsAdapter, getStatisticsHeaderVariables, getStatisticsResultCache, getVarMap, hasStatistics, initialize, isActive, isWriting, receiveData, toHTMLTablestring, toXML, updateAdapter, writeDataMethods inherited from class FWSimIOAdapter
addProcessTime, addVariable, checkCondition, createFormFields, createVariables, getCreateFormXML, getEditFormXML, getFieldMap, getFrequence, getHeaderVariables, getHeaderXML, getJexlRule, getKeyMap, getName, getOrderNumber, getVariable, isArrayMode, isConditionCheck, removeVariable, setFrequenceAndRule, setInterface, setOrderNumber, toString, writeHeaderList
-
Constructor Details
-
NetCDFOutputAdapter
public NetCDFOutputAdapter(org.jdom2.Element aResourceElement, int aOrderNumber, FWSimVarMap aVarMap) Creates the adapter from anoutputelement.- Parameters:
aResourceElement- theoutputelementaOrderNumber- order number of the adapteraVarMap- template variable map of the solution
-
NetCDFOutputAdapter
public NetCDFOutputAdapter(String aFile, String aName, String aDivider, int aOrderNumber, FWSimIOAdapter.FREQUENCE aFrequence, String aCacheSize, ProcessTime aProcessTime, FWSimSession aSession) Creates the adapter with its own NetCDF interface.- Parameters:
aFile- output fileaName- name of the adapter; the interface is named<name>_INTERFACEaDivider- not usedaOrderNumber- order number of the adapteraFrequence- frequency of the outputaCacheSize- capacity of the queueaProcessTime- runtime statistics of the adapteraSession- the session
-
NetCDFOutputAdapter
Copy constructor used when the interface is replaced.- Parameters:
aOldAdapter- the adapter to copyaInterface- the new interface
-
-
Method Details
-
init
Creates the NetCDF file with its dimensions, one variable per output variable (with units, description and aggregation mode as attributes) and global attributes describing solution, project and output. A file created before is closed first. Errors (also a wrong column layout) are logged and leave the writernull.- Specified by:
initin classFWSimOutputAdapter- Parameters:
aVarMap- variable map used for replacing tokens
-
writeData
Writes an output line to the NetCDF file (in the writer thread): a new date or simulation id is added to its dimension first, then each value (from the fourth column on) is written at its time and simulation index. Errors are logged.- Specified by:
writeDatain classFWSimOutputAdapter- Parameters:
aObjectToWrite- the output line- See Also:
-
finalize
Closes the file pool and the NetCDF writer.- Overrides:
finalizein classFWSimIOAdapter- Throws:
Exception- if closing fails- See Also:
-
updateFile
Determines the output file for the current project; if it differs from the current file, the current file is closed and a new file is created. Called by the output manager at the start of a project, after the lines of the previous project are written.- Parameters:
aVarMap- variable map of the first simulation of the project
-