-
Notifications
You must be signed in to change notification settings - Fork 0
/
point_xp_dec_reject.py
50 lines (41 loc) · 1.65 KB
/
point_xp_dec_reject.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
### Script to remove extreme dec targets from PointXP script. Will run through the target list, find AltAz coordinates, and then convert to RA Dec.
# If the Dec is greater than maxdec, the target will be removed from the list.
import os
from astropy.coordinates import EarthLocation,SkyCoord
from astropy.time import Time
from astropy import units as u
from astropy.coordinates import AltAz, Angle, ICRS
from pathlib import Path
# set the location of the observatory
observing_location = EarthLocation(lat=31.66 * u.deg, lon=-110.6 * u.deg, height=1.5 * u.km)
observing_time = Time('2020-07-02 12:00:00')
# Read in the target list
infile = Path(r'C:\Users\MACRO\Documents\Sidereal Technology\STI\PointXPRun.Script')
outfile = infile.parent / (infile.stem + '_edited.Script')
maxdec = 75
lines = infile.open().read().splitlines()
outlines = [lines[0]]
n=1
kicks = 0
for i in range(1,len(lines),6):
group = lines[i:i+6]
cmd, az, alt = group[0].split()
if cmd != 'SlewAltAz':
exit("Barf")
dd, mm, ss = alt.split(':')
altdeg = Angle(f'{dd}d{mm}m{ss}s')
dd, mm, ss = az.split(':')
azdeg = Angle(f'{dd}d{mm}m{ss}s')
altaz = AltAz(az=azdeg, alt=altdeg, location=observing_location, obstime=observing_time)
# convert to RA Dec
radec = altaz.transform_to(ICRS())
print(f"Alt: {alt} Az: {az} --> dec {radec.dec.degree} degrees", end=' ')
if radec.dec.degree <= maxdec:
outlines.extend(group)
print()
else:
print(f" --> kicked out #{n}")
kicks += 1
n += 1
outfile.write_text('\n'.join(outlines))
print(f"Kicked {kicks} out of {n-1} targets")