Click or drag to resize

DfsExtensions Class

Set of extension methods for different interfaces and classes.
Inheritance Hierarchy
SystemObject
  DHI.Generic.MikeZero.DFSDfsExtensions

Namespace:  DHI.Generic.MikeZero.DFS
Assembly:  DHI.Generic.MIKEZero.DFS (in DHI.Generic.MIKEZero.DFS.dll) Version: 19.0.0.0 (11.1.1.1111)
Syntax
public static class DfsExtensions

The DfsExtensions type exposes the following members.

Methods
  NameDescription
Public methodStatic memberAxisEquals
Check whether two spatial axis equals.
Public methodStatic memberClone
Make a clone/copy of a spatial axis. Array data are copied (deep clone)
Public methodStatic memberCreateAllCoordinates
Create coordinates for all data points, based on the spatial axis.

It calculates node coordinates for all nodes in the axis, i.e. the number of Coords returned may not equal the number of data values in the item. And the coordinates may be offset by half a grid cell compared to the center coordinate for the data values.

Public methodStatic memberCreateEmptyItemData(IDfsSimpleDynamicItemInfo)
Public methodStatic memberCreateEmptyItemData(IDfsFile, Int32)
Public methodStatic memberCreateEmptyItemDataT(IDfsSimpleDynamicItemInfo)
Public methodStatic memberCreateEmptyItemDataT(IDfsFile, Int32)
Create an IDfsItemDataT of the correct type for the item with the given itemNumber.

The result can be used by ReadItemTimeStep(IDfsItemData, Int32)

If not the item is of type {T}, an exception will be thrown.

Public methodStatic memberCreateEmptyItemDatas(IDfsFile)
Public methodStatic memberCreateEmptyItemDatasT(IDfsFile)
Create an IDfsItemDataT of the provided type for each of the dynamic items in the file.

The result can be used by ReadItemTimeStep(IDfsItemData, Int32)

If not all items are of type {T}, an exception will be thrown.

Public methodStatic memberdfsDecodeT
Public methodStatic memberdfsEncodeT
Public methodStatic memberEndDateTime(IDfsEqCalendarAxis)
Get the end date time for an equidistant calendar axis.
Public methodStatic memberEndDateTime(IDfsNonEqCalendarAxis)
Get the end date time for a non-equidistant calendar axis.
Public methodStatic memberGeometryItemType
Get the item type of the spatial axis geometry.
Public methodStatic memberGetDateTimes(IDfsEqCalendarAxis)
Return an array of DateTimes which are the times for each timestep
Public methodStatic memberGetDateTimes(IDfsTemporalAxis)
Return an array of DateTimes which are the times for each timestep.

For non-equidistant axis, only the first and the last time are populated correctly. The rest are populated with MinValue.

For a complete list of DateTimes, also for non-equidistant axis, use the GetDateTimes(IDfsFile, DateTime, Boolean).

For time type axis, first time is StartTimeOffsetInSeconds(IDfsTemporalAxis) after MinValue.

Public methodStatic memberGetDateTimes(Void, DateTime)
Public methodStatic memberGetDateTimes(IDfsEqTimeAxis, DateTime)
Return an array of DateTimes which are the times for each timestep, using startTime as "zero" time.
Public methodStatic memberGetDateTimes(Void, DateTime, IDfsFile)
Public methodStatic memberGetRelativeSeconds
Return an array of doubles which are the the number of seconds since the start time for each timestep.

For non-equidistant axis, only the first and the last time are populated correctly. The rest are populated with -1

For time type axis, first time is StartTimeOffsetInSeconds(IDfsTemporalAxis)

Public methodStatic memberIsCalendar
Returns true if the temporal axis is a calendar axis
Public methodStatic memberIsEditable
Returns true if the filemode corresponds to a file that is editable.
Public methodStatic memberIsEquidistant
Returns true if the temporal axis is equidistant.
Public methodStatic memberMonthFraction
Gets the fractional month value of the DateTime.

The value returned for a specific day in the month way will differ for each month, depending on the number of days in each month

Public methodStatic memberReShapeT(T, Int32, Int32)
Reshape a 1D array to a 2D array of size [xCount , yCount]

The length of the arr must match (xCount X yCount)

Public methodStatic memberReShapeT(T, Int32, Int32, Int32)
Reshape a 1D array to a 3D array of size [xCount , yCount, zCount]

The length of the arr must match (xCount X yCount X , zCount)

Public methodStatic memberSearch(IDfsFile, DateTime)
Searches the dfs file for the time step index of a time, and returns the zero-based time step index. The time axis of the file must be a calendar type time axis

NOTE: For the non-equidistant time axes, the metod will read the first item in the file for a number of timesteps in random order, performing a binary search in the file data on disc. This will be slow if used many times on the same file. In such a case, use the lazy version of GetDateTimes(IDfsFile, Boolean) or GetDateTimes(IDfsFile, DateTime, Boolean).

For the equidistant time axis, the method will calculate the time step index directly without reading data from the file.

Public methodStatic memberSearch(IDfsFile, Double)
Searches the dfs file for the time step index of a time, and returns the zero-based time step index.

NOTE: For the non-equidistant time axes, the metod will read the first item in the file for a number of timesteps in random order, performing a binary search in the file data on disc. This will be slow if used many times on the same file. In such a case, use the lazy version of GetDateTimes(IDfsFile, Boolean) or GetDateTimes(IDfsFile, DateTime, Boolean).

For the equidistant time axis, the method will calculate the time step index directly without reading data from the file.

Public methodStatic memberSetStartDateTime
Set the start time of a calendar axis.

Will throw an exception in case of a time axis

Public methodStatic memberSetTimeStepInSeconds
Sets the time step in seconds for an equidistant temporal axis.

If the time axis is not equidistant, an exception is thrown

If the time axis unit can not be converted to seconds, an exception is thrown

Public methodStatic memberStartDateTime
Get the start time of a calendar axis.

Will throw an exception in case of a time axis

Public methodStatic memberStartTime Obsolete.
Get the start time of a calendar axis.

Will throw an exception in case of a time axis

Public methodStatic memberStartTimeOffsetInSeconds
Return the start time offset in seconds
Public methodStatic memberTimeAsDateTime
Convert the Time to a DateTime.

If the time axis is not a calender type time axis, an exception is thrown.

Public methodStatic memberTimeInSeconds
Convert the Time to seconds.
Public methodStatic memberTimeSpan
Time span of all data in file, in unit described by TimeUnit.

The StartTimeOffset is not included in the span. The span starts at the time of the StartTimeOffset

Convenience method that returns/calculates the time span consistently for all types of time axes,

Public methodStatic memberTimeSpanAsTimeSpan
Calculate the time span as a System.TimeSpan
Public methodStatic memberTimeSpanInSeconds
Calculate the time span in seconds
Public methodStatic memberTimeStepInSeconds(IDfsEqCalendarAxis)
Calculate the time step in seconds for an equidistant calendar axis

If the time axis unit can not be converted to seconds, an exception is thrown

Public methodStatic memberTimeStepInSeconds(IDfsEqTimeAxis)
Calculate the time step in seconds for an equidistant time axis

If the time axis unit can not be converted to seconds, an exception is thrown

Public methodStatic memberTimeStepInSeconds(IDfsTemporalAxis)
Calculate the time step in seconds for an equidistant temporal axis.

If the time axis is not equidistant, zero is returned.

If the time axis unit can not be converted to seconds, an exception is thrown

Public methodStatic memberToDateTime
Returns the relativeTime as a DateTime. The time axis must be a calendar type axis.
Public methodStatic memberToDoubleArray(Single)
Copies the float array into a double array.
Public methodStatic memberToDoubleArray(Single, Double)
Copies the float array into a double array.
Public methodStatic memberToFloatArray(Double)
Copies the double array into a float array.

The double values are truncated and the higher precision of a double number is lost.

Public methodStatic memberToFloatArray(Double, Single)
Copies the double array into a float array.

The double values are truncated and the higher precision of a double number is lost.

Public methodStatic memberToRelativeSeconds
Returns the dateTime in relative seconds from the start time of the time axis, in the unit used by the file. The time axis must be a calendar type axis.

Note that for the equidistant axes, the first time step may be offset (see StartTimeOffset), however the time returned here is relative to the start time and not the first time step. This is matching the time returned by the read methods (Time).

Public methodStatic memberToRelativeTime(IDfsTemporalAxis, DateTime)
Returns the dateTime in relative time from the start time of the time axis, in the unit used by the file. The time axis must be a calendar type axis.

Note that for the equidistant axes, the first time step may be offset (see StartTimeOffset), however the time returned here is relative to the start time and not the first time step. This is matching the time returned by the read methods (Time).

Public methodStatic memberToRelativeTime(IDfsTemporalAxis, Double)
Converts a time value in seconds to a time value in the unit of the temporal axis.
Public methodStatic memberToSeconds
Converts a time value in the unit of the temporal axis (TimeUnit) to a time value in seconds.
Public methodStatic memberToSecondsFactor(eumUnit)
Returns a factor for converting from a time value in the specified time unit to a time value in seconds.

For month and year time units, the factor not uniquely defined, and may not return the value you want to use.

Public methodStatic memberToSecondsFactor(IDfsTemporalAxis)
Returns a factor for converting from a time value in the specified time unit to a time value in seconds.

For month and year time units, the factor is not uniquely defined, and may not return the value you want to use.

Public methodStatic memberTotalYear
Gets the value of the DateTime as whole and fractional years.

The fractional value returned for a specific day in the year way will differ for years being leap-years and years not being leap-years.

Public methodStatic memberUpdate
Updates the destination axis with the properties from the source axis. Only the editable properties are edited.
Public methodStatic memberXCoordinatesTo2D
Copy the x coordinates of an IDfsAxisCurveLinearD2 to a 2D array.
Public methodStatic memberYCoordinatesTo2D
Copy the y coordinates of an IDfsAxisCurveLinearD2 to a 2D array.
Top
See Also