Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to t0 in schedtel and exoplanet_transits #81

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 14 additions & 21 deletions pyscope/telrun/exoplanet_transits.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,31 +104,24 @@ def exoplanet_transits_cli(
if transit_depth_percent is not None:
transit_depth = np.log10(1 + transit_depth_percent / 100) / 0.4

tz = timezonefinder.TimezoneFinder().timezone_at(lng=lon.deg, lat=lat.deg)
tz = zoneinfo.ZoneInfo(tz)
logger.debug(f"tz = {tz}")

if date is None:
logger.info("Using current date at observatory location")
tz = timezonefinder.TimezoneFinder().timezone_at(
lng=observatory.observatory_location.lon.deg,
lat=observatory.observatory_location.lat.deg,
)
date = datetime.datetime.now(pytz.timezone(tz))
logger.debug("Using current date at observatory location")
date = datetime.datetime.now()
else:
date = datetime.datetime.strptime(date, "%Y-%m-%d")
date = datetime.datetime(date.year, date.month, date.day, 12, 0, 0, tzinfo=tz)

t0 = (
astrotime.Time(
datetime.datetime(date.year, date.month, date.day, 12, 0, 0),
format="datetime",
scale="utc",
)
- (
(
astrotime.Time(date, format="datetime", scale="utc")
- astrotime.Time.now()
).day
% 1
)
* u.day
t0 = astrotime.Time(
datetime.datetime(date.year, date.month, date.day, 12, 0, 0, tzinfo=tz),
format="datetime",
)
logger.debug(f"t0 = {t0}")
t1 = t0 + 1 * u.day
logger.info("Searching UT range: %s to %s" % (t0.iso, t1.iso))
logger.debug(f"t1 = {t1}")

min_ra = observatory.lst(t=t0).to(u.deg).value
max_ra = observatory.lst(t=t1).to(u.deg).value
Expand Down
29 changes: 12 additions & 17 deletions pyscope/telrun/schedtel.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,25 +287,20 @@ def schedtel_cli(
)

# Schedule
tz = timezonefinder.TimezoneFinder().timezone_at(lng=lon.deg, lat=lat.deg)
tz = zoneinfo.ZoneInfo(tz)
logger.debug(f"tz = {tz}")

if date is None:
logger.info("Using current date at observatory location")
tz = timezonefinder.TimezoneFinder().timezone_at(lng=obs_long, lat=obs_lat)
date = datetime.datetime.now(pytz.timezone(tz))
logger.debug("Using current date at observatory location")
date = datetime.datetime.now()
else:
date = datetime.datetime.strptime(date, "%Y-%m-%d")
date = datetime.datetime(date.year, date.month, date.day, 12, 0, 0, tzinfo=tz)

t0 = (
astrotime.Time(
datetime.datetime(date.year, date.month, date.day, 12, 0, 0),
format="datetime",
scale="utc",
)
- (
(
astrotime.Time(date, format="datetime", scale="utc")
- astrotime.Time.now()
).day
% 1
)
* u.day
t0 = astrotime.Time(
datetime.datetime(date.year, date.month, date.day, 12, 0, 0, tzinfo=tz),
format="datetime",
)
t1 = t0 + 1 * u.day
logger.info("Schedule time range: %s to %s" % (t0.iso, t1.iso))
Expand Down