Jump to content

Search the Community

Showing results for tags 'Expression'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • About this forum
    • How to use this forum
    • Forum Feedback
    • Announcement
  • TUFLOW FV Modelling
    • Dongles/Licensing/Installation
    • Mesh Building
    • Numerical Scheme
    • Model Building
    • Initial Conditions
    • Boundary Conditions
    • Turbulence
    • Structures
    • 3D Module
    • AD Module
    • Atmospheric Module
    • ST + MORPH Module
    • Post Processing
    • Other
    • Errors
  • Other 3rd party products
    • SMS
    • MatLab
    • Excel
    • GIS
    • Text Editors

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 4 results

  1. The expression tool can be taken even further. If you want to input some function that requires input from two separate model runs, this can be achieved with a simple specifier. First you need to input a cell array of model files in the modfil input, the order of this is important. Then, (for example if we were comparing water level between two runs with different bathymetery), we specify our variables with M1. or M2. beforehand. eg. 'M1.H - M2.H' will subtract the water level of the second model in the model cell array from the water level of the first model. This has the same limitations of normal expressions, therefore at this stage it is not possible to do these comparisons on models with different numbers of cells.
  2. The 'expression' property of fvg objects has a few more advanced options for truly customized output. One of these is the ability to bring in a workspace variable as part of your expression. Just put a dollar sign ($) in front of the variable that you wish to include from your workspace, ie. if you have a variable a=2; and you want to offset your water levels by this then '$a+H' would be your expression string. For single scalars though it is probably better to specify it directly, ie. if you want to offset all the water levels by 2m then 'H+2' is easier than storing the 2m in a variable beforehand. The real strength of this is for vectors, keep in mind that as usual, these vector and matrix operations will have specific limitations on size, and there are no extra checks in place to account for this. A useful example of using this is to plot the difference in a variable since a particular timestep, for example the start. A quick example is plotting the total change in bed level since the beginning of the model run, it will require extracting a variable seperately first. tmp = netcdf_get_var(modfil,'names','ZB','timestep',1); %BMTWBM function that will extract ZB at the first timestep firstbedlevel = tmp.ZB; %get it out of a structure and save it to a useful variable fobj = fvgraphics; %usual, gca customsheet = fvg_sheet(fobj, modfil, 'expression', 'ZB - $firstbedlevel') There are a lot of possibilities with this, the only downside being that it does require a bit of setting up first to get the variable that you want. Keep in mind that this variable will be 'saved' into the function persistantly, so even if you clear the original 'firstbedlevel' from your workspace, or change it, only the original one will be used in the calculations. If you wish to update the variable, then you must call the 'set' method on the expression again. ie. firstbedlevel = firstbedlevel+1; %changed the variable set(customsheet,'expression','ZB - $firstbedlevel'); %now it will bring in the new version of 'firstbedlevel';
  3. fvg objects all have a great property call 'expression'. This allows the users to overload the variables with a custom combination of variables. The scope of uses for this ranges from changing current velocity units to km/h, up to computing total change in bed level over time. the expression needs to be a string. eg. fvg_sheet(fobj , modfil , 'expression' , 'V*3.6') This will read in the variable V, then multiply it by 3.6, then plot that. You do not specify the variables when doing this, it is all done on the expression. This doesnt affect any other properties. a few things to keep in mind: The expression will allow some matlab builtins, sum, hypot, min, max, etc. but the correct, and sensible usage of all the functions is up to the users discretion. The variables that you will be working with will typically have some dimension followed by a number of cells dimension. The first dimension can be depth levels, or it could be number of sediments. keep that in mind when executing expressions that might change depending on whether doing calculations 'element-wise', or on the whole array. The expression calculations occur before depth averaging, so operations that occur on 2D and 3D variables at the same time ie. H*SAL will not work. Derived variables that may be allowed in the 'variables' property (ie. Vmag) will not be available in the expression string, you will have to calculate these from scratch if you need them, ie. 'hypot(V_x,V_y)'.
  4. When I look at the waves within a simulation I like to view the wave heights overlain with wave vectors. The magnitude of the vectors is the WVHT output and the direction the WVDIR output (cartesian convention). A neat way to do this is to use the "Expression" property of a fvg_sheetvec object. Example: % create the control object fvcObj = fvgraphics; % visualise the wave heights sheetObj = fvg_sheet(fvcObj,'mymodel.nc','Variables','WVHT'); % create the expression which defines the x-component and then the y-component of your vectors. The x-component must come first expression{1} = 'WVHT.*cosd(WVDIR)'; expression{2} = 'WVHT.*sind(WVDIR)'; % create the vector object vecObj = fvg_sheetvec(fvcObj,'mymodel.nc','Expression',expression)
  • Create New...