Ejemplo n.º 1
0
    def __init__(self):
        Toplevel.__init__(self, border=8, bg="slate grey")

        self.user = UserValues()

        # get trasparency windows
        self.wait_visibility()
        self.wm_attributes('-alpha', trasparency)

        self.title("Load a new skymap")
        self.attributes("-topmost", True)

        self.label_1 = Label(self, text="LVC skymap", bg="slate grey")
        self.label_1.grid(row=0, column=0, sticky=E, pady=0)

        # default: input skymap
        skymap_input = StringVar(self, value=self.user.get_skymap())
        self.entry_new_skymap = Entry(self,
                                      width=30,
                                      justify=CENTER,
                                      textvariable=skymap_input)
        self.entry_new_skymap.grid(row=0, padx=15, column=1)

        #Btns
        self.show = Button(self, text='Load', command=self.new_skymap)
        self.show.grid(column=2, row=0, sticky=W, padx=2, pady=5)

        self.close = Button(self, text="Close", command=self.close_window)
        self.close.grid(column=5, row=0, sticky=E, padx=2, pady=5)
Ejemplo n.º 2
0
    def __init__(self, infile_coords='GWsky_coords'):
        """Creating a class in which the instance attributes are based on the dictionary
       "GWsky_coords" by default. GWsky_coords is created and pickled by the "config_values"
       module and will be deleted when the "SkyCoverageGUI" will be closed.
       It contains the keys: "ra", "dec". ra and dec represents the central location of a FoV. 
        
        Starting sky coordinates:
             self.input_ra: right ascension [deg]
             self.input_dec: declination [deg]
         """

        self.infile_coords = infile_coords
        self.entries_GWsky_new = []  # new entries during the FoV sequence

        self.user = UserValues()  # compositions
        self.lvc = LVCskymap()
        self.query = Query()
        self.airmass = Airmass()
        self.moon = Moon()

        with open(infile_coords, 'rb') as data:
            coords_GWsky = pickle.load(data)

        for k, v in coords_GWsky.items():
            setattr(self, k, v)
Ejemplo n.º 3
0
    def __init__(self):

        self.user = UserValues()  #comp.
        self.skymap = self.user.get_skymap()
        print(self.skymap)  # TEST
        self.nside = self.user.get_nside()

        self.is_3d = Is3d(self.skymap)  #comp --> eredita
        self.tfield, self.header = self.is_3d.get_header()
        self.prob, self.distmu, self.distsigma, self.distnorm = self.is_3d.get_values(
            self.tfield)
Ejemplo n.º 4
0
    def __init__(self):
        Toplevel.__init__(self, border=8, bg="slate grey")

        self.user = UserValues()

        # putting the entry value(s) in a list
        self.entries_GWsky = []

        self.wait_visibility()
        self.wm_attributes('-alpha', 0.8)  # transparency

        self.title(" Starting FoV")
        self.attributes("-topmost", True)

        self.label_1 = Label(self, text="RA (°) DEC (°)", bg="slate grey")
        self.label_1.grid(row=0, column=0, sticky=E, pady=0)

        # default: sky coords of maximum probability pixel
        fov_coords = str(self.user.get_ra_max_pixel()), str(
            self.user.get_dec_max_pixel())

        max_pixel_default = StringVar(self, value=fov_coords)
        self.entry_1 = Entry(self,
                             width=30,
                             justify=CENTER,
                             textvariable=max_pixel_default)

        self.entry_1.grid(row=0, padx=15, column=1)

        self.entryScroll = Scrollbar(self,
                                     orient=HORIZONTAL,
                                     command=self.__scrollHandler)
        self.entryScroll.grid(row=1, column=1, sticky=E + W)
        self.entry_1['xscrollcommand'] = self.entryScroll.set

        #Btn

        self.show = Button(self, text='Show', command=self.show_starting_fov)
        self.show.grid(column=2, row=0, sticky=W, padx=2, pady=5)

        self.checkbox = Button(self,
                               text="Not show",
                               command=self.no_show_starting_fov)
        self.checkbox.grid(column=3, row=0, sticky=E, padx=2, pady=5)

        self.close = Button(self,
                            text="Obs",
                            fg='dark green',
                            command=self.obs)
        self.close.grid(column=4, row=0, sticky=W, padx=2, pady=5)

        self.close = Button(self, text="Close", command=self.close_window)
        self.close.grid(column=5, row=0, sticky=E, padx=2, pady=5)
Ejemplo n.º 5
0
    def pinpoint(self, ra_transient, dec_transient, label):        
        """Finding in which confidence level the source falls.
        
        Input parameters
        ---------------
        ra_transient, dec_transient : float
              sky coordinates in degrees
        label : string
              id source transient
        """
        
        # (re)initialization: skymap/nside
        self.user = UserValues()
        skymap = self.user.get_skymap() 
        nside = int(self.user.get_nside())

        # getting probability array
        prob = moc.read_prob(skymap)

        # user input values: from/to/resolution
        from_percentage = float(self.entry_from.get())/100.0
        to_percentage = float(self.entry_to.get())/100.0
        resolution_percentage = float(self.entry_grid.get())/100.0

        # from sky coords to ipix
        ipix = healpixIpix.find_ipix(ra_transient, dec_transient,
                                     nside)            

        find = "n"         
        while from_percentage <= to_percentage or find =="y":
            ipixs = moc.ipixs_in_percentage(prob, from_percentage)        
            is_there = ipix in ipixs  # is the ipix within the MOC contour plot defined by user?
            
            if is_there != True: # ipix not found                            
                from_percentage = from_percentage + resolution_percentage                
            else:
                find = "y"  # ipix found    
                res_yes = ("The sky coord" + " " + "ra="+str(ra_transient)+"°," + ' ' + "dec="+str(dec_transient)+"°"+" " + "(label:" + label+")" \
                           "lies within the" + " " + str(from_percentage*100)+'%' + " " + "c.l.\n" +"["+skymap+"]")
                MSG.pinpoint_find(label, res_yes)

                return find
            
        # ipix not found [from_percentage -- to_percentage]
        from_percentage = to_percentage
        
        res_no = ("The sky coord" + " " + "ra="+str(ra_transient)+"°," + ' '
                 + "dec="+str(dec_transient)+"°"+" " + "(label:" + label+")" \
                 + " " + "is not localized within the" + " " + str(from_percentage*100)+'%' + " " + "c.l.\n" +"["+skymap+"]")

        MSG.pinpoint_nofind(label, res_no)
Ejemplo n.º 6
0
    def in_skymap(self):
        """Checking if an object falls in a given probability level defined by an user.
           List of sources are inserted in 'self.entry_sources'."""

        aladin.md(self.entry_folder.get()) # creating folder defined by user
        aladin.remove(self.entry_folder.get() + '~1') # removing multiple copy of the folder
                                                      # TO DO BETTER
        # (re)initialization: skymap/nside
        self.user = UserValues()
        skymap = self.user.get_skymap()
        nside = int(self.user.get_nside())

        # getting probability array
        prob = moc.read_prob(skymap)

        # user input: MOC confidence level in percentage
        percentage = float(self.entry_percentage.get())/100.0

        # splitting the entries              
        labels, ra_transients, dec_transients = self.__split_entries_3()       
      
        for ra_transient, dec_transient, label in zip(
           ra_transients, dec_transients, labels):

            # aladin stack organization: draw source position/move in folder
            aladin.draw_newtool(label)
            aladin.draw_source(ra_transient, dec_transient, label)
            aladin.mv(label, self.entry_folder.get())

            # from sky coords to ipix
            ipixs = moc.ipixs_in_percentage(prob, percentage)
            
            try:
                ipix = healpixIpix.find_ipix(ra_transient, dec_transient,
                                             nside)
            
                is_there = ipix in ipixs  # is the ipix within the MOC contour plot defined by user?

                if is_there is True: # ipix found
                    res_true = ("The sky coord" + " " + "ra="+str(ra_transient)+"°," + " " + "dec="+str(dec_transient)+"°" + " " + \
                                "(labels: " + label+")" + " " +  "lies within the" + " " + str(percentage*100)+'%' + " " + "c.l.\n" +"["+skymap+"]")
                    MSG.in_skymap_true(label, res_true)
                else:
                    res_false = ("The sky coord" + " " + "ra="+str(ra_transient)+"°," + " " +"dec="+str(dec_transient)+"°" + " " + \
                                 "(labels: " + label+")" + " " + "is outside the" + " " + str(percentage*100)+'%' + " " + "c.l.\n" + "["+skymap+"]")
                    MSG.in_skymap_false(label, res_false)

            except ValueError as value_error:
                MSG.value_error(value_error)
Ejemplo n.º 7
0
    def __init__(self):
        """Getting user-values from config_values module."""

        self.user = UserValues()
        self.aladin = AladinScriptCommands()

        self.latitude = self.user.get_latitude()
        self.longitude = self.user.get_longitude()
        self.altitude = self.user.get_altitude()
        self.obs_time = Time(self.user.get_obs_time())

        self.dt = TimeDelta(7200.0, format='sec')

        self.step = 0
        self.end_step = 11
Ejemplo n.º 8
0
    def __init__(self):
        """Getting user-values from config_values module."""

        self.user = UserValues()

        self.latitude = self.user.get_latitude()
        self.longitude = self.user.get_longitude()
        self.altitude = self.user.get_altitude()
        self.obs_time = self.user.get_obs_time()

        self.dt = TimeDelta(3600.0, format='sec')

        self.airmass_list = []
        self.time_list = []
        self.step = 0
        self.end_step = 11
Ejemplo n.º 9
0
    def __cond_distance_source(self, label, r, dp_dr):
        """Plot of the conditional distance distribution  along the line of sight."""
        
        # (re)initialization: skymap
        self.user = UserValues() 
        skymap=self.user.get_skymap()
        
        fig, ax = plt.subplots()

        ax.plot(r, dp_dr)
        title_string = label + ':' + ' '+ ' \n conditional distance distribution along the line of sight \n' + '['+skymap+']'
        ax.set_title(title_string,fontsize=10)
        ax.set_xlabel('distance (Mpc)')
        ax.set_ylabel('prob Mpc$^{-1}$')

        plt.show()
Ejemplo n.º 10
0
    import tkMessageBox
    import tkFont
except ImportError:
    from tkinter import *
    from tkinter import font, messagebox

import healpy as hp
import numpy as np

from aladinSAMP import AladinScriptCommands
aladin = AladinScriptCommands()

from config_values import UserValues

# global variable: level of trasparency window
user = UserValues()
trasparency = user.get_win_trasparency()


class LoadSkymap(Toplevel):
    """Loading a new skymap."""
    def __init__(self):
        Toplevel.__init__(self, border=8, bg="slate grey")

        self.user = UserValues()

        # get trasparency windows
        self.wait_visibility()
        self.wm_attributes('-alpha', trasparency)

        self.title("Load a new skymap")
Ejemplo n.º 11
0
    def __init__(self):
        Toplevel.__init__(self, border=8, bg="slate grey")

        self.user = UserValues()
        self.moc = MOC_confidence_region()

        self.observatory = astropy.coordinates.EarthLocation(
            lat=self.user.get_latitude() * u.deg,
            lon=self.user.get_longitude() * u.deg,
            height=self.user.get_altitude() * u.m)

        self.wait_visibility()
        self.wm_attributes('-alpha', 0.8)  # transparency

        self.title("Observability" + "starting from" +
                   self.user.get_obs_time())
        self.attributes("-topmost", True)

        self.bttn_clicks = 0  # counter ">>" Button

        # first label
        self.label_1 = Label(self,
                             text="Show the region in the",
                             bg="slate grey")
        self.label_1.grid(row=0, column=0, sticky=E, padx=0)

        moc_value = 90  # default
        moc_default = StringVar(self, value=moc_value)

        self.entry_percentage = Entry(self,
                                      width=5,
                                      justify=CENTER,
                                      textvariable=moc_default)
        self.entry_percentage.grid(row=0, padx=2, column=1)

        # second label
        self.label_2 = Label(self,
                             text="% MOC in which the airmass is ≤",
                             bg="slate grey")
        self.label_2.grid(row=0, column=2, sticky=E, pady=0)

        airmass_value = "2.5"  # default
        airmass_default = StringVar(self, value=airmass_value)

        self.entry_airmass = Entry(self,
                                   width=5,
                                   justify=CENTER,
                                   textvariable=airmass_default)
        self.entry_airmass.grid(row=0, padx=2, column=3)

        #Btn
        self.show = Button(self, text='Show', command=self.moc_obs)
        self.show.grid(column=4, row=0, sticky=W, padx=2, pady=5)

        #self.moon = Button(self, text="Sun/Moon",
        #                    command=self.close_window)
        #self.moon.grid(column=5,row=0, sticky=W, padx=2, pady=5)

        self.forward = Button(self, text=">>", command=self.moc_obs_update)
        self.forward.grid(column=6, row=0, sticky=E, padx=2, pady=5)

        self.close = Button(self, text="Close", command=self.close_window)
        self.close.grid(column=7, row=0, sticky=E, padx=2, pady=5)