Last active
April 11, 2019 12:24
-
-
Save dragonlost/6b5f32725cb604d5a0ac5ae07430f0d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Wed Apr 10 16:42:50 2019 | |
@author: Sébastien Durand | |
""" | |
from astropy import units as u | |
from astropy.coordinates import GCRS, CartesianRepresentation, EarthLocation, AltAz | |
from astropy.time import Time | |
from tqdm import tqdm | |
import numpy as np | |
import time_function as tt | |
import ccsds as cc | |
#_________________________________START Fonction____________________________ | |
def ground_station_intervisibility(time_vector,sat_gcrs, ground_station): | |
for gs in range(len(ground_station)): | |
sat_altaz = sat_gcrs[0].transform_to(AltAz(obstime=time_vector[0],location=ground_station[gs][1])) | |
sat_altaz_GS = [[sat_altaz.az.value],[sat_altaz.alt.value]] | |
for i in tqdm(range(1,len(time_vector)), ascii=True, desc="Convert frame to ALT_AZ frame :"): | |
sat_altaz = sat_gcrs[i].transform_to(AltAz(obstime=time_vector[i],location=ground_station[gs][1])) | |
sat_altaz_GS[0].append(sat_altaz.az.value) | |
sat_altaz_GS[1].append(sat_altaz.alt.value) | |
return sat_altaz_GS | |
#_________________________________END Fonction____________________________ | |
#_________________________START Personal specification_______________________ | |
t_start = Time(60096, format='mjd') | |
t_end = Time(60316, format='mjd') | |
time_interval = 60*u.s | |
orbit_sat_file='TRAJ_0012.txt' | |
ground_station = [["French Guiana",EarthLocation(lat=5.251*u.deg, lon=-52.804*u.deg, height=15*u.m),0,'00001']] | |
#_________________________END Personal specification_______________________ | |
# create time_vector | |
time_vector = tt.time_step_gen(time_interval.to('s').value, | |
t_start, t_end, | |
input_type="astropy", output_type="astropy") | |
time_vector = Time(time_vector,format='mjd', scale='utc') | |
# read sat orbit | |
cic, origin, comment, header, data_time, data_science = cc.read_ccsds(orbit_sat_file) | |
# convert sat orbit in astropy position | |
sat_gcrs= GCRS(obstime=time_vector, x=data_science.T[0]*u.km, y=data_science.T[1]*u.km, z=data_science.T[2]*u.km, representation_type=CartesianRepresentation) | |
#reduce sat data | |
sat_gcrs=sat_gcrs[:10000] | |
time_vector=time_vector[:10000] | |
#_________________________________START SCRIPT____________________________ | |
# produce Ground station intervisibility | |
time_event, event_type, visibility_GS, sat_altaz_GS = ground_station_intervisibility(time_vector,sat_gcrs, ground_station) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment