Pyehpem and International Space Station

230 views
Skip to first unread message

Kevin Davis

unread,
Feb 1, 2020, 7:21:29 PM2/1/20
to weewx-user
Has anybody played with adding upcoming sightings to there page?

Adding it to pyehpem seems easy enough, just brainstorming a way to loop through to produce the next X number of sightings. 


Glenn McKechnie

unread,
Feb 1, 2020, 8:31:31 PM2/1/20
to weewx...@googlegroups.com
Maybe https://github.com/davies-barnard/isswatch

It's an extension that will generate a html listing
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to weewx-user+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/6a633f9e-f97f-4ad3-988b-fced6de3e903%40googlegroups.com.
>


--


Cheers
Glenn

rorpi - read only raspberry pi & various weewx addons
https://github.com/glennmckechnie

Susan Mackay

unread,
Feb 2, 2020, 9:32:33 PM2/2/20
to weewx-user
Also consider using SkyField instead of PyEphem as it is newer and supported.
Look at https://rhodesmill.org/skyfield/earth-satellites.html and the example under the title 'Finding when a satellite rises and sets'
Susan

Kevin Davis

unread,
Feb 3, 2020, 10:14:17 AM2/3/20
to weewx...@googlegroups.com
Thanks a lot Susan!  That's exactly what I was looking for. 

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Kevin Davis

unread,
Feb 3, 2020, 10:54:40 AM2/3/20
to weewx...@googlegroups.com
And additionally Susan, apropos of nothing, but I noticed you're a ham, as am I; KE7K here.

Had my 40m WSPR transmitter running last night and made it to just south of you,  into Tasmania to VK7JJ; 13127 km away from me using 200 mw!

7 3

Susan Mackay

unread,
Feb 3, 2020, 8:33:05 PM2/3/20
to weewx-user
Had my 40m WSPR transmitter running last night and made it to just south of you,  into Tasmania to VK7JJ; 13127 km away from me using 200 mw!
Very impressive! I've not got into WSPR myself - I'm more of a D-Star girl. Next you should try a moon bounce.
I've been playing with the 'find_events' function (it is brand new; as in only a few days old) and it gives you the rise and set times of the satellite as it passes through the minimum elevation that you set - and NOT the actual rise and set times at the horizon. I've communicated with the author about this to suggest that there should be an option as to which rise/set times it gives you. I'm also looking at the source code to see if there is an easy way around this.
Susan VK3ANZ

Kevin Davis

unread,
Feb 3, 2020, 9:09:25 PM2/3/20
to weewx...@googlegroups.com
I would love to do some moon-bounce!  Looks like so much fun and lots to learn.  I have a pi-star here on the bench to build but haven't gotten around to it yet, but I do stay pretty active on All-Star.  Usually connected to the East Coast Reflector. 

 While I've been a programmer for 25+ years(IBM mainframes), this project is actually my first Python attempt and basically my first experience with object oriented taboot.   Below is what I've got so far for building the next few passes of the ISS.  

Perhaps you could explain to me the difference in "passes through the minimum elevation" vs. at the horizon?

I'm trying to get any pass that goes over 10deg.  The only issue I'm having is it giving me a rise and set time and degree that are below 10, so perhaps I'm not calling it correctly. 


from skyfield.api import Topos, load
from datetime import timedelta

# Load TLE Information Feed
tle_url = 'http://celestrak.com/NORAD/elements/stations.txt'
satellites = load.tle(tle_url, reload=True)

# Create ISS object
iss = satellites['ISS (ZARYA)']

# Create Corbett object
corbett = Topos('45.27 N', '122.40 W')

# Create Timescale object
ts = load.timescale()

# Calculate/Output TLE Epoch Staleness value
current_time = ts.now()
epoch_stale_days = current_time - iss.epoch
if epoch_stale_days > 0:
  epoch_stale_direction = 'past'
else:
  epoch_stale_direction = 'before'
print('{:.3f} days {} ISS TLE Epoch'.format(epoch_stale_days, epoch_stale_direction))


# Calculate passes over the next X days
to_time = ts.utc(current_time.utc_datetime() + timedelta(days=2))
t, events = iss.find_events(corbett, current_time, to_time, altitude_degrees=10.0)
for ti, event in zip(t, events):
        name = ('Rise', 'Culminate','Set')[event]
        difference = iss - corbett
        topocentric = difference.at(ti)
        alt, az, distance = topocentric.altaz()
        print('{} @ {} -  Bearing: {}  Altitude: {}'.format(name,ti.utc_iso(),int(az.degrees),int(alt.degrees)))

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Kevin Davis

unread,
Feb 9, 2020, 11:30:26 AM2/9/20
to weewx-user
Ok, I'm getting a little closer, but I'm struggling on how to incorporate this directly into the weewx reporting system.

I have written a Python program which builds(currently ugly) a data set of ISS passes.  I am  buildiing a file called iss.inc, outisde of weewx through a daily cron job, and simply doing a #include in index.html.tmpl skin.  

What is the proper way to fold this into the normal reporting cycle?

Thomas Keffer

unread,
Feb 9, 2020, 11:35:12 AM2/9/20
to weewx-user
See the section Adding new bodies to the almanac in the Customizing Guide for instructions.

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Kevin Davis

unread,
Feb 9, 2020, 11:42:58 AM2/9/20
to weewx...@googlegroups.com
I'm not using Pyephem for calculating these, I'm using Skyfield and I have written iss.py to build the data set. 

Sorry if I'm asking a remedial question.  I'm still wrapping my head around Python and OO programming.   

vince

unread,
Feb 9, 2020, 11:51:10 AM2/9/20
to weewx-user
On Sunday, February 9, 2020 at 8:42:58 AM UTC-8, Kevin Davis wrote:
I'm not using Pyephem for calculating these, I'm using Skyfield and I have written iss.py to build the data set. 

Sorry if I'm asking a remedial question.  I'm still wrapping my head around Python and OO programming.   


The results change 'very' rarely, so personally I'd just call your python script via cron daily or so, writing the output file you are already including in your weewx template.

If you want to change your .inc file format, you could do it in your python script (ie, making it write prettier HTML etc.) 

p q

unread,
Feb 9, 2020, 11:53:53 AM2/9/20
to weewx...@googlegroups.com
I don't see anything improper about doing it the way you're doing it. It's not following the general architecture for Weewx, but if it works for you and you're learning, I think you should keep at it.

To make it look better, take a look at the tables that are already in this skin - either using the browser debugging tools are the template itself. You can add HTML coding to your output before you include it and to fix the formatting.

I'm doing something similar with getting earthquake data from USGS onto my site.




--
Peter Quinn
(415)794-2264

Kevin Davis

unread,
Feb 9, 2020, 11:54:23 AM2/9/20
to weewx...@googlegroups.com
That certainly seems the easiest way, I just have a FOMO on doing it the "right" way.  LOL.

Thanks for the input and that's probably what I'll stick with for now then.  Just pretty it up and call it a day. 

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Walter Smith

unread,
Feb 10, 2020, 12:40:26 PM2/10/20
to weewx-user
Doing something very similar.  Cron job at midnight, Python script to format a list of stuff from Skyfield I want to display in my template.  Prefix the list with a "#set global" line:

with open('skyprint2A.txt','w') as f3:
   f3.write('#set global $skytext2 = ')
   json.dump(l_out_lines_txt, f3)

which gives a file containing:

#set global $skytext2 = [["Mon Feb 10", "06:57 AM", "Sun Rises 01:08 earlier Length of Day 10:30:46 02:19 longer"], ["Mon Feb 10", "07:41 AM", "Mercury Rises  52% Illuminated"], ["Mon Feb 10", "08:08 AM", "Moon Sets"], ["Mon Feb 10", "08:42 AM", "Venus Rises  70% Illuminated"], ["Mon Feb 10", "05:28 PM", "Sun Sets 01:11 later"], ["Mon Feb 10", "07:01 PM", "Mercury Sets"], ["Mon Feb 10", "07:20 PM", "Moon Rises  95% Illuminated"], ["Mon Feb 10", "08:59 PM", "Venus Sets"], ["Tue Feb 11", "06:56 AM", "Sun Rises 01:10 earlier Length of Day 10:33:07 02:21 longer"], ["Tue Feb 11", "07:38 AM", "Mercury Rises  47% Illuminated"], ["Tue Feb 11", "08:41 AM", "Venus Rises  70% Illuminated"], ["Tue Feb 11", "08:43 AM", "Moon Sets"], ["Tue Feb 11", "05:29 PM", "Sun Sets 01:11 later"], ["Tue Feb 11", "07:02 PM", "Mercury Sets"], ["Tue Feb 11", "08:34 PM", "Moon Rises  89% Illuminated"], ["Tue Feb 11", "09:01 PM", "Venus Sets"], ["Sat Feb 15", "04:17 PM", "Moon Phase Last Quarter"], ["Thu Mar 19", "10:49 PM", "Vernal Equinox"]]

then in my template:

#include "skyprint2A.txt"
 
            Sky Events
          <table>
             <tr>
                <td>Date</td>
                <td>Time</td>
                <td>Event</td>
             </tr>
             #for $seq1 in $skytext2
                <tr>
                   <td>$seq1[0]</td>
                   <td>$seq1[1]</td>
                   <td>$seq1[2]</td>
                </tr>
             #end for
          </table>

Kevin Davis

unread,
Feb 10, 2020, 12:44:09 PM2/10/20
to weewx...@googlegroups.com
Very cool.  Thanks for the input.   Certainly helps me to see a working example!

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Kevin Davis

unread,
Feb 11, 2020, 1:25:44 PM2/11/20
to weewx...@googlegroups.com
What am I missing here?

String in my iss_all.json file:
#set global $iss_all = [["Tue Feb 11 10:54 am","SW/10","NE/9","69","6min 45sec"],["Tue Feb 11 12:31 pm","W/10","NE/9","33","6min 16sec"],["Tue Feb 11 02:09 pm","WNW/10","ENE/9","28","6min 3sec"],["Tue Feb 11 03:46 pm","WNW/10","E/9","72","6min 46sec"],["Tue Feb 11 05:23 pm","W/10","SSE/9","19","5min 0sec"],["Wed Feb 12 10:07 am","SSW/10","ENE/9","43","6min 24sec"],["Wed Feb 12 11:44 am","WSW/10","NE/9","41","6min 29sec"],["Wed Feb 12 01:21 pm","WNW/10","NE/9","27","5min 57sec"],["Wed Feb 12 02:58 pm","WNW/10","E/9","51","6min 38sec"],["Wed Feb 12 04:35 pm","W/10","SE/9","30","6min 9sec"],["Thu Feb 13 09:20 am","S/11","ENE/9","27","5min 40sec"],["Thu Feb 13 10:56 am","WSW/10","NE/9","54","6min 41sec"],["Thu Feb 13 12:33 pm","WNW/10","NE/9","27","5min 58sec"],["Thu Feb 13 02:10 pm","WNW/10","ENE/9","39","6min 27sec"],["Thu Feb 13 03:47 pm","W/10","SE/9","47","6min 38sec"],["Fri Feb 14 08:33 am","SSE/10","E/9","17","4min 39sec"],["Fri Feb 14 10:08 am","SW/10","NE/9","78","6min 47sec"],["Fri Feb 14 11:46 am","W/10","NE/9","29","6min 4sec"],["Fri Feb 14 01:23 pm","WNW/10","ENE/9","32","6min 12sec"],["Fri Feb 14 03:00 pm","WNW/10","ESE/9","76","6min 47sec"],["Fri Feb 14 04:38 pm","WSW/10","S/9","12","2min 53sec"],["Sat Feb 15 07:47 am","SE/10","ESE/9","10","1min 39sec"],["Sat Feb 15 09:20 am","SW/10","NE/9","69","6min 44sec"],["Sat Feb 15 10:58 am","W/10","NE/9","33","6min 16sec"],["Sat Feb 15 12:35 pm","WNW/10","ENE/9","28","6min 3sec"],["Sat Feb 15 02:12 pm","WNW/10","E/9","72","6min 47sec"],["Sat Feb 15 03:49 pm","W/10","SSE/9","19","5min 0sec"],["Sun Feb 16 08:33 am","SSW/10","ENE/9","43","6min 23sec"],["Sun Feb 16 10:10 am","WSW/10","NE/9","41","6min 28sec"]]

From my iss.inc template
  <table>
        <tr>
                <td class="label">Start Time</td>
                <td class="label">Rise</td>
                <td class="label">Set</td>
                <td class="label">Max</td>
                <td class="label">Length of Pass</td>
        </tr>
        #include "iss_all.json"
        #for $pass in $iss_all
        <tr>
                <td class="data">$pass[0]</td>
                <td class="data">$pass[1]</td>
                <td class="data">$pass[2]</td>
                <td class="data">$pass[3]</td>
                <td class="data">$pass[4]</td>
        </tr>
        #end for
  </table>


My error:
Feb 11 10:23:02 corbett wee_reports[31488]: ****  Traceback (most recent call last):
Feb 11 10:23:02 corbett wee_reports[31488]: ****    File "/usr/share/weewx/weewx/cheetahgenerator.py", line 332, in generate
Feb 11 10:23:02 corbett wee_reports[31488]: ****      fd.write(str(compiled_template))
Feb 11 10:23:02 corbett wee_reports[31488]: ****    File "/usr/lib/python2.7/dist-packages/Cheetah/Template.py", line 1005, in __str__
Feb 11 10:23:02 corbett wee_reports[31488]: ****      rc = getattr(self, mainMethName)()
Feb 11 10:23:02 corbett wee_reports[31488]: ****    File "_etc_weewx_skins_Seasons_index_html_tmpl.py", line 258, in respond
Feb 11 10:23:02 corbett wee_reports[31488]: ****    File "/usr/lib/python2.7/dist-packages/Cheetah/Template.py", line 1597, in _handleCheetahInclude
Feb 11 10:23:02 corbett wee_reports[31488]: ****      nestedTemplateClass = compiler.compile(source=source, file=file)
Feb 11 10:23:02 corbett wee_reports[31488]: ****    File "/usr/lib/python2.7/dist-packages/Cheetah/Template.py", line 796, in compile
Feb 11 10:23:02 corbett wee_reports[31488]: ****      raise e
Feb 11 10:23:02 corbett wee_reports[31488]: ****    File "_etc_weewx_skins_Seasons_iss_incwk.py", line 144
Feb 11 10:23:02 corbett wee_reports[31488]: ****      for pass in VFFSL(SL,"iss_all",True): # generated from line 21, col 2
Feb 11 10:23:02 corbett wee_reports[31488]: ****             ^
Feb 11 10:23:02 corbett wee_reports[31488]: ****  SyntaxError: invalid syntax

Walter Smith

unread,
Feb 11, 2020, 3:48:36 PM2/11/20
to weewx-user
Cheetah doesn't like $pass as a variable name.  It must confuse Cheetah, there's a #pass directive.  Try a different variable name there.

Glenn McKechnie

unread,
Feb 11, 2020, 3:48:55 PM2/11/20
to weewx...@googlegroups.com
pass is a reserved word. It's a statement with a meaning of its own so
the python interpretor does not understand its use as a variable name.

Rename it to something else - iss_pass ?
>>> <https://groups.google.com/d/msgid/weewx-user/7e38d3ef-7a1c-4c6b-973a-b877ff72dc56%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to weewx-user+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/CAHiQ_B2-_QuQoCnO8OMeZC7za92BjWop55HTZ-_ww%2BKeE_-1CA%40mail.gmail.com.

Kevin Davis

unread,
Feb 11, 2020, 4:00:40 PM2/11/20
to weewx...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages