Two viewers

I have previously looked at using Excel for generation of images from data listing  3D coordinates of points and lists of connections (see  https://newtonexcelbach.wordpress.com/2012/09/27/daily-download-11-perspective-projection/ for instance), but this approach is limited in what can be done:

  • It will only generate a “wire-frame” image
  • It doesn’t provide any means of processing the data
  • It is very slow if the images contains more than a few thousand lines

Paraview (to quote from their web site) is “an open-source, multi-platform data analysis and visualization application. ParaView users can quickly build visualizations to analyze their data using qualitative and quantitative techniques. The data exploration can be done interactively in 3D or programmatically using ParaView’s batch processing capabilities.

ParaView was developed to analyze extremely large datasets using distributed memory computing resources. It can be run on supercomputers to analyze datasets of exascale size as well as on laptops for smaller data.”

It came to my attention through the latest edition of “Programming the Finite Element Method” which I recently purchased.  This publication contains Fortran routines for generating Paraview readable files of finite element models, including output data, which can then be used to generate surface contoured images and animations for instance.  As well as being open-source, Paraview uses Python as a scripting language, which would seem to offer the possibility of linking it to Excel for direct transfer of data.

It must be said that the program appears to be sufficiently complex to require a significant learning period before it can be used effectively, but comments from a user at OSGeology suggest that this will be worth the effort.

A related product is the Kiwi Viewer which will allow the VTK files used by Paraview to be viewed on tablet and phone devices (both I-phone and Android).

You Tube video illustrating some basics of working in Paraview:

And the Kiwi Viewer in action:

Posted in Animation, Computing - general, Finite Element Analysis, Newton | Tagged , , | Leave a comment

Download update 2

I have updated the Downloads spreadsheet on Skydrive to include all new files added this year, and I have also added two Category columns, which link to the Download by Category page, giving more details and links for each file.  The list can be sorted on-line if you select “edit” mode, or download and open in Excel.

Posted in Computing - general, Excel, Newton, UDFs, VBA | Tagged , , , | Leave a comment

Download update – Python downloads

Download files related to linking to Python from Excel are to be found in:

Python matrix functions in Excel, using Pyxll:
Download file: http://interactiveds.com.au/software/Matrixpyxll.zip

Python for VBA users – 4; Python data types:  The main Python data types, including numpy arrays, with examples of their use in PyXll functions.
Download file: http://interactiveds.com.au/software/pyTypes.zip

Python for VBA users – 5; Using built in numpy functions:
Download file: http://interactiveds.com.au/software/py_Polynomial.zip

Also see the PyXll add-in, which is required for the downloads in this category.

 

Posted in Excel, Link to Python, UDFs, VBA | Tagged , , , , , | Leave a comment

Extracting numbers from text strings

There is often a need to extract numbers from the start or end of text strings.  It’s not too hard to do with on-sheet formulas, but after having done it a few thousand times I decided it would be worth spending 5 minutes writing two VBA User Defined Functions (UDFs) to do the job.  Here they are:

NumRight() will extract a number from the right hand end of a text string, with the number delimited by a space by default, or optionally any other character:

Function NumRight(NumStrings As Variant, Optional Delim As String = " ") As Variant
Dim i As Long, numrows As Long, OutA() As Variant, j As Long, NumDig As Long, Numstring As String, StringLen As Long

    If TypeName(NumStrings) = "Range" Then NumStrings = NumStrings.Value2
    If TypeName(NumStrings) = "String" Then
        numrows = 1
    Else
        numrows = UBound(NumStrings)
    End If

    ReDim OutA(1 To numrows, 1 To 1)
    On Error Resume Next
    For i = 1 To numrows
        If IsArray(NumStrings) = True Then
            Numstring = NumStrings(i, 1)
        Else
            Numstring = NumStrings
        End If
        StringLen = Len(Numstring)
        j = 1
        Do While Left(Right(Numstring, j), 1) <> Delim
            If j >= StringLen Then Exit Do
            j = j + 1
        Loop
        If j >= StringLen Then
            OutA(i, 1) = ""
        Else
            OutA(i, 1) = CDbl(Right(Numstring, j - 1))
        End If
    Next i
    NumRight = OutA
End Function

Numleft() is similar, but extracts a number from the left hand end.

Function NumLeft(NumStrings As Variant, Optional Delim As String = " ") As Variant
Dim i As Long, numrows As Long, OutA() As Variant, j As Long, NumDig As Long, Numstring As String, StringLen As Long

    If TypeName(NumStrings) = "Range" Then NumStrings = NumStrings.Value2
    If TypeName(NumStrings) = "String" Then
        numrows = 1
    Else

        numrows = UBound(NumStrings)
    End If

    ReDim OutA(1 To numrows, 1 To 1)
    On Error Resume Next
    For i = 1 To numrows
        If IsArray(NumStrings) = True Then
            Numstring = NumStrings(i, 1)
        Else
            Numstring = NumStrings
        End If

        StringLen = Len(Numstring)
        j = 1
        Do While Right(Left(Numstring, j), 1) <> Delim
            If j >= StringLen Then Exit Do
            j = j + 1
        Loop
        If j >= StringLen Then
            OutA(i, 1) = ""
        Else
            OutA(i, 1) = CDbl(Left(Numstring, j - 1))
        End If

    Next i
    NumLeft = OutA
End Function

For both functions the input “NumStrings” may be either a single cell or a single column range. In the latter case the function must be entered as an array function to return all the results:

  • Enter the function, with the input range being a single column range
  • Select the range of output rows, with the function in the top row
  • Press F2 (Edit)
  • Press Ctrl-Shift-Enter

The functions may be found in GetNum.xlsb, and have also been added to Text-in2.xlsb.

Here’s what they look like in use:

NumLeft and NumRight functions

NumLeft and NumRight functions

Posted in Excel, UDFs, VBA | Tagged , , , , , , | 13 Comments

1 Million Page Views

At some time in the next couple of hours or so the number of page views here will pass the 1 million mark, so congratulations in advance one millionth page viewer.

Stats by country4

I thought it would be interesting to see where all these viewers of 1 million pages come from, so here are the figures (since Feb 2012, when WordPress started publishing the daily count by country):

By Total Page Views

By Total Page Views

Unsurprisingly, the list sorted by total page views is headed by the English speaking countries, with the USA well ahead and Australia in third place, but more surprisingly:

By Page views / Million Population

By Page views / Million Population

, when sorted by page views per million population the USA falls to 21st place, Australia remains 3rd, headed by Latvia well ahead in first place, followed by Iceland.  Singapore is the first Asian country, ahead of the UK and Canada.  Hong Kong takes the second Asian spot in 13th place, but down at the bottom of the list:

By Page views / Million Population

By Page views / Million Population

mainland China comes in at 190th out of 192, with only 80 views from close to 20% of the World’s population.

So greetings to my fan or fans in Latvia and Iceland, I hope you find the blog continues to be worth reading!

Posted in Computing - general | Tagged , | 3 Comments