chubin / pyphoon

:waning_gibbous_moon: ASCII Art Phase of the Moon (Python version)
http://wttr.in/Moon
MIT License
1.3k stars 95 forks source link

moon is not the correct orientations for southern hemisphere #1

Open dlangille opened 8 years ago

dlangille commented 8 years ago

When in the southern hemisphere, the moon waxes and wanes in the opposite direction.

re: http://twitter.com/igor_chubin/status/717791483127066625

martinbra commented 4 years ago

For showing the south hemisphere moon phases apparently it's only needed to rotate the moon drawing upside down and place the text accordingly. So, I would like to propose 2 different steps:

  1. Prepare the upside down drawings (rotating the existing arrays with something as south=[a[::-1] for a in north[::-1]]) and add an optional command line argument -s --hemisphere [NORTH/SOUTH/AUTO] to show the moon upside down (auto to be implemented in step 2).
  2. Implement auto hemisphere detection by IP and/or localization as used in wttr.in/.

What are your thoughts on this?

dlangille commented 4 years ago

That sounds good. Thank you.

martinbra commented 4 years ago

oh, my mistake thinking it would only be needed to rotate the ascii art. Look at the original and rotated moon:

             .---------.            
         .--'   o   .   `--.        
       .'@  @@@@@@    .   . `.      
     .'@@  @@@@@@@@  @@@@   . `.    
   .'    . @@@@@@@@ @@@@@@    . `.  
  / @@ o    @@@@@@.  @@@@    O   @\ 
  |@@@@              @@@@@@     @@| 
 / @@@@@   `.-.     @@@@@@@@  .  @@\ 
 |@ @@                @@@@@@ @@@   |
 \      @@    @   .()  @@   @@@@@  /
  |   @      @@@        @@@  @@@  | 
  \  .   @@  @\  .     .  @@    o / 
   `.   @@@@  _\ /    .      o  .'  
     `.  @@    ()--           .'    
       `.     / |      o    .'      
         `--./   .      .--'        
             `---------'           

rotated (look at the perimeter and the parentesis):

             '---------`
         '--.      .   /.--`
       '.    o      | /     .`
     '.           --)(    @@  .`
   '.  o      .    / \_  @@@@   .`
  / o    @@  .     .  \@  @@   .  \
  |  @@@  @@@        @@@      @   |
 /  @@@@@   @@  )(.   @    @@      \
 |   @@@ @@@@@@                @@ @|
 \@@  .  @@@@@@@@     .-.`   @@@@@ /
  |@@     @@@@@@              @@@@|
  \@   O    @@@@  .@@@@@@    o @@ /
   .` .    @@@@@@ @@@@@@@@ .    '.
     .` .   @@@@  @@@@@@@@  @@'.
       .` .   .    @@@@@@  @'.
         .--`   .   o   '--.
             .---------.

I will have to either swap some characters, like parentesis, or redo the ascii art.

I was thinking that keeping the art and making a swap table was better:

( --> )
) --> (
. --> `
` --> .
_ --> ^
' --> ,

which results in the following:

             ,---------.
         ,--`      `   /`--.
       ,`    o      | /     `.
     ,`           --()    @@  `.
   ,`  o      `    / \^  @@@@   `.
  / o    @@  `     `  \@  @@   `  \
  |  @@@  @@@        @@@      @   |
 /  @@@@@   @@  ()`   @    @@      \
 |   @@@ @@@@@@                @@ @|
 \@@  `  @@@@@@@@     `-`.   @@@@@ /
  |@@     @@@@@@              @@@@|
  \@   O    @@@@  `@@@@@@    o @@ /
   `. `    @@@@@@ @@@@@@@@ `    ,`
     `. `   @@@@  @@@@@@@@  @@,`
       `. `   `    @@@@@@  @,`
         `--.   `   o   ,--`
             `---------`

Which is not optimal, since some dots inside the moon have been replaced.

What are your thoughts on the matter?

dlangille commented 4 years ago

My results are the same.

I started searching for flipping ascii art, but that was mostly table flipping. Next was: mirror ascii art

https://stackoverflow.com/questions/13112671/how-to-horizontally-mirror-ascii-art

martinbra commented 4 years ago

Yeah, the issues are the same. Although rewriting every moon doesn't seen the smart thing to do, It's probably the best one can do to get a better outcome, to stay as faithful as possible to the original art.

What do you think @dlangille and @chubin ?

chubin commented 4 years ago

@martinbra

I think that your last drawing with fixes was pretty good, and we should use it. And for other cases (e.g. other moon sizes), we should just make the automatic flipping. This program is not just some moonphase viewer, it is a port of the original program developed in 197x, almost 50 years ago, and so we wouldn't like to diverge from it substantively. That being said, I think it is ok to add some new features, especially if they are isolated in a separate modules.

I thik that you original plan https://github.com/chubin/pyphoon/issues/1#issuecomment-676997422 was pretty good, so let's do it. Please:

  1. Make the changes
  2. Open a PR with them
  3. It will be merged

Then we try to bind it to wttr.in as you said.

I think this feature is very important, at least it is steadily being requested from time to time since years

chubin commented 4 years ago

29 is merged now,

I've updated it on wttr.in, but it is not yet enabled in the wttr.in code

$ pyphoon -s south
                 ,  
             ,  
          , 
       ,-   
      / 
    ,/  
   /    
  /     
  | 
 /   New Moon +
 |   0 21:17:30
 |   First Quarter -
 |   5 17:38:04
 \  
  | 
  \     
   \    
    `\  
      \ 
       `-   
          ` 
             `  
                 `
chubin commented 4 years ago

I think, this issue can be closed now, and we can move to wttr.in: https://github.com/chubin/wttr.in/issues/247

martinbra commented 4 years ago

I think so. Thanks Chubin.

dlangille commented 4 years ago

I am happy with any solution. :)

chubin commented 4 years ago

I've reopened the issue, because we want to add a note about the southern hemisphere in the output (https://github.com/chubin/wttr.in/issues/247)