 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2619 Location: Sydney
|
Posted: Sat Jul 12, 2025 4:29 am Post subject: %PL with x_date |
|
|
I am wanting to generate plots based on historical data over a period of years.
Can %PL provide an X axis as date format ?
This also requires the conversion of date to a reference date.
Please not 1/1/1900 with the Excel error.
Perhaps using 1/1/1 as the first day ? with function JDATE
What might be available ? |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8220 Location: Salford, UK
|
Posted: Sat Jul 12, 2025 8:51 am Post subject: |
|
|
John
The native %pl uses %gr so you can call draw_characters@ to draw text. Also link=columns can be used to present vertical columns.
The function GET_PLOT_POINT@ gets the pixel coordinates of a particular point relative to the axes.
Here is a simple example that calls draw_characters@...
Code: | WINAPP
MODULE mydata
USE clrwin
INTEGER,PARAMETER::n=1000,link_none=0,link_lines=1,link_curves=2
INTEGER,PARAMETER::all_graphs=0,graph1=0
LOGICAL shown
DOUBLE PRECISION y(n)
CONTAINS
INTEGER FUNCTION show()
INTEGER errstate
errstate = change_plot_int@(0,"link",graph1,link_curves)
if(errstate /= 0) print*, clearwin_string@("ERROR_REPORT")
errstate = change_plot_int@(0,"colour",graph1,RGB@(255,0,0))
errstate = change_plot_dbl@(0,"y_max",all_graphs,1.5d0)
shown = .true.
CALL simpleplot_redraw@()
show = 2
END FUNCTION show
INTEGER FUNCTION clear()
INTEGER errstate
call clear_screen@()
errstate = change_plot_int@(0,"link",graph1,link_none)
shown = .false.
CALL simpleplot_redraw@()
clear = 2
END FUNCTION clear
INTEGER FUNCTION legend()
IF(shown .AND. clearwin_string@("CALLBACK_REASON") == "PLOT_ADJUST") THEN
CALL draw_characters@("Legend:..", 300, 100, 0)
CALL draw_line_between@(300,120,360,120,RGB@(0,0,255))
ENDIF
legend = 2
END FUNCTION legend
END MODULE mydata
PROGRAM main
USE mydata
INTEGER i,x
DOUBLE PRECISION p1,p2,p3,z
!read*,i
p1=1.5d0
p2=150.0d0
p3=15d0
x=0
DO i=1,n
z=p1*sin(x/p3)*exp(-x/p2)
!print*, i-1,x,z
y(i) = z
x=x+1
ENDDO
shown = .false.
i=winio@('%ww[no_border]%ca[Damped wave]%pv&')
i=winio@('%mn[Edit[Show, Clear]]&', show, clear)
i=winio@('%fn[Tahoma]&')
i=winio@('%ts&', 1.1d0)
i=winio@('%tc&',rgb@(0,0,80))
i=winio@('%it&')
i=winio@('%`bg&',rgb@(230,255,225))
CALL winop@("%pl[native,gridlines]")
CALL winop@('%pl[title="Sample plot"]')
CALL winop@("%pl[x_axis=Time(Milliseconds)]")
CALL winop@("%pl[y_axis=Amplitude]")
CALL winop@("%pl[smoothing=4]") ! anti-aliasing
CALL winop@("%pl[link=none]") ! delay drawing
!CALL winop@("%pl[scale=log_linear]")
i=winio@("%^pl",500,400,n,0.0d0,1.0d0,y,legend)
END
|
I can look later for date routines if no one else knows how to do this. |
|
Back to top |
|
 |
Kenneth_Smith
Joined: 18 May 2012 Posts: 820 Location: Lanarkshire, Scotland.
|
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2619 Location: Sydney
|
Posted: Sun Jul 13, 2025 9:17 am Post subject: |
|
|
Thanks Paul and Ken for your info.
This has given me a way forward.
The history of Julian years is interesting.
I am not certain, but i think it was defined in about 45 BC.
The year after 1 BC was 1 AD; no year 0
The concept of leap years being every 4 years was not finalised until about 25 AD, so the leap years that were applied between 45BC to 25AD are not as the present formulas define. (not sure of the accuracy of claimed leap years used before 25AD)
So the formula for day of the week for the 1st of Jan for years prior to about 25AD is only arbitary.
I have been using a subroutine JDATE (below) to calculate the julian day since a nominal "1/1/1" for many years (since 2002), which can usefully be modified for any other reference 'day 1".
As for day of week, I have to keep checking, as I vary the day_1 reference.
Code: | integer*4 FUNCTION jdate (year,month,day)
!
! Converts DAY/MONTH/YEAR to a Julian date transformed to 1/1/2000
!
INTEGER*4 day, month, year, yyyy
!
if (year > 1800) then
yyyy = year
else if (year > 100) then
yyyy = -1
else if (year > 79) then
yyyy = year + 1900
else if (year > 0 ) then
yyyy = year + 2000
else
yyyy = -1
end if
!
! "Tony T. Warnock" <u091889@lanl.gov>
! Sent by: fortran-owner@lahey.com
! 31/10/2002 02:04 AM
!
! jdate = 367*year
! 1 - 7*(year+(month+9)/12)/4
! 1 - 3*((year+(month-9)/7)/100+1)/4
! 1 + 275*month/9+day
! 1 - 730516
!
jdate = 367*yyyy &
- 7*(yyyy+(month+9)/12)/4 &
- 3*((yyyy+(month-9)/7)/100+1)/4 &
+ (275*month)/9 - 30 &
+ day $
- 1 ! 1/1/0
! offset for selected first day reference
! - 693961 ! 1900/1/1
! - 723180 ! 1980/1/1
! - 726833 ! 1990/1/1
! - 728659 ! 1995/1/1
! - 730485 ! 2000/1/1
!
END FUNCTION jdate |
Interestingly, I have recently created a database of historical records, using 31 days in every month, which greatly simplifies the conversion from date to days and also simplifies the calculation of the number of months or years between two dates. It stores an extra 7 days per year, which is not much to waste!
The day_of_week is not so easy using this simplification ! |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8220 Location: Salford, UK
|
Posted: Sun Jul 13, 2025 10:16 am Post subject: |
|
|
The current usage is from the Gregorian calendar (1582). |
|
Back to top |
|
 |
wahorger

Joined: 13 Oct 2014 Posts: 1259 Location: Morrison, CO, USA
|
Posted: Sun Jul 13, 2025 1:59 pm Post subject: |
|
|
Satellite orbits are (sometimes) computed using Julian dates. This also allows ephemeris data from before the adoption of the Gregorian calendar to work smoothly for planetary calculations.
It is also interesting that Julian dates use solar noon as the start of the day, so satellite software subtracts 0.5 from the Julian time to reference midnight.
I'm not an expert; I learned this from working with orbital data and the tutelage of a mathematician who specialized in orbitology. |
|
Back to top |
|
 |
Kenneth_Smith
Joined: 18 May 2012 Posts: 820 Location: Lanarkshire, Scotland.
|
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2619 Location: Sydney
|
Posted: Mon Jul 14, 2025 3:27 am Post subject: |
|
|
I first became aware of the accuracy of calendars when modelling tides. The accuracy of tidal prediction based on lunar and planetary movement is incredible.
The history of the calendar is also amazing.
First to consider how they were able to predict leap years so accurately (Ceasar 45 BC) based on the period of planetary movements.
While Pope Gregory adopted the latest calendar in 1582, Galileo was tried by the Inquisition for his views in "Dialogue Concerning the Two Chief World Systems" (1632).
Yet, after all this Microsoft declares 1900 was a leap year !
( this has been annoying to me as many tide prediction coefficients have been based on 1-Jan-1900 ) |
|
Back to top |
|
 |
|
|
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
|