Example #1
0
    def start_observation(self):
        signal.signal(signal.SIGINT, self.handler)
        table = self.create_table()
        print("#################", table)
        num = len(table)

        #self.ctrl.dome_track()

        date = dt.today()
        month = str("{0:02d}".format(date.month))
        day = str("{0:02d}".format(date.day))
        hour = str("{0:02d}".format(date.hour))
        minute = str("{0:02d}".format(date.minute))
        second = str("{0:02d}".format(date.second))
        #data_name = "opt_"+str(date.year)+month+day+hour+minute+second#real
        data_name = "/home/amigos/s_opt/image/"

        for _tbl in table:
            print("table", table)
            now = dt.utcnow()

            #store parameters in lists to use self.calc.coordinate_calc
            __ra = [_tbl[1] * 3600.]
            __dec = [_tbl[2] * 3600.]
            __now = [now]

            ret = self.calc.coordinate_calc(__ra, __dec, __now, 'j2000', 0, 0,
                                            'hosei_230.txt', 2600, 5, 20, 0.07)
            real_el = ret[1][0] / 3600.
            print('#L161', ret)
            if real_el >= 30. and real_el < 80.:
                #self.ctrl.onepoint_move(_tbl[1], _tbl[2], "J2000",lamda = 500)#lamda = 0.5 => 500

                #stop moving antenna and dome tracking
                #self.ctrl.antenna_tracking_check()
                #self.ctrl.dome_tracking_check()

                now = dt.now()
                status = self.ctrl.read_status()
                #n_star = self.calc_star_azel(_tbl[1], _tbl[2], _date)
                ret = self.calc.coordinate_calc(__ra, __dec, __now, 'j2000', 0,
                                                0, 'hosei_230.txt', 2600, 5,
                                                20, 0.07)
                #__x = [_tbl[0]]
                #__y = [_tbl[3]]
                #__now = [dt.utcnow()]
                print('###ret###', ret)

                ccd.ccd_controller().all_sky_shot(_tbl[0], _tbl[3],
                                                  ret[0][0] / 3600.,
                                                  ret[1][0] / 3600., data_name,
                                                  status)
            else:
                #out of range(El)
                pass

        self.ctrl.move_stop()
        print("OBSERVATION END")
        self.ctrl.obs_status(active=False)
        return
Example #2
0
#! /usr/bin/env python2

import time
import os
import sys
import argparse
sys.path.append("/home/amigos/ros/src/necst/lib")
sys.path.append("/home/amigos/ros/src/necst/scripts/controller")
import ROS_controller
#import ccd
#import S_ccd as ccd
import ccd_old as ccd
import signal
ccd = ccd.ccd_controller()

# Info
# ----

name = 'oneshot'
description = 'Get oneshot data'

# Default parameters
# ------------------

star = ''
filename = ''

# Argument handler
# ================

p = argparse.ArgumentParser(description=description)
Example #3
0
    def start_observation(self, sort='az'):
        hosei_opt = "hosei_opt.txt"

        signal.signal(signal.SIGINT, self.handler)
        table = self.create_table(sort=sort, hosei_opt=hosei_opt)
        print("[{}]  CREATE OBJECT TABLE".format(
            datetime.datetime.strftime(datetime.datetime.now(), "%H:%M:%S")))

        date = datetime.datetime.today()
        month = str("{0:02d}".format(date.month))
        day = str("{0:02d}".format(date.day))
        hour = str("{0:02d}".format(date.hour))
        minute = str("{0:02d}".format(date.minute))
        second = str("{0:02d}".format(date.second))
        data_name = "opt_" + str(
            date.year) + month + day + hour + minute + second

        print("[{}]  MAKE DIRECTORY".format(
            datetime.datetime.strftime(datetime.datetime.now(), "%H:%M:%S")))
        os.mkdir("/home/amigos/data/opt/" + data_name)

        print("[{0}]  HOSEI FILE {1}".format(
            datetime.datetime.strftime(datetime.datetime.now(), "%H:%M:%S"),
            hosei_opt))

        self.con.dome.tracking(True)

        for _tbl in table:
            now = datetime.datetime.utcnow()

            #store parameters in lists to use self.calc.coordinate_calc
            __ra = [_tbl[1] * 3600.]
            __dec = [_tbl[2] * 3600.]
            __now = [now]

            press = self.red.weather.pressure()
            out_temp = self.red.weather.out_temp()
            out_humi = self.red.weather.out_humi()
            ret = self.calc.coordinate_calc(__ra,
                                            __dec,
                                            __now,
                                            'fk5',
                                            0,
                                            0,
                                            hosei_opt,
                                            lamda=0.5,
                                            press=press,
                                            temp=out_temp,
                                            humi=out_humi / 100)
            real_el = ret[1][0] / 3600.
            print("[{0}]  OBJECT RA {1}".format(
                datetime.datetime.strftime(datetime.datetime.now(),
                                           "%H:%M:%S"), ret[0][0] / 3600.))
            print("[{0}]  OBJECT DEC {1}".format(
                datetime.datetime.strftime(datetime.datetime.now(),
                                           "%H:%M:%S"), ret[1][0] / 3600.))
            if real_el >= 30. and real_el < 79.5:
                print("[{}]  ANTENNA TRACKING START".format(
                    datetime.datetime.strftime(datetime.datetime.now(),
                                               "%H:%M:%S")))
                self.con.antenna.onepoint_move(
                    _tbl[1],
                    _tbl[2],
                    "fk5",
                    hosei=hosei_opt,
                    lamda=0.5,
                    rotation=False)  #lamda = 0.5 => 500
                print("[{}]  ANTENNA MOVING".format(
                    datetime.datetime.strftime(datetime.datetime.now(),
                                               "%H:%M:%S")))

                print("[{}]  ANTENNA TRACKING CHECK".format(
                    datetime.datetime.strftime(datetime.datetime.now(),
                                               "%H:%M:%S")))
                while round(self.red.antenna.az(), 4) != round(
                        self.red.antenna.az_cmd(), 4) or round(
                            self.red.antenna.el(), 4) != round(
                                self.red.antenna.el_cmd(), 4):
                    time.sleep(0.1)
                    continue

                press = self.red.weather.pressure()
                out_temp = self.red.weather.out_temp()
                out_humi = self.red.weather.out_humi()
                ret = self.calc.coordinate_calc(__ra,
                                                __dec,
                                                __now,
                                                'fk5',
                                                0,
                                                0,
                                                hosei_opt,
                                                lamda=0.5,
                                                press=press,
                                                temp=out_temp,
                                                humi=out_humi / 100)

                try:
                    ccd.ccd_controller().all_sky_shot(_tbl[0], _tbl[3],
                                                      ret[0][0] / 3600.,
                                                      ret[1][0] / 3600.,
                                                      data_name)
                    pass
                except Exception as e:
                    print("[{0}]  ERROR OCCURED : {1}".format(
                        datetime.datetime.strftime(datetime.datetime.now(),
                                                   "%H:%M:%S"), e))
                    self.con.dome.tracking(False)
                    self.con.antenna.stop()
                    time.sleep(3)
                    sys.exit()

            else:
                print("[{0}]  THIS OBJECT IS OUT OF RANGE(EL)".format(
                    datetime.datetime.strftime(datetime.datetime.now(),
                                               "%H:%M:%S")))
                pass

        self.con.antenna.stop()
        time.sleep(3.)

        ###plot Qlook
        ###==========
        optdata_dir = '/home/amigos/data/opt/'
        try:
            print("[{}]  POINTING ANALYSIS".format(
                datetime.datetime.strftime(datetime.datetime.now(),
                                           "%H:%M:%S")))
            opt_analy.opt_plot([optdata_dir + data_name],
                               savefig=True,
                               figname=data_name,
                               interactive=True)
        except Exception as e:
            print("[{0}]  ERROR OCCURED : {1}".format(
                datetime.datetime.strftime(datetime.datetime.now(),
                                           "%H:%M:%S"), e))

        try:
            import glob
            date = data_name[:8]
            file_list = glob.glob('{}{}*'.format(optdata_dir, date))
            opt_analy.opt_plot(file_list, savefig=True, interactive=True)
            pass
        except Exception as e:
            print("[{0}]  ERROR OCCURED : {1}".format(
                datetime.datetime.strftime(datetime.datetime.now(),
                                           "%H:%M:%S"), e))
        ###==========

        self.con.antenna.stop()
        print("[{}]  END OBSERVATION".format(
            datetime.datetime.strftime(datetime.datetime.now(), "%H:%M:%S")))
        return
Example #4
0
# ====
import os
from datetime import datetime as dt
import time
import signal
import numpy
from astropy.coordinates import SkyCoord,EarthLocation,AltAz,get_body
from astropy.time import Time
import astropy.units as u
nanten2 = EarthLocation(lat = -22.96995611*u.deg, lon = -67.70308139*u.deg, height = 4863.85*u.m)

import ROS_controller
con = ROS_controller.controller()
con.dome_track()
import ccd_old
ccd = ccd_old.ccd_controller()
def handler(num, flame):
    con.move_stop()
    con.dome_stop()
    print("!!ctrl + c!!")
    print("Stop antenna")
    con.obs_status(active=False)
    sys.exit()
signal.signal(signal.SIGINT, handler)

# Initial configurations
# ----------------------

now = dt.utcnow()
timestamp = now.strftime('opt_%Y%m%d%H%M%S')
dirname = "/home/amigos/data/experiment/opt_cross_point/"
Example #5
0
    def start_observation(self, sort='az'):
        signal.signal(signal.SIGINT, self.handler)
        table = self.create_table(sort=sort)
        print("#################", table)
        num = len(table)

        self.ctrl.dome_track()

        date = dt.today()
        month = str("{0:02d}".format(date.month))
        day = str("{0:02d}".format(date.day))
        hour = str("{0:02d}".format(date.hour))
        minute = str("{0:02d}".format(date.minute))
        second = str("{0:02d}".format(date.second))
        data_name = "opt_" + str(
            date.year) + month + day + hour + minute + second  #real
        #data_name = "/home/amigos/s_opt/image/"

        for _tbl in table:
            print("table", table)
            now = dt.utcnow()

            #store parameters in lists to use self.calc.coordinate_calc
            __ra = [_tbl[1] * 3600.]
            __dec = [_tbl[2] * 3600.]
            __now = [now]

            ret = self.calc.coordinate_calc(__ra, __dec, __now, 'fk5', 0, 0,
                                            'hosei_opt.txt', 0.5, 980, 260,
                                            0.07)
            real_el = ret[1][0] / 3600.
            print('#L161', ret)
            if real_el >= 30. and real_el < 79.5:
                #temp_coord = SkyCoord(_tbl[1], _tbl[2], frame="fk5", unit="deg")
                #temp_coord.location = nanten2
                #temp_coord.obstime = Time(dt.utcnow())
                #azel = temp_coord.altaz
                #self.ctrl.onepoint_move(azel.az.deg, azel.alt.deg, "altaz", -5700, -6100, "altaz", lamda=0.5)
                self.ctrl.onepoint_move(_tbl[1],
                                        _tbl[2],
                                        "fk5",
                                        hosei="hosei_opt.txt",
                                        lamda=0.5,
                                        rotation=False)  #lamda = 0.5 => 500

                #stop moving antenna and dome tracking
                self.ctrl.antenna_tracking_check()
                self.ctrl.dome_tracking_check()

                now = dt.now()
                status = self.ctrl.read_status()
                #n_star = self.calc_star_azel(_tbl[1], _tbl[2], _date)
                ret = self.calc.coordinate_calc(__ra, __dec, __now, 'fk5', 0,
                                                0, 'hosei_opt.txt', 2600, 5,
                                                20, 0.07)
                #__x = [_tbl[0]]
                #__y = [_tbl[3]]
                #__now = [dt.utcnow()]
                print('###ret###', ret)
                try:
                    ccd.ccd_controller().all_sky_shot(_tbl[0], _tbl[3],
                                                      ret[0][0] / 3600.,
                                                      ret[1][0] / 3600.,
                                                      data_name, status)
                except Exception as e:
                    print(e)
                    self.ctrl.move_stop()
                    time.sleep(3)
                    sys.exit()
            else:
                #out of range(El)
                pass

        self.ctrl.move_stop()
        time.sleep(3.)

        ###plot Qlook
        ###==========
        optdata_dir = '/home/nfs/necopt-old/ccd-shot/data/'
        try:
            print('Analysis ...')
            opt_analy.opt_plot([optdata_dir + data_name],
                               savefig=True,
                               figname=data_name,
                               interactive=True)
        except Exception as e:
            print(e)

        try:
            import glob
            date = dataname[:8]
            file_list = glob.glob('{}{}*'.format(optdata_dir, date))
            opt_analy.opt_plot(file_list, savefig=True, interactive=True)
            pass
        except Exception as e:
            print(e)
        ###==========

        print("OBSERVATION END")
        self.ctrl.obs_status(active=False)
        return