![forums.silverfrost.com Forum Index](templates/subSilver/images/logo_phpBB.gif) |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Mon Feb 27, 2017 9:10 am Post subject: Native %pl |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Mon Feb 27, 2017 10:25 am Post subject: |
|
|
In theory you should be able to use CREATE_GRAPHICS_REGION@ and COPY_GRAPHICS_REGION@ but I have not tried this. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Mon Feb 27, 2017 2:18 pm Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Mon Feb 27, 2017 3:00 pm Post subject: |
|
|
Ken
You can use a grave accent with %pl as in %gr. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Mon Feb 27, 2017 6:20 pm Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Mon Feb 27, 2017 9:47 pm Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Feb 28, 2017 10:20 am Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
DanRRight
Joined: 10 Mar 2008 Posts: 2816 Location: South Pole, Antarctica
|
Posted: Wed Mar 01, 2017 2:58 am Post subject: |
|
|
Paul,
Please continue working with %pl
LOG_LINEAR and LINEAR_LOG are urgent next! |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Wed Mar 01, 2017 8:15 am Post subject: |
|
|
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](images/smiles/icon_rolleyes.gif) |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Wed Mar 01, 2017 3:26 pm Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Wed Mar 01, 2017 10:02 pm Post subject: |
|
|
Thanks for that update Paul. Works fine now
Ken |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Sat Mar 11, 2017 12:29 pm Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Sat Mar 11, 2017 1:08 pm Post subject: |
|
|
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.
![](http://www.tr5mx.co.uk/example1.jpg) |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
DanRRight
Joined: 10 Mar 2008 Posts: 2816 Location: South Pole, Antarctica
|
Posted: Sun Mar 12, 2017 9:20 pm Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|