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
import pickle # Python 3 support try: from Tkinter import * 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()
class Moon(object): 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 def get_location(self): observatory = astropy.coordinates.EarthLocation( lat=self.latitude * u.deg, lon=self.longitude * u.deg, height=self.altitude * u.m) return observatory def get_time(self): self.time = Time(self.obs_time) return self.time def moon_on_sky(self): self.get_location() #self.get.time() self.sky_position() def steps(self): """Moon position in step of one hour for an input sky position (ra, dec). 10 steps are performed: step <10; dt = 1h.""" #obs_time = Time(self.obs_time) self.aladin.draw_newtool("Moon") self.time = Time(self.obs_time) self.observatory = self.get_location() while self.step < self.end_step: time_update = self.time + self.step * self.dt position_moon = get_moon(time_update, self.observatory) #val = self.airmass(ra, dec, self.altitude, self.longitude, self.altitude, # time_input) #self.airmass_list.append(val) #self.time_list.append(str(time_input)) self.step += 1 self.aladin.draw_string(position_moon.ra, position_moon.dec, "MOON" + "-->" + str(time_update.isot)) #print str(time_update.isot) #print position_moon.ra, position_moon.ra def illumination(self): """Return the fraction of the moon illumination. Modified version of astroplan project.""" sun = get_sun(self.obs_time) observatory = self.get_location() moon = get_moon(self.obs_time, observatory) #print moon elongation = sun.separation(moon) i = np.arctan2(sun.distance * np.sin(elongation), moon.distance - sun.distance * np.cos(elongation)) k = (1 + np.cos(i)) / 2.0 return round(k.value, 2) def from_fov(self, ra_fov_center, dec_fov_center): """ Return the Moon position over the sky.""" observatory = self.get_location() moon = get_moon(self.obs_time, observatory) distance = Utils.separation(ra_fov_center, dec_fov_center, moon.ra, moon.dec) #print moon.ra*u.deg, moon.dec*u.deg return distance.deg def sky_position(self): """Plot the Moon position on the Aladin plane.""" time = Time(self.obs_time) observatory = self.get_location() position_moon = get_moon(time, observatory) illumination = self.illumination() #self.aladin.draw_string(position_moon.ra, position_moon.dec, "MOON position") self.aladin.draw_moon(position_moon.ra, position_moon.dec, illumination)
import healpy as hp import numpy as np import json import time import pickle from astropy.vo.samp import SAMPHubError # no work in py3 from astropy.time import Time from astropy.io.votable import parse from astropy.io.votable.tree import VOTableFile, Resource, Field, Param from astropy.utils.data import download_file from aladinSAMP import AladinViaSAMP, AladinScriptCommands # class access samp = AladinViaSAMP() aladin = AladinScriptCommands() class UserInput(object): """Insert user values at the command prompt to create the configuration files.""" def __init__(self): """ skymap : a valid LVC skymap in healpix format; prob_contours : a valid probability contours file in json format; fov_width : field-of-view width in degrees; fov_height : field-of-view height in degrees; fov_radius : field-of-view radius in degrees; latitude : Geodetic coordinates of the Observatory [deg]; longitude : " [deg]; altitude : " [m]; obs_time : starting time yyyy-mm-dd hh:mm:ss;
import astropy from astropy import units as u from astropy.time import Time, TimeDelta from astropy.coordinates import SkyCoord, EarthLocation, AltAz from astropy.table import Table import numpy as np #import healpy as hp # fatto i moc puoi togliere #from scipy.stats import norm from mocpy import MOC from aladinSAMP import AladinScriptCommands #samp = AladinViaSAMP() # potresti toglierlo, ereditato da aladin cone jupyter aladin = AladinScriptCommands() aladin.setconf_icrsd() # setting ICRSd from config_values import UserValues from lvc_skymap import LVCskymap from query import Query from airmass import Airmass from moon import Moon from moc_region import MOC_confidence_region from utils import Utils Utils.create_folders(folders=["Queries", "Coords", "FoV"]) Utils.load_user_fov("GWsky_fov.vot")
import healpy as hp import numpy as np import json import time import pickle from astropy.vo.samp import SAMPHubError # no work in py3 from astropy.time import Time from astropy.io.votable import parse from astropy.io.votable.tree import VOTableFile, Resource, Field, Param from astropy.utils.data import download_file from aladinSAMP import AladinViaSAMP, AladinScriptCommands # class access samp = AladinViaSAMP() aladin = AladinScriptCommands() class UserInput(object): """Insert user values at the command prompt to create the configuration files.""" def __init__(self): """ skymap : a valid LVC skymap in healpix format; prob_contours : a valid probability contours file in json format; fov_width : field-of-view width in degrees; fov_height : field-of-view height in degrees; fov_radius : field-of-view radius in degrees; latitude : Geodetic coordinates of the Observatory [deg]; longitude : " [deg]; altitude : " [m];
def contour_default(self, _from, _to, _step, skymap=""): """Creating & Showing MOC plots (from 10% to 90% in step of 10%) in a folder.""" import time from aladinSAMP import AladinScriptCommands aladin = AladinScriptCommands() colors = [ "#ff0000", "#ffaa00 ", "#aaff00", "#00ff00", "#00ffa9", "#00a9ff", "#0000ff", "#aa00ff", "#ff00aa" ] # skymap viewer color #short_name = skymap suffix = skymap[0:] aladin.md('MOC' + suffix) # creating a stack folder aladin.remove('MOC' + suffix + '~1') # removing multiple copy of the folder for i, color in zip(np.arange(_from, _to, _step), colors): aladin.cmoc((i / 100.0), skymap, 'moc' + str(i / 100.0) + suffix) time.sleep(1) # random break to organize the aladin planes plane = 'moc' + str(i / 100.0) + suffix aladin.set_color(plane, color) aladin.set_moc('moc' + str(i / 100.0) + suffix) aladin.mv('moc' + str(i / 100.0) + suffix, 'MOC' + suffix)