wintertoo 1.6.2__tar.gz → 1.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of wintertoo might be problematic. Click here for more details.

Files changed (37) hide show
  1. {wintertoo-1.6.2 → wintertoo-1.7.0}/PKG-INFO +1 -1
  2. {wintertoo-1.6.2 → wintertoo-1.7.0}/pyproject.toml +1 -1
  3. {wintertoo-1.6.2 → wintertoo-1.7.0}/tests/test_schedule.py +2 -0
  4. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/data/__init__.py +1 -5
  5. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/database.py +1 -1
  6. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/models/too.py +20 -0
  7. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/schedule.py +1 -1
  8. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/submit.py +1 -1
  9. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/utils.py +15 -23
  10. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/validate.py +3 -3
  11. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo.egg-info/PKG-INFO +1 -1
  12. {wintertoo-1.6.2 → wintertoo-1.7.0}/.github/dependabot.yml +0 -0
  13. {wintertoo-1.6.2 → wintertoo-1.7.0}/.github/workflows/automerge.yml +0 -0
  14. {wintertoo-1.6.2 → wintertoo-1.7.0}/.github/workflows/black.yml +0 -0
  15. {wintertoo-1.6.2 → wintertoo-1.7.0}/.github/workflows/continuous_integration.yml +0 -0
  16. {wintertoo-1.6.2 → wintertoo-1.7.0}/.github/workflows/isort.yml +0 -0
  17. {wintertoo-1.6.2 → wintertoo-1.7.0}/.github/workflows/pylint.yml +0 -0
  18. {wintertoo-1.6.2 → wintertoo-1.7.0}/.gitignore +0 -0
  19. {wintertoo-1.6.2 → wintertoo-1.7.0}/.pre-commit-config.yaml +0 -0
  20. {wintertoo-1.6.2 → wintertoo-1.7.0}/LICENSE +0 -0
  21. {wintertoo-1.6.2 → wintertoo-1.7.0}/README.md +0 -0
  22. {wintertoo-1.6.2 → wintertoo-1.7.0}/setup.cfg +0 -0
  23. {wintertoo-1.6.2 → wintertoo-1.7.0}/tests/test_fields.py +0 -0
  24. {wintertoo-1.6.2 → wintertoo-1.7.0}/tests/testdata/test_schedule.json +0 -0
  25. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/__init__.py +0 -0
  26. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/data/observing_request_schema.json +0 -0
  27. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/data/summer_fields.txt +0 -0
  28. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/data/winter_fields.txt +0 -0
  29. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/errors.py +0 -0
  30. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/fields.py +0 -0
  31. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/models/__init__.py +0 -0
  32. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/models/image.py +0 -0
  33. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo/models/program.py +0 -0
  34. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo.egg-info/SOURCES.txt +0 -0
  35. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo.egg-info/dependency_links.txt +0 -0
  36. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo.egg-info/requires.txt +0 -0
  37. {wintertoo-1.6.2 → wintertoo-1.7.0}/wintertoo.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wintertoo
3
- Version: 1.6.2
3
+ Version: 1.7.0
4
4
  Author-email: Robert Stein <rdstein@caltech.edu>, Danielle Frostig <frostig@mit.edu>, Viraj Karambelkar <viraj@astro.caltech.edu>
5
5
  License: MIT
6
6
  Project-URL: homepage, https://github.com/winter-telescope/wintertoo
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "wintertoo"
7
- version = "1.6.2"
7
+ version = "1.7.0"
8
8
  description = ""
9
9
  authors = [
10
10
  {name = "Robert Stein", email = "rdstein@caltech.edu"},
@@ -82,6 +82,8 @@ class TestSchedule(unittest.TestCase):
82
82
  dec_deg=11.253441,
83
83
  total_exposure_time=100.0,
84
84
  n_dither=1,
85
+ start_time_mjd=62721.1894969287,
86
+ end_time_mjd=62722.1894969452,
85
87
  target_name="test_radec",
86
88
  ),
87
89
  program=program,
@@ -54,10 +54,6 @@ def get_default_value(key: str):
54
54
 
55
55
 
56
56
  # define location of Palomar Observatory
57
- PALOMAR_LOC = coords.EarthLocation(
58
- lat=coords.Latitude("33d21m25.5s"),
59
- lon=coords.Longitude("-116d51m58.4s"),
60
- height=1696.0,
61
- )
57
+ PALOMAR_LOC = coords.EarthLocation.of_site("Palomar")
62
58
 
63
59
  palomar_observer = astroplan.Observer(location=PALOMAR_LOC)
@@ -37,7 +37,7 @@ def get_engine(
37
37
  )
38
38
 
39
39
 
40
- def get_program_details( # pylint: disable=too-many-arguments,too-many-locals
40
+ def get_program_details( # pylint: disable=R0913,R0914,R0917
41
41
  program_name: str,
42
42
  program_api_key: str,
43
43
  program_db_user: str = None,
@@ -2,6 +2,7 @@
2
2
  Models for ToO requests
3
3
  """
4
4
 
5
+ import logging
5
6
  from typing import List, Optional, Union
6
7
 
7
8
  from astropy.time import Time
@@ -24,6 +25,8 @@ from wintertoo.data import (
24
25
  )
25
26
  from wintertoo.errors import WinterValidationError
26
27
 
28
+ logger = logging.getLogger(__name__)
29
+
27
30
  MIN_EXPOSURE_TIME = 0.28
28
31
  MAX_EXPOSURE_TIME = 300.0
29
32
 
@@ -248,3 +251,20 @@ class WinterRaDecToO(Winter, RaDecToO):
248
251
 
249
252
 
250
253
  AllTooClasses = Union[SummerFieldToO, SummerRaDecToO, WinterFieldToO, WinterRaDecToO]
254
+
255
+
256
+ def is_summer(too: Union[Winter, Summer]) -> bool:
257
+ """
258
+ Checks a ToO Request to ensure it is either a Summer or Winter request
259
+
260
+ :param too: ToO request
261
+ :return: boolean
262
+ """
263
+ if isinstance(too, Summer):
264
+ return True
265
+ if isinstance(too, Winter):
266
+ return False
267
+
268
+ err = f"Unrecognised ToO type {type(too)}"
269
+ logger.error(err)
270
+ raise TypeError(err)
@@ -18,8 +18,8 @@ from wintertoo.models.too import (
18
18
  SummerRaDecToO,
19
19
  WinterFieldToO,
20
20
  WinterRaDecToO,
21
+ is_summer,
21
22
  )
22
- from wintertoo.utils import is_summer
23
23
  from wintertoo.validate import validate_schedule_df
24
24
 
25
25
  logger = logging.getLogger(__name__)
@@ -66,7 +66,7 @@ def export_schedule_to_sqlitedb(schedule: pd.DataFrame, base_save_path: str) ->
66
66
  return save_path
67
67
 
68
68
 
69
- def submit_schedule( # pylint: disable=too-many-arguments
69
+ def submit_schedule( # pylint: disable=R0913,R0917
70
70
  schedule: pd.DataFrame,
71
71
  program_api_key: str,
72
72
  program_name: str,
@@ -5,16 +5,16 @@ Created on Tue Jan 25 13:51:59 2022
5
5
  @author: frostig, belatedly edited by Robert Stein
6
6
  """
7
7
  import logging
8
- from typing import Union
9
8
 
10
9
  import astropy.time
11
10
  import numpy as np
12
11
  import pandas as pd
12
+ from astropy import units as u
13
13
  from astropy.coordinates import AltAz, SkyCoord
14
14
  from astropy.time import Time
15
+ from astropy.utils.masked import Masked
15
16
 
16
17
  from wintertoo.data import PALOMAR_LOC, palomar_observer
17
- from wintertoo.models.too import Summer, Winter
18
18
 
19
19
  logger = logging.getLogger(__name__)
20
20
 
@@ -51,8 +51,15 @@ def up_tonight(time_mjd: astropy.time.Time, ra: str, dec: str) -> tuple[bool, st
51
51
  """
52
52
  loc = SkyCoord(ra=ra, dec=dec, frame="icrs")
53
53
  time = Time(time_mjd, format="mjd")
54
+
55
+ # Rise/fade can fail if target is close to a bin edge
54
56
  sun_rise = palomar_observer.sun_rise_time(time, which="previous")
57
+ if isinstance(sun_rise.value, Masked):
58
+ sun_rise = palomar_observer.sun_rise_time(time - 0.05 * u.day, which="previous")
55
59
  sun_set = palomar_observer.sun_set_time(time, which="next")
60
+ if isinstance(sun_rise.value, Masked):
61
+ sun_set = palomar_observer.sun_rise_time(time + 0.05 * u.day, which="next")
62
+
56
63
  night = sun_set.jd - sun_rise.jd
57
64
  if night >= 1:
58
65
  # if next day, subtract a day
@@ -66,10 +73,12 @@ def up_tonight(time_mjd: astropy.time.Time, ra: str, dec: str) -> tuple[bool, st
66
73
  df = pd.DataFrame(data={"time": time_array, "alt": altaz.alt})
67
74
  df = df[df["alt"] >= MINIMUM_ELEVATION]
68
75
 
69
- try:
70
- time_up = df["time"].iloc[-1] - df["time"].iloc[0]
71
- except KeyError:
72
- time_up = 0
76
+ time_up = 0
77
+ if len(df) > 0:
78
+ try:
79
+ time_up = df["time"].iloc[-1] - df["time"].iloc[0]
80
+ except KeyError:
81
+ pass
73
82
 
74
83
  if time_up > 0:
75
84
  is_available = (
@@ -85,23 +94,6 @@ def up_tonight(time_mjd: astropy.time.Time, ra: str, dec: str) -> tuple[bool, st
85
94
  return avail_bool, is_available
86
95
 
87
96
 
88
- def is_summer(too: Union[Winter, Summer]) -> bool:
89
- """
90
- Checks a ToO Request to ensure it is either a Summer or Winter request
91
-
92
- :param too: ToO request
93
- :return: boolean
94
- """
95
- if isinstance(too, Summer):
96
- return True
97
- if isinstance(too, Winter):
98
- return False
99
-
100
- err = f"Unrecognised ToO type {type(too)}"
101
- logger.error(err)
102
- raise TypeError(err)
103
-
104
-
105
97
  def get_date(time: Time) -> int:
106
98
  """
107
99
  Get the date from a time object
@@ -20,7 +20,7 @@ from wintertoo.utils import up_tonight
20
20
  logger = logging.getLogger(__name__)
21
21
 
22
22
 
23
- def get_and_validate_program_details( # pylint: disable=too-many-arguments
23
+ def get_and_validate_program_details( # pylint: disable=R0913,R0917
24
24
  program_name: str,
25
25
  program_api_key: str,
26
26
  program_db_user: str = None,
@@ -256,7 +256,7 @@ def validate_time_allocation(
256
256
  raise WinterValidationError(err)
257
257
 
258
258
 
259
- def validate_schedule_with_program( # pylint: disable=too-many-arguments
259
+ def validate_schedule_with_program(
260
260
  schedule_request: pd.DataFrame,
261
261
  program: Program,
262
262
  ):
@@ -297,7 +297,7 @@ def validate_schedule_with_program( # pylint: disable=too-many-arguments
297
297
  )
298
298
 
299
299
 
300
- def validate_schedule_request( # pylint: disable=too-many-arguments
300
+ def validate_schedule_request( # pylint: disable=R0913,R0917
301
301
  schedule_request: pd.DataFrame,
302
302
  program_name: str,
303
303
  program_api_key: str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wintertoo
3
- Version: 1.6.2
3
+ Version: 1.7.0
4
4
  Author-email: Robert Stein <rdstein@caltech.edu>, Danielle Frostig <frostig@mit.edu>, Viraj Karambelkar <viraj@astro.caltech.edu>
5
5
  License: MIT
6
6
  Project-URL: homepage, https://github.com/winter-telescope/wintertoo
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes