Skip to content

Commit

Permalink
Merge branch 'issue-462'. Closes #462
Browse files Browse the repository at this point in the history
  • Loading branch information
talister committed Jul 24, 2020
2 parents 1682630 + b124a13 commit 9526e47
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion neoexchange/astrometrics/ephem_subs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
warnings.simplefilter('ignore', category=AstropyDeprecationWarning)
from astroquery.jplhorizons import Horizons
from astropy.table import Column
from astropy.time import Time

# Local imports
from astrometrics.time_subs import datetime2mjd_utc, datetime2mjd_tdb, mjd_utc2mjd_tt, ut1_minus_utc, round_datetime
Expand Down Expand Up @@ -684,7 +685,7 @@ def convert_horizons_table(ephem, include_moon=False):
columns (if [include_moon] is True).
The modified Astropy Table is returned"""

dates = Column([datetime.strptime(d, "%Y-%b-%d %H:%M") for d in ephem['datetime_str']])
dates = Time([datetime.strptime(d, "%Y-%b-%d %H:%M") for d in ephem['datetime_str']])
if 'datetime' not in ephem.colnames:
ephem.add_column(dates, name='datetime')
# Convert units of RA/Dec rate from arcsec/hr to arcsec/min and compute
Expand Down
18 changes: 9 additions & 9 deletions neoexchange/photometrics/obsgeomplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def plot_helio_geo_dist(ephem, title=None, base_dir=''):
# Generate the figure **without using pyplot**.
fig = Figure()
ax = fig.subplots()
dates = ephem['datetime']
dates = ephem['datetime'].datetime
ax.plot(dates, ephem['r'], color=hel_color, linestyle='-')
ax.plot(dates, ephem['delta'], color=geo_color, linestyle='-')

Expand Down Expand Up @@ -202,7 +202,7 @@ def plot_brightness(ephem, title=None, base_dir=''):
ax = fig.subplots()
ax2 = ax.twinx()

dates = ephem['datetime']
dates = ephem['datetime'].datetime
line_mag = ax.plot(dates, ephem[mag_column], color=hel_color, linestyle='-')
line_elong = ax2.plot(dates, ephem['elong'], color=geo_color, linestyle='-')
lines = [line_mag[0], line_elong[0] ]
Expand Down Expand Up @@ -276,13 +276,13 @@ def determine_hours_up(ephem_ca, site_code, dbg=False):

# Determine times of darkness for the site for the first night and use
# the hour value of "sunset" as the boundary value of the night range
dark_start, dark_end = determine_darkness_times(site_code, dates[0])
dark_start, dark_end = determine_darkness_times(site_code, dates[0].datetime)
dark_start = dark_start - timedelta(hours=2)
dark_end = dark_end + timedelta(hours=2)
start_date = dates[0].replace(hour=dark_start.hour, minute=0, second=0, microsecond=0)
start_date = dates[0].datetime.replace(hour=dark_start.hour, minute=0, second=0, microsecond=0)
if start_date > dark_start:
start_date = start_date - timedelta(days=1)
end_date = dates[-1].replace(hour=dark_end.hour, minute=0, second=0, microsecond=0)
end_date = dates[-1].datetime.replace(hour=dark_end.hour, minute=0, second=0, microsecond=0)
if dates[-1] < end_date:
if dbg: print("Subtracting 1 day from", end_date,dates[-1])
end_date -= timedelta(days=1)
Expand All @@ -301,7 +301,7 @@ def determine_hours_up(ephem_ca, site_code, dbg=False):
vis_times = ''
if len(visible_ephem) > 0:
time_up = visible_ephem[-1]['datetime'] - visible_ephem[0]['datetime']
hours_up = time_up.total_seconds()/3600.0
hours_up = time_up.datetime.total_seconds()/3600.0
vis_times = " ({}->{})".format(visible_ephem[0]['datetime'], visible_ephem[-1]['datetime'])
hours_visible.append(hours_up)
if dbg: print("For {}: {}->{}: {:.2f} hours{}".format(plot_date, date.strftime("%Y-%m-%d %H:%M"), end_dt.strftime("%Y-%m-%d %H:%M"), hours_up, vis_times))
Expand All @@ -326,7 +326,7 @@ def plot_hoursup(ephem_ca, site_code, title=None, add_altitude=False, add_rate=T
return ''

first = ephem_ca[0]
dates = ephem_ca['datetime']
dates = ephem_ca['datetime'].datetime
close_approach = dates[ephem_ca['delta'].argmin()]
visible_dates, hours_visible = determine_hours_up(ephem_ca, site_code, dbg)
mag_column = 'V'
Expand Down Expand Up @@ -429,7 +429,7 @@ def plot_uncertainty(ephem, title=None, base_dir=''):
ca_color = '#4700c3'

first = ephem[0]
dates = ephem['datetime']
dates = ephem['datetime'].datetime

ca_idx = ephem['delta'].argmin()
close_approach = None
Expand All @@ -440,7 +440,7 @@ def plot_uncertainty(ephem, title=None, base_dir=''):
fig = Figure()
ax = fig.subplots()

unc_line = ax.plot(ephem['datetime'], ephem['RSS_3sigma'], 'k-')
unc_line = ax.plot(dates, ephem['RSS_3sigma'], 'k-')
unc_line = unc_line[0]
ylim = ax.get_ylim()
ax.set_ylim(0, ylim[1]*1.05)
Expand Down

0 comments on commit 9526e47

Please sign in to comment.