From acaf6eb81d47027e6613c5a31aa86f393cdf78b7 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Wed, 24 Feb 2016 12:52:09 +0100 Subject: [PATCH 01/20] removed targetsFile from schedule structure --- setup.py | 2 +- src/__init__.py | 8 ++++---- src/schedule.py | 28 ---------------------------- test/test_installation.py | 2 +- test/test_schedule.py | 2 +- 5 files changed, 7 insertions(+), 35 deletions(-) diff --git a/setup.py b/setup.py index e70fe90..dfb431f 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name = "basie", - version = "0.6.2", + version = "0.7.0", description = "schedule creator for italian radiotelescopes", author = "Marco Bartolini, Simona Righini", author_email = "bartolini@ira.inaf.it", diff --git a/src/__init__.py b/src/__init__.py index dc59ff2..e96272f 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -178,7 +178,7 @@ You will find the doc under doc/html/ -@version: 0.6.2 +@version: 0.7.0 @status: stable @authors: Marco Bartolini, Simona Righini @organization: INAF -IRA @@ -187,7 +187,7 @@ @contact: bartolini@ira.inaf.it """ -VERSION = "0.6.2" +VERSION = "0.7.0" NURAGHE_TAG = "nuraghe-0.6" ESCS_TAG = "escs-0.6" @@ -255,8 +255,8 @@ def cmd_line(): dst_directory = os.path.abspath(ns.directory) conf = rich_validator.validate_configuration(configuration_file) #setting target file in the same directory as schedule file - conf['targetsFile'] = os.path.join(src_directory, conf['targetsFile']) - parsed_targets = target_parser.parse_file(conf['targetsFile']) + targetsFile = os.path.join(src_directory, conf.pop('targetsFile')) + parsed_targets = target_parser.parse_file(targetsFile) logger.debug("parsed targets: %s" % (parsed_targets,)) _schedule = schedule.Schedule(**conf) for _target, _scanmode, _backend, _ in parsed_targets: diff --git a/src/schedule.py b/src/schedule.py index e94e74d..641f1e9 100644 --- a/src/schedule.py +++ b/src/schedule.py @@ -52,7 +52,6 @@ def __init__(self, radiotelescope = "SRT", #should we change this? receiver = "C", #should we change this? outputFormat = "fits", - targetsFile = "targets.txt", ): logger.debug("creating schedule") self.projectID = projectID @@ -71,7 +70,6 @@ def __init__(self, self._configure_totalpower_sections() logger.info("Scheduling %s radiotelescope using receiver %s" % (self.radiotelescope.name, self.receiver.name)) - self.targetsFile = targetsFile self.outputFormat = outputFormat if isinstance(restFrequency, (list, tuple)): self.restFrequency = map(lambda(x):float(x) * u.MHz, restFrequency) @@ -125,32 +123,6 @@ def add_scan(self, _target, _scantype, _backend): else: raise ScheduleError("cannot find scantype %s" % (_scantype,)) - #explode 'BOTH' scans into 2 separate scans - #for _scan_name, _scan_definition in self.scan_definitions.iteritems(): - # logger.debug("examinating %s || %s" % (_scan_name, - # type(_scan_definition))) - # if isinstance(_scan_definition, tuple): #only BOTH scans return a tuple - # logger.info("exploding scan %s in 2 separate scans" % (_scan_name,)) - # self.scan_definitions.pop(_scan_name) - # if ((_scan_name + "_lon" in self.scan_definitions) or - # (_scan_name + "_lat" in self.scan_definitions)): - # raise ScheduleError("Cannot explode scan %s in separate subscans" % (_scan_name,)) - # self.scan_definitions[_scan_name + "_lon"] = _scan_definition[0] - # self.scan_definitions[_scan_name + "_lat"] = _scan_definition[1] - # #explode 'both' targets into 2 separate targets - # while _scan_name in [_target_scan_name - # for (_, _target_scan_name, _) - # in self.targets]: - # index = [_tsn for (_, _tsn, _) in self.targets].index(_scan_name) - # _target, _scan_name, _line = self.targets[index] - # logger.info("exploding target %s in two separate targets" % (_target.label,)) - # self.targets[index] = (_target, - # _scan_name + "_lat", - # _line) - # self.targets.insert(index, (_target, - # _scan_name + "_lon", - # _line)) - def set_base_dir(self, base_path): """ diff --git a/test/test_installation.py b/test/test_installation.py index 4419152..030a70e 100644 --- a/test/test_installation.py +++ b/test/test_installation.py @@ -5,7 +5,7 @@ class TestInstallation(unittest.TestCase): def test_version(self): - self.assertEqual(basie.VERSION, "0.6.2") + self.assertEqual(basie.VERSION, "0.7.0") def test_astropy_version(self): import astropy diff --git a/test/test_schedule.py b/test/test_schedule.py index cbfd7df..7789726 100644 --- a/test/test_schedule.py +++ b/test/test_schedule.py @@ -11,7 +11,7 @@ class TestSchedule(unittest.TestCase): def test_schedule_generation(self): conf = validate_configuration("src/user_templates/configuration.txt") - conf['targetsFile'] = "src/user_templates/targets.txt" + conf.pop("targetsFile") sched = schedule.Schedule(**conf) self.assertEqual(sched.projectID, conf['projectID']) sched.set_base_dir(BASE_PATH) From e9b4db7d9a0d521345c7546940ab1bcdf75e41f6 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Fri, 26 Feb 2016 11:57:49 +0100 Subject: [PATCH 02/20] clean Schedule constructor and tests --- src/__init__.py | 17 ++++++++++++++++- src/schedule.py | 23 +++++++++++++---------- test/test_schedule.py | 7 +++++++ 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/__init__.py b/src/__init__.py index e96272f..12b4246 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -234,6 +234,7 @@ def cmd_line(): #imports are here as logging has already been configured import schedule, rich_validator, utils, target_parser, receiver + from radiotelescope import radiotelescopes try: if ns.get_templates: @@ -258,7 +259,21 @@ def cmd_line(): targetsFile = os.path.join(src_directory, conf.pop('targetsFile')) parsed_targets = target_parser.parse_file(targetsFile) logger.debug("parsed targets: %s" % (parsed_targets,)) - _schedule = schedule.Schedule(**conf) + #prepare Schedule contructor arguments + schedule_params = conf + radiotelescope = radiotelescopes[conf.radiotelescope] + try: + receiver = radiotelescope.receivers["conf.receiver"] + except: + raise ScheduleError("radiotelescope does not have specified receiver") + schedule_params.radiotelescope = radiotelescope + schedule_params.receiver = receiver + backends = schedule_params.pop("backends") + scantypes = schedule_params.pop("scantypes") + logger.debug(schedule_params) + _schedule = schedule.Schedule(**schedule_params) + _schedule.backends = backends + _schedule.scantypes = scantypes for _target, _scanmode, _backend, _ in parsed_targets: _schedule.add_scan(_target, _scanmode, _backend) _schedule.set_base_dir(dst_directory) diff --git a/src/schedule.py b/src/schedule.py index 641f1e9..4e0c3b2 100644 --- a/src/schedule.py +++ b/src/schedule.py @@ -33,6 +33,8 @@ from .errors import * import layout from . import VERSION, NURAGHE_TAG, ESCS_TAG +import datetime + import scan import backend from .radiotelescopes import radiotelescopes @@ -47,10 +49,8 @@ def __init__(self, tsys = 1, scheduleRuns = 1, restFrequency = [0.0], - scantypes = {}, - backends = {}, - radiotelescope = "SRT", #should we change this? - receiver = "C", #should we change this? + radiotelescope = radiotelescopes["SRT"], #should we change this? + receiver = radiotelescopes["SRT"].receivers["C"], #should we change this? outputFormat = "fits", ): logger.debug("creating schedule") @@ -60,11 +60,12 @@ def __init__(self, self.repetitions = repetitions self.tsys = tsys self.runs = scheduleRuns - self.scantypes = scantypes - self.backends = backends - self.radiotelescope = radiotelescopes[radiotelescope.upper()] - logger.debug("GOT RADIOTELESCOPE: %s" % (self.radiotelescope,)) - self.receiver = self.radiotelescope.receivers[receiver.upper()] + self.scantypes = {} + self.backends = {} + self.radiotelescope = radiotelescope + if not receiver in radiotelescope.receivers.values(): + raise ScheduleError("receiver does not belong to telescope") + self.receiver = receiver self.base_dir = os.path.abspath('.') #default self.scans = [] self._configure_totalpower_sections() @@ -75,6 +76,8 @@ def __init__(self, self.restFrequency = map(lambda(x):float(x) * u.MHz, restFrequency) else: self.restFrequency = [float(restFrequency) * u.MHz] + self.creation_date = datetime.datetime.now() + self.last_modified = self.creation_date def _configure_totalpower_sections(self): for name, bck in self.backends.iteritems(): @@ -122,7 +125,7 @@ def add_scan(self, _target, _scantype, _backend): ) else: raise ScheduleError("cannot find scantype %s" % (_scantype,)) - + self.last_modified = datetime.datetime.now() def set_base_dir(self, base_path): """ diff --git a/test/test_schedule.py b/test/test_schedule.py index 8706ad0..be72038 100644 --- a/test/test_schedule.py +++ b/test/test_schedule.py @@ -2,6 +2,7 @@ import os import shutil from basie import schedule +from basie.radiotelescopes import radiotelescopes from basie.rich_validator import validate_configuration BASE_PATH = "/tmp/basie_test" @@ -12,7 +13,13 @@ class TestSchedule(unittest.TestCase): def test_schedule_generation(self): conf = validate_configuration("src/user_templates/configuration.txt") conf.pop("targetsFile") + backends = conf.pop("backends") + scantypes = conf.pop("scantypes") + conf["radiotelescope"] = radiotelescopes[conf["radiotelescope"]] + conf["receiver"] = conf["radiotelescope"].receivers[conf["receiver"]] sched = schedule.Schedule(**conf) + sched.backends = backends + sched.scantypes = scantypes self.assertEqual(sched.projectID, conf['projectID']) sched.set_base_dir(BASE_PATH) sched._write_schedule_files() From 91c3569d5b80d533dc76ed2e9be5b7fe92da8181 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Fri, 26 Feb 2016 12:16:04 +0100 Subject: [PATCH 03/20] schedule constructor uses key names --- src/schedule.py | 10 +++++----- test/test_schedule.py | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/schedule.py b/src/schedule.py index 4e0c3b2..858502f 100644 --- a/src/schedule.py +++ b/src/schedule.py @@ -49,8 +49,8 @@ def __init__(self, tsys = 1, scheduleRuns = 1, restFrequency = [0.0], - radiotelescope = radiotelescopes["SRT"], #should we change this? - receiver = radiotelescopes["SRT"].receivers["C"], #should we change this? + radiotelescope = "SRT", #should we change this? + receiver = "C", #should we change this? outputFormat = "fits", ): logger.debug("creating schedule") @@ -62,10 +62,10 @@ def __init__(self, self.runs = scheduleRuns self.scantypes = {} self.backends = {} - self.radiotelescope = radiotelescope - if not receiver in radiotelescope.receivers.values(): + self.radiotelescope = radiotelescopes[radiotelescope] + if not receiver in self.radiotelescope.receivers.keys(): raise ScheduleError("receiver does not belong to telescope") - self.receiver = receiver + self.receiver = self.radiotelescope.receivers[receiver] self.base_dir = os.path.abspath('.') #default self.scans = [] self._configure_totalpower_sections() diff --git a/test/test_schedule.py b/test/test_schedule.py index be72038..d92adb6 100644 --- a/test/test_schedule.py +++ b/test/test_schedule.py @@ -15,8 +15,6 @@ def test_schedule_generation(self): conf.pop("targetsFile") backends = conf.pop("backends") scantypes = conf.pop("scantypes") - conf["radiotelescope"] = radiotelescopes[conf["radiotelescope"]] - conf["receiver"] = conf["radiotelescope"].receivers[conf["receiver"]] sched = schedule.Schedule(**conf) sched.backends = backends sched.scantypes = scantypes From 31f06980a8303b09ac4b9f0f3df769700e0d0095 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Mon, 29 Feb 2016 11:27:31 +0100 Subject: [PATCH 04/20] closes #7 Angles to the fourth decimal point --- RELEASENOTES.md | 5 +++++ src/__init__.py | 6 +++--- src/valid_angles.py | 2 +- test/test_target.py | 2 +- test/test_valid_angles.py | 6 +++--- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 35ea9e8..1022b3e 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,5 +1,10 @@ # RELEASE NOTES +## v0.7.0 + + - [x] Angles now rounded to the 4th decimal point. + - [x] *nop* instruction removed from roach backend configuration. + ## v0.6.2 Release notes: diff --git a/src/__init__.py b/src/__init__.py index 12b4246..ee95fff 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -234,7 +234,7 @@ def cmd_line(): #imports are here as logging has already been configured import schedule, rich_validator, utils, target_parser, receiver - from radiotelescope import radiotelescopes + from radiotelescopes import radiotelescopes try: if ns.get_templates: @@ -261,9 +261,9 @@ def cmd_line(): logger.debug("parsed targets: %s" % (parsed_targets,)) #prepare Schedule contructor arguments schedule_params = conf - radiotelescope = radiotelescopes[conf.radiotelescope] + radiotelescope = radiotelescopes[conf["radiotelescope"]] try: - receiver = radiotelescope.receivers["conf.receiver"] + receiver = radiotelescope.receivers[conf["receiver"]] except: raise ScheduleError("radiotelescope does not have specified receiver") schedule_params.radiotelescope = radiotelescope diff --git a/src/valid_angles.py b/src/valid_angles.py index a88f212..d7c8f32 100644 --- a/src/valid_angles.py +++ b/src/valid_angles.py @@ -32,7 +32,7 @@ from astropy.coordinates import Angle -ANGLE_DECIMALS = 3 +ANGLE_DECIMALS = 4 """ CONSTANT. Decimal angles digits used in string fomratting """ diff --git a/test/test_target.py b/test/test_target.py index 515ba9b..73285b0 100644 --- a/test/test_target.py +++ b/test/test_target.py @@ -25,7 +25,7 @@ def test_parse_file(self): t_zero, scan_zero, _, _ = targets[0] self.assertEqual(t_zero.label, "Alpha") self.assertEqual(scan_zero, "EqCross1_3") - self.assertEqual(t_zero.coord.lon.fmt(), "12:00:00.000h") + self.assertEqual(t_zero.coord.lon.fmt(), "12:00:00.0000h") t_gamma, _, _, _= targets[5] self.assertEqual(t_gamma.tsys, 2) self.assertEqual(t_gamma.repetitions, 4) diff --git a/test/test_valid_angles.py b/test/test_valid_angles.py index e27701c..3bbc0f4 100644 --- a/test/test_valid_angles.py +++ b/test/test_valid_angles.py @@ -37,16 +37,16 @@ def test_parsing(self): def test_fmt_dec(self): ang = VAngle(15.0) - self.assertEqual(ang.fmt_dec(), u"15.000d") + self.assertEqual(ang.fmt_dec(), u"15.0000d") def test_fmt_dms(self): ang = VAngle(15.0) - self.assertEqual(ang.fmt_dms(), u"15:00:00.000") + self.assertEqual(ang.fmt_dms(), u"15:00:00.0000") def test_fmt_hms(self): ang = VAngle(15.0) _str = ang.fmt_hms() - self.assertEqual(_str, u"01:00:00.000h") + self.assertEqual(_str, u"01:00:00.0000h") #self.assertEqual(_str[-1], u"h") def test_sum(self): From 54cdf9527a7416f7ec8168b96a1e5e71d1524edb Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Tue, 1 Mar 2016 10:41:08 +0100 Subject: [PATCH 05/20] added schedule files tests --- test/test_schedule.py | 63 ++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/test/test_schedule.py b/test/test_schedule.py index d92adb6..457d497 100644 --- a/test/test_schedule.py +++ b/test/test_schedule.py @@ -4,22 +4,55 @@ from basie import schedule from basie.radiotelescopes import radiotelescopes from basie.rich_validator import validate_configuration +from basie import target_parser -BASE_PATH = "/tmp/basie_test" -shutil.rmtree(BASE_PATH, True) #ignores errors -os.mkdir(BASE_PATH) +BASE_PATH = "~/.basie_test" class TestSchedule(unittest.TestCase): - def test_schedule_generation(self): - conf = validate_configuration("src/user_templates/configuration.txt") - conf.pop("targetsFile") - backends = conf.pop("backends") - scantypes = conf.pop("scantypes") - sched = schedule.Schedule(**conf) - sched.backends = backends - sched.scantypes = scantypes - self.assertEqual(sched.projectID, conf['projectID']) - sched.set_base_dir(BASE_PATH) - sched._write_schedule_files() - self.assertTrue(os.path.exists(sched._get_filename("scd"))) + def setUp(self): + shutil.rmtree(BASE_PATH, True) #ignores errors + os.makedirs(BASE_PATH) + self.conf = validate_configuration("src/user_templates/configuration.txt") + targetsFile = os.path.join("src/user_templates", self.conf.pop('targetsFile')) + parsed_targets = target_parser.parse_file(targetsFile) + backends = self.conf.pop("backends") + scantypes = self.conf.pop("scantypes") + self.sched = schedule.Schedule(**self.conf) + self.sched.backends = backends + self.sched.scantypes = scantypes + for _target, _scanmode, _backend, _ in parsed_targets: + self.sched.add_scan(_target, _scanmode, _backend) + self.sched.set_base_dir(BASE_PATH) + + def tearDown(self): + shutil.rmtree(BASE_PATH, True) #ignores errors + + def test_schedule_parameters(self): + self.assertEqual(self.sched.projectID, self.conf['projectID']) + + def test_write_schedule_files(self): + self.sched._write_schedule_files() + self.assertTrue(os.path.exists(self.sched._get_filename("scd"))) + self.assertTrue(os.path.exists(self.sched._get_filename("lis"))) + self.assertTrue(os.path.exists(self.sched._get_filename("bck"))) + self.assertTrue(os.path.exists(self.sched._get_filename("cfg"))) + + def test_schedule_files_do_not_contain_whitespaces(self): + self.sched._write_schedule_files() + with open(self.sched._get_filename("scd"), "rt") as scd: + for line in scd.readlines(): + if not line.startswith("#"): + self.assertNotIn(" ", line) + with open(self.sched._get_filename("lis"), "rt") as lis: + for line in lis.readlines(): + if not line.startswith("#"): + self.assertNotIn(" ", line) + with open(self.sched._get_filename("bck"), "rt") as bck: + for line in bck.readlines(): + if not line.startswith("#"): + self.assertNotIn(" ", line) + with open(self.sched._get_filename("cfg"), "rt") as cfg: + for line in cfg.readlines(): + if not line.startswith("#"): + self.assertNotIn(" ", line) From d210f67abcec978581731745b9ac93132a27fd9e Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Tue, 1 Mar 2016 13:51:02 +0100 Subject: [PATCH 06/20] versioned beta --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index dfb431f..c47c0d6 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name = "basie", - version = "0.7.0", + version = "0.7.0-beta", description = "schedule creator for italian radiotelescopes", author = "Marco Bartolini, Simona Righini", author_email = "bartolini@ira.inaf.it", From b2c4902a06676fd31adb6bfdbf9ce69d5560d867 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Tue, 1 Mar 2016 16:46:19 +0100 Subject: [PATCH 07/20] closes #8, added ftrack parameter --- src/schedule.py | 6 ++++-- src/schemas/schedule.ini | 1 + src/user_templates/configuration.txt | 1 + test/test_schedule.py | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/schedule.py b/src/schedule.py index 858502f..7812add 100644 --- a/src/schedule.py +++ b/src/schedule.py @@ -52,6 +52,7 @@ def __init__(self, radiotelescope = "SRT", #should we change this? receiver = "C", #should we change this? outputFormat = "fits", + ftrack = False, ): logger.debug("creating schedule") self.projectID = projectID @@ -76,6 +77,7 @@ def __init__(self, self.restFrequency = map(lambda(x):float(x) * u.MHz, restFrequency) else: self.restFrequency = [float(restFrequency) * u.MHz] + self.ftrack = ftrack self.creation_date = datetime.datetime.now() self.last_modified = self.creation_date @@ -166,7 +168,7 @@ def _write_schedule_files(self): for f in self.restFrequency: if not f == 0: restFrequency = True - if restFrequency: + if restFrequency and self.ftrack: freqstring = ";".join(map(lambda(x):str(x.value), self.restFrequency)) rst_procedure = procedures.Procedure("restFrequency", 0, @@ -215,7 +217,7 @@ def _write_schedule_files(self): _subscan.SEQ_ID = subscan_number #PRE SCAN procedures if subscan_number == 1: - if not _scan.target.velocity.is_zero(): + if self.ftrack: if isinstance(_scan.backend, backend.XBackend): #TODO: we need to test FTRACKALL before using it #_subscan.pre_procedure += procedures.FTRACKALL diff --git a/src/schemas/schedule.ini b/src/schemas/schedule.ini index 12b55ed..13bcebd 100644 --- a/src/schemas/schedule.ini +++ b/src/schemas/schedule.ini @@ -8,6 +8,7 @@ repetitions = integer(min=1, default=1) tsys = integer(min=-1, default=0) #outputFormat = option('fits', 'mbfits', 'FITS', 'MBFITS', 'MBFits') restFrequency = list +ftrack = boolean(default=False) targetsFile = filename diff --git a/src/user_templates/configuration.txt b/src/user_templates/configuration.txt index db977a6..3ab02dc 100644 --- a/src/user_templates/configuration.txt +++ b/src/user_templates/configuration.txt @@ -15,6 +15,7 @@ tsys = 0 #optional restFrequency in Mhz, can be a list #restFrequency = 22345.18,22410.10 #restFrequency = 22000 +#ftrack = True # File name of the target specs in this same directory targetsFile = targets.txt diff --git a/test/test_schedule.py b/test/test_schedule.py index 457d497..5b5a427 100644 --- a/test/test_schedule.py +++ b/test/test_schedule.py @@ -6,7 +6,7 @@ from basie.rich_validator import validate_configuration from basie import target_parser -BASE_PATH = "~/.basie_test" +BASE_PATH = ".basie_test" class TestSchedule(unittest.TestCase): def setUp(self): From 53535465327f6fd108f9317c126d99c58542dfbe Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Tue, 1 Mar 2016 16:48:07 +0100 Subject: [PATCH 08/20] versioned 0.6.3 --- src/__init__.py | 4 ++-- test/test_installation.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/__init__.py b/src/__init__.py index ee95fff..237876d 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -178,7 +178,7 @@ You will find the doc under doc/html/ -@version: 0.7.0 +@version: 0.6.3 @status: stable @authors: Marco Bartolini, Simona Righini @organization: INAF -IRA @@ -187,7 +187,7 @@ @contact: bartolini@ira.inaf.it """ -VERSION = "0.7.0" +VERSION = "0.6.3" NURAGHE_TAG = "nuraghe-0.6" ESCS_TAG = "escs-0.6" diff --git a/test/test_installation.py b/test/test_installation.py index b59d332..24154ec 100644 --- a/test/test_installation.py +++ b/test/test_installation.py @@ -5,7 +5,7 @@ class TestInstallation(unittest.TestCase): def test_version(self): - self.assertEqual(basie.VERSION, "0.7.0") + self.assertEqual(basie.VERSION, "0.6.3") def test_astropy_version(self): import astropy From 47f3f5c587d3b8713bb3ec396051983ff32ff8ec Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Tue, 1 Mar 2016 17:25:10 +0100 Subject: [PATCH 09/20] added offset interleave into Raster Map scans --- src/rich_validator.py | 3 ++- src/scanmode/maps.py | 13 +++++++++++-- src/scanmode/subscan.py | 16 ++++++++++++++++ src/user_templates/configuration.txt | 10 +++++----- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/rich_validator.py b/src/rich_validator.py index edda183..25a17ec 100644 --- a/src/rich_validator.py +++ b/src/rich_validator.py @@ -158,8 +158,9 @@ def check_raster_map(value): except: logger.debug("RASTER map specify scans per beam") spacing = v.is_float(value[6], min=1) + offset = v.is_integer(value[7], min=0) return RasterMapScan(_frame, start_point, scan_axis, length_x, length_y, - spacing, duration) + spacing, duration, offset) def check_nodding_sequence(value): if not isinstance(value, list): diff --git a/src/scanmode/maps.py b/src/scanmode/maps.py index 43eef4f..c7e25c7 100644 --- a/src/scanmode/maps.py +++ b/src/scanmode/maps.py @@ -175,10 +175,11 @@ def _do_scan(self, _target, _receiver, _frequency): class RasterMapScan(MapScan): def __init__(self, frame, start_point, scan_axis, - length_x, length_y, spacing, duration): + length_x, length_y, spacing, duration, offset=0): MapScan.__init__(self, frame, start_point, scan_axis, length_x, length_y, spacing) self.duration = duration + self.offset_interleave = offset def _get_offsets(self): """ @@ -231,7 +232,7 @@ def _do_scan(self, _target, _receiver, _frequency): )) self._offsets = self._get_offsets() _subscans = [] - for offset_lon, offset_lat in self._offsets: + for i, (offset_lon, offset_lat) in enumerate(self._offsets): logger.debug("OFFSETS: %f %f" % (offset_lon.deg, offset_lat.deg)) _offset = Coord(self.frame, offset_lon, offset_lat) _subscans.append(subscan.get_sid_tsys(_target, @@ -239,5 +240,13 @@ def _do_scan(self, _target, _receiver, _frequency): self.extremes, self.duration, self.beamsize)) + if not self.offset_interleave == 0: + if i % self.offset_interleave == 0: + _subscans.append(subscan.get_off_tsys(_target, + _offset, + self.extremes, + self.duration, + self.beamsize)) return _subscans + diff --git a/src/scanmode/subscan.py b/src/scanmode/subscan.py index 0368cdf..c3aecf1 100644 --- a/src/scanmode/subscan.py +++ b/src/scanmode/subscan.py @@ -332,3 +332,19 @@ def get_sid_tsys(_target, st = get_tsys(_target, _offsets) return ss, st +def get_off_tsys(_target, + offset, + extremes, + duration, + beamsize): + extremes_offsets = utils.extrude_from_rectangle(offset.lon.deg, + offset.lat.deg, + extremes, + beamsize.deg * TSYS_SIGMA) + _offsets = Coord(offset.frame, + VAngle(extremes_offsets[0]), + VAngle(extremes_offsets[1])) + ss = get_sidereal(_target, _offsets, duration) + st = get_tsys(_target, _offsets) + return ss, st + diff --git a/src/user_templates/configuration.txt b/src/user_templates/configuration.txt index 3ab02dc..611f665 100644 --- a/src/user_templates/configuration.txt +++ b/src/user_templates/configuration.txt @@ -78,12 +78,12 @@ targetsFile = targets.txt #OTFMAPNAME = OTFMAP FRAME AXIS START LENGTH_X LENGTH_Y SPEED SCANS_PER_BEAM EQMap1x1S = OTFMAP EQ BOTH TL 0.4d 0.4d 5.0 3 - #RASTERMAPNAME = RASTERMAP FRAME AXIS START LENGTH_X LENGTH_Y DURATION SEPARATION - HorRasterTL = RASTERMAP HOR LON TL 0.4d 0.4d 10.0 0.05d - HorRasterTR = RASTERMAP HOR LAT TR 0.4d 0.4d 5.0 0.05d + #RASTERMAPNAME = RASTERMAP FRAME AXIS START LENGTH_X LENGTH_Y DURATION SEPARATION OFFSET_INTERLEAVE + HorRasterTL = RASTERMAP HOR LON TL 0.4d 0.4d 10.0 0.05d 0 + HorRasterTROff = RASTERMAP HOR LAT TR 0.4d 0.4d 5.0 0.05d 1 - #RASTERMAPNAME = RASTERMAP FRAME AXIS START LENGTH_X LENGTH_Y DURATION SCANS_PER_BEAM - HorRasterTRS = RASTERMAP HOR LAT TR 0.4d 0.4d 5.0 3 + #RASTERMAPNAME = RASTERMAP FRAME AXIS START LENGTH_X LENGTH_Y DURATION SCANS_PER_BEAM OFFSET_INTERLEAVE + HorRasterTRS = RASTERMAP HOR LAT TR 0.4d 0.4d 5.0 3 0 #ONOFFNAME = ONOFF DURATION OFF_FRAME LON_OFF LAT_OFF [on,off,on_cal,off_cal .. ] OnOff = ONOFF 4.0 EQ 1.0d 1.0d [4on,4off,2off_cal] From ae157265c9ab7e7d23c718d0a5057fecc1067821 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Tue, 1 Mar 2016 17:41:00 +0100 Subject: [PATCH 10/20] closes #9 --- RELEASENOTES.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 1022b3e..703dc05 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,9 +1,28 @@ # RELEASE NOTES -## v0.7.0 +## v0.6.3 +Release notes: - [x] Angles now rounded to the 4th decimal point. - - [x] *nop* instruction removed from roach backend configuration. + - [x] **nop** instruction removed from roach backend configuration. + - [x] added explicit **ftrack** parameter in configuration file. + - [x] added **offset interleave** parameter in raster map scans. + +**Note on ftrack**: in order to use ftrack procedures the user now must specify +```python +restFrequency = something_different_from_zero +ftrack = True +``` +in the configuration file. Note that this will activate ftrack procedures even +when the target velocity is null. On the contrary, setting a *restFrequency* +value and a target *velocity* will not automatically trigger the *ftrack* +procedure if not explicitly specified by the *ftrack* parameter in the +configuration file. + +**Note on raster maps**: Raster maps now include a new parameter called +**offset_interleave**. If **offset_interleave** is differrent from zero this +will tell basie to add one subscan outside the map after **offset_interleave** +subscans inside the map. ## v0.6.2 From 9fa58e5fe7272d5107b7777372245a37d4ed97b4 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Tue, 1 Mar 2016 17:53:48 +0100 Subject: [PATCH 11/20] better docs --- README.md | 11 ----------- RELEASENOTES.md | 4 +++- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 70af9c3..aa3d840 100644 --- a/README.md +++ b/README.md @@ -176,14 +176,3 @@ schedule. and modified from user template in step 1. if run with -f overrides eventual existing files. - -## BUILD DOCUMENTATION - -You can generate a local copy of the developer documentation using epydoc via - -``` -$make doc -``` - -You will find the doc under doc/html/ - diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 703dc05..1ec05c0 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -22,7 +22,9 @@ configuration file. **Note on raster maps**: Raster maps now include a new parameter called **offset_interleave**. If **offset_interleave** is differrent from zero this will tell basie to add one subscan outside the map after **offset_interleave** -subscans inside the map. +subscans inside the map. By default the offset position is taken 5 beamsizes +outside the map perimeter for single feed receivers, while it is take 5 receiver +extents for multifeed receivers. ## v0.6.2 From fc9ff9bdaf32c25f21d8c9f11f516b2d67b89598 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Thu, 3 Mar 2016 14:14:07 +0100 Subject: [PATCH 12/20] Address #10, better raster maps with multifeed --- src/scanmode/maps.py | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/scanmode/maps.py b/src/scanmode/maps.py index c7e25c7..8e90983 100644 --- a/src/scanmode/maps.py +++ b/src/scanmode/maps.py @@ -181,6 +181,62 @@ def __init__(self, frame, start_point, scan_axis, self.duration = duration self.offset_interleave = offset + def _get_spacing(self, receiver, frequency): + if receiver.is_multifeed() and receiver.has_derotator: + #we can exploit multifeed derotator optimization + logger.info("applying multifeed derotator optimization for map generation") + if not isinstance(self.spacing, VAngle): + approx_spacing = self.beamsize / self.spacing + scans_per_interleave = ceil(receiver.interleave / approx_spacing) + if not scans_per_interleave == self.spacing: + #logger.warning("Rounding to {0} scans per interleave".format(scans_per_interleave)) + pass + self.spacing = receiver.interleave / scans_per_interleave + logger.info("Spacing subscans by {0}".format(self.spacing)) + else: + if (self.spacing > (receiver.interleave / 2)): + logger.warning("Spacing is too high, map will be undersampled") + scans_per_interleave = floor(receiver.interleave / self.spacing) + #this is necessary for tsys and offsets + self.beamsize = receiver.feed_extent * 2 + if scans_per_interleave == 0: + logger.warning("Spacing is too high for this receiver") + scans_per_interleave = 1 + self.spacing = 0 + major_spacing = receiver.feed_extent * 2 #+ self.spacing + self.dimension_x = 0 + self.offset_x = [] + self.dimension_y = 0 + self.offset_y = [] + if self.scan_axis == "LON": + _offset_x = (-1 * (self.length_x / 2)) - receiver.feed_extent + while _offset_x <= (self.length_x / 2 + receiver.feed_extent): + self.offset_x.append(_offset_x) + _offset_x = _offset_x + self.spacing + _offset_y = (-1 * (self.length_y / 2)) + receiver.feed_extent + while _offset_y <= (self.length_y / 2 + receiver.feed_extent): + for i in range(scans_per_interleave): + self.offset_y.append(_offset_y) + _offset_y = _offset_y + self.spacing + #self.offset_y.append(_offset_y + i * self.spacing) + _offset_y = _offset_y + major_spacing + else: #self.scan_axis == "LAT" + _offset_x = (-1 * (self.length_x / 2)) + receiver.feed_extent + while _offset_x <= (self.length_x / 2 + receiver.feed_extent): + for i in range(scans_per_interleave): + self.offset_x.append(_offset_x) + _offset_x = _offset_x + self.spacing + #self.offset_x.append(_offset_x + i * self.spacing) + _offset_x = _offset_x + major_spacing + _offset_y = (-1 * (self.length_y / 2)) - receiver.feed_extent + while _offset_y <= (self.length_y / 2 + receiver.feed_extent): + self.offset_y.append(_offset_y) + _offset_y = _offset_y + self.spacing + self.dimension_x = len(self.offset_x) + self.dimension_y = len(self.offset_y) + else: + super(RasterMapScan, self)._get_spacing() + def _get_offsets(self): """ Get ordered offsets for each point of the raster scan From 0b51fdc21a542aa0113d584277dcf9d27f6e9f12 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Thu, 3 Mar 2016 15:14:34 +0100 Subject: [PATCH 13/20] fixed bug in beamsize calculation --- setup.py | 3 --- src/receiver.py | 4 ++-- test/test_receivers.py | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 test/test_receivers.py diff --git a/setup.py b/setup.py index c47c0d6..51ade7a 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,6 @@ author = "Marco Bartolini, Simona Righini", author_email = "bartolini@ira.inaf.it", maintainer = "Marco Bartolini", - mainteiner_email =" bartolini@ira.inaf.it", license = "License :: OSI Approved :: BSD License", url = "http://github.com/flyingfrog81/basie/", packages = ["basie", "basie.scanmode"], @@ -17,6 +16,4 @@ package_data = {"basie" : ["schemas/*.ini", "user_templates/*.txt"]}, scripts = ["scripts/basie"], - install_requires = ["configobj", "validate", "astropy>=1.0", "zodbpickle", - "ZODB", "BTrees"], ) diff --git a/src/receiver.py b/src/receiver.py index f0959e8..a2332dc 100644 --- a/src/receiver.py +++ b/src/receiver.py @@ -110,8 +110,8 @@ def get_beamsize(self, freq=None): if not freq: logger.warning("RECEIVER %s using default beamsize at min frequency" % (self.name,)) - freq = self.fmin.value - if((not self.fmin <= freq <= self.fmax) and (freq > 0)): + freq = self.fmin + if((not self.fmin <= freq <= self.fmax) and (freq > 0 * MHz)): logger.warning("RECEIVER %s beamsize at frequency %f out of range" % (self.name, freq.value,)) logger.debug("Getting beamsize\nfreq: %s\nt0: %s\nt1: %s" % \ diff --git a/test/test_receivers.py b/test/test_receivers.py new file mode 100644 index 0000000..7fb154f --- /dev/null +++ b/test/test_receivers.py @@ -0,0 +1,14 @@ +#coding=utf-8 + +import unittest2 as unittest + +from basie.radiotelescopes import SRT +from basie.valid_angles import VAngle + +class TestReceiver(unittest.TestCase): + def setUp(self): + self.receiver = SRT.receivers["KM"] + + def test_get_beamsize(self): + beamsize = VAngle(self.receiver.beamsize) + self.assertTrue(beamsize >= VAngle(0)) From a9e03a61bd4d85bccc9970fc50b82e90da3f5938 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Thu, 3 Mar 2016 15:16:25 +0100 Subject: [PATCH 14/20] fixes beamsize --- src/receiver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/receiver.py b/src/receiver.py index a2332dc..99fc297 100644 --- a/src/receiver.py +++ b/src/receiver.py @@ -111,7 +111,7 @@ def get_beamsize(self, freq=None): logger.warning("RECEIVER %s using default beamsize at min frequency" % (self.name,)) freq = self.fmin - if((not self.fmin <= freq <= self.fmax) and (freq > 0 * MHz)): + if((not self.fmin <= freq <= self.fmax) and (freq > 0 * u.MHz)): logger.warning("RECEIVER %s beamsize at frequency %f out of range" % (self.name, freq.value,)) logger.debug("Getting beamsize\nfreq: %s\nt0: %s\nt1: %s" % \ From 3ed67cf9b5813548d27a803edde582302f851437 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Thu, 3 Mar 2016 16:44:27 +0100 Subject: [PATCH 15/20] better logging and error management --- src/scanmode/maps.py | 11 +++++++---- src/schedule.py | 18 ++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/scanmode/maps.py b/src/scanmode/maps.py index 8e90983..8b60404 100644 --- a/src/scanmode/maps.py +++ b/src/scanmode/maps.py @@ -5,6 +5,7 @@ from basie import utils, frame from basie.valid_angles import VAngle +from basie.errors import * from scanmode import ScanMode from ..frame import Coord @@ -182,6 +183,7 @@ def __init__(self, frame, start_point, scan_axis, self.offset_interleave = offset def _get_spacing(self, receiver, frequency): + self.beamsize = VAngle(receiver.get_beamsize(max(frequency))) if receiver.is_multifeed() and receiver.has_derotator: #we can exploit multifeed derotator optimization logger.info("applying multifeed derotator optimization for map generation") @@ -200,10 +202,11 @@ def _get_spacing(self, receiver, frequency): #this is necessary for tsys and offsets self.beamsize = receiver.feed_extent * 2 if scans_per_interleave == 0: - logger.warning("Spacing is too high for this receiver") - scans_per_interleave = 1 - self.spacing = 0 - major_spacing = receiver.feed_extent * 2 #+ self.spacing + #logger.warning("Spacing is too high for this receiver") + raise ScanError("Spacing is too high for this receiver") + #scans_per_interleave = 1 + #self.spacing = 0 + major_spacing = receiver.feed_extent * 2 self.dimension_x = 0 self.offset_x = [] self.dimension_y = 0 diff --git a/src/schedule.py b/src/schedule.py index 7812add..77d2dbe 100644 --- a/src/schedule.py +++ b/src/schedule.py @@ -168,6 +168,8 @@ def _write_schedule_files(self): for f in self.restFrequency: if not f == 0: restFrequency = True + if self.ftrack and not restFrequency: + logger.warning("no rest frequency specified, ftrack will not be used") if restFrequency and self.ftrack: freqstring = ";".join(map(lambda(x):str(x.value), self.restFrequency)) @@ -204,8 +206,7 @@ def _write_schedule_files(self): _scan.backend = copy(_scan.backend) _scan.backend.name += "CT" else: - data_writer = "MANAGEMENT/FitsZilla" #TODO: read this from conf - #TODO: add back scnlayout when passing to mbfits + data_writer = "MANAGEMENT/FitsZilla" #scdfile.write("%s:%s\t%s\n" % # (_scan.backend.name, data_writer, scanlayout,)) scdfile.write("%s:%s\n" % @@ -213,11 +214,15 @@ def _write_schedule_files(self): _used_backends.add(_scan.backend) #BEGIN SUBSCANS LOOP subscans_set = set() #all subscans in this scan + if (_scan.target.velocity.is_zero() and + restFrequency and + self.ftrack): + logger.warning("using ftrack with zero velocity") for _subscan in _scan.subscans: _subscan.SEQ_ID = subscan_number #PRE SCAN procedures if subscan_number == 1: - if self.ftrack: + if restFrequency and self.ftrack: if isinstance(_scan.backend, backend.XBackend): #TODO: we need to test FTRACKALL before using it #_subscan.pre_procedure += procedures.FTRACKALL @@ -233,13 +238,6 @@ def _write_schedule_files(self): _subscan.pre_procedure += procedures.DEROTATORBSC if(isinstance(_scan.scanmode, PointScan)): _subscan.pre_procedure += procedures.ZEROOFF - #if isinstance(_subscan, OTFSubscan): - #ADD WAIT post subscan proceudure - #wait_time = ((_scan._scanmode.speed / 60.0) / - # self.radiotelescope.max_acc * - # self.radiotelescope.acc_scale_factor) - #wait_time = utils.ceil_to_half(wait_time) - #_subscan.add_post_procedure(procedures.WAIT(wait_time)) #ADD SUBSCAN PROCEDURES TO THE SET OF USED ONES _used_procedures.add(_subscan.pre_procedure) _used_procedures.add(_subscan.post_procedure) From 7e27d1c8bb479c7371a8376f4df3c15dcd9e2d26 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Thu, 3 Mar 2016 17:04:49 +0100 Subject: [PATCH 16/20] release notes v0.6.3 --- RELEASENOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 1ec05c0..938fa25 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -7,6 +7,7 @@ Release notes: - [x] **nop** instruction removed from roach backend configuration. - [x] added explicit **ftrack** parameter in configuration file. - [x] added **offset interleave** parameter in raster map scans. + - [x] Fixes algorithm for Raster Maps scans using multifeed receiver. **Note on ftrack**: in order to use ftrack procedures the user now must specify ```python From dbd3528079b1d8901fb640042728ca43053b67b6 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Fri, 4 Mar 2016 15:04:25 +0100 Subject: [PATCH 17/20] optimized scan numbering and repetitions as per issue #11 --- src/scan.py | 19 ++++++++++--------- src/schedule.py | 17 ++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/scan.py b/src/scan.py index 0eca29b..39a3b7c 100644 --- a/src/scan.py +++ b/src/scan.py @@ -19,16 +19,16 @@ def __init__(self, receiver, frequency, backend, - repetitions, - tsys, + schedule_repetitions = 1, + schedule_tsys = 0, ): self.target = target self.scanmode = scanmode self.receiver = receiver self.backend = backend self.frequency = frequency - self.repetitions = repetitions - self.tsys = tsys + self.repetitions = target.repetitions or schedule_repetitions + self.tsys = target.tsys or schedule_tsys if self.target.offset_coord.is_null(): try: self.target.offset_coord.frame = scanmode.frame @@ -47,19 +47,20 @@ def subscans(self): base_subscans = self.scanmode._do_scan(self.target, self.receiver, self.frequency) + counter = 0 for rep in xrange(self.repetitions): for sn, ss in enumerate(base_subscans): - logger.debug("REP: %d SUBSCAN: %d" % (rep, sn)) - subscan_number = rep * self.scanmode.unit_subscans + sn - logger.debug("subscan_number %d" % (subscan_number,)) + #logger.debug("REP: %d SUBSCAN: %d" % (rep, sn)) + #subscan_number = rep * self.scanmode.unit_subscans + sn yield_tsys = False #should we add a TSYS subscan? - if subscan_number == 0 and self.tsys >= 0: + if rep == 0 and sn == 0 and self.tsys >= 0: yield_tsys = True - elif self.tsys > 0 and not(subscan_number % self.tsys): + elif self.tsys > 0 and not(counter % self.tsys): yield_tsys = True if yield_tsys: subscans.append(copy.deepcopy(ss[1])) subscans.append(copy.deepcopy(ss[0])) + counter += 1 return subscans diff --git a/src/schedule.py b/src/schedule.py index 77d2dbe..bdbf657 100644 --- a/src/schedule.py +++ b/src/schedule.py @@ -98,8 +98,8 @@ def add_scan(self, _target, _scantype, _backend): self.receiver, self.restFrequency, self.backends[_backend], - _target.repetitions or self.repetitions, - _target.tsys or self.tsys, + self.repetitions, + self.tsys, ) ) else: @@ -111,8 +111,8 @@ def add_scan(self, _target, _scantype, _backend): self.receiver, self.restFrequency, self.backends[_backend], - _target.repetitions or self.repetitions, - _target.tsys or self.tsys, + self.repetitions, + self.tsys, ) ) self.scans.append( @@ -121,8 +121,8 @@ def add_scan(self, _target, _scantype, _backend): self.receiver, self.restFrequency, self.backends[_backend], - _target.repetitions or self.repetitions, - _target.tsys or self.tsys, + self.repetitions, + self.tsys, ) ) else: @@ -218,8 +218,7 @@ def _write_schedule_files(self): restFrequency and self.ftrack): logger.warning("using ftrack with zero velocity") - for _subscan in _scan.subscans: - _subscan.SEQ_ID = subscan_number + for subscan_id, _subscan in enumerate(_scan.subscans): #PRE SCAN procedures if subscan_number == 1: if restFrequency and self.ftrack: @@ -246,7 +245,7 @@ def _write_schedule_files(self): #WRITE SUBSCAN IN SCD FILE scdfile.write("%d_%d\t%f\t%d\t%s\t%s\n" % ( scan_number, - _subscan.SEQ_ID, + subscan_number, _subscan.duration, _subscan.ID, _subscan.pre_procedure.execute(), From 4e49caf4810706f47b5c2e7989796cf15783581b Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Fri, 4 Mar 2016 15:36:54 +0100 Subject: [PATCH 18/20] removes duplication of subscans from onoff and nodding scantypes. address issue #11 --- src/scanmode/nodding.py | 20 +++++++++--------- src/scanmode/onoff.py | 45 +++++++++++++++++++++-------------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/scanmode/nodding.py b/src/scanmode/nodding.py index e67bc48..ddc6e88 100644 --- a/src/scanmode/nodding.py +++ b/src/scanmode/nodding.py @@ -24,16 +24,16 @@ def _do_scan(self, _target, _receiver, _frequency): offset_b = _receiver.feed_offsets[self.feed_b] _subscans = [] for element in self.sequence: + if element[1] == "a": + offset = offset_a + else: + offset = offset_b + ss = subscan.get_sidereal(_target, + offset, + self.duration, + is_cal=element[2]) + st = subscan.get_tsys(_target, + offset) for repetitions in range(element[0]): - if element[1] == "a": - offset = offset_a - else: - offset = offset_b - ss = subscan.get_sidereal(_target, - offset, - self.duration, - is_cal=element[2]) - st = subscan.get_tsys(_target, - offset) _subscans.append((ss, st)) return _subscans diff --git a/src/scanmode/onoff.py b/src/scanmode/onoff.py index 16e4eab..504693b 100644 --- a/src/scanmode/onoff.py +++ b/src/scanmode/onoff.py @@ -22,29 +22,30 @@ def __init__(self, duration, offset_lon, offset_lat, offset_frame, sequence): def _do_scan(self, _target, _receiver, _frequency): _subscans = [] for element in self.sequence: - for repetitions in range(element[0]): - if element[1] == "on": #ON SOURCE - ss = subscan.get_sidereal( - _target, - Coord(self.offset_frame, - VAngle(0.0), - VAngle(0.0)), - self.duration, - is_cal = element[2]) - elif element[1] == "off": #OFF SOURCE - ss = subscan.get_sidereal( - _target, - Coord(self.offset_frame, - self.offset_lon, - self.offset_lat), - self.duration, - is_cal=element[2]) - else: - raise ScheduleError("unknown onoff position: %s" % (element[1],)) - #TSYS is calculated at off position - st = subscan.get_tsys(_target, + if element[1] == "on": #ON SOURCE + ss = subscan.get_sidereal( + _target, + Coord(self.offset_frame, + VAngle(0.0), + VAngle(0.0)), + self.duration, + is_cal = element[2]) + elif element[1] == "off": #OFF SOURCE + ss = subscan.get_sidereal( + _target, Coord(self.offset_frame, self.offset_lon, - self.offset_lat)) + self.offset_lat), + self.duration, + is_cal=element[2]) + else: + raise ScheduleError("unknown onoff position: %s" % (element[1],)) + #TSYS is calculated at off position + st = subscan.get_tsys(_target, + Coord(self.offset_frame, + self.offset_lon, + self.offset_lat)) + for repetitions in range(element[0]): _subscans.append((ss, st)) return _subscans + From 781403d9db847b1ce6942afe9ed0e3ce9b43cda4 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Fri, 4 Mar 2016 15:42:40 +0100 Subject: [PATCH 19/20] relaxed some library version from requirements, addresses issue #11 --- requirements.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/requirements.txt b/requirements.txt index 1e26780..c7db2d0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,15 +1,15 @@ -BTrees==4.1.4 -argparse==1.2.1 +BTrees>=4.1.4 +argparse>=1.2.1 numpy>=1.6.1 astropy>=1.0.1 -configobj==4.7.2 +configobj validate -persistent==4.1.1 -pickleshare==0.5 -transaction==1.4.4 -zc.lockfile==1.1.0 -zdaemon==4.1.0 -ZConfig==3.0.4 -ZODB==4.2.0 -zodbpickle==0.6.0 -zope.interface==4.1.2 +persistent>=4.1.1 +pickleshare>=0.5 +transaction>=1.4.4 +zc.lockfile>=1.1.0 +zdaemon>=4.1.0 +ZConfig>=3.0.4 +ZODB>=4.2.0 +zodbpickle>=0.6.0 +zope.interface>=4.1.2 From f7e7abe3bac374f87a47e4b1ab1b0fda5246ced9 Mon Sep 17 00:00:00 2001 From: bartolini_ira Date: Fri, 4 Mar 2016 16:43:57 +0100 Subject: [PATCH 20/20] better scan names for BOTH axis --- src/schedule.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/schedule.py b/src/schedule.py index bdbf657..7bdf408 100644 --- a/src/schedule.py +++ b/src/schedule.py @@ -91,6 +91,10 @@ def _configure_totalpower_sections(self): bck.set_sections(self.receiver.nifs) def add_scan(self, _target, _scantype, _backend): + try: + _frame = _scantype.frame + except Exception, e: + _frame = _target.coord.frame if _scantype in self.scantypes: self.scans.append( scan.Scan(_target, @@ -105,8 +109,14 @@ def add_scan(self, _target, _scantype, _backend): else: if((_scantype + "_lon" in self.scantypes) and (_scantype + "_lat" in self.scantypes)): + try: + _frame = self.scantypes[_scantype + "_lon"].frame + except: + _frame = _target.coord.frame + _target_lon = copy(_target) + _target_lon.label += "_%s" % (_frame.lon_name,) self.scans.append( - scan.Scan(_target, + scan.Scan(_target_lon, self.scantypes[_scantype + "_lon"], self.receiver, self.restFrequency, @@ -115,8 +125,10 @@ def add_scan(self, _target, _scantype, _backend): self.tsys, ) ) + _target_lat = copy(_target) + _target_lat.label += "_%s" % (_frame.lat_name,) self.scans.append( - scan.Scan(_target, + scan.Scan(_target_lat, self.scantypes[_scantype + "_lat"], self.receiver, self.restFrequency,