Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creating scripts to take manual observations - WIP #207

Closed
wants to merge 8 commits into from
Closed
61 changes: 61 additions & 0 deletions scripts/take_day_flats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from panoptes.utils import current_time
from panoptes.utils import wait_for_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, headers={}))
print(f"Exposure {new_filename} started.")

print(f"Waiting for exposures {i:03d}/{num_exposures:03d}")
wait_for_events(exposure_events)


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))
print(f"Waiting for cameras to move to filter {filter_name}")
wait_for_events(filter_events)

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=filter_name)

move_all_cameras_to_filter(cameras=create_cameras_from_config(),
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,
base_dir='/var/huntsman/images/temp/dayflats/')