almanac package¶
Submodules¶
almanac.apogee module¶
- almanac.apogee.create_apogee_id_lookup()[source]¶
Create a lookup dictionary mapping APOGEE IDs to SDSS IDs.
- almanac.apogee.get_almanac_data(observatory, mjd, fibers=False, meta=False, only_assign_sdss_id_to_first_exposure_per_configuration=True)[source]¶
Return comprehensive almanac data for all exposures taken from a given observatory on a given MJD.
- Parameters:
- Returns:
Tuple containing: - observatory name - MJD - A list of exposures - Table of exposure data - dictionary of sequence indices - dictionary of fiber mappings
- almanac.apogee.get_arclamp_sequences(exposures)[source]¶
Return a list of tuples indicating the start and end exposure numbers for a sequence of arc lamp exposures.
- almanac.apogee.get_expected_number_of_exposures(observatory, mjd)[source]¶
Query the SDSS database to get the expected exposures for a given observatory and MJD. This is useful for identifying missing exposures.
- Return type:
- almanac.apogee.get_exposures(observatory, mjd)[source]¶
Generate exposures taken from a given observatory on a given MJD.
- almanac.apogee.get_science_sequences(exposures)[source]¶
Return a list of tuples indicating the start and end exposure numbers for a sequence of science exposures.
- almanac.apogee.get_sequences(exposures, image_type, fields, ignore_interrupting_darks=False)[source]¶
Get exposure number ranges for sequences of a specific image type.
- Parameters:
exposures (
List[Exposure]) – Astropy Table containing exposure metadata.image_type (
Literal['blackbody','dark','object','domeflat','arclamp','twilightflat','internalflat','quartzflat','missing']) – The image type to search for (e.g., “Object”, “ArcLamp”).fields (
Tuple[str,...]) – Tuple of column names to group exposures by.ignore_interrupting_darks (
bool) – [optional] Whether to allow (and ignore) dark exposures interrupting sequences.
- Return type:
- Returns:
List of tuples containing (start_exposure, end_exposure) for each sequence.
- almanac.apogee.get_unique_exposure_paths(paths)[source]¶
Process a list of file paths to find unique exposures and determine which chips are available.
almanac.cli module¶
almanac.config module¶
- class almanac.config.Config(sdssdb=<factory>, database_connect_time_warning=3, sdssdb_exposure_min_mjd=<factory>, logging_level=20, platelist_dir='/uufs/chpc.utah.edu/common/home/sdss09/software/svn.sdss.org/data/sdss/platelist/trunk/plates/', sdsscore_dir='/uufs/chpc.utah.edu/common/home/sdss50/software/git/sdss/sdsscore/main/', apogee_dir='/uufs/chpc.utah.edu/common/home/sdss/sdsswork/data/apogee/', mapper_dir='/uufs/chpc.utah.edu/common/home/sdss50/sdsswork/data/mapper/', display_field_names=<factory>)[source]¶
Bases:
object-
platelist_dir:
str= '/uufs/chpc.utah.edu/common/home/sdss09/software/svn.sdss.org/data/sdss/platelist/trunk/plates/'¶
-
sdssdb:
DatabaseConfig¶
-
sdssdb_exposure_min_mjd:
ObservatoryMJD¶
-
platelist_dir:
- class almanac.config.ConfigManager[source]¶
Bases:
objectA utility class to save and load dataclass configurations using YAML.
- class almanac.config.DatabaseConfig(user='sdss_user', host='operations.sdss.org', port=5432, domain='operations.sdss.*')[source]¶
Bases:
object
almanac.database module¶
almanac.display module¶
- class almanac.display.BufferedHandler[source]¶
Bases:
HandlerCustom logging handler that buffers log records
- class almanac.display.ObservationsDisplay(mjd_min, mjd_max, observatories=('apo', 'lco'))[source]¶
Bases:
object- color_apo = 'dodger_blue3'¶
- color_both = 'purple4'¶
- color_lco = 'green4'¶
- color_missing = 'red'¶
- color_no_data = 'bright_black'¶
- color_outside_range = 'black'¶
- color_unknown = 'white'¶
- class almanac.display.Task(name, total=100, completed=0, status=TaskStatus.PENDING)[source]¶
Bases:
object-
status:
TaskStatus= 'pending'¶
-
status:
- class almanac.display.TaskStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum- COMPLETED = 'completed'¶
- FAILED = 'failed'¶
- PENDING = 'pending'¶
- RUNNING = 'running'¶
- almanac.display.display_exposures(exposures, sequences=None, console=None, header_style='bold cyan', column_names=None, sequence_styles=('green', 'yellow'), missing_style='blink bold red', title_style='bold blue')[source]¶
Display exposure information using Rich table formatting.
- Parameters:
exposures (
List[Exposure]) – List of Exposure objects containing exposure datasequences (
Optional[Dict[str,List[Tuple[int,int]]]]) – Dictionary mapping sequence names to lists of (start, end) tuples (default: None)console (
Optional[Console]) – Rich Console instance (default: None, creates new one)header_style (
str) – Style for table headers (default: “bold cyan”)sequence_styles (
Tuple[str,...]) – Tuple of styles to cycle through for sequences (default: (“green”, “yellow”))missing_style (
str) – Style for missing/error entries (default: “red”)title_style (
str) – Style for the table title (default: “bold blue”)
- Return type:
almanac.io module¶
- almanac.io.convert_value_for_hdf5(value, target_dtype)[source]¶
Convert a Python value to be compatible with HDF5 storage.
- almanac.io.extract_field_data(models, field_name)[source]¶
Extract data for a specific field from all models.
- almanac.io.get_hdf5_dtype(pydantic_type, sample_value=None)[source]¶
Map Pydantic field types to appropriate HDF5/NumPy dtypes.
- Parameters:
pydantic_type – The Pydantic field type annotation
sample_value – A sample value to help determine string lengths, etc.
- Returns:
Appropriate NumPy dtype for HDF5
- almanac.io.update(fp, observatory, mjd, exposures, sequences, fibers=False, verbose=False, compression=True)[source]¶
- almanac.io.write_almanac(output, results, fibers=False, verbose=False, compression=True)[source]¶
Write the results of an Almanac query to an HDF5 file.
- Parameters:
output (
str) – Path to the output HDF5 file.results (
List[Tuple[str,int,List[Exposure],Dict[str,List[Any]]]]) – List of tuples containing (observatory, mjd, exposures, sequences). - observatory: str, e.g., “apo” or “lco” - mjd: int, Modified Julian Date - exposures: List[Exposure], list of Exposure models - sequences: Dict[str, List[Any]], dictionary of sequences by image typefibers (
bool) – Whether to include fiber data in the output.verbose (
bool) – Whether to print progress information.compression (
bool) – Compression algorithm to use for datasets. If True, uses ‘gzip’.
almanac.logger module¶
almanac.utils module¶
- almanac.utils.adjusted_fiber_index_to_fiber_id(adjusted_fiber_index)[source]¶
Adjusted fiber index runs from 1 to 600 (inclusive) to account for APO and LCO.
Separate from whether it is APO or LCO, the fiber index runs in the opposite direction as what we call fiber_id.
- almanac.utils.get_current_mjd()[source]¶
Get current Modified Julian Date as integer.
- Return type:
- Returns:
Current MJD as integer
- almanac.utils.parse_mjds(mjd, mjd_start, mjd_end, date, date_start, date_end, earliest_mjd=0, return_nones=False)[source]¶
Parse MJD and date parameters to determine observation date range.
- Parameters:
mjd (
Optional[int]) – Single MJD value (can be negative for relative to current)mjd_start (
Optional[int]) – Start MJD for range (can be negative for relative to current)mjd_end (
Optional[int]) – End MJD for range (can be negative for relative to current)date (
Optional[str]) – Single date string in “YYYY-MM-DD” formatdate_start (
Optional[str]) – Start date string in “YYYY-MM-DD” formatdate_end (
Optional[str]) – End date string in “YYYY-MM-DD” formatearliest_mjd (
int) – Earliest allowed MJD value (default: 0)return_nones (
bool) – If True, return None for mjd range if no dates are specified (default: False)
- Returns:
MJD values (single int, range, or tuple)
Start MJD (int)
End MJD (int)
- Return type:
Tuple containing
- Raises:
ValueError – If more than one time specification method is provided
RuntimeError – If no valid time specification is found