Skip to content
Snippets Groups Projects
Commit 31e61c9a authored by Mattia Mancini's avatar Mattia Mancini
Browse files

SSB-47: small refactoring and formatting

parent 0d027bf6
Branches
Tags
1 merge request!44Merge back holography to master
......@@ -6,10 +6,24 @@ import astropy.units as u
# Always try to download the most recent IERS tables.
from astropy.utils.data import download_file
from astropy.utils import iers
from astropy.time import Time
iers.IERS.iers_table = iers.IERS_A.open(download_file(iers.IERS_A_URL, cache=True))
def mjd_to_astropy_time(mjd_time_seconds) -> Time:
"""
Convert the modified julian date in seconds in a datetime object
:param mjd_time_seconds: modified julian data in seconds
:return: the date time of the given julian date
:rtype: datetime
"""
hour_in_seconds = 60 * 60
day_in_seconds = hour_in_seconds * 24
return Time(mjd_time_seconds / day_in_seconds, format='mjd', scale='utc')
def lm_from_radec(ra, dec, ra0, dec0):
r'''
Calculate direction cosines given a right ascension and
......
......@@ -126,13 +126,15 @@ class CalibrationTable:
observation_source: str,
observation_date: str,
calibration_name: str,
commment: str,
calibration_date: str,
comment: str,
gains):
new_calibration_table = deepcopy(self)
new_calibration_table.observation_source = observation_source
new_calibration_table.observation_date = observation_date
new_calibration_table.calibration_name = calibration_name,
new_calibration_table.comment = commment
new_calibration_table.calibration_name = calibration_name
new_calibration_table.calibration_date = calibration_date
new_calibration_table.comment = comment
new_calibration_table.data = gains
return new_calibration_table
......
......@@ -3,11 +3,10 @@ import re
from enum import IntEnum
import numpy
from astropy.time import Time
from casacore.tables import table as MS_Table
from lofar.calibration.common.coordinates import pqr_from_icrs
from .holography_dataset_definitions import *
from ..coordinates import mjd_to_astropy_time as __mjd_to_astropy_time
class CASA_POLARIZATION_INDEX(IntEnum):
......@@ -22,19 +21,6 @@ class CASA_POLARIZATION_INDEX(IntEnum):
ms_name_pattern = r'L(?P<sas_id>\d{6})(_SAP\d{3})*_SB(?P<sub_band_id>\d{3})_uv\.MS'
def __mjd_to_astropy_time(mjd_time_seconds):
"""
Convert the modified julian date in seconds in a datetime object
:param mjd_time_seconds: modified julian data in seconds
:return: the date time of the given julian date
:rtype: datetime
"""
hour_in_seconds = 60 * 60
day_in_seconds = hour_in_seconds * 24
return Time(mjd_time_seconds / day_in_seconds, format='mjd', scale='utc')
def _compute_lm_from_ra_dec_station_position_rotation_matrix_and_time(ra_dec_epoch,
rotation_matrix,
mjd_times):
......
......@@ -5,6 +5,7 @@ import logging
logger = logging.getLogger(__name__)
def is_observation_in_range(start, end, from_datetime, to_datetime):
"""
Checks if a given observation with start and end time happened in the time range specified.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment