comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Saved Visualizations
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Saved Visualizations [message #74820] Thu, 03 February 2011 09:14 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Folks,

I had *no* idea how nice it is to save data visualizations.
It opens up a whole new world of possibilities! I just
saved a visualization on my Windows machine, e-mailed it
to my Linux machine and opened it up. Now I'm looking
at exactly the same visualization on both machines!

Wow! E-mail one of these babies to your colleagues and
they can be looking at *exactly* what you are looking
at. And for teaching purposes! My goodness... My whole
perspective on IDL has changed in the past couple of
weeks. I don't think I will ever use a normal IDL
graphics window again! :-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Saved Visualizations [message #74878 is a reply to message #74820] Sat, 05 February 2011 07:10 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
SonicKenking writes:

> Following your suggestions, I came up with a new method for the
> FSC_Window_Command class for creating the command struct variable in
> IDL main level. It is written using the LIST method as the template.

Yes, this looks like it is going in the right direction.
You are very close to being ready to unpack those save files!

I have a full day planned away from my desk today, but
I'll study these more carefully when I get back. In the
future, feel free to e-mail the code directly to me. My
newsreader mangles long text lines. :-)

Cheers,

David

P.S. Just as a side note, the only person I know who
wrote an iTool from scratch (outside of ITTVIS employees),
spent nearly a *year* combing through the documentation
to understand the system before he wrote a single line of
code. Makes you think, doesn't it. :-)



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Saved Visualizations [message #74882 is a reply to message #74820] Fri, 04 February 2011 23:22 Go to previous message
SonicKenking is currently offline  SonicKenking
Messages: 51
Registered: October 2010
Member
> Well, since you are interested in noodling around with
> save files, why don't you write a routine that can
> allow the user to view and unpack the commands in the
> save file?
>
> There is already a preliminary "viewer" in the commands
> LIST method. But I can see a program that "unpacks" a
> command to produce variables at the main IDL level containing
> all the data. Perhaps each command could be put into a
> structure variable that was returned to the main IDL level.
>
>    cmd -> {p1:cmd.p1, p1:cmd.p2, ..., NLevels:cmd.extra.nlevels}
>
> Such a thing could be very useful because it would
> allow users to "recover" data from previous visualizations.
>

Hi David,

Following your suggestions, I came up with a new method for the
FSC_Window_Command class for creating the command struct variable in
IDL main level. It is written using the LIST method as the template.

I also added an keyword option to FSC_CmdWindow::ListCommand. The
method will also create the struct variable when the option is turned
on.

The command struct variable has the data structure as follows:
cmdStruct = {command: 'cgContour', nparams: 1, type: 0, p1: data,
keywords: {nlevel: 10, fill: 1}}

I also wrote a small procedure, which takes the cmdStruct as input
parameter and execute it. The struct variable can be saved as IDL
source files (*.pro files) with proper output format. So it almost
sounds like another way (ASCII files) for saving the visualization. It
is quite interesting.

Here is the method, FSC_Window_Command::CreateCommandStruct, for
create the command struct variable in IDL main level.

PRO FSC_Window_Command::CreateCommandStruct, structName, Quiet=quiet

Compile_Opt idl2

; Error handling.
Catch, theError
IF theError NE 0 THEN BEGIN
Catch, /CANCEL
void = Error_Message()
RETURN
ENDIF

; Struct variable name
IF N_Elements(structName) EQ 0 THEN structName='cmd'

cmdString = self.command
cmdStruct = Create_Struct('Command', cmdString, 'nparams',
self.nparams, 'type', self.type)
CASE self.nparams OF
0:
1: cmdStruct = Create_Struct(cmdStruct, 'p1', *self.p1)
2: cmdStruct = Create_Struct(cmdStruct, 'p1', *self.p1, 'p2',
*self.p2)
3: cmdStruct = Create_Struct(cmdStruct, 'p1', *self.p1, 'p2',
*self.p2, 'p3', *self.p3)
ENDCASE
IF Ptr_Valid(self.keywords) THEN BEGIN
cmdStruct = Create_Struct(cmdStruct, 'keywords',
*self.keywords)
ENDIF

; Copy the variable to the MAIN level
(Scope_VarFetch(structName, /Enter, Level=1)) =
Temporary(cmdStruct)
IF NOT Keyword_Set(quiet) THEN $
PRINT, 'Created command struct variable ', structName, ' in
IDL $MAIN level.'

END

############################################################ ###############

Here is the modified version of FSC_CmdWindow::ListCommand for adding
the option to create the command struct variable. The changes are only
adding three new lines.

PRO FSC_CmdWindow::ListCommand, cmdIndex,
CREATECOMMANDSTRUCT=createCommandStruct

; List the commands in the command window.

Compile_Opt idl2

; Error handling.
Catch, theError
IF theError NE 0 THEN BEGIN
Catch, /CANCEL
void = Error_Message()
RETURN
ENDIF

createCommandStruct = Keyword_Set(createCommandStruct)

; How many commands are there?
count = self.cmds -> Get_Count()

IF N_Elements(cmdIndex) EQ 0 THEN BEGIN
FOR j = 0, count-1 DO BEGIN
thisCmdObj = self.cmds -> Get_Item(j, /DEREFERENCE)

; Preface the commands with their index number.
thisCmdObj -> List, StrTrim(j,2) + '.'

; Create the command struct
IF createCommandStruct THEN thisCmdObj ->
CreateCommandStruct, 'cmd' + StrTrim(j,2)
ENDFOR
ENDIF ELSE BEGIN
IF cmdIndex LT (count-1) THEN BEGIN
thisCmdObj = self.cmds -> Get_Item(cmdIndex, /DEREFERENCE)

; Preface the commands with their index number.
thisCmdObj -> List, StrTrim(cmdIndex,2) + '.'

; Create the command struct
IF createCommandStruct THEN thisCmdObj ->
CreateCommandStruct, 'cmd' + StrTrim(cmdIndex,2)
ENDIF ELSE Message, 'The command index is out of range of the
number of commands.'
ENDELSE

END


############################################################ ###############

The last one is the small procedure for execute the command in the
struct variable. Note that the winid keyword does not work. The plot
always goes into a new cgWindow. I am not sure why it is the case.

PRO cgRunCmdStruct, cmd, WinID=winid

Compile_Opt idl2

; Error handling.
Catch, theError
IF theError NE 0 THEN BEGIN
Catch, /CANCEL
void = Error_Message()
RETURN
ENDIF

void = Where(Tag_Names(cmd) EQ 'KEYWORDS', count)
IF count NE 0 THEN extraKeywords = cmd.keywords

CASE cmd.nparams OF
0:
1: cgWindow, cmd.command, cmd.p1, Method=cmd.type,
WinID=winid, _Extra=extraKeywords

2: cgWindow, cmd.command, cmd.p1, cmd.p2, Method=cmd.type,
WinID=winid, _Extra=extraKeywords

3: cgWindow, cmd.command, cmd.p1, cmd.p2, cmd.p3,
Method=cmd.type, WinID=winid, _Extra=extraKeywords
ENDCASE

END
Re: Saved Visualizations [message #74903 is a reply to message #74820] Fri, 04 February 2011 04:56 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
SonicKenking writes:

> I'd like to help out if possible. Let me know what I can do.

Well, since you are interested in noodling around with
save files, why don't you write a routine that can
allow the user to view and unpack the commands in the
save file?

There is already a preliminary "viewer" in the commands
LIST method. But I can see a program that "unpacks" a
command to produce variables at the main IDL level containing
all the data. Perhaps each command could be put into a
structure variable that was returned to the main IDL level.

cmd -> {p1:cmd.p1, p1:cmd.p2, ..., NLevels:cmd.extra.nlevels}

Such a thing could be very useful because it would
allow users to "recover" data from previous visualizations.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Saved Visualizations [message #74904 is a reply to message #74820] Fri, 04 February 2011 01:54 Go to previous message
SonicKenking is currently offline  SonicKenking
Messages: 51
Registered: October 2010
Member
> Would you like to work on Coyote Graphics Development?
> Coyote already spends half the day grumbling about
> "slave labor for less than slave wages." We could probably
> use some help. :-)
>


I'd like to help out if possible. Let me know what I can do.
Re: Saved Visualizations [message #74907 is a reply to message #74820] Thu, 03 February 2011 20:21 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
SonicKenking writes:

> Now the question I have is how I can easily get the data out of the
> save files? So I can do some further noodling based on the save files.

Would you like to work on Coyote Graphics Development?
Coyote already spends half the day grumbling about
"slave labor for less than slave wages." We could probably
use some help. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Saved Visualizations [message #74908 is a reply to message #74820] Thu, 03 February 2011 20:05 Go to previous message
SonicKenking is currently offline  SonicKenking
Messages: 51
Registered: October 2010
Member
On Feb 4, 4:14 am, David Fanning <n...@dfanning.com> wrote:
> Folks,
>
> I had *no* idea how nice it is to save data visualizations.
> It opens up a whole new world of possibilities! I just
> saved a visualization on my Windows machine, e-mailed it
> to my Linux machine and opened it up. Now I'm looking
> at exactly the same visualization on both machines!
>
> Wow! E-mail one of these babies to your colleagues and
> they can be looking at *exactly* what you are looking
> at. And for teaching purposes! My goodness... My whole
> perspective on IDL has changed in the past couple of
> weeks. I don't think I will ever use a normal IDL
> graphics window again! :-)
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.idlcoyote.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

WoW!! This is awesome!

I often do quite a lot ad-hoc checks on my data, which are mainly just
noodling around the data and plot them with improvised ideas. These
kinda works are often difficult to track back. But this save/restore
window helps a ton. It saves not only the plot but also the data with
it.

Now the question I have is how I can easily get the data out of the
save files? So I can do some further noodling based on the save files.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Need Workaroud for UNIX Color Bug
Next Topic: Converting map altitude coordinates (Z)

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:27:41 PDT 2025

Total time taken to generate the page: 0.00662 seconds