Read Data in From Files as String

Tecplot's automation language

Python scripts were supported in the alpha version for Legacy 360 (2013). Python inquiries in 2017 should be directed to the PyTecplot Forum.

Moderators: davetaflin, salter, steve, jprenaud, straton, Chris Idso

wandadars
Newbie
Posts: 3
Joined: Tue May 27, 2014 2:48 pm
Location: Florida

Read Data in From Files as String

Postby wandadars » Thu May 29, 2014 8:33 am

Hi,

I'm using Tecplot 360 2013. I want to load multiple data files into tecplot and perform the same operation on all of the files. I want to write a macro that reads in the names of the files from a text file and then opens those files.

my files have names like: cylds_<number>.plt. The number is a floating point number written in scientific notation i.e. 5.034E-03.

I'm using the following command to read in the number suffix for the files from a file that I created called Extracted_Data_Labels.txt.

Code: Select all

$!READDATASET  '"|MFBD|/Extracted_Data_Labels.txt" '
$!VARSET |CTR| +=1
$!GetFieldValue |Value|
ZONE = 1
VAR = 2
Index = |CTR|


The code where I try to open and read the file with the given number from the data file is:

Code: Select all

$!READDATASET  '"|MFBD|/cylds_|Value|.plt" '
  READDATAOPTION = NEW
  RESETSTYLE = YES
  INCLUDETEXT = NO
  INCLUDEGEOM = NO
  INCLUDECUSTOMLABELS = NO
  VARLOADMODE = BYNAME
  ASSIGNSTRANDIDS = YES
  INITIALPLOTTYPE = CARTESIAN2D
  VARNAMELIST = '"x" "y" "z" "r" "ru" "rv" "rw" "rE" "p" "T" "a"'


I get the following error when I try to run my macro:

Code: Select all

Filename Error: File does not exist.
Filename: ...ls/supersonic/Ma2_0/cylds_000300034997053444.plt

Clearly it is converting the scientific notation number in the file to an actual number instead of keeping it as a string.

How can I read in data like that as a string instead of having it convert it to a floating point number? Is there another way to do this?

Contents of Data File, Extracted_Data_Labels.txt:
    3.00035E-04
    6.00076E-04
    9.00084E-04
    1.20012E-03
    1.50016E-03
    1.80018E-03
    2.10022E-03
    2.40026E-03
    2.70028E-03
    3.00031E-03



Thank you,
Chris

User avatar
salter
Moderator
Posts: 188
Joined: Thu Dec 21, 2006 10:57 am
Location: NASA Langley Research Center
Contact:

Re: Read Data in From Files as String

Postby salter » Fri May 30, 2014 5:23 am

Chris,

You probably need to format the output for the variable in Tecplot. For macro variables, you can have formats such as the exponential engineering format. Check the "tprm.pdf" document under $TEC360HOME/doc/tecplot/ for the syntax. It is something like |Value%10.4g| I think.
Steve...

Aerospace Research Engineer
Aerothermodynamics Branch
NASA Langley Research Center

wandadars
Newbie
Posts: 3
Joined: Tue May 27, 2014 2:48 pm
Location: Florida

Re: Read Data in From Files as String

Postby wandadars » Fri May 30, 2014 8:08 am

Thank you for your reply Steve.

Your suggestion is working. Using the exponential notation |var%12.5E| is putting the number in a form that is much closer to the form that I have in the files. I'm having another issue though with the format of the exponential part of the number.

I read in the number from the file as a floating point number. Then when I go to open the filename I use the format spec to express the number in the exponential format for it to match the file name i.e. 3.00035E-002.

Code: Select all

$!READDATASET  '"|MFBD|/cylds_|Value%12.5E|.plt" '


The only trouble is that my files use 2 digits to express the exponential part of the number in exponential notation, but when I run the Tecplot macro I get 3 digits in the exponent.

My files: cylds_3.00035E-02.plt
What Tecplot tries to open: cylds_3.00035E-002.plt

This mismatch causes and error.

I find this strange because the format doesn't match what the Tecplot scripting guide says. For reference, on page 25 of the scripting guide it gives the following example for formatting variables:

Code: Select all

$!Pause "Maximum contour value is: |MAXC%12.6e|"
Here the result would be:
       "Maximum contour value is: 3.568421e+02


In the scripting guide we see 2 digits, but in practice I'm seeing 3 used.

Have you ever had any experience with this? I've been looking for a way to control the number of digits it uses, but I haven't found anything yet. My last resort will be to manually add another digit to the file names.

Edit: I made a script to add one more digit to the exponential part of the filenames.

Thank you,
Chris


Return to “Tecplot Macro Language”

Who is online

Users browsing this forum: No registered users and 1 guest