From 511b885706cc0873492ee850a517bf3765f14860 Mon Sep 17 00:00:00 2001 From: Lee Spitler Date: Fri, 11 Sep 2020 17:00:39 +1000 Subject: [PATCH 1/8] starting script --- scripts/take_day_flats.py | 76 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 scripts/take_day_flats.py diff --git a/scripts/take_day_flats.py b/scripts/take_day_flats.py new file mode 100644 index 00000000..cb9c522f --- /dev/null +++ b/scripts/take_day_flats.py @@ -0,0 +1,76 @@ +from panoptes.utils import current_time +from panoptes.utils import wait_for_events + + +def take_pics_OLD( + cameras, + base_date=None, + exptime=30, + num_exposures=150, + base_dir='/var/huntsman/images/temp'): + """Takes pics with the cameras""" + # Set a base date for all pics and use that as directory name. + base_date = base_date or current_time(flatten=True) + + for i in range(num_exposures): + print(f"Starting exposures {i:03d} of {num_exposures:03d}.") + + exposure_events = [] + + # Share timestamp filename across all cameras. + timestamp = current_time(flatten=True) + for cam_name, camera in cameras.items(): + new_filename = f'{base_dir}/{base_date}/{camera.uid}/{timestamp}.fits' + + exposure_events.append(camera.take_exposure(seconds=exptime, filename=new_filename)) + print(f"Exposure {new_filename} started.") + + print(f"Waiting for exposures {i:03d}/{num_exposures:03d}") + wait_for_events(exposure_events) + + +def take_pics(field, + observation, + cameras, + base_date=None, + num_exposures=1, + base_dir='/var/huntsman/images/temp' + take_flats=False): + """Takes pics with the cameras""" + + # Set a base date for all pics and use that as directory name. + base_date = base_date or current_time(flatten=True) + + for i in range(num_exposures): + print(f"Starting exposures {i:03d} of {num_exposures:03d}.") + + exposure_events = [] + + # Share timestamp filename across all cameras. + timestamp = current_time(flatten=True) + for cam_name, camera in cameras.items(): + new_filename = f'{base_dir}/{base_date}/{camera.uid}/{timestamp}.fits' + + exposure_events.append(camera.take_observation(observation, filename=new_filename)) + print(f"Exposure {new_filename} started.") + + print(f"Waiting for exposures {i:03d}/{num_exposures:03d}") + wait_for_events(exposure_events) + + +if __name__ == '__main__': + + test_exptime = 0.07 * u.second + test_coordinates = SkyCoord('00h00m00s', '+00d00m00s', frame='icrs') + test_field = Field(name='day_flats', position=test_coordinates) + test_observation = Observation(field=test_field, exptime=test_exptime, min_nexp=1, + exp_set_size=1, priority=100, filter_name='halpha') + + + take_pics(field=test_field, + observation=test_observation, + cameras=create_cameras_from_config(), # or single camera if needed + base_date=None, + exptime=test_exptime, + num_exposures=1, + base_dir='/var/huntsman/images/temp/') From 7046b63857e44c931ba99425adf82fe13da51b20 Mon Sep 17 00:00:00 2001 From: Lee Spitler Date: Fri, 11 Sep 2020 17:01:07 +1000 Subject: [PATCH 2/8] delete old function --- scripts/take_day_flats.py | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/scripts/take_day_flats.py b/scripts/take_day_flats.py index cb9c522f..1ed02e33 100644 --- a/scripts/take_day_flats.py +++ b/scripts/take_day_flats.py @@ -2,33 +2,6 @@ from panoptes.utils import wait_for_events -def take_pics_OLD( - cameras, - base_date=None, - exptime=30, - num_exposures=150, - base_dir='/var/huntsman/images/temp'): - """Takes pics with the cameras""" - # Set a base date for all pics and use that as directory name. - base_date = base_date or current_time(flatten=True) - - for i in range(num_exposures): - print(f"Starting exposures {i:03d} of {num_exposures:03d}.") - - exposure_events = [] - - # Share timestamp filename across all cameras. - timestamp = current_time(flatten=True) - for cam_name, camera in cameras.items(): - new_filename = f'{base_dir}/{base_date}/{camera.uid}/{timestamp}.fits' - - exposure_events.append(camera.take_exposure(seconds=exptime, filename=new_filename)) - print(f"Exposure {new_filename} started.") - - print(f"Waiting for exposures {i:03d}/{num_exposures:03d}") - wait_for_events(exposure_events) - - def take_pics(field, observation, cameras, From 98fc7ba5dd14052f89e18aa028eddc705fe343ce Mon Sep 17 00:00:00 2001 From: Lee Spitler Date: Fri, 11 Sep 2020 17:06:30 +1000 Subject: [PATCH 3/8] change basedir --- scripts/take_day_flats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/take_day_flats.py b/scripts/take_day_flats.py index 1ed02e33..4cc372a3 100644 --- a/scripts/take_day_flats.py +++ b/scripts/take_day_flats.py @@ -46,4 +46,4 @@ def take_pics(field, base_date=None, exptime=test_exptime, num_exposures=1, - base_dir='/var/huntsman/images/temp/') + base_dir='/var/huntsman/images/temp/dayflats/') From 8b237ed28cabfeaa9863a44a92cddf163f5ad231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Andr=C3=A9s?= Date: Fri, 11 Sep 2020 17:59:49 +1000 Subject: [PATCH 4/8] Added filter_name to move filterwheel and modified camera.take_observation to have headers={} - Added filter_name argument to move all the filterwheels automatically - Added headers={} inside camera.take_observation() to avoid a current bug in POCS --- scripts/take_day_flats.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/take_day_flats.py b/scripts/take_day_flats.py index 4cc372a3..294427ce 100644 --- a/scripts/take_day_flats.py +++ b/scripts/take_day_flats.py @@ -5,6 +5,7 @@ def take_pics(field, observation, cameras, + filter_name, base_date=None, num_exposures=1, base_dir='/var/huntsman/images/temp' @@ -24,7 +25,8 @@ def take_pics(field, for cam_name, camera in cameras.items(): new_filename = f'{base_dir}/{base_date}/{camera.uid}/{timestamp}.fits' - exposure_events.append(camera.take_observation(observation, filename=new_filename)) + camera.filterwheel.move_to(f'{filter_name}') + exposure_events.append(camera.take_observation(observation, filename=new_filename, headers={})) print(f"Exposure {new_filename} started.") print(f"Waiting for exposures {i:03d}/{num_exposures:03d}") From d965ed401afc23ad0fc6edb3cb748fce97038100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Andr=C3=A9s?= Date: Fri, 11 Sep 2020 18:08:36 +1000 Subject: [PATCH 5/8] Update take_day_flats.py Added filter_name when calling the function take_pics --- scripts/take_day_flats.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/take_day_flats.py b/scripts/take_day_flats.py index 294427ce..521825d5 100644 --- a/scripts/take_day_flats.py +++ b/scripts/take_day_flats.py @@ -35,16 +35,18 @@ def take_pics(field, if __name__ == '__main__': + filter_name = 'halpha' test_exptime = 0.07 * u.second test_coordinates = SkyCoord('00h00m00s', '+00d00m00s', frame='icrs') test_field = Field(name='day_flats', position=test_coordinates) test_observation = Observation(field=test_field, exptime=test_exptime, min_nexp=1, - exp_set_size=1, priority=100, filter_name='halpha') + exp_set_size=1, priority=100, filter_name=filter_name) take_pics(field=test_field, observation=test_observation, cameras=create_cameras_from_config(), # or single camera if needed + filter_name=filter_name, base_date=None, exptime=test_exptime, num_exposures=1, From 241507f69524261e48f6222ebe2a4e079fd53615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Andr=C3=A9s?= Date: Fri, 11 Sep 2020 22:26:26 +1000 Subject: [PATCH 6/8] Added function to move all camera filters --- scripts/take_day_flats.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/take_day_flats.py b/scripts/take_day_flats.py index 521825d5..ce4158c2 100644 --- a/scripts/take_day_flats.py +++ b/scripts/take_day_flats.py @@ -5,7 +5,6 @@ def take_pics(field, observation, cameras, - filter_name, base_date=None, num_exposures=1, base_dir='/var/huntsman/images/temp' @@ -25,7 +24,6 @@ def take_pics(field, for cam_name, camera in cameras.items(): new_filename = f'{base_dir}/{base_date}/{camera.uid}/{timestamp}.fits' - camera.filterwheel.move_to(f'{filter_name}') exposure_events.append(camera.take_observation(observation, filename=new_filename, headers={})) print(f"Exposure {new_filename} started.") @@ -33,6 +31,13 @@ def take_pics(field, wait_for_events(exposure_events) +def move_all_cameras_to_filter(cameras, filter_name): + filter_events = [] + for cam_name, camera in cameras.items(): + filter_events.append(camera.filterwheel.move_to(filter_name)) + print(f"Waiting for cameras to move to filter {filter_name}") + wait_for_events(filter_events) + if __name__ == '__main__': filter_name = 'halpha' @@ -42,6 +47,8 @@ def take_pics(field, test_observation = Observation(field=test_field, exptime=test_exptime, min_nexp=1, exp_set_size=1, priority=100, filter_name=filter_name) + move_all_cameras_to_filter(cameras=create_cameras_from_config(), + filter_name=filter_name) take_pics(field=test_field, observation=test_observation, From 08c15589c700821ce68d65a380467b8a3b6af27e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Andr=C3=A9s?= Date: Fri, 11 Sep 2020 22:27:53 +1000 Subject: [PATCH 7/8] Added docstring to new function --- scripts/take_day_flats.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/take_day_flats.py b/scripts/take_day_flats.py index ce4158c2..202521d1 100644 --- a/scripts/take_day_flats.py +++ b/scripts/take_day_flats.py @@ -32,6 +32,7 @@ def take_pics(field, def move_all_cameras_to_filter(cameras, filter_name): + """Move all cameras to the same filter""" filter_events = [] for cam_name, camera in cameras.items(): filter_events.append(camera.filterwheel.move_to(filter_name)) From d751e39d8f05dda4e255ace86b4059e412427a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Andr=C3=A9s?= Date: Fri, 11 Sep 2020 22:29:23 +1000 Subject: [PATCH 8/8] Fixed indentation bugs --- scripts/take_day_flats.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/take_day_flats.py b/scripts/take_day_flats.py index 202521d1..a41b038e 100644 --- a/scripts/take_day_flats.py +++ b/scripts/take_day_flats.py @@ -36,8 +36,8 @@ def move_all_cameras_to_filter(cameras, filter_name): filter_events = [] for cam_name, camera in cameras.items(): filter_events.append(camera.filterwheel.move_to(filter_name)) - print(f"Waiting for cameras to move to filter {filter_name}") - wait_for_events(filter_events) + print(f"Waiting for cameras to move to filter {filter_name}") + wait_for_events(filter_events) if __name__ == '__main__': @@ -49,7 +49,7 @@ def move_all_cameras_to_filter(cameras, filter_name): exp_set_size=1, priority=100, filter_name=filter_name) move_all_cameras_to_filter(cameras=create_cameras_from_config(), - filter_name=filter_name) + filter_name=filter_name) take_pics(field=test_field, observation=test_observation,