It is currently May 4th, 2024, 1:11 pm

Display image based on sunrise / sunset measures

Get help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 16198
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote: November 16th, 2019, 10:21 pm Hi Balala
I would like to use the code above for the position of the moon.
I replaced sunrise and sunset with moonrise and moonset but the formulas should be adapted,I think.
Beside eclectic-tech reply, please pack the whole config you have and upload the package. This is a pretty old topic and I don't have anymore the whole config, that's why I'm asking you to upload the package. There might be other issues as well when you switch from Sun to Moon. Note that Sun is always rising before it is setting down, but this is not always true in case of the Moon.
User avatar
xenium
Posts: 868
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote: November 17th, 2019, 7:29 am Beside eclectic-tech reply, please pack the whole config you have and upload the package. This is a pretty old topic and I don't have anymore the whole config, that's why I'm asking you to upload the package. There might be other issues as well when you switch from Sun to Moon. Note that Sun is always rising before it is setting down, but this is not always true in case of the Moon.
It is a separate skin only for the Moon
MOON_.rmskin
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16198
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote: November 17th, 2019, 7:59 am It is a separate skin only for the Moon
MOON_.rmskin
The new code, Just replace the old one with this:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
Solidcolor=0,0,0,1

[Variables]
locationCode=FRXX0076
Link=https://weather.com/en-GB/weather/tenday/l/
URL=#Link##locationCode#

[MeasureMoon]
Measure=WebParser
Url=#URL#
RegExp=(?siU)(?(?=.*{"validDate":".*").*,"moonrise":"(.*)","moonset":"(.*)")
UpdateRate=600
LogSubstringErrors=0

[MeasureMoonrise]
Measure=WebParser
Url=[MeasureMoon]
StringIndex=1
RegExpSubstitute=1
Substitute="^.*T(.*):.*$":"\1"

[MeasureMoonset]
Measure=WebParser
Url=[MeasureMoon]
StringIndex=2
RegExpSubstitute=1
Substitute="^.*T(.*):.*$":"\1"

[MeasureMoonriseHour]
Measure=String
String=[MeasureMoonrise]
RegExpSubstitute=1
Substitute="^(\d{1,2}):\d{1,2}$":"\1","^$":"0"
DynamicVariables=1

[MeasureMoonriseMinute]
Measure=String
String=[MeasureMoonrise]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0"
DynamicVariables=1

[MeasureMoonriseMoment]
Measure=Calc
Formula=( 60 * [MeasureMoonriseHour] + [MeasureMoonriseMinute] )
DynamicVariables=1

[MeasureMoonsetHour]
Measure=String
String=[MeasureMoonset]
RegExpSubstitute=1
Substitute="^(\d{1,2}):\d{1,2}$":"\1","^$":"0"
DynamicVariables=1

[MeasureMoonsetMinute]
Measure=String
String=[MeasureMoonset]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0"
DynamicVariables=1

[MeasureMoonsetMoment]
Measure=Calc
Formula=( 60 * [MeasureMoonsetHour] + [MeasureMoonsetMinute] )
DynamicVariables=1

[MeasureHour]
Measure=Time
Format=%#H

[MeasureMinute]
Measure=Time
Format=%M

[MeasureDayLength]
Measure=Calc
Formula=(( MeasureMoonsetMoment > MeasureMoonriseMoment ) ? ( MeasureMoonsetMoment - MeasureMoonriseMoment ) : ( 1440 - MeasureMoonriseMoment + MeasureMoonsetMoment ))

[MeasureSinceMoonrise]
Measure=Calc
Formula=(( MeasureMoonsetMoment > MeasureMoonriseMoment ) ? (( 60 * MeasureHour + MeasureMinute - MeasureMoonriseMoment ) / ( 0.00001 + MeasureDayLength )) : ((( 60 * MeasureHour + MeasureMinute ) > MeasureMoonriseMoment ) ? (( 60 * MeasureHour + MeasureMinute - MeasureMoonriseMoment ) / ( 0.00001 + MeasureDayLength )) : (( 1440 - MeasureMoonriseMoment + 60 * MeasureHour + MeasureMinute ) / ( 0.00001 + MeasureDayLength ))))

[MeasureTime]
Measure=Calc
Formula=( 60 * MeasureHour + MeasureMinute )
IfCondition=(((MeasureMoonsetMoment>MeasureMoonriseMoment)&&((#CURRENTSECTION#>=MeasureMoonriseMoment)&&(#CURRENTSECTION#<MeasureMoonsetMoment)))||((MeasureMoonriseMoment>MeasureMoonsetMoment)&&((#CURRENTSECTION#>=MeasureMoonriseMoment)||(#CURRENTSECTION#<MeasureMoonsetMoment))))
IfTrueAction=[!ShowMeter "MeterMoon"]
IfFalseAction=[!HideMeter "MeterMoon"]

[MeterSoil]
Meter=Shape
X=0
Y=250
Shape=Line 0,0,178,0 | Extend MyModifiers1
Shape2=Line 2,1,180,1 | Extend MyModifiers2
MyModifiers1=StrokeWidth 2 | Stroke Color 220,220,220
MyModifiers2=StrokeWidth 2 | Stroke Color 0,0,0,80
UpdateDivider=-1

[MeterMoonPath]
Meter=Shape
X=0r
Y=0r
Shape=Arc 9,0,168,0,80,80 | Extend MyModifiers1
Shape2=Arc 11,1,170,1,80,80 | Extend MyModifiers2
MyModifiers1=StrokeWidth 2 | Stroke Color 220,220,220
MyModifiers2=StrokeWidth 2 | Stroke Color 0,0,0,80
UpdateDivider=-1

[MeterMoon]
Meter=Shape
X=0r
Y=0r
Shape=Ellipse (10+160*[MeasureSinceMoonrise]),(20*(Abs([MeasureSinceMoonrise]-0.5))+10*(1-Abs(2*[MeasureSinceMoonrise]-1))-80*Sin(Acos(2*[MeasureSinceMoonrise]-1))),10 | StrokeWidth 1 | Fill RadialGradient MyGradient1
MyGradient1=3,2 | 255,180,0 ; 0.0 | 210,210,0 ; 1.0
DynamicVariables=1

[MeterMoonrise]
Meter=String
MeasureName=MeasureMoonrise
X=10
Y=30r
W=300
H=38
FontSize=10
FontColor=255,255,255,190
StringStyle=Bold
StringEffect=SHADOW
FontFace=arial
StringAlign=left
FontEffectColor=0,0,0,50
AntiAlias=1
Text=Moonrise %1

[MeterMoonset]
Meter=String
MeasureName=MeasureMoonset
X=10
Y=30r
W=300
H=38
FontSize=10
FontColor=255,255,255,190
StringStyle=Bold
StringEffect=SHADOW
FontFace=arial
StringAlign=left
FontEffectColor=0,0,0,50
AntiAlias=1
Text=Moonset %1
Please give it a try and let me know if it does properly work.
User avatar
xenium
Posts: 868
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote: November 18th, 2019, 8:24 pm Please give it a try and let me know if it does properly work.
Good job !
Thank you very much
I noticed only one strange thing:
When moonrise and moonset are on the same day, the moon appears exactly when it's time for moonrise.
When the moonset is the next day the moon appears after one minute from the time for the moonrise.
User avatar
balala
Rainmeter Sage
Posts: 16198
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote: November 20th, 2019, 8:45 am I noticed only one strange thing:
When moonrise and moonset are on the same day, the moon appears exactly when it's time for moonrise.
When the moonset is the next day the moon appears after one minute from the time for the moonrise.
I'm not sure how are you testing this, because the Moonrise and Moonset are got by WebParser measures, but there indeed is a small mistake into the IfCondition option of the [MeasureTime] measure. Some equalities are missing. Add them:

Code: Select all

[MeasureTime]
...
IfCondition=(((MeasureMoonsetMoment>MeasureMoonriseMoment)&&((#CURRENTSECTION#>=MeasureMoonriseMoment)&&(#CURRENTSECTION#<=MeasureMoonsetMoment)))||((MeasureMoonriseMoment>MeasureMoonsetMoment)&&((#CURRENTSECTION#>=MeasureMoonriseMoment)||(#CURRENTSECTION#<=MeasureMoonsetMoment))))
User avatar
xenium
Posts: 868
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote: November 20th, 2019, 5:31 pm I'm not sure how are you testing this, because the Moonrise and Moonset are got by WebParser measures, but there indeed is a small mistake into the IfCondition option of the [MeasureTime] measure. Some equalities are missing. Add them:

Code: Select all

[MeasureTime]
...
IfCondition=(((MeasureMoonsetMoment>MeasureMoonriseMoment)&&((#CURRENTSECTION#>=MeasureMoonriseMoment)&&(#CURRENTSECTION#<=MeasureMoonsetMoment)))||((MeasureMoonriseMoment>MeasureMoonsetMoment)&&((#CURRENTSECTION#>=MeasureMoonriseMoment)||(#CURRENTSECTION#<=MeasureMoonsetMoment))))
The same thing happens.
I found 2 locations for each situation and manually changed the PC clock for the moonrise time:
PPXX0014 (moon appears correctly)
JAXX0085 (moon appears after 1 minute)
User avatar
balala
Rainmeter Sage
Posts: 16198
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote: November 20th, 2019, 6:01 pm The same thing happens.
How are you testing it, because I have no idea?
User avatar
xenium
Posts: 868
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote: November 20th, 2019, 6:53 pm How are you testing it, because I have no idea?
I introduced the new location and manually changed the clock of the PC, to correspond with the time of the moonrise.
At one location ( CHXX0008 )the moon appears exactly when it is moonrise time, at the other location ( SWXX0031 ), the moon appears after one minute after moonrise time.
User avatar
balala
Rainmeter Sage
Posts: 16198
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote: November 20th, 2019, 7:22 pm At one location ( CHXX0008 )the moon appears exactly when it is moonrise time, at the other location ( SWXX0031 ), the moon appears after one minute after moonrise time.
There something really weird is going on. I have no idea why is this happening, but it definitely does. More researches are needed. Hope will figure it out sooner or later and will come with a solution.
Stay tuned...
User avatar
balala
Rainmeter Sage
Posts: 16198
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

balala wrote: November 20th, 2019, 8:29 pm There something really weird is going on. I have no idea why is this happening, but it definitely does. More researches are needed. Hope will figure it out sooner or later and will come with a solution.
Stay tuned...
Ok, finally it seems I succeeded figuring out what's going on. There was a really stupid mistake: a missing equality sign from the Formula option of the [MeasureSinceMoonrise] measure. Please add it and check the skin again:

Code: Select all

[MeasureSinceMoonrise]
Measure=Calc
Formula=(( MeasureMoonsetMoment > MeasureMoonriseMoment ) ? (( 60 * MeasureHour + MeasureMinute - MeasureMoonriseMoment ) / ( 0.00001 + MeasureDayLength )) : ((( 60 * MeasureHour + MeasureMinute ) >= MeasureMoonriseMoment ) ? (( 60 * MeasureHour + MeasureMinute - MeasureMoonriseMoment ) / ( 0.00001 + MeasureDayLength )) : (( 1440 - MeasureMoonriseMoment + 60 * MeasureHour + MeasureMinute ) / ( 0.00001 + MeasureDayLength ))))
The missing equality is the following one: (( 60 * MeasureHour + MeasureMinute ) >= MeasureMoonriseMoment ).
It took me long before I found this issue. Stupid mistake...