Skip to content

Commit

Permalink
make docstrings raw
Browse files Browse the repository at this point in the history
  • Loading branch information
juanep97 committed Jan 18, 2024
1 parent 123b96b commit f63482d
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions iop4lib/db/epoch.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from iop4lib.db import RawFit, ReducedFit, Epoch

class Epoch(models.Model):
"""A class representing an epoch.
r"""A class representing an epoch.
Identified by the telescope and date of the night. Provides method for fetching the data
from the telescope archives and reducing the data.
Expand Down Expand Up @@ -77,49 +77,49 @@ class Meta:

@property
def epochname(self):
"""Returns a human readable string that uniquely identifies the epoch, as an alternative to the id."""
r""" Returns a human readable string that uniquely identifies the epoch, as an alternative to the id. """
return f"{self.telescope}/{self.night.strftime('%Y-%m-%d')}"

@property
def rawfitsdir(self):
"""Returns the path to the directory where the raw fits of this epoch are stored."""
r""" Returns the path to the directory where the raw fits of this epoch are stored. """
return os.path.join(iop4conf.datadir, "raw", self.epochname)

@property
def calibrationdir(self):
"""Returns the path to the directory where the calibration files of this epoch are stored."""
r""" Returns the path to the directory where the calibration files of this epoch are stored. """
return os.path.join(iop4conf.datadir, "calibration", self.epochname)

@property
def masterbiasdir(self):
"""Returns the path to the directory where the masterbias files of this epoch are stored."""
r""" Returns the path to the directory where the masterbias files of this epoch are stored. """
return os.path.join(iop4conf.datadir, "masterbias", self.epochname)

@property
def masterflatdir(self):
"""Returns the path to the directory where the masterflat files of this epoch are stored."""
r""" Returns the path to the directory where the masterflat files of this epoch are stored. """
return os.path.join(iop4conf.datadir, "masterflat", self.epochname)

@property
def masterdarkdir(self):
"""Returns the path to the directory where the masterdark files of this epoch are stored."""
r""" Returns the path to the directory where the masterdark files of this epoch are stored."""
return os.path.join(iop4conf.datadir, "masterdark", self.epochname)

@property
def yyyymmdd(self):
"""Returns the date of the epoch in the format YYYYMMDD."""
r""" Returns the date of the epoch in the format YYYYMMDD. """
return self.night.strftime("%Y%m%d")

@property
def yymmdd(self):
"""Returns the date of the epoch in the format YYMMDD."""
r""" Returns the date of the epoch in the format YYMMDD. """
return self.night.strftime("%y%m%d")

# helper property to return the jyear of the epoch at noon (12:00)

@property
def jyear(self):
"""Returns the jyear of the epoch at noon (before the night)."""
r""" Returns the jyear of the epoch at noon (before the night). """

from astropy.time import Time
from datetime import datetime, date, time
Expand Down Expand Up @@ -193,7 +193,7 @@ def __str__(self):

@staticmethod
def epochname_to_tel_night(epochname : str) -> tuple[str, datetime.date]:
"""Parses an epochname to a telescope and night."""
r""" Parses an epochname to a telescope and night. """

matches = re.findall(r"([a-zA-Z0-9]+)/([0-9]{2,4}-?[0-9]{2}-?[0-9]{2})$", epochname)

Expand Down Expand Up @@ -231,7 +231,7 @@ def create(cls,
fallback_to_local=True,
auto_merge_to_db=True,
rawfits_kwargs=dict()):
"""Create an Epoch object for the given telescope and night, reusing an existing DB entry if it exists.
r"""Create an Epoch object for the given telescope and night, reusing an existing DB entry if it exists.
Parameters
----------
Expand Down Expand Up @@ -276,9 +276,9 @@ def create(cls,
return epoch

def __init__(self, *args, **kwargs):
"""Provides some defaults for attributes that are not stores in DB.
r"""Provides some defaults for attributes that are not stores in DB.
Should be the same as default kwargs in .create() for consistency.
Should be the same as default kwargs in `.create()` for consistency.
"""
super().__init__(*args, **kwargs)
self.auto_link_rawfits = True
Expand All @@ -291,13 +291,12 @@ def __init__(self, *args, **kwargs):
# methods

def list_remote_raw_fnames(self):
"""Checks remote file list and builds self.rawfits from them.
"""
r"""Checks remote file list and builds self.rawfits from them. """
return Telescope.by_name(self.telescope).list_remote_raw_fnames(self)


def link_rawfits(self):
""" Links rawfits to this epoch. """
r""" Links rawfits to this epoch. """

from iop4lib.db import RawFit

Expand Down Expand Up @@ -355,9 +354,7 @@ def link_rawfits(self):


def get_summary_rawfits_status(self):
"""
Returns list of flags present in the rawfits of this epoch.
"""
r""" Returns list of flags present in the rawfits of this epoch. """
from iop4lib.db import RawFit

flag_vals_present = self.rawfits.all().values_list('flags', flat=True).distinct()
Expand Down Expand Up @@ -412,7 +409,7 @@ def build_master_darks(self, **kwargs):
return self.build_masters(MasterDark, **kwargs)

def reduce(self, force_rebuild=False):
""" Reduces all (LIGHT) rawfits of this epoch.
r""" Reduces all (LIGHT) rawfits of this epoch.
If force_rebuild is False, only rawfits that have not been reduced yet (that do not have
the BUILT_REDUCED flag) will be reduced, else all rawfits of this epoch of type LIGHT be
Expand All @@ -429,7 +426,7 @@ def reduce(self, force_rebuild=False):

@staticmethod
def reduce_rawfits(rawfits, force_rebuild=False, epoch=None):
""" Bulk reduces a list of RawFit in a multiprocessing pool. `rawfits` can be an iterable such as a QuerySet.
r""" Bulk reduces a list of RawFit in a multiprocessing pool. `rawfits` can be an iterable such as a QuerySet.
If force_rebuild is False, only rawfits that have not been reduced yet (that do not have
the BUILT_REDUCED flag) will be reduced, else all rawfits in the list will be reduced.
Expand Down Expand Up @@ -460,7 +457,7 @@ def reduce_rawfits(rawfits, force_rebuild=False, epoch=None):

@staticmethod
def reduce_reducedfits(reduced_L, epoch=None):
""" Bulk reduces a list of ReducedFit in a multiprocessing pool.
r""" Bulk reduces a list of ReducedFit in a multiprocessing pool.
If iop4conf.nthreads > 1, the reduction will be done in parallel processes.
Expand Down

0 comments on commit f63482d

Please sign in to comment.