Absolute Min or Max over time

User recently asked : What is the minimum temperature experienced at any point, throughout the whole time domain?  (absolute temporal minimum) Good question. This conceptually boils down to finding the minimum at each time, and then traversing the temporal domain looking for new minimum.

The Min() function works at a particular timestep, and will automatically update when the timestep is changed, but it is not easy to keep track of what the Min(Min()) is.

EnSight already has some very helpful temporal functions to return new variables that are sampled over time. One of them is “TempMinmaxField”, which returns the minimum or maximum over time in a particular element or node. This returns a new scalar or vector field which is minimum or maximum experienced over time in each element or node. This works great, but is limited to a geometry which does not change connectivity. His geometry is changing, so this feature does not work.

However, there are some Python provided hooks into the variable information which will immediately return items like the minimum or maximum. Now, this function is not tied to any particular part, but is rather the variable attribute rather than part related quantity.

Here is an example of using that Python call to return both the absolute minimum and maximum over time for a particular variable:

# SUBROUTINE to loop through all timesteps to figure out min and max over time
def find_minmax(step_min,step_max,varname):
nstep = step_max – step_min + 1
min_val = 9e99
max_val = -9e99
a = ensight.query(ensight.VARIABLE_OBJECTS)
var_list = a[2]
for i in range(len(var_list)):
name_now = var_list[i]
if name_now == varname:
var_id = i
for i in range(nstep):
b = ensight.query(ensight.VARIABLE_INFORMATION,var_id)
local_min_val = b[2][0]
local_max_val = b[2][1]
if local_min_val < min_val:
min_val = local_min_val
if local_max_val > max_val:
max_val = local_max_val

Direct Access to Variable information

Want a quick look at the variables in your model? Want to figure out minimums and maximums in a few steps? Through the use of Python in EnSight, you can get direct access to items such as what variable names are available (to check to see what the dataset has, or figure out if your potential new names conflict with any already there). You can also get quick access to items like min and max (for the model). This is particularly handy with regards to Vectors, where you can direct return of all components and magnitude.

# Obtain variable min and max info
varname = "Momentum"

print "========================="
a = ensight.query(ensight.VARIABLE_OBJECTS)
var_list = a[2]
for i in range(len(var_list)):
    name_now = var_list[i]
    if name_now == varname:
        print "Found ",varname
        var_id = i
        print "Var_Id = ",var_id
        type_flag = a[1][var_id + 1]
        print "Type_flag = ",type_flag
        b = ensight.query(ensight.VARIABLE_INFORMATION,var_id)
        if type_flag == 0:
            min_val = b[2][0]
            max_val = b[2][1]
            print "Min_val = ",min_val
            print "Max_val = ",max_val
        if type_flag == 1:
            minx = b[2][0]
            maxx = b[2][1]
            miny = b[2][2]
            maxy = b[2][3]
            minz = b[2][4]
            maxz = b[2][5]
            minmag = b[2][6]
            maxmag = b[2][7]
            print "Minvals = ",minx,miny,minz
            print "Maxvals = ",maxx,maxy,maxz
            print "Mag     = ",minmag,maxmag

temporal statistics

The EnSight calculator has the StatMoment function to calculate spatial  statistical quantities: mean, variance, skew, and kurtosis as shown in the image below from the User Manual.

But the EnSight calculator includes only the ability to calculate three temporal statistical quantities, min max and mean using two calculator functions.  An EnSight Python script is provided to calculate temporal mean, temporal variance, temporal skew and temporal kurtosis as well as temporal sum, temporal RMS, temporal min and temporal max scalars.  These are calculated over time rather than space, resulting in a spatial scalar with each element containing it’s temporal statistics.

These variables are named per the comments in the python script.

The user will have to edit this python script and change the variable name var_name to be their variable name, change the begin and end time values, and change the values of the variance_flag, skew_flag, and kurt_flag to True or False, in order to calculate these values.  Note that in order to calculate variance, skew or kurtosis, all other previous values must be True.

Note that an entire pass through all the timesteps is required for each of the temporal statistical values requested. That is, mean, variance, skew and kurtosis will require a total of 4 passes through all time.  Temporal sum, temporal RMS, temporal min, and temporal max will require an additional 4 passes.  For large datasets with a large number of times this can take quite a while.  First run this with the variance, skew and kurtosis flags set to false and set the min and max time close together to get an idea of how long it takes for one pass through.

Note that this will work for static geometry with temporal variables, or changing coordinate geometry with temporal variables.  It will not work for changing connectivity geometry, where the geometry connectivity changes at each timestep.  Do a query>dataset to determine if what kind of geometry is in your specific dataset.

The python script makes creative use of the temporal mean function included in EnSight to do temporal integrations using intermediate variables.  The Temporal Mean calculator function in EnSight uses, by default, the Trapezoidal rule for temporal integration.  The results using this integration are shown below.


Temporal Statistics Results for Flow2d Dataset

As of EnSight 9.2.2(e), a statistical integration option is allowed for Temporal Mean.  This methodology simply uses the data and the step size in a rectangular integration. This python script turns this form of integration on for the duration of the script then restores it back to the default of using Trapezoidal Rule.  Shown below are the results using this new statistical integration.  For this dataset there is not significant difference until the kurtosis.

and the temporal sum, min, max, and RMS are shown below.

Click on the link below to get the python script.