Skip to content

Commit

Permalink
try TOC in Times Square
Browse files Browse the repository at this point in the history
  • Loading branch information
pothiers committed Sep 27, 2024
1 parent f0471c7 commit 872cfec
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 51 deletions.
74 changes: 43 additions & 31 deletions notebooks_tsqr/NightLog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@
"cell_type": "markdown",
"id": "0",
"metadata": {},
"source": [
"# Table of Contents\n",
"* [Overview of NightLog Report](#overview)\n",
"* [DDV](#ddv)\n",
"* [Almanac](#almanac)"
]
},
{
"cell_type": "markdown",
"id": "1",
"metadata": {},
"source": [
"# Initialization"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -28,13 +39,13 @@
"#!day_obs = 'TODAY' # TODO Change to 'TODAY' to test with default before push \n",
"\n",
"# Total number of days of data to display (ending on day_obs)\n",
"number_of_days = '1' # TODO Change to '1' to test with default before push "
"number_of_days = '31' # TODO Change to '1' to test with default before push "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"id": "3",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -69,7 +80,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"id": "4",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -95,7 +106,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4",
"id": "5",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -111,15 +122,15 @@
},
{
"cell_type": "markdown",
"id": "5",
"id": "6",
"metadata": {},
"source": [
"# Overview"
"# Overview of NightLog Report <a id=\"overview\"></a>"
]
},
{
"cell_type": "markdown",
"id": "6",
"id": "7",
"metadata": {},
"source": [
"### Where an this run?\n",
Expand All @@ -133,14 +144,14 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"id": "8",
"metadata": {},
"outputs": [],
"source": [
"# Display overview of Report context \n",
"md(f'''## Project Wide Night(s) Report \n",
"- Run on logs from **{server}/**\n",
"- Report **{days} observing night(s)** with the last reported night starting **{date}**.\n",
"md(f'''## Project-Wide Night(s) Report \n",
"- Run on logs and databases from **{server}/**\n",
"- Report **{days} observing night(s)** with the last reported night starting on **{date}**.\n",
"- This report will include available data from noon **{min_date}** to noon **{max_date}** (inclusive).\n",
"- Using ***Prototype* Logging and Reporting** Version: **{lrversion}**\n",
"''')\n",
Expand All @@ -150,21 +161,22 @@
"sources_md_str += '\\n- EFD'\n",
"sources_md_str += '\\n- (DDV)'\n",
"sources_md_str += '\\n- (Astroplan for Almanac)'\n",
"md(f'### This report uses the following sources: {sources_md_str}')"
"md(f'### This report uses the following data sources: {sources_md_str}')"
]
},
{
"cell_type": "markdown",
"id": "8",
"id": "9",
"metadata": {},
"source": [
"# DDV"
"<a id=\"ddv\"></a>\n",
"# DDV "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"id": "10",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -174,7 +186,7 @@
},
{
"cell_type": "markdown",
"id": "10",
"id": "11",
"metadata": {},
"source": [
"# Almanac"
Expand All @@ -183,7 +195,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "11",
"id": "12",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -193,7 +205,7 @@
},
{
"cell_type": "markdown",
"id": "12",
"id": "13",
"metadata": {},
"source": [
"# Night Report"
Expand All @@ -202,7 +214,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "13",
"id": "14",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -221,7 +233,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "14",
"id": "15",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -247,7 +259,7 @@
},
{
"cell_type": "markdown",
"id": "15",
"id": "16",
"metadata": {},
"source": [
"# Exposure Log"
Expand All @@ -256,7 +268,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "16",
"id": "17",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -279,7 +291,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "17",
"id": "18",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -298,7 +310,7 @@
},
{
"cell_type": "markdown",
"id": "18",
"id": "19",
"metadata": {},
"source": [
"# Narrative Log\n"
Expand All @@ -307,7 +319,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "19",
"id": "20",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -328,7 +340,7 @@
},
{
"cell_type": "markdown",
"id": "20",
"id": "21",
"metadata": {},
"source": [
"# Developer Only Section"
Expand All @@ -337,7 +349,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "21",
"id": "22",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -348,7 +360,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "22",
"id": "23",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -361,7 +373,7 @@
},
{
"cell_type": "markdown",
"id": "23",
"id": "24",
"metadata": {},
"source": [
"# Finale"
Expand All @@ -370,7 +382,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "24",
"id": "25",
"metadata": {},
"outputs": [],
"source": [
Expand Down
79 changes: 61 additions & 18 deletions python/lsst/ts/logging_and_reporting/almanac.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,96 @@
from datetime import datetime, date, time, timedelta
import datetime as dt
import math
from astroplan import Observer
from astropy.time import Time

# Compare to https://www.timeanddate.com/sun/@5296409
class Almanac:
"""Get almanac data for a night give a day_obs.
A day_obs is the date of the start of an observing night. Therefore
for sunrise and morning twilight we get time on the date AFTER day_obs.
For sunset and evening twilight we get time on date of day_obs.
For moonrise/set we get the time nearest to the midnight after day_ob.
"""


def __init__(self, *, day_obs=None, site='Rubin'):
if day_obs is None:
astro_day = date.today() - timedelta(days=1)
astro_day = dt.date.today() - dt.timedelta(days=1)
else:
astro_day = datetime.strptime(str(day_obs), '%Y%m%d').date()
astro_day = dt.datetime.strptime(str(day_obs), '%Y%m%d').date()

self.observer = Observer.at_site(site, timezone='Chile/Continental')
self.astro_day = astro_day
self.astro_noon = datetime.combine(self.astro_day,time(12))

day1 = dt.timedelta(days=1)
self.astro_midnight = Time(dt.datetime.combine(self.astro_day+day1,
dt.time(0)
),
format='datetime'
)
self.get_moon()
self.get_sun()

def get_moon(self):
self.moon_rise_time = self.observer.moon_rise_time(self.astro_noon)
self.moon_set_time = self.observer.moon_set_time(self.astro_noon)
self.moon_rise_time = self.observer.moon_rise_time(
self.astro_midnight,
which='nearest'
)
self.moon_set_time = self.observer.moon_set_time(
self.astro_midnight,
which='nearest'
)

# Percent of moon lit
self.moon_illum = self.observer.moon_illumination(self.astro_noon)
self.moon_illum = self.observer.moon_illumination(
self.astro_midnight
)

def get_sun(self):
time = self.observer.datetime_to_astropy_time(self.astro_noon)

# ast(ronoimical) twilight: -18 degrees)
self.ast_twilight_morning = self.observer.twilight_morning_astronomical(
time)
self.astro_midnight,
which='next'
)
self.ast_twilight_evening = self.observer.twilight_evening_astronomical(
time)
self.astro_midnight,
which='previous'
)


# nau(tical) twilight: -12 degrees)
self.nau_twilight_morning = self.observer.twilight_morning_nautical(
time)
self.astro_midnight,
which='next'
)
self.nau_twilight_evening = self.observer.twilight_evening_nautical(
time)
self.astro_midnight,
which='previous'
)


# civ(il) twilight: -6 degrees)
self.civ_twilight_morning = self.observer.twilight_morning_civil(
time)
self.astro_midnight,
which='next'
)
self.civ_twilight_evening = self.observer.twilight_evening_civil(
time)
self.astro_midnight,
which='previous'
)

self.sun_rise_time = self.observer.sun_rise_time(
self.astro_midnight,
which='next'
)
self.sun_set_time = self.observer.sun_set_time(
self.astro_midnight,
which='previous'
)

self.sun_rise_time = self.observer.sun_rise_time(time)
self.sun_set_time = self.observer.sun_set_time(time)
@property
def night_hours(self):
day_delta = self.ast_twilight_morning - self.ast_twilight_evening
return day_delta.to_value('hr')

@property
def as_dict(self):
Expand Down
Loading

0 comments on commit 872cfec

Please sign in to comment.