forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Native %pl
Goto page 1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
Kenneth_Smith



Joined: 18 May 2012
Posts: 61
Location: Glasgow, Scotland.

PostPosted: Mon Feb 27, 2017 9:10 am    Post subject: Native %pl Reply with quote

I have down loaded the new release and have been trying out the new native %pl. Very impressed - good job Paul and Co, this eliminates the need to write code to draw plots to %gr regions. It works on some data sets where the old %pl failed - which caused me much grief in the past.

Question. The new %pl clearly draws to a graphics region. Is it possible to divert the output of %pl from the screen to a graphics region in memory?

I ask this, as now that we have a nice plot (possibly more than one via a number of sequential calls to %pl) on the screen, the next step is to add a call back to copy the image(s) to a jpeg (or similar) file. I know how to do this for a plot drawn directly in a %gr region but I'm struggling to see how to do this for a %pl plot.

Thanks

Ken
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4622
Location: Salford, UK

PostPosted: Mon Feb 27, 2017 10:25 am    Post subject: Reply with quote

In theory you should be able to use CREATE_GRAPHICS_REGION@ and COPY_GRAPHICS_REGION@ but I have not tried this.
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 61
Location: Glasgow, Scotland.

PostPosted: Mon Feb 27, 2017 2:18 pm    Post subject: Reply with quote

Paul,

That's what I thought, but how do we get the handle of the graphics region created by %pl? That's what has stumped me on this.

Thanks

Ken
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4622
Location: Salford, UK

PostPosted: Mon Feb 27, 2017 3:00 pm    Post subject: Reply with quote

Ken

You can use a grave accent with %pl as in %gr.
Back to top
View user's profile Send private message
aebolzan



Joined: 06 Jul 2007
Posts: 229
Location: La Plata, Argentina

PostPosted: Mon Feb 27, 2017 6:20 pm    Post subject: Reply with quote

Yes!, you can export the graph, for instance, to a jpg file:

filejpg='plot.jpg'
ipc= export_image@(filejpg)

If you are using only a single %pl for plotting all graphs (thanks to the new implementation of Paul), you don't need to use the grave accent: the graph region used by %pl is selected by default.

I have tested this....

Agustin
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 61
Location: Glasgow, Scotland.

PostPosted: Mon Feb 27, 2017 9:47 pm    Post subject: Reply with quote

Excellent Paul, thank you. I can see the way forward now.

This works fine in terms of creating the jpeg files, but I did note that Checkmate x64 does not like this code.

Code:

    program test
      use clrwin
      implicit none
      integer plot_to_file_cb ; external plot_to_file_cb
      integer n,i
      integer(kind=3) plot1, plot2
      common plot1, plot2
      parameter(n=10)
      real*8 x(n),y(n),z(n)
      plot1 = 1
      plot2 = 2
      do i=1,n
        x(i)=0.1d0*(i-1)
        y(i)= -x(i)*x(i)
        z(i)= -y(i)
      enddo
      i=winio@('%ca[plots]%pv&')
      i=winio@('%`bg[white]&')
      call winop@("%pl[title=graph]")
      call winop@("%pl[width=2]")
      call winop@("%pl[y_max=0.9]")
      call winop@("%pl[x_array]")
      call winop@("%pl[link=curves]")
      call winop@("%pl[symbol=9]")
      call winop@("%pl[colour=red]")
      call winop@("%pl[pen_style=2]")
      call winop@("%pl[framed]")
      i = winio@('%`pl&',400,250,n,x,y,plot1)
      i = winio@('%2nl&')
      i = winio@('%ff%cn%ws&','A space between the graphics regions')
      i = winio@('%ff&')
      call winop@("%pl[title=graph]")
      call winop@("%pl[width=2]")
      call winop@("%pl[y_max=0.9]")
      call winop@("%pl[x_array]")
      call winop@("%pl[link=curves]")
      call winop@("%pl[symbol=9]")
      call winop@("%pl[colour=red]")
      call winop@("%pl[pen_style=2]")
      call winop@("%pl[framed]")
      i=winio@('%`pl&',400,250,n,x,z,plot2)
     
      i=winio@('%sf%ff%nl%cn%^tt[plot]&',plot_to_file_cb)
      i= winio@('%tt[ok]')
      end

      integer function plot_to_file_cb()
      use clrwin
      implicit none
      integer i
      integer(kind=3) plot1, plot2
      common plot1, plot2
        i = select_graphics_object@(plot1)
        write(6,*) i
        i = export_image@('plot1.jpg')
        write(6,*) i
        i = select_graphics_object@(plot2)
        write(6,*) i
        i = export_image@('plot2.jpg')
        write(6,*) i
        plot_to_file_cb = 1
      end function plot_to_file_cb

Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4622
Location: Salford, UK

PostPosted: Tue Feb 28, 2017 10:20 am    Post subject: Reply with quote

I have noted the failure when using %pl with "/64 /check".
For the time being it will be necessary to add "/inhibit_check 16" in this context.
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 1393
Location: North Pole, Russia

PostPosted: Wed Mar 01, 2017 2:58 am    Post subject: Reply with quote

Paul,

Please continue working with %pl
LOG_LINEAR and LINEAR_LOG are urgent next!
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4622
Location: Salford, UK

PostPosted: Wed Mar 01, 2017 8:15 am    Post subject: Reply with quote

Dan

It is a priority but right now we are working on the speed of PRINT etc. which is an issue that you have raised; that is, apart from the immediate everyday stuff like reading forum posts that turn out to be about the meaning of "palindrome" Rolling Eyes
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4622
Location: Salford, UK

PostPosted: Wed Mar 01, 2017 1:58 pm    Post subject: Reply with quote

Kenneth

The problem when compiling with /64 /CHECK has been fixed.
Please try the following download but keep a backup of your existing DLLs.

https://www.dropbox.com/s/4tlx2ynkeq9o8cj/newDLLs2.zip?dl=0
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1554
Location: Yateley, Hants, UK

PostPosted: Wed Mar 01, 2017 3:26 pm    Post subject: Reply with quote

What does it matter what the speed of PRINT is, since Windows spools output to a printer and even buffers it?

It would have to be some primitive hardware for PRINT to the screen not to scroll past at unreadable speed unless one makes strenuous efforts to slow it down.

Eddie
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 61
Location: Glasgow, Scotland.

PostPosted: Wed Mar 01, 2017 10:02 pm    Post subject: Reply with quote

Thanks for that update Paul. Works fine now
Very Happy

Ken
Back to top
View user's profile Send private message Visit poster's website
Kenneth_Smith



Joined: 18 May 2012
Posts: 61
Location: Glasgow, Scotland.

PostPosted: Sat Mar 11, 2017 12:29 pm    Post subject: Reply with quote

Another problem with the new native %pl I have come across it that if you plot a step function and select [link=lines] the plot overshoots in both directions at the time when the derivative of the function is large. This is illustrated by the following:-

Code:
program step
implicit none
include<windows.ins>
integer i
real(kind=2), dimension(1:1000) :: time_plot, volt_plot
real(kind=2) delta_t, time

delta_t = 0.001d0
time = 0.d0

do i = 1, 1000
 time_plot(i) = time
 if (time .lt. 0.5d0) then
   volt_plot(i) = 0.d0
 else
   volt_plot(i) = 1.d0
 end if
 time = time+delta_t
end do
i = winio@('%ww&')
CALL winop@("%pl[native]")
call winop@("%pl[x_array]")
call winop@("%pl[n_graphs=1]")
call winop@("%pl[link=lines]")
CALL winop@("%pl[title='Voltage step']")
call winop@("%pl[x_axis='Time [s]']")
call winop@("%pl[y_axis='V [pu]']")
call winop@("%pl[y_min=0.d0]")
call winop@("%pl[y_max=1.1d0]")
call winop@("%pl[dy=0.2d0]")
call winop@("%pl[width=2]")
i = winio@('%pl&',400,400, 1000, time_plot, volt_plot)

CALL winop@("%pl[native]")
call winop@("%pl[x_array]")
call winop@("%pl[n_graphs=1]")
call winop@("%pl[link=none]")
call winop@("%pl[symbol=10]")
call winop@("%pl[symbol_size=1]")
CALL winop@("%pl[title='Voltage step']")
call winop@("%pl[x_axis='Time [s]']")
call winop@("%pl[y_axis='V [pu]']")
call winop@("%pl[y_min=0.d0]")
call winop@("%pl[y_max=1.1d0]")
call winop@("%pl[dy=0.2d0]")
call winop@("%pl[width=2]")
i = winio@('%pl',400,400, 1000, time_plot, volt_plot)
       
end program step


This code produces the output below with the problem areas marked up, the second plot just shows the data points [link=none].



The old %pl does not have this problem with the same data set.

Regards

Ken
Back to top
View user's profile Send private message Visit poster's website
Kenneth_Smith



Joined: 18 May 2012
Posts: 61
Location: Glasgow, Scotland.

PostPosted: Sat Mar 11, 2017 1:08 pm    Post subject: Reply with quote

The bigger the step change, the larger the overshoot. This is a screenshot of the problem which originally had me look into this in more detail.

Back to top
View user's profile Send private message Visit poster's website
DanRRight



Joined: 10 Mar 2008
Posts: 1393
Location: North Pole, Russia

PostPosted: Sun Mar 12, 2017 9:20 pm    Post subject: Reply with quote

I have mentioned this too. Suspect this is because new ℅pl always use smoothing of data. The linear interpolation option has to be introduced which is simpler (connects two points with the line) and has no such effect. There exist other types of smoothing, splines, B-splines etc
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page 1, 2, 3, 4, 5  Next
Page 1 of 5

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group