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
No related branches found
No related tags found
1 merge request!44Merge back holography to master
...@@ -6,10 +6,24 @@ import astropy.units as u ...@@ -6,10 +6,24 @@ import astropy.units as u
# Always try to download the most recent IERS tables. # Always try to download the most recent IERS tables.
from astropy.utils.data import download_file from astropy.utils.data import download_file
from astropy.utils import iers 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)) 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): def lm_from_radec(ra, dec, ra0, dec0):
r''' r'''
Calculate direction cosines given a right ascension and Calculate direction cosines given a right ascension and
......
...@@ -126,13 +126,15 @@ class CalibrationTable: ...@@ -126,13 +126,15 @@ class CalibrationTable:
observation_source: str, observation_source: str,
observation_date: str, observation_date: str,
calibration_name: str, calibration_name: str,
commment: str, calibration_date: str,
comment: str,
gains): gains):
new_calibration_table = deepcopy(self) new_calibration_table = deepcopy(self)
new_calibration_table.observation_source = observation_source new_calibration_table.observation_source = observation_source
new_calibration_table.observation_date = observation_date new_calibration_table.observation_date = observation_date
new_calibration_table.calibration_name = calibration_name, new_calibration_table.calibration_name = calibration_name
new_calibration_table.comment = commment new_calibration_table.calibration_date = calibration_date
new_calibration_table.comment = comment
new_calibration_table.data = gains new_calibration_table.data = gains
return new_calibration_table return new_calibration_table
......
...@@ -3,11 +3,10 @@ import re ...@@ -3,11 +3,10 @@ import re
from enum import IntEnum from enum import IntEnum
import numpy import numpy
from astropy.time import Time
from casacore.tables import table as MS_Table from casacore.tables import table as MS_Table
from lofar.calibration.common.coordinates import pqr_from_icrs from lofar.calibration.common.coordinates import pqr_from_icrs
from .holography_dataset_definitions import * from .holography_dataset_definitions import *
from ..coordinates import mjd_to_astropy_time as __mjd_to_astropy_time
class CASA_POLARIZATION_INDEX(IntEnum): class CASA_POLARIZATION_INDEX(IntEnum):
...@@ -22,19 +21,6 @@ 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' 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, def _compute_lm_from_ra_dec_station_position_rotation_matrix_and_time(ra_dec_epoch,
rotation_matrix, rotation_matrix,
mjd_times): mjd_times):
......
...@@ -5,6 +5,7 @@ import logging ...@@ -5,6 +5,7 @@ import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def is_observation_in_range(start, end, from_datetime, to_datetime): 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. 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.
Finish editing this message first!
Please register or to comment