Author Topic: Sum/Moon Graphic  (Read 23632 times)

0 Members and 1 Guest are viewing this topic.

Offline Vasco

  • Forecaster
  • *****
  • Posts: 658
    • PWS
Re: Sun/Moon Graphic
« Reply #25 on: August 21, 2024, 09:17:27 AM »
Managed to spoof it by copying a "jpsun.png" of my own (with black background!) into ./cache.

I notice that the equinox/solstice labels seem to appear at the same elevation for all station latitudes: so they look right for Saratoga's 37°N but not so good for my 56°N?
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline swright1957

  • Senior Member
  • **
  • Posts: 89
    • Hytheweather.co.uk
Re: Sum/Moon Graphic
« Reply #26 on: August 21, 2024, 09:27:05 AM »
Mine looks the same as yours Vasco
"anything's possible with the weather"



Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9700
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sum/Moon Graphic
« Reply #27 on: August 21, 2024, 10:51:26 AM »
Yep, the original code had fixed graph positions (x,y) for the three legends.  I'm looking at making them dynamic so they will be at the top of the three curves.  I'm also adding a selectable proxy setting (for those needing a proxy) AND an optional setting to use clientrawextra.txt for those who don't have gregoriantojd() PHP function enabled.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 658
    • PWS
Re: Sum/Moon Graphic
« Reply #28 on: August 21, 2024, 10:56:36 AM »
Yep, the original code had fixed graph positions (x,y) for the three legends.  I'm looking at making them dynamic so they will be at the top of the three curves.  I'm also adding a selectable proxy setting (for those needing a proxy) AND an optional setting to use clientrawextra.txt for those who don't have gregoriantojd() PHP function enabled.

Wow! Christmas is early this year  :grin:
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9700
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sum/Moon Graphic
« Reply #29 on: August 21, 2024, 12:29:16 PM »
@vasco, here's a test that has WD for moon data and the optional proxy settings for you to try.  The lack of gregoriantojd() should be avoided with this WD setting enabled.

Ed. note .. updated file below.
« Last Edit: August 21, 2024, 01:47:33 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 658
    • PWS
Re: Sun/Moon Graphic
« Reply #30 on: August 21, 2024, 01:29:29 PM »
@vasco, here's a test that has WD for moon data and the optional proxy settings for you to try.

Sorry, Ken, no luck. I can't even get error reporting when I run it direct from my browser, just the little "missing" icon.

NOTE: I have renamed it sunposa_test.php
« Last Edit: August 21, 2024, 01:41:27 PM by Vasco »
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9700
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sum/Moon Graphic
« Reply #31 on: August 21, 2024, 01:46:57 PM »
Ok, one more test with the attached.. it should show the error message about the fetch.

Ed. note: attachment removed .. most recent at post below.
« Last Edit: August 21, 2024, 05:07:41 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 658
    • PWS
Re: Sum/Moon Graphic
« Reply #32 on: August 21, 2024, 02:08:02 PM »
No change, no error messages. . . (Renamed sunposa_test2.php this time)

I definitely need a dialogue with my ISP!
« Last Edit: August 21, 2024, 02:14:18 PM by Vasco »
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9700
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sum/Moon Graphic
« Reply #33 on: August 21, 2024, 05:06:39 PM »
Ok, I've replaced the file_get_contents with a curl function.  Set your proxy address in $myProxy, and enable the clientrawextra and give this a try.
It also has the legends fixed for Jun 21, Equinox and Dec 21 (I think).
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 658
    • PWS
Re: Sum/Moon Graphic
« Reply #34 on: August 21, 2024, 06:02:52 PM »
No change, no error messages. . . (Renamed sunposa_test3.php this time)

Getting late here, will investigate further tomorrow.
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9700
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sum/Moon Graphic
« Reply #35 on: August 21, 2024, 08:25:37 PM »
So the sunposa_test3.php is getting the error:
Quote
<b>Warning</b>:  imagepng(./cache/jpsun.png): failed to open stream: Permission denied in <b>/opt/local/share/httpd/sites/weather/htdocs/ajax/sunposa_test3.php</b> on line <b>724</b><br />
I think the issue may be caused by you putting a ./cache/jpsun.png image there and now the permissions are wrong for the script to write it.
I suggest you delete it an run sunmoon_test3.php again.  If it still fails, check the permissions on the ./cache/ directory to make sure PHP can write in it (0755).

BTW.. I've updated the GitHub distribution with this version.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 658
    • PWS
Re: Sun/Moon Graphic
« Reply #36 on: August 22, 2024, 05:40:50 AM »
I think the issue may be caused by you putting a ./cache/jpsun.png image there and now the permissions are wrong for the script to write it.

I thought of that overnight, too! Yes, it is working now, thanks. . . I also get the tempImg.gif

But the sun image has a black background, like mine had.

And despite setting H:i for times I get G:i a for zenith, sunrise and sunset. . .  :???:

EDIT: ?debug=y still says
Code: [Select]
php.ini setting 'allow_url_fopen = true;'  (Note: this enables fetch of sun image).
« Last Edit: August 22, 2024, 09:29:41 AM by Vasco »
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9700
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sum/Moon Graphic
« Reply #37 on: August 22, 2024, 09:39:40 AM »
As to the moon data from clientrawextra.txt, it shows
Quote
558   Moonrise   Time   21:27
559   Moonset   Time   09:36
560   Moon Phase   Percent   89 %
561   Moon Age   Number   17
so the 24h time is there.
and Settings.php has
Quote
$SITE['WDdateMDY'] = false;   // for weather software date format of month/day/year.  =false for day/month/year

and sunposa_test3.php has (on your site)
Quote
$sr = date("h:i a",$sun_info["sunrise"]);
$zen = date("h:i a",$sun_info["transit"]);
$ss = date("h:i a",$sun_info["sunset"]);
so the three sun times (sunrise,sunset,transit) 'should' show with the am/pm -- that was in the original code.

I've added a couple of settings (and will be overridden by $SITE entries) for date/time formats.

Try this V3.03 version.

As to why your Sun image isn't transparent after processing, I'll have to further investigate.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 658
    • PWS
Re: Sum/Moon Graphic
« Reply #38 on: August 22, 2024, 10:20:45 AM »
and sunposa_test3.php has (on your site)
Code: [Select]
$sr = date("h:i a",$sun_info["sunrise"]);
$zen = date("h:i a",$sun_info["transit"]);
$ss = date("h:i a",$sun_info["sunset"]);
so the three sun times (sunrise,sunset,transit) 'should' show with the am/pm -- that was in the original code.

I've added a couple of settings (and will be overridden by $SITE entries) for date/time formats.

Try this V3.03 version.
That works!

Quote
As to why your Sun image isn't transparent after processing, I'll have to further investigate.
Probably another PHP function missing  :roll:
« Last Edit: August 22, 2024, 10:56:56 AM by Vasco »
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline broadstairs

  • Forecaster
  • *****
  • Posts: 1078
Re: Sum/Moon Graphic
« Reply #39 on: August 22, 2024, 10:28:21 AM »
Ken might I suggest that the degree symbol for Sun AZ and EL and Moon EL be changed to &deg; as I found mine got changed at some point and it showed up in my editor as a '?'. Changing to the &deg; works perfectly. In this new version I see there is an option to change times to 24 hr but this does not work for Moonrise which still shows as 12 hr clock. I should explain I do not use WD any longer but CumulusMX!

Stuart
« Last Edit: August 22, 2024, 10:52:15 AM by broadstairs »
Ecowitt GW1003 with ultrasonic wind gauge, lightning sensor and PM2.5 sensor with Personal Weather Tablet as a console.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9700
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sum/Moon Graphic
« Reply #40 on: August 22, 2024, 10:51:00 AM »
Alas, the sunposa.php doesn't use HTML or HTML entities like &deg; .. it uses actual characters only in the GD library for text.  I tried it, and it just displays '&deg;' as a literal instead of '°'
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline broadstairs

  • Forecaster
  • *****
  • Posts: 1078
Re: Sum/Moon Graphic
« Reply #41 on: August 22, 2024, 10:55:48 AM »
Alas, the sunposa.php doesn't use HTML or HTML entities like &deg; .. it uses actual characters only in the GD library for text.  I tried it, and it just displays '&deg;' as a literal instead of '°'

I don't have it live at present but my JPGraph displays it just fine.

 [ You are not allowed to view attachments ]

Stuart
Ecowitt GW1003 with ultrasonic wind gauge, lightning sensor and PM2.5 sensor with Personal Weather Tablet as a console.

Offline Vasco

  • Forecaster
  • *****
  • Posts: 658
    • PWS
Re: Sum/Moon Graphic
« Reply #42 on: August 22, 2024, 10:58:54 AM »
I don't have it live at present but my JPGraph displays it just fine.

Don't know if it makes any difference, but is your sunposa.php coded in UTF-8 instead of ANSI/ASCII?
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9700
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sum/Moon Graphic
« Reply #43 on: August 22, 2024, 11:20:33 AM »
In sunposa.php the code
Code: [Select]
$graph->xaxis->title->Set("Sun AZ: $az2[0]°                                       Zenith: $zen                                         Sun EL: $he2[0]°");
just displays '&deg;' instead of ''°" when changed to
Code: [Select]
$graph->xaxis->title->Set("Sun AZ: $az2[0]&deg;                                       Zenith: $zen                                         Sun EL: $he2[0]&deg;");I tried it on PHP 8.2 with JPgraph 4.4.2 and that's what I saw.

The same happened with
Code: [Select]
$txt3 =new Text("Moon EL: $he5[0]°");
for the moon elevation.

I know the underlying GD library doesn't have HTML support as I discovered years ago with the degree sign in thermometer.php .. for that, I ended up using
Code: [Select]
    $cnt = chr(176) . $UOM; // chr(176) = degree sign in ISO-8859-1
    imagestring( $image, $font+2, ($width/2)-((strlen($cnt)/2)*ImageFontWidth($font+2)),
       (10-(integer)(ImageFontHeight($font+2) / 2)),
       $cnt, $tx);
to draw the '°F' or '°C' at the top.

The sunposa.php is encoded in ANSI (ISO-8859-1)
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline broadstairs

  • Forecaster
  • *****
  • Posts: 1078
Re: Sum/Moon Graphic
« Reply #44 on: August 22, 2024, 01:05:52 PM »
OK.

However this new version is not showing the Moonrise time as 24hr, all other times are fine. As I pointed out though I do not use Weather Display but CumulusMX.

Stuart
Ecowitt GW1003 with ultrasonic wind gauge, lightning sensor and PM2.5 sensor with Personal Weather Tablet as a console.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9700
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sum/Moon Graphic
« Reply #45 on: August 22, 2024, 02:00:24 PM »
Hi Stuart,
Does the sunposa.php show
Quote
$sr = date("h:i a",$sun_info["sunrise"]);
$zen = date("h:i a",$sun_info["transit"]);
$ss = date("h:i a",$sun_info["sunset"]);
or
Quote
$sr = date($timeOnlyFormat,$sun_info["sunrise"]);
$zen = date($timeOnlyFormat,$sun_info["transit"]);
$ss = date($timeOnlyFormat,$sun_info["sunset"]);
-- if the latter, you have V3.03 from above which has the latter format.

Is there an URL to your sunposa.php script?
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline broadstairs

  • Forecaster
  • *****
  • Posts: 1078
Re: Sum/Moon Graphic
« Reply #46 on: August 22, 2024, 02:48:08 PM »
I don't have a public url but it is the latter 3.03.

Stuart
Ecowitt GW1003 with ultrasonic wind gauge, lightning sensor and PM2.5 sensor with Personal Weather Tablet as a console.

Offline Vasco

  • Forecaster
  • *****
  • Posts: 658
    • PWS
Re: Sun/Moon Graphic
« Reply #47 on: August 23, 2024, 12:06:34 PM »
As to why your Sun image isn't transparent after processing, I'll have to further investigate.
Probably another PHP function missing  :roll:

Almost the right answer. . . Ken has discovered that the problem lies with the GD library on my ISP's SunOS server: the GD image function imagecolortransparent() used in sunposa.php is not working as expected. Many thanks for trying, Ken  :-)

Anyway, I'm getting used to the sun image appearing in a little black box. . .
« Last Edit: August 23, 2024, 12:16:00 PM by Vasco »
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline broadstairs

  • Forecaster
  • *****
  • Posts: 1078
Re: Sum/Moon Graphic
« Reply #48 on: August 24, 2024, 10:25:45 AM »
I now have this working on my website at https://www.stella-maris.org.uk/CumulusMX/wx.phtml just scroll down. I had to edit the code to convert the moonrise time from 12hr clock to 24hr as it is extracted from the US site which only supplies the 12hr time, the new code only converts the sun times not the moonrise. It also has the '&deg;' added at the appropriate point to make sure the degree symbol shows up OK.

At some point I will attempt to use the CU-tags scripts to get the CumulusMX data instead of the WD files.

Stuart
Ecowitt GW1003 with ultrasonic wind gauge, lightning sensor and PM2.5 sensor with Personal Weather Tablet as a console.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9700
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sum/Moon Graphic
« Reply #49 on: August 24, 2024, 12:44:25 PM »
Just discovered an error in JPGraph 4.4.2 with PHP 8.2.20 which now throws two errors
Quote
<b>Deprecated</b>:  Creation of dynamic property LinearTicks::$ticks_label is deprecated in <b>/var/www/weather/htdocs/jpgraph-4.4.2/src/jpgraph.php</b> on line <b>4442</b><br />
<b>Deprecated</b>:  Creation of dynamic property LinearTicks::$ticks_label is deprecated in <b>/var/www/weather/htdocs/jpgraph-4.4.2/src/jpgraph.php</b> on line <b>4462</b><br />
which makes the PNG not displayable.

To fix, edit line 4168 in ./jpgraph-4.4.2-src-only/src/jpgraph.php

to change
Quote
    public $maj_ticks_pos = array(), $maj_ticklabels_pos = array(),
           $ticks_pos = array(), $maj_ticks_label = array();
to
Quote
    public $maj_ticks_pos = array(), $maj_ticklabels_pos = array(),
           $ticks_pos = array(), $ticks_label = array(), $maj_ticks_label = array();
and that should fix the error.  Thanks to @vasco for having an updated host to have the error displayed with PHP 8.2.20.
« Last Edit: August 24, 2024, 12:58:44 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

 

anything