Charmed Quark Systems, Ltd. - Support Forums and Community

Full Version: 4.6.0 - Weather Channel Icon
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was messing about in my weather template and decided to add a moon phase icon. I added an image of type 'Field Weather Channel Image' and picked the 'Current Moon Phase Icon' field from the Weather Underground driver. I got a mapped condition icon. So I read the docs to discover that the moon phase isn't supported out of the weather moon phase field in spite of it being available.

Is there a set of icons to be used with a logo image widget that correspond to the WU moon phase numbers? And/Or shouldn't the numbers be unique and distinct from the condition icons so that you could use the 'Field Weather Channel Image'?
The moon stuff has its own set of numbers and images. It was added way after the fact. I guess the original WC driver didn't provide such info, and so it wasn't until years later that we switched to the WU driver that did. So the moon stuff is completely separate and you have to do it with a logo image widget generally.

Some folks have image sets for the moon phase values from the WU data. If you search around here you'll probably find the original discussions when this field was added and working out what the numbers meant and all that. The images are probably referenced there.
There seems to be a discrepancy between the WU driver and the WU web site wrt to the moon phase.

WU driver:

CurMoonPhase - Full
CurMoonPhaseIcon - 18

WU web site:

CurMoonPhase - Waning Gibbous, 92% visible
CurMoonPhaseIcon - 17

FWIW the weather channel web site has the same description and icon #17 as well.

Either the feed or the interpretation is bad as the two web sites agree with the Naval Observatory.
The driver is currently reporting Full & 19

I queried the same station that I have configured:

  "response": {
  "features": {
  "astronomy": 1
        ,    "moon_phase": {
        "phaseofMoon":"Waning Gibbous",
        "current_time": {
        "sunrise": {
        "sunset": {
    "sun_phase": {
        "sunrise": {
        "sunset": {

The URL I used is:

The reason for the +1 is that zero has to be reserved as a well known 'unknown' value. We create the description internally, based on the number (though adjusted back down to be zero based.) Maybe our calculation is a bit off. What we currently do is:

const tCIDLib::TFloat8 f8CurVal = tCIDLib::TFloat8(c4Val);
tCIDLib::TFloat8 f8PerPhase = (29.5305882 / 8.0);

const tCIDLib::TCh* pszPhase;
if (f8CurVal < f8PerPhase)
    pszPhase = L"New";
else if (f8CurVal < (f8PerPhase * 2))
    pszPhase = L"Waxing Cresent";
else if (f8CurVal < (f8PerPhase * 3))
    pszPhase = L"First Quarter";
else if (f8CurVal < (f8PerPhase * 4))
    pszPhase = L"Waxing Gibbous";
else if (f8CurVal < (f8PerPhase * 5))
    pszPhase = L"Full";
else if (f8CurVal < (f8PerPhase * 6))
    pszPhase = L"Waning Gibbous";
else if (f8CurVal < (f8PerPhase * 7))
    pszPhase = L"Third Quarter";
    pszPhase = L"Waning Cresent";

So it looks like full is in the middle of the range, with waxing first and waning last. I have no idea now where I found this calculation. The reason for doing it ourself is so that we can maintain a consistent terminology over time, even if we have to switch sources.
The weather channel is different (and I think correct) in that the new moon, quarter moons, and full each occupy a day; Between are waxing & waning crescent and waxing/waning gibbous; This matches Naval Observatory convention; The divide into 8ths doesn't:

/* ==== MOON PHASES ========================= */

.wx-icon.wx-moonphase { float: left; height: 18px; width: 18px; margin-right: 5px; background-image: url(''); background-repeat: no-repeat; }
.wx-icon.wx-moonphase.wx-moon-29 { background-position: 0 0; }              /* new moon */
.wx-icon.wx-moonphase.wx-moon-6 { background-position: 0 -129px; }          /* waxing crescent */    
.wx-icon.wx-moonphase.wx-moon-7 { background-position: 0 -110px; }          /* first quarter */  
.wx-icon.wx-moonphase.wx-moon-13 { background-position: 0 -92px; }          /* waxing gibbous */
.wx-icon.wx-moonphase.wx-moon-15 { background-position: 0 -73px; }          /* full moon */
.wx-icon.wx-moonphase.wx-moon-21 { background-position: 0 -55px; }          /* waning gibbous */  
.wx-icon.wx-moonphase.wx-moon-22 { background-position: 0 -37px; }          /* last quarter */  
.wx-icon.wx-moonphase.wx-moon-28 { background-position: 0 -18px; }          /* waning crescent */
So it should be I guess a period of 1/29.53 starting at each of 0%, 25%, 50%, and 75% for the special quarter values, and then anything between those would be the other four values?
I believe that is correct...
Dean Roddey Wrote:So it should be I guess a period of 1/29.53 starting at each of 0%, 25%, 50%, and 75% for the special quarter values, and then anything between those would be the other four values?
I believe the WU site sends an integral age from 0 to 29 which you map to 1-30

1 = New
2 - 7 = Waxing crescent
8 = First quarter
9 - 14 = Waxing gibbous
15 - 16 = Full
17 - 22 = Waning gibbous
23 = Last quarter
24 - 29 = Waning crescent
30 - New

This will also work well in a field mapped image widget if I can extract 8 lunar icons.
Also, WU is different than Weather Channel. WC uses many more levels. The problem is that the icon set that I have was originally for WC, so you need to trim it down by half. It needs tweaking to get the actual icon in sync with the real world.

Mark - Look for an email shortly.