<p>While you have &quot;illumination&quot; it would seem to be easier just to map &quot;moon age&quot; (in days) to a character</p>
<p>The average synodic month is 29.53 days, and you have 28 characters, so calculating <code>age*28/29.53</code> and then rounding to give a number between 1 and 28 (or 0 and 27). Then it is just a matter of adding 97 if that number is in the range 0-13, or 36 if that number is 14... etc.</p>
<p>Slightly better would be to find out the actual length of the synodic month (if you can calculate moon age and illumination this should be possible) and use it in place of 29.53.  The actual length varies from about 29.2 to 29.8 days depending mostly on the position of the Earth's orbit</p>

CC BY-SA 4.0
2020-11-08T11:11:24.353Z
Thank you for this feedback! I have little to no clue about astronomy (as you might have guessed). To me calculating based on illumination should yield the same results as based on moon age, no? I initially picked illumination as it's fixed between {0,1} or 0-100% and I can ignore the fact that I don't have the actual length of the synodic month. For the calculation of all of those phase parameters I use [algorithms provided by a Spanish scientist](http://conga.oan.es/~alonso/doku.php?id=blog:sun_moon_position).
Marcel Stör
CC BY-SA 4.0
2020-11-08T11:22:30.617Z
If you want accurate you'd need to investigate how the person who made the font did the shapes.  I suspect they were just drawn by eye to give 28 moon shapes and don't correspond linearly to illumination or age or anything else. I suspect that mapping illumination linearly to a shape will work just as well.  I think the whole thing is rather over engineered!  The calcuation is an good quartic model of the moon.  The font is a rough sketch!  If you need *accurate*, then you'll need to make your own font (which isn't too hard) or get the software to draw the moon (also not impossible)
James K
CC BY-SA 4.0
2020-11-08T08:46:32.633Z
2020-11-08T08:46:32.633Z
James K
<p>For LaTeX there are the following packages using fonts but they are limited:</p>
<ul>
<li>wasysym (full, new, and quarters)</li>
<li>mathabx (same)</li>
<li>stix (math astro symbols)</li>
<li>china2e (artistic full, new, and quarters)</li>
<li>moonphase (similar)</li>
</ul>
<p>none that I can see with a full range of 28. It would be possible to write some parameterised TikZ to create the shapes within a circle to do this, which would let you add or subtract fine adjustments, but it would be a macro, not a font.</p>

CC BY-SA 4.0
2020-11-15T22:15:31.500Z
2020-11-15T22:15:31.500Z
Peter Flynn
<p>I use algorithms that give me the moon phase, age and illumination (and more) for a given timestamp and location. I am struggling to map that information to a (font) icon of the <a href="https://www.dafont.com/moon-phases.font" rel="nofollow noreferrer">Moon Phases font</a>. Each icon is an approximation because it ignores the rotation. Still, I'd like to map illumination (I guess?) to icon as precisely as possible.</p>
<p><a href="https://i.sstatic.net/lyf5j.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/lyf5j.png" alt="enter image description here" /></a></p>
<p>As you can see above there are 13 characters/icons per half cycle; 26 characters a-z. However, new/full moon are represented by the numbers 0 and 1. Particularly there's a gap between m and n where the new moon is in reality. The font uses a-z and A-Z to distinguish between northern hemisphere and southern hemisphere (again, I guess).</p>
<p><strong>Mental model</strong></p>
<pre><code>Illumination 100%                              0%                              100%

Moon         full                              new                             full

              |---------------------------------|--------------------------------|

Character     1            a - m                0             n - z              1
</code></pre>
<p>Assuming my mental model is correct this means (for the northern hemisphere)</p>
<ul>
<li>13 characters plus 0/1 to distribute across the 0-100% illumination range</li>
<li>pick 0 if the illumination is &lt;= 100/15 i.e. &lt;= ~6.66%</li>
<li>pick 1 if the illumination is &gt;= 100 - 100/15 i.e. &gt;= 93.33%</li>
<li>if waning (waning gibbous, last quarter, waning crescent)
<ul>
<li>round(illumination/100 * 15) + 97 to find character index for a-m</li>
</ul>
</li>
<li>if waxing
<ul>
<li>round(illumination/100 * 15) + 110 to find character index for n-z</li>
</ul>
</li>
</ul>
<p>Does that sound about correct?</p>

CC BY-SA 4.0
2020-11-07T22:52:05.830Z
Maybe belongs to [Stack Overflow](http://stackoverflow.com) or something?
WarpPrime
CC BY-SA 4.0
2020-11-07T22:54:21.000Z
I don't think so. I can turn the (pseudo-)algorithm into code but I am not sure I understand the science behind this correctly.
Marcel Stör
CC BY-SA 4.0
2020-11-08T00:08:41.593Z
I think your question can be well-answered here. Some readers may be off-put by the focus of your post on algorithm implementation but you are simply working to state the problem clearly. For the sake of readers and answerers here, I think it's necessary to *emphasize the astronomy aspects* of the problem and de-emphasize the algorithmic and coding aspects somewhat.
uhoh
CC BY-SA 4.0
2020-11-08T00:23:14.800Z
I see that you have selected 28 icons in your complete sequence, and those choices in that order appears to me to be pretty good. A GIF showing them cycle continuously would be a great way to check continuity and smoothness. The challenge you explain here is to select one based on a phase parameter from an algorithm. But you haven' yet explained much about that phase parameter. Does it return 50% for both first quarter and third quarter? If so, how will you decide which icon to show? Please add details about how the phase parameter progresses, this may be a problem.
uhoh
CC BY-SA 4.0
2020-11-08T21:38:15.417Z
@uhoh believe me your feedback is really appreciated! The thing is, I probably don't know what I don't know. I _think_ all necessary information is weaved into my description. The algorithm I use does give me the moon phase. Hence, I know which icon (sub)set to choose from. In other comments we already discussed whether to use illumination or moon age as the basis for my calculation. It would probably be enough if someone confirmed my mental model sketch to be correct.
Marcel Stör
CC BY-SA 4.0
2020-11-08T21:39:22.907Z
"Does it return 50% for both first quarter and third quarter? If so, how will you decide which icon to show?" A simple plot or description of how the "phase" parameter varies versus time would be extremely helpful, *thanks!*
uhoh
CC BY-SA 4.0
2020-11-08T22:14:45.590Z
Maybe I don't understand the implication of (the answer to) this question. The phase is derived from the lunar age using the 29.530588853 constant as an approximation for the length of a month. I never verified if I get 50% but based on the age I know which icon to pick.
Marcel Stör
CC BY-SA 4.0
2020-11-09T01:40:04.983Z
Your drawing shows 100% at full and 0% at new and then 100% at the next full. That means it will be at 50% twice per month. It will be at 60% twice per month, or 42% twice per month. When you get those values, how do you know they are around first quarter or third quarter? Please show a plot of the shape of your "phase" parameter versus time.
uhoh
CC BY-SA 4.0
2020-11-10T11:16:12.380Z
Phase is an angle; 0 to 360 degrees or 0 to 2 radians. percent full is ambiguous.
uhoh
<moon-phases><algorithm>
Mapping illumination to moon phase (font) icon
Marcel Stör
# Mapping illumination to moon phase (font) icon

(Asked by: username_0 on 2020-11-07)

I use algorithms that give me the moon phase, age and illumination (and more) for a given timestamp and location. I am struggling to map that information to a (font) icon of the Moon Phases font. Each icon is an approximation because it ignores the rotation. Still, I'd like to map illumination (I guess?) to icon as precisely as possible.

As you can see above there are 13 characters/icons per half cycle; 26 characters a-z. However, new/full moon are represented by the numbers 0 and 1. Particularly there's a gap between m and n where the new moon is in reality. The font uses a-z and A-Z to distinguish between northern hemisphere and southern hemisphere (again, I guess).
Mental model
Illumination 100%                              0%                              100%

Moon         full                              new                             full

              |---------------------------------|--------------------------------|

Character     1            a - m                0             n - z              1

Assuming my mental model is correct this means (for the northern hemisphere)

13 characters plus 0/1 to distribute across the 0-100% illumination range
pick 0 if the illumination is <= 100/15 i.e. <= ~6.66%
pick 1 if the illumination is >= 100 - 100/15 i.e. >= 93.33%
if waning (waning gibbous, last quarter, waning crescent)

round(illumination/100 * 15) + 97 to find character index for a-m


if waxing

round(illumination/100 * 15) + 110 to find character index for n-z



Does that sound about correct?

**Tags:** moon-phases, algorithm

> **Comments:**
> **username_1**: Maybe belongs to [Stack Overflow](http://stackoverflow.com) or something?  
> **username_0**: I don't think so. I can turn the (pseudo-)algorithm into code but I am not sure I understand the science behind this correctly.  
> **username_2**: I think your question can be well-answered here. Some readers may be off-put by the focus of your post on algorithm implementation but you are simply working to state the problem clearly. For the sake of readers and answerers here, I think it's necessary to *emphasize the astronomy aspects* of the problem and de-emphasize the algorithmic and coding aspects somewhat.  
> **username_2**: I see that you have selected 28 icons in your complete sequence, and those choices in that order appears to me to be pretty good. A GIF showing them cycle continuously would be a great way to check continuity and smoothness. The challenge you explain here is to select one based on a phase parameter from an algorithm. But you haven' yet explained much about that phase parameter. Does it return 50% for both first quarter and third quarter? If so, how will you decide which icon to show? Please add details about how the phase parameter progresses, this may be a problem.  
> **username_0**: @username_2 believe me your feedback is really appreciated! The thing is, I probably don't know what I don't know. I _think_ all necessary information is weaved into my description. The algorithm I use does give me the moon phase. Hence, I know which icon (sub)set to choose from. In other comments we already discussed whether to use illumination or moon age as the basis for my calculation. It would probably be enough if someone confirmed my mental model sketch to be correct.  
> **username_2**: "Does it return 50% for both first quarter and third quarter? If so, how will you decide which icon to show?" A simple plot or description of how the "phase" parameter varies versus time would be extremely helpful, *thanks!*  
> **username_0**: Maybe I don't understand the implication of (the answer to) this question. The phase is derived from the lunar age using the 29.530588853 constant as an approximation for the length of a month. I never verified if I get 50% but based on the age I know which icon to pick.  
> **username_2**: Your drawing shows 100% at full and 0% at new and then 100% at the next full. That means it will be at 50% twice per month. It will be at 60% twice per month, or 42% twice per month. When you get those values, how do you know they are around first quarter or third quarter? Please show a plot of the shape of your "phase" parameter versus time.  
> **username_2**: Phase is an angle; 0 to 360 degrees or 0 to 2 radians. percent full is ambiguous.  

---

## 2 answers

### Answer by username_3 on 2020-11-08. Score: 2

While you have "illumination" it would seem to be easier just to map "moon age" (in days) to a character

The average synodic month is 29.53 days, and you have 28 characters, so calculating `age*28/29.53` and then rounding to give a number between 1 and 28 (or 0 and 27). Then it is just a matter of adding 97 if that number is in the range 0-13, or 36 if that number is 14... etc.

Slightly better would be to find out the actual length of the synodic month (if you can calculate moon age and illumination this should be possible) and use it in place of 29.53. The actual length varies from about 29.2 to 29.8 days depending mostly on the position of the Earth's orbit

> **Comments:**
> **username_0**: Thank you for this feedback! I have little to no clue about astronomy (as you might have guessed). To me calculating based on illumination should yield the same results as based on moon age, no? I initially picked illumination as it's fixed between {0,1} or 0-100% and I can ignore the fact that I don't have the actual length of the synodic month. For the calculation of all of those phase parameters I use [algorithms provided by a Spanish scientist](http://conga.oan.es/~alonso/doku.php?id=blog:sun_moon_position).  
> **username_3**: If you want accurate you'd need to investigate how the person who made the font did the shapes.  I suspect they were just drawn by eye to give 28 moon shapes and don't correspond linearly to illumination or age or anything else. I suspect that mapping illumination linearly to a shape will work just as well.  I think the whole thing is rather over engineered!  The calcuation is an good quartic model of the moon.  The font is a rough sketch!  If you need *accurate*, then you'll need to make your own font (which isn't too hard) or get the software to draw the moon (also not impossible)  

---

### Answer by username_4 on 2020-11-15. Score: 2

For LaTeX there are the following packages using fonts but they are limited:

* wasysym (full, new, and quarters)
* mathabx (same)
* stix (math astro symbols)
* china2e (artistic full, new, and quarters)
* moonphase (similar)

none that I can see with a full range of 28. It would be possible to write some parameterised TikZ to create the shapes within a circle to do this, which would let you add or subtract fine adjustments, but it would be a macro, not a font.


---

