From ddccc128c8ee0d0f5f67958258c1a3f1a51c1ba0 Mon Sep 17 00:00:00 2001 From: kazirygl Date: Mon, 4 May 2026 13:18:50 +0200 Subject: [PATCH 01/14] Update discosscan.py These changes calculate the velocity axis without the assumption that it is perfectly centered on VLSR. --- src/discosscan.py | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/discosscan.py b/src/discosscan.py index 0dcc652..5172783 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -124,10 +124,25 @@ def _load_metadata(self, section, polarization, index): with fits.open(self.subscans[index][0]) as subscan: self.location = (subscan[0].header["SiteLongitude"] * u.rad, subscan[0].header["SiteLatitude"] * u.rad) - self.location = (self.location[0].to(u.deg), + self.longitude = self.location[0].to(u.deg) #KR + self.latitude = self.location[1].to(u.deg) #KR + self.location = (self.location[0].to(u.deg), self.location[1].to(u.deg)) self.ra = subscan[0].header["RightAscension"] self.dec = subscan[0].header["Declination"] + self.ra_ha = (subscan[0].header["RightAscension"]*u.rad).to(u.hourangle) #KR + self.dec_deg = (subscan[0].header["Declination"] *u.rad).to(u.deg) #KR + self.height = subscan[0].header["SiteHeight"]*u.m #KR + self.time_obs = subscan[0].header["DATE"] #KR + self.lsrk_time = Time(self.time_obs) #KR + self.obsloc = EarthLocation.from_geodetic(self.longitude, self.latitude, self.height) #KR + self.sourcecoord = SkyCoord(self.ra_ha, self.dec_deg,unit=(u.hourangle, u.deg)) #KR + v_bary = self.sourcecoord.radial_velocity_correction(kind='barycentric', obstime=self.lsrk_time, location=self.obsloc) #KR + icrs = ICRS(self.sourcecoord.ra, self.sourcecoord.dec, pm_ra_cosdec=0*u.mas/u.yr, pm_dec=0*u.mas/u.yr, radial_velocity=v_bary, distance=1*u.pc) #KR + self.barycorr = icrs.transform_to(LSRK()).radial_velocity #KR + self.vrad_def = subscan[0].header["VLSR"] #in km/s KR + self.beta = - (self.vrad_def - (self.barycorr).to("km / s").value) / CLIGHT #KR + self.observation_time = Time(subscan["DATA TABLE"].data["time"][0], format = "mjd", scale = "utc", @@ -262,7 +277,10 @@ def write_observation(self, scan_cycle, first_subscan_index): logger.debug("offset at 0 %f" % self.offsetFrequencyAt0) obs.head.spe.vres = - (self.freq_resolution / self.central_frequency) * CLIGHT # frequency resolution must have the same unity like the central_frequency - obs.head.spe.voff = self.summary["velocity"]["vrad"] + self.drc = ((self.central_frequency - 1* self.freq_resolution)/(self.rest_frequency)) #KR + self.dr2c = ((self.central_frequency - 1* self.freq_resolution)/(self.rest_frequency))**2 #KR + obs.head.spe.voff = CLIGHT * (1-self.drc) + self.barycorr.to("km / s").value #self.summary["velocity"]["vrad"] #KR - radio convention + #obs.head.spe.voff = self.summary["velocity"]["vrad"] KR COMMENTED obs.head.spe.bad = 0. obs.head.spe.image = 0. if self.summary["velocity"]["vframe"] == "BARY": @@ -278,10 +296,15 @@ def write_observation(self, scan_cycle, first_subscan_index): else: obs.head.spe.vtype = code.velo.unk logger.debug("velocity: UNK") - v_observer = -((self.central_frequency - self.rest_frequency) / - self.rest_frequency) * CLIGHT - obs.head.spe.doppler = - (v_observer + obs.head.spe.voff) / CLIGHT #doppler in units of c light - #the negative sign is a class convention. + + + v_observer = obs.head.spe.voff - (self.barycorr).to("km / s").value #KR + obs.head.spe.doppler = - (v_observer) / CLIGHT #KR + #KR commented the lines below + #v_observer = -((self.central_frequency - self.rest_frequency) / + # self.rest_frequency) * CLIGHT + #obs.head.spe.doppler = - (v_observer + obs.head.spe.voff) / CLIGHT #doppler in units of c light + # #the negative sign is a class convention. logger.debug("Doppler %f" % obs.head.spe.doppler) obs.head.spe.line = "SEC%d-%s" % (sec_id, pol) on, off, cal = onoffcal[sec_id][pol] From 9db6318aec5daa1ab9f8f79e4d89efd968b3da2d Mon Sep 17 00:00:00 2001 From: kazirygl Date: Mon, 4 May 2026 13:37:53 +0200 Subject: [PATCH 02/14] Update discosscan.py --- src/discosscan.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/discosscan.py b/src/discosscan.py index 5172783..31be82c 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -28,6 +28,7 @@ from astropy import units as u from astropy.time import Time from astropy.constants import c as C +from astropy.coordinates import ICRS, LSRK, SkyCoord, EarthLocation import pyclassfiller from pyclassfiller import code @@ -122,8 +123,7 @@ def convert_cycle(self, index): def _load_metadata(self, section, polarization, index): with fits.open(self.subscans[index][0]) as subscan: - self.location = (subscan[0].header["SiteLongitude"] * u.rad, - subscan[0].header["SiteLatitude"] * u.rad) + self.location = (subscan[0].header["SiteLongitude"] * u.rad,subscan[0].header["SiteLatitude"] * u.rad) self.longitude = self.location[0].to(u.deg) #KR self.latitude = self.location[1].to(u.deg) #KR self.location = (self.location[0].to(u.deg), @@ -319,11 +319,11 @@ def write_observation(self, scan_cycle, first_subscan_index): tsys = counts2kelvin * off_mean obs.head.gen.tsys = tsys logger.debug("tsys: %f" % (tsys,)) - obs.datay = ((on - off) / off ) * tsys + obs.datay = np.float32(((on - off) / off ) * tsys) #Elia else: logger.debug("skip calibration") obs.head.gen.tsys = 1. # ANTENNA TEMP TABLE is unknown - obs.datay = (on - off) / off + obs.datay = np.float32((on - off) / off) #Elia obs.write() self.file_class_out.close() From da9d76ed7d0760a441d0be413892564074dbd027 Mon Sep 17 00:00:00 2001 From: kazirygl Date: Mon, 4 May 2026 13:49:29 +0200 Subject: [PATCH 03/14] Update discosscan.py --- src/discosscan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/discosscan.py b/src/discosscan.py index 31be82c..00da0a1 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -125,7 +125,7 @@ def _load_metadata(self, section, polarization, index): with fits.open(self.subscans[index][0]) as subscan: self.location = (subscan[0].header["SiteLongitude"] * u.rad,subscan[0].header["SiteLatitude"] * u.rad) self.longitude = self.location[0].to(u.deg) #KR - self.latitude = self.location[1].to(u.deg) #KR + self.latitude = self.location[1].to(u.deg) #KR self.location = (self.location[0].to(u.deg), self.location[1].to(u.deg)) self.ra = subscan[0].header["RightAscension"] From d94cd3c62744e9ff891c385df07e06769acb8e89 Mon Sep 17 00:00:00 2001 From: kazirygl Date: Mon, 4 May 2026 13:51:21 +0200 Subject: [PATCH 04/14] Update discosscan.py --- src/discosscan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/discosscan.py b/src/discosscan.py index 00da0a1..c79d0c0 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -126,7 +126,7 @@ def _load_metadata(self, section, polarization, index): self.location = (subscan[0].header["SiteLongitude"] * u.rad,subscan[0].header["SiteLatitude"] * u.rad) self.longitude = self.location[0].to(u.deg) #KR self.latitude = self.location[1].to(u.deg) #KR - self.location = (self.location[0].to(u.deg), + self.location = (self.location[0].to(u.deg), self.location[1].to(u.deg)) self.ra = subscan[0].header["RightAscension"] self.dec = subscan[0].header["Declination"] From 7d227bcc99155050343f7d046f79d3127182f6f8 Mon Sep 17 00:00:00 2001 From: kazirygl Date: Mon, 4 May 2026 13:55:14 +0200 Subject: [PATCH 05/14] Update discosscan.py --- src/discosscan.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/discosscan.py b/src/discosscan.py index c79d0c0..ec24445 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -125,9 +125,8 @@ def _load_metadata(self, section, polarization, index): with fits.open(self.subscans[index][0]) as subscan: self.location = (subscan[0].header["SiteLongitude"] * u.rad,subscan[0].header["SiteLatitude"] * u.rad) self.longitude = self.location[0].to(u.deg) #KR - self.latitude = self.location[1].to(u.deg) #KR - self.location = (self.location[0].to(u.deg), - self.location[1].to(u.deg)) + self.latitude = self.location[1].to(u.deg) #KRself.location = (self.location[0].to(u.deg),self.location[1].to(u.deg)) + self.location = (self.location[0].to(u.deg),self.location[1].to(u.deg)) self.ra = subscan[0].header["RightAscension"] self.dec = subscan[0].header["Declination"] self.ra_ha = (subscan[0].header["RightAscension"]*u.rad).to(u.hourangle) #KR From 3325c3a1a4a46be25bb0cd7ba85010e1ae00521c Mon Sep 17 00:00:00 2001 From: kazirygl Date: Mon, 4 May 2026 13:59:05 +0200 Subject: [PATCH 06/14] Update discosscan.py --- src/discosscan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/discosscan.py b/src/discosscan.py index ec24445..e9a1a59 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -125,7 +125,7 @@ def _load_metadata(self, section, polarization, index): with fits.open(self.subscans[index][0]) as subscan: self.location = (subscan[0].header["SiteLongitude"] * u.rad,subscan[0].header["SiteLatitude"] * u.rad) self.longitude = self.location[0].to(u.deg) #KR - self.latitude = self.location[1].to(u.deg) #KRself.location = (self.location[0].to(u.deg),self.location[1].to(u.deg)) + self.latitude = self.location[1].to(u.deg) #KR self.location = (self.location[0].to(u.deg),self.location[1].to(u.deg)) self.ra = subscan[0].header["RightAscension"] self.dec = subscan[0].header["Declination"] @@ -298,7 +298,7 @@ def write_observation(self, scan_cycle, first_subscan_index): v_observer = obs.head.spe.voff - (self.barycorr).to("km / s").value #KR - obs.head.spe.doppler = - (v_observer) / CLIGHT #KR + obs.head.spe. doppler = - (v_observer) / CLIGHT #KR #KR commented the lines below #v_observer = -((self.central_frequency - self.rest_frequency) / # self.rest_frequency) * CLIGHT From 8dcc6ac45747c0d5fbd1fbbb9fb9d078cd9687e3 Mon Sep 17 00:00:00 2001 From: kazirygl Date: Mon, 4 May 2026 14:02:17 +0200 Subject: [PATCH 07/14] Update discosscan.py --- src/discosscan.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/discosscan.py b/src/discosscan.py index e9a1a59..b39ea76 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -298,8 +298,7 @@ def write_observation(self, scan_cycle, first_subscan_index): v_observer = obs.head.spe.voff - (self.barycorr).to("km / s").value #KR - obs.head.spe. doppler = - (v_observer) / CLIGHT #KR - #KR commented the lines below + obs.head.spe. doppler = - (v_observer) / CLIGHT #KR #KR commented the lines below #v_observer = -((self.central_frequency - self.rest_frequency) / # self.rest_frequency) * CLIGHT #obs.head.spe.doppler = - (v_observer + obs.head.spe.voff) / CLIGHT #doppler in units of c light From d7d1a9bc1ab6bed1a50b5c90617f70fbc965c0f7 Mon Sep 17 00:00:00 2001 From: kazirygl Date: Mon, 4 May 2026 14:05:20 +0200 Subject: [PATCH 08/14] Update discosscan.py --- src/discosscan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/discosscan.py b/src/discosscan.py index b39ea76..531a87c 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -298,7 +298,7 @@ def write_observation(self, scan_cycle, first_subscan_index): v_observer = obs.head.spe.voff - (self.barycorr).to("km / s").value #KR - obs.head.spe. doppler = - (v_observer) / CLIGHT #KR #KR commented the lines below + obs.head.spe.line = "SEC%d-%s" % (sec_id, pol) #KR commented the lines below #v_observer = -((self.central_frequency - self.rest_frequency) / # self.rest_frequency) * CLIGHT #obs.head.spe.doppler = - (v_observer + obs.head.spe.voff) / CLIGHT #doppler in units of c light From faca71b665f073fe627db98c9970f60306a6677f Mon Sep 17 00:00:00 2001 From: Kazi Rygl Date: Mon, 4 May 2026 14:13:53 +0200 Subject: [PATCH 09/14] my first commit --- src/discosscan.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/discosscan.py b/src/discosscan.py index 531a87c..f01cf54 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -279,7 +279,7 @@ def write_observation(self, scan_cycle, first_subscan_index): self.drc = ((self.central_frequency - 1* self.freq_resolution)/(self.rest_frequency)) #KR self.dr2c = ((self.central_frequency - 1* self.freq_resolution)/(self.rest_frequency))**2 #KR obs.head.spe.voff = CLIGHT * (1-self.drc) + self.barycorr.to("km / s").value #self.summary["velocity"]["vrad"] #KR - radio convention - #obs.head.spe.voff = self.summary["velocity"]["vrad"] KR COMMENTED + #obs.head.spe.voff = self.summary["velocity"]["vrad"] KR COMMENTED obs.head.spe.bad = 0. obs.head.spe.image = 0. if self.summary["velocity"]["vframe"] == "BARY": @@ -298,8 +298,8 @@ def write_observation(self, scan_cycle, first_subscan_index): v_observer = obs.head.spe.voff - (self.barycorr).to("km / s").value #KR - obs.head.spe.line = "SEC%d-%s" % (sec_id, pol) #KR commented the lines below - #v_observer = -((self.central_frequency - self.rest_frequency) / + obs.head.spe. doppler = - (v_observer) / CLIGHT #KR #KR commented the lines below + #v_observer = -((self.central_frequency - self.rest_frequency) / # self.rest_frequency) * CLIGHT #obs.head.spe.doppler = - (v_observer + obs.head.spe.voff) / CLIGHT #doppler in units of c light # #the negative sign is a class convention. From 626d52c218a2ba6ff8f25878dcc14fbc7eff14e7 Mon Sep 17 00:00:00 2001 From: Kazi Rygl Date: Mon, 4 May 2026 15:28:12 +0200 Subject: [PATCH 10/14] updated --- src/discosscan.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/discosscan.py b/src/discosscan.py index f01cf54..34c20d3 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -278,7 +278,8 @@ def write_observation(self, scan_cycle, first_subscan_index): obs.head.spe.vres = - (self.freq_resolution / self.central_frequency) * CLIGHT # frequency resolution must have the same unity like the central_frequency self.drc = ((self.central_frequency - 1* self.freq_resolution)/(self.rest_frequency)) #KR self.dr2c = ((self.central_frequency - 1* self.freq_resolution)/(self.rest_frequency))**2 #KR - obs.head.spe.voff = CLIGHT * (1-self.drc) + self.barycorr.to("km / s").value #self.summary["velocity"]["vrad"] #KR - radio convention + obs.head.spe.voff = CLIGHT * (1-self.drc) + self.barycorr.to("km / s").value + #self.summary["velocity"]["vrad"] #KR - radio convention #obs.head.spe.voff = self.summary["velocity"]["vrad"] KR COMMENTED obs.head.spe.bad = 0. obs.head.spe.image = 0. @@ -298,7 +299,8 @@ def write_observation(self, scan_cycle, first_subscan_index): v_observer = obs.head.spe.voff - (self.barycorr).to("km / s").value #KR - obs.head.spe. doppler = - (v_observer) / CLIGHT #KR #KR commented the lines below + obs.head.spe. doppler = - (v_observer) / CLIGHT #KR + #KR commented the lines below #v_observer = -((self.central_frequency - self.rest_frequency) / # self.rest_frequency) * CLIGHT #obs.head.spe.doppler = - (v_observer + obs.head.spe.voff) / CLIGHT #doppler in units of c light From 1a1a1f16de3e0b8a2a65baf14b817f4a1c722b34 Mon Sep 17 00:00:00 2001 From: Kazi Rygl Date: Mon, 4 May 2026 15:32:03 +0200 Subject: [PATCH 11/14] updated --- src/discosscan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/discosscan.py b/src/discosscan.py index 34c20d3..4d09e86 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -297,14 +297,14 @@ def write_observation(self, scan_cycle, first_subscan_index): obs.head.spe.vtype = code.velo.unk logger.debug("velocity: UNK") - + v_observer = obs.head.spe.voff - (self.barycorr).to("km / s").value #KR obs.head.spe. doppler = - (v_observer) / CLIGHT #KR #KR commented the lines below #v_observer = -((self.central_frequency - self.rest_frequency) / # self.rest_frequency) * CLIGHT #obs.head.spe.doppler = - (v_observer + obs.head.spe.voff) / CLIGHT #doppler in units of c light - # #the negative sign is a class convention. + # #the negative sign is a class convention. logger.debug("Doppler %f" % obs.head.spe.doppler) obs.head.spe.line = "SEC%d-%s" % (sec_id, pol) on, off, cal = onoffcal[sec_id][pol] From 62919c80fe1326d2c6e236ae4097c9fefb82d5d9 Mon Sep 17 00:00:00 2001 From: Kazi Rygl Date: Mon, 4 May 2026 15:36:36 +0200 Subject: [PATCH 12/14] updated --- src/discosscan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/discosscan.py b/src/discosscan.py index 4d09e86..b2611c3 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -299,9 +299,9 @@ def write_observation(self, scan_cycle, first_subscan_index): v_observer = obs.head.spe.voff - (self.barycorr).to("km / s").value #KR - obs.head.spe. doppler = - (v_observer) / CLIGHT #KR + obs.head.spe. doppler = - (v_observer) / CLIGHT #KR #KR commented the lines below - #v_observer = -((self.central_frequency - self.rest_frequency) / + #v_observer = -((self.central_frequency - self.rest_frequency) / # self.rest_frequency) * CLIGHT #obs.head.spe.doppler = - (v_observer + obs.head.spe.voff) / CLIGHT #doppler in units of c light # #the negative sign is a class convention. From 9ed26c3c97f47706101f4e1036cc10f62d25e487 Mon Sep 17 00:00:00 2001 From: Kazi Rygl Date: Mon, 4 May 2026 15:38:32 +0200 Subject: [PATCH 13/14] updated --- src/discosscan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/discosscan.py b/src/discosscan.py index b2611c3..ae295ae 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -319,7 +319,7 @@ def write_observation(self, scan_cycle, first_subscan_index): tsys = counts2kelvin * off_mean obs.head.gen.tsys = tsys logger.debug("tsys: %f" % (tsys,)) - obs.datay = np.float32(((on - off) / off ) * tsys) #Elia + obs.datay = np.float32(((on - off) / off ) * tsys) #Elia else: logger.debug("skip calibration") obs.head.gen.tsys = 1. # ANTENNA TEMP TABLE is unknown From 600a960254c678d8ea6a191b615d9c09e85eeb82 Mon Sep 17 00:00:00 2001 From: Kazi Rygl Date: Mon, 4 May 2026 15:42:18 +0200 Subject: [PATCH 14/14] updated --- src/discosscan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/discosscan.py b/src/discosscan.py index ae295ae..a8bfbdc 100644 --- a/src/discosscan.py +++ b/src/discosscan.py @@ -319,7 +319,7 @@ def write_observation(self, scan_cycle, first_subscan_index): tsys = counts2kelvin * off_mean obs.head.gen.tsys = tsys logger.debug("tsys: %f" % (tsys,)) - obs.datay = np.float32(((on - off) / off ) * tsys) #Elia + obs.datay = np.float32(((on - off) / off ) * tsys) #Elia IRA else: logger.debug("skip calibration") obs.head.gen.tsys = 1. # ANTENNA TEMP TABLE is unknown