text stringlengths 81 112k |
|---|
r"""Initialize and return immutable Settings dictionary.
Settings dictionary allows you to setup settings values from multiple
sources and make sure that values cannot be changed, updated by anyone else
after initialization. This helps keep things clear and not worry about
hidden settings change somewh... |
Inject settings values to given context.
:param mixed:
Settings can be a string (that it will be read from Python path),
Python module or dict-like instance.
:param context:
Context to assign settings key values. It should support dict-like item
assingment.
:param fail_silen... |
Iterate over settings values from settings module or dict-like instance.
:param mixed: Settings instance to iterate.
def iter_settings(mixed: Settings) -> Iterator[Tuple[str, Any]]:
"""Iterate over settings values from settings module or dict-like instance.
:param mixed: Settings instance to iterate.
... |
Shortcut helper to setup locale for backend application.
:param lc_all: Locale to use.
:param first_weekday:
Weekday for start week. 0 for Monday, 6 for Sunday. By default: None
:param lc_collate: Collate locale to use. By default: ``<lc_all>``
:param lc_ctype: Ctype locale to use. By default: ... |
Shortcut helper to configure timezone for backend application.
:param timezone: Timezone to use, e.g. "UTC", "Europe/Kiev".
def setup_timezone(timezone: str) -> None:
"""Shortcut helper to configure timezone for backend application.
:param timezone: Timezone to use, e.g. "UTC", "Europe/Kiev".
"""
... |
Read through the HISTORY cards in an image header looking for detrend
input lines.
Detrend inputs are given on lines like:
HISTORY imcombred: file_id
We require that the value in file_id be store in the CADC archive before
adding to the inputs list.
def inputs(header):
"""Read through the HIS... |
Takes an elixir style file name and decodes it's content.
Values returned as a dictionary. Elixir filenames have the format
RUNID.TYPE.FILTER/EXPTIME.CHIPID.VERSION.fits
def elixir_decode(elixir_filename):
"""
Takes an elixir style file name and decodes it's content.
Values returned as a diction... |
Create a file an MEF fits file called filename. Generate a random
filename if None given
def create_mef(filename=None):
"""
Create a file an MEF fits file called filename. Generate a random
filename if None given
"""
import pyfits, time
if not filename:
### here I know what filen... |
Remove the padding lines that CFHT adds to headers
def strip_pad(hdu):
"""Remove the padding lines that CFHT adds to headers"""
l = hdu.header.ascardlist()
d = []
for index in range(len(l)):
if l[index].key in __comment_keys and str(l[index])==__cfht_padding:
d.append(index)
... |
Stick infiles into outfiles as FITS extensions.
outfile willl contain an MEF format file of the single extension FITS
files named in the infiles array
def stack(outfile,infiles,verbose=0):
"""
Stick infiles into outfiles as FITS extensions.
outfile willl contain an MEF format file of the single e... |
Use get a fits image from the CADC.
def adGet(file_id, archive="CFHT", extno=None, cutout=None ):
"""Use get a fits image from the CADC."""
import os, string, re,urllib
#proxy="http://www1.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/authProxy/getData"
proxy="http://test.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/aut... |
Opens a FITS format file and calls _open_fix if header doesn't
verify correctly.
def _open(file,mode='copyonwrite'):
"""Opens a FITS format file and calls _open_fix if header doesn't
verify correctly.
"""
import pyfits
try:
infits=pyfits.open(file,mode)
hdu=infits
except... |
Search the HISTORY fields of a header looking for the FLIPS
processing date.
def find_proc_date(header):
"""Search the HISTORY fields of a header looking for the FLIPS
processing date.
"""
import string, re
for h in header.ascardlist():
if h.key=="HISTORY":
g=h.value
... |
Search through header and find
the elixir formated string(s) that match the the
input 'type'.
header is a FITS HDU.
Elixir formated strings are crunid.type.filter/exptime.chipid.version.
def find_detrend_keyword(header, type):
"""Search through header and find
the elixir formated string(s) tha... |
Takes in a fits file name, open the file in binary mode and creates an HDU.
Will attempt to fix some of the header keywords to match the standard FITS format.
def _open_fix(file):
"""Takes in a fits file name, open the file in binary mode and creates an HDU.
Will attempt to fix some of the header keyword... |
Send a query to the SSOS web service, looking for available observations using the given track.
:param mpc_observations: a list of mpc.Observations
:param lunation_count: how many dark runs (+ and -) to search into
:return: an SSOSData object
:rtype: SSOSData
def query_ssos(self, mpc_o... |
Send a query to the SSOS web service, looking for available observations using the given track.
:param target_name: name of target to query against SSOIS db
:param lunation_count: ignored
:rtype: SSOSData
def query_ssos(self, target_name, lunation_count=None):
"""Send a query to the SS... |
Build an astrom.Observation object for a SourceReading
:param expnum: (str) Name or CFHT Exposure number of the observation.
:param ccd: (str) CCD is this observation associated with. (can be None)
:param ftype: (str) exposure time (specific to CFHT imaging)
:return: An astrom.Observat... |
given the result table create 'source' objects.
:param ssos_result_filename_or_lines:
:param mpc_observations: a list of mpc.Observation objects used to retrieve the SSOS observations
def parse(self, ssos_result_filename_or_lines, mpc_observations=None):
"""
given the result table crea... |
:type search_end_date: astropy.io.Time
:param search_end_date: search for frames take after the given date.
def search_end_date(self, search_end_date):
"""
:type search_end_date: astropy.io.Time
:param search_end_date: search for frames take after the given date.
"""
ass... |
:return: A dictionary of SSOS query parameters.
:rtype: dict
def params(self):
"""
:return: A dictionary of SSOS query parameters.
:rtype: dict
"""
params = dict(format=RESPONSE_FORMAT,
verbose=self.verbose,
epoch1=str(self.sea... |
:return: A string containing the TSV result from SSOS
:rtype: str
:raise: AssertionError
def get(self):
"""
:return: A string containing the TSV result from SSOS
:rtype: str
:raise: AssertionError
"""
params = self.param_dict_builder.params
logger... |
Over-rides normal behaviour of shifting focus to any child. Prefers
the one set explicityly by use_as_focus.
:param **kwargs:
def SetFocus(self, **kwargs):
"""
Over-rides normal behaviour of shifting focus to any child. Prefers
the one set explicityly by use_as_focus.
... |
run the actual step3 on the given exp/ccd combo
def step3(expnums, ccd, version, rate_min,
rate_max, angle, width, field=None, prefix=None, dry_run=False,
maximum_flux_ratio=3, minimum_area=5, minimum_median_flux=1000.0):
"""run the actual step3 on the given exp/ccd combo"""
jmp_args = [... |
Given an instance, and under the assumption that member variables have the
same name as the __init__ arguments, extract the arguments so they can
be used to reconstruct the instance when deserializing
def extract_init_args(instance):
"""
Given an instance, and under the assumption that member variables... |
Display list of choices. As many as we can get in a page.
def list(self,header,choices):
"Display list of choices. As many as we can get in a page."
if not self.__list_window:
(y,x)=self.__main.getmaxyx()
self.__list_window = self.__main.subwin(35,x,0,0)
... |
Reset the reference position values to correspond to the center
of the reference frame.
Algorithm used here developed by Colin Cox - 27-Jan-2004.
def recenter(self):
"""
Reset the reference position values to correspond to the center
of the reference frame.
Algorithm use... |
Builds a new keyword based on original keyword name and
a prepend string.
def _buildNewKeyname(self,key,prepend):
""" Builds a new keyword based on original keyword name and
a prepend string.
"""
if len(prepend+key) <= 8: _new_key = prepend+key
else: _new_key = ... |
Makes a (deep)copy of this object for use by other objects.
def copy(self,deep=yes):
""" Makes a (deep)copy of this object for use by other objects.
"""
if deep:
return copy.deepcopy(self)
else:
return copy.copy(self) |
Pull the three images and then scramble the MJD-OBS keywords
def scrambleTriples(expnums,ccd):
"""Pull the three images and then scramble the MJD-OBS keywords"""
import pyfits, MOPfits
mjd=[]
fid=[]
fs=[]
filenames=[]
for expnum in expnums:
if int(ccd)<18:
cutout="[-*,-*... |
Pull the three images and then scramble the MJD-OBS keywords
def getTriples(expnums,ccd):
"""Pull the three images and then scramble the MJD-OBS keywords"""
import pyfits, MOPfits
filenames=[]
for expnum in expnums:
if int(ccd)<18:
cutout="[-*,-*]"
else:
cutout="... |
Given a list of exposure numbers, find all the KBOs in that set of exposures
def searchTriples(filenames,plant=False):
"""Given a list of exposure numbers, find all the KBOs in that set of exposures"""
print filenames
if opt.none :
return
import MOPfits,os
import MOPdbaccess
import ... |
Ushort a the pixels
def ushort(filename):
"""Ushort a the pixels"""
import pyfits
f=pyfits.open(filename,mode='update')
f[0].scale('int16','',bzero=32768)
f.flush()
f.close() |
Parses a file into an AstromData structure.
Args:
filename: str
The name of the file whose contents will be parsed.
Returns:
data: AstromData
The file contents extracted into a data structure for programmatic
access.
def parse(self, filename):
... |
See src/pipematt/step1matt-c
def _write_observation_headers(self, observations):
"""
See src/pipematt/step1matt-c
"""
for observation in observations:
header = observation.header
def get_header_vals(header_list):
header_vals = []
... |
See src/pipematt/step3matt-c
def _write_sys_header(self, sys_header):
"""
See src/pipematt/step3matt-c
"""
header_vals = [sys_header[RMIN], sys_header[RMAX], sys_header[ANGLE],
sys_header[AWIDTH]]
self._write_line("## RMIN RMAX ANGLE AWIDTH")
... |
See src/jjk/measure3
def _write_source_data(self, sources):
"""
See src/jjk/measure3
"""
for i, source in enumerate(sources):
self._write_source(source) |
Writes the header part of the astrom file so that only the source
data has to be filled in.
def write_headers(self, observations, sys_header):
"""
Writes the header part of the astrom file so that only the source
data has to be filled in.
"""
if self._header_written:
... |
Writes out data for a single source.
def write_source(self, source):
"""
Writes out data for a single source.
"""
if not self._header_written:
observations = [reading.get_observation() for reading in source.get_readings()]
self.write_headers(observations, self.sy... |
Writes a full AstromData structure at once.
def write_astrom_data(self, astrom_data):
"""
Writes a full AstromData structure at once.
"""
self.write_headers(astrom_data.observations, astrom_data.sys_header)
self._write_source_data(astrom_data.sources) |
Return x/y in the original frame, based on a guess as much as anything.
:param x: x pixel coordinate
:type x: float
:param y: y pixel coordinate
:type y: float
:return: x,y
:rtype: float, float
def _original_frame(self, x, y):
"""
Return x/y in the origin... |
:type pix_coord: list
:param pix_coord: an x,y pixel coordinate, origin = 1
def pix_coord(self, pix_coord):
"""
:type pix_coord: list
:param pix_coord: an x,y pixel coordinate, origin = 1
"""
try:
pix_coord = list(pix_coord)
except:
pass
... |
The location of the source in the reference image, in terms of the
current image coordinates.
def reference_source_point(self):
"""
The location of the source in the reference image, in terms of the
current image coordinates.
"""
xref = isinstance(self.xref, Quantity) an... |
Calculates the offsets between readings' coordinate systems.
Args:
other_reading: ossos.astrom.SourceReading
The reading to compare coordinate systems with.
Returns:
(offset_x, offset_y):
The x and y offsets between this reading and the other reading's
... |
Returns:
inverted: bool
True if the stored image is inverted.
def compute_inverted(self):
"""
Returns:
inverted: bool
True if the stored image is inverted.
"""
# astheader = storage.get_astheader(self.obs.expnum, self.obs.ccdnum, version=self.... |
Given the location of a source in the image, create an Observation.
def from_source_reference(expnum, ccd, x, y):
"""
Given the location of a source in the image, create an Observation.
"""
image_uri = storage.dbimages_uri(expnum=expnum,
ccd=Non... |
Writes out data for a single source.
def write_source(self, source, comment=None, reject=False):
"""
Writes out data for a single source.
"""
if not self._header_written:
observations = [reading.get_observation() for reading in source.get_readings()]
self.write_h... |
Convert Modfied Juian Date (JD = 2400000.5) to GMST
Taken from P.T. Walace routines.
def mjd2gmst(mjd):
"""Convert Modfied Juian Date (JD = 2400000.5) to GMST
Taken from P.T. Walace routines.
"""
tu = (mjd - MJD0) / (100*DPY)
st = math.fmod(mjd, 1.0) * D2PI + (24110.54841 + (864018... |
Compute the norm of the gradients for each sample in a batch, and
penalize anything on either side of unit norm
def _gradient_penalty(self, real_samples, fake_samples, kwargs):
"""
Compute the norm of the gradients for each sample in a batch, and
penalize anything on either side of unit... |
Compute the RA/DEC of the line based on the X/Y in the comment and the WCS of the associated image.
Comment of supplied astrometric line (mpc_in) must be in OSSOSComment format.
@param mpc_in: An line of astrometric measurement to recompute the RA/DEC from the X/Y in the comment.
@type mpc_in: mp_ephem.Ob... |
Wrap a call to func in a try/except that repeats on ConnectionError
@param func:
@param args:
@param kwargs:
@return:
def _connection_error_wrapper(func, *args, **kwargs):
"""
Wrap a call to func in a try/except that repeats on ConnectionError
@param func:
@param args:
@param kwargs... |
Get the mag of the object given the mp_ephem.ephem.Observation
def recompute_mag(mpc_in, skip_centroids=False):
"""
Get the mag of the object given the mp_ephem.ephem.Observation
"""
# TODO this really shouldn't need to build a 'reading' to get the cutout...
from ossos.downloads.cutouts import dow... |
Compare the orbit fit given the oringal and modified astrometry.
def compare_orbits(original_obs, modified_obs, cor_file):
"""Compare the orbit fit given the oringal and modified astrometry."""
origin = orbfit.Orbfit(original_obs)
modified = orbfit.Orbfit(modified_obs)
orbpt = file(cor_file+".orb", '... |
Return this instance summed to mono. If the instance is already mono,
this is a no-op.
def mono(self):
"""
Return this instance summed to mono. If the instance is already mono,
this is a no-op.
"""
if self.channels == 1:
return self
x = self.sum(axi... |
Return audio samples encoded as bytes given a particular audio format
Args:
flo (file-like): A file-like object to write the bytes to. If flo
is not supplied, a new :class:`io.BytesIO` instance will be
created and returned
fmt (str): A libsndfile-friendl... |
Append defaults from schema to instance need to be validated.
:param validator_class: Apply the change for given validator class.
def extend_with_default(validator_class: Any) -> Any:
"""Append defaults from schema to instance need to be validated.
:param validator_class: Apply the change for given valid... |
Compute weights, given a scale or time-frequency representation
:param other: A time-frequency representation, or a scale
:return: a numpy array of weights
def weights(self, other):
"""
Compute weights, given a scale or time-frequency representation
:param other: A time-frequenc... |
:param fk_candidate_observations: name of the fk*reals.astrom file to check against Object.planted
def rates_angles(fk_candidate_observations):
"""
:param fk_candidate_observations: name of the fk*reals.astrom file to check against Object.planted
"""
detections = fk_candidate_observations.get_sources(... |
Downloads a FITS image as a HDUList.
Args:
uri: The URI of the FITS image to download.
kwargs: optional arguments to pass to the vos client.
For example, passing view="cutout" and cutout=[1] will result
in a cutout of extension 1 from the FITS image specified by the
... |
Downloads apcor data.
Args:
uri: The URI of the apcor data file.
Returns:
apcor: ossos.downloads.core.ApcorData
def download_apcor(self, uri):
"""
Downloads apcor data.
Args:
uri: The URI of the apcor data file.
Returns:
apcor:... |
Creates an ApcorData record from the raw string format.
Expected string format:
ap_in ap_out ap_cor apcor_err
def from_string(cls, rawstr):
"""
Creates an ApcorData record from the raw string format.
Expected string format:
ap_in ap_out ap_cor apcor_err
"... |
Run the OSSOS jmpmakepsf script.
def run(expnum, ccd, version, dry_run=False, prefix="", force=False):
"""Run the OSSOS jmpmakepsf script.
"""
message = storage.SUCCESS
if storage.get_status(task, prefix, expnum, version=version, ccd=ccd) and not force:
logging.info("{} completed successfully... |
Run the OSSOS mopheader script.
def run(expnum, ccd, version, dry_run=False, prefix="", force=False, ignore_dependency=False):
"""Run the OSSOS mopheader script.
"""
message = storage.SUCCESS
logging.info("Attempting to get status on header for {} {}".format(expnum, ccd))
if storage.get_status(tas... |
Compute htm index of htm_level at position ra,dec
def htmIndex(ra,dec,htm_level=3):
"""Compute htm index of htm_level at position ra,dec"""
import re
if os.uname()[0] == "Linux": javabin = '/opt/java2/bin/java '
htm_level = htm_level
verc_htm_cmd = javabin+'-classpath /usr/cadc/misc/htm/htmIndex.ja... |
Convert an RA/DEC/RADIUS to an imcopy cutout
def circTOcutout(wcs,ra,dec,rad):
"""Convert an RA/DEC/RADIUS to an imcopy cutout"""
(x1,y1)=wcs.rd2xy((ra+rad/2.0,dec-rad/2.0))
(x2,y2)=wcs.rd2xy((ra-rad/2.0,dec+rad/2.0))
xl=min(x1,x2)
xr=max(x1,x2)
yl=min(y1,y2)
yu=max(y1,y2)
### cons... |
Run GB's predict using an ABG file as input.
def predict(abg,date,obs=568):
"""Run GB's predict using an ABG file as input."""
import orbfit
import RO.StringUtil
(ra,dec,a,b,ang) = orbfit.predict(abg,date,obs)
obj['RA']=ra
obj['DEC']=dec
obj['dRA']=a
obj['dDEC']=b
obj['dANG']=ang
... |
Configure the logging given the level desired
def config_logging(level):
"""
Configure the logging given the level desired
"""
logger = logging.getLogger('')
logger.setLevel(level)
if level < logging.DEBUG:
log_format = "%(asctime)s %(message)s"
else:
log_format = "%(asctim... |
Run a subprocess, check for .OK and raise error if does not exist.
args: list of arguments, for value is the command to execute.
def exec_prog(args):
"""Run a subprocess, check for .OK and raise error if does not exist.
args: list of arguments, for value is the command to execute.
"""
program_... |
Return the x/y pixel boundaries of the data section.
:param datasec: str e.g. '[33:2080,1:4612]'
:return: ((xmin,xmax),(ymin,ymax))
def get_pixel_bounds_from_datasec_keyword(datasec):
"""
Return the x/y pixel boundaries of the data section.
:param datasec: str e.g. '[33:2080,1:4612]'
:return: (... |
Given two sets of x/y positions match the lists, uniquely.
:rtype : numpy.ma, numpy.ma
:param pos1: list of x/y positions.
:param pos2: list of x/y positions.
:param tolerance: float distance, in pixels, to consider a match
Algorithm:
- Find all the members of pos2 that are within toleranc... |
the stream to write the log content too.
@return:
def stream(self):
"""
the stream to write the log content too.
@return:
"""
if self._stream is None:
self._stream = tempfile.NamedTemporaryFile(delete=False)
try:
self._stream.write(... |
Send back the client we were sent, or construct a default one.
@rtype vospace.client
def client(self):
"""
Send back the client we were sent, or construct a default one.
@rtype vospace.client
"""
if self._client is not None:
return self._client
self... |
Closes the stream.
def close(self):
"""
Closes the stream.
"""
self.flush()
try:
if self.stream is not None:
self.stream.flush()
_name = self.stream.name
self.stream.close()
self.client.copy(_name, self.... |
Read time from a single string, using a set of possible formats.
def parse_string(self, timestr, subfmts):
"""Read time from a single string, using a set of possible formats."""
# Datetime components required for conversion to JD by ERFA, along
# with the default values.
components = ('... |
Generator that yields a dict of values corresponding to the
calendar date and time for the internal JD values.
def str_kwargs(self):
"""
Generator that yields a dict of values corresponding to the
calendar date and time for the internal JD values.
"""
iys, ims, ids, ihms... |
Parse through a command line of arguments to over-ride the values
in the users .dbrc file.
If no user name is given then the environment variable $USERNAME is
used. If $USERNAME is not defined then prompt for input.
def _get_db_options(args):
"""Parse through a command line of arguments to over-ride t... |
Read through the users .dbrc file to get password for the db/user
combination suplied. If no password is found then prompt for one
def _get_db_password(dbSystem,db,user):
"""Read through the users .dbrc file to get password for the db/user
combination suplied. If no password is found then prompt for one
... |
Create a connection to the database specified on the command line
def _get_db_connect(dbSystem,db,user,password):
"""Create a connection to the database specified on the command line
"""
if dbSystem=='SYBASE':
import Sybase
try:
dbh = Sybase.connect(dbSystem,
... |
builds a TSV file in the format of SSOIS by querying for possilbe observations in CADC/CAOM2.
This is a fall back program, should only be useful when SSOIS is behind.
def caom2(mpc_filename, search_date="2014 07 24.0"):
"""
builds a TSV file in the format of SSOIS by querying for possilbe observations in ... |
Downloads a cutout of the FITS image for a given source reading.
Args:
reading: ossos.astrom.SourceReading
The reading which will be the focus of the downloaded image.
focus: tuple(int, int)
The x, y coordinates that should be the focus of the downloaded
... |
Load the targets from a file.
def load_objects(self, directory_name=None):
"""Load the targets from a file.
"""
# for name in Neptune:
# self.kbos[name] = Neptune[name]
if directory_name is not None:
# defaults to looking at .ast files only
if direc... |
convert from plot to canvas coordinates.
See also c2p.
def p2c(self, p=None):
"""convert from plot to canvas coordinates.
See also c2p."""
if p is None:
p = [0, 0]
x = (p[0] - self.x1) * self.xscale + self.cx1
y = (p[1] - self.y1) * self.yscale + self.cy1
... |
Convert from plot to screen coordinates
def p2s(self, p=None):
"""Convert from plot to screen coordinates"""
if not p: p = [0, 0]
s = self.p2c(p)
return self.c2s(s) |
Convert from canvas to screen coordinates
def c2s(self, p=None):
"""Convert from canvas to screen coordinates"""
if not p:
p = [0, 0]
return p[0] - self.canvasx(self.cx1), p[1] - self.canvasy(self.cy2) |
Return the RA/DEC of the center of the visible Canvas.
def centre(self):
"""Return the RA/DEC of the center of the visible Canvas."""
return self.p2s(self.canvasx(self.width / 2.0)), self.p2s(self.canvasy(self.height / 2.0)) |
Draw a grid of RA/DEC on Canvas.
def coord_grid(self):
"""Draw a grid of RA/DEC on Canvas."""
ra2 = math.pi * 2
ra1 = 0
dec1 = -1 * math.pi / 2.0
dec2 = math.pi / 2.0
dra = math.fabs((self.x2 - self.x1) / 4.0)
ddec = math.fabs((self.y2 - self.y1) / 4.0)
... |
Draw a line of size and orientation at x,y
def tickmark(self, x, y, size=10, orientation=90):
"""Draw a line of size and orientation at x,y"""
(x1, y1) = self.p2c([x, y])
x2 = x1 + size * math.cos(math.radians(orientation))
y2 = y1 - size * math.sin(math.radians(orientation))
s... |
Set the coordinate boundaries of plot
def limits(self, x1, x2, y1, y2):
"""Set the coordinate boundaries of plot"""
self.x1 = x1
self.x2 = x2
self.y1 = y1
self.y2 = y2
self.xscale = (self.cx2 - self.cx1) / (self.x2 - self.x1)
self.yscale = (self.cy2 - self.cy1) ... |
Expand to the full scale
def reset(self):
"""Expand to the full scale"""
sun = ephem.Sun()
this_time = Time(self.date.get(), scale='utc')
sun.compute(this_time.iso)
self.sun = Coord((sun.ra, sun.dec))
self.doplot()
self.plot_pointings() |
Put this object in the search box
def updateObj(self, event):
"""Put this object in the search box"""
name = self.objList.get("active")
self.SearchVar.set(name)
self.object_info.set(str(self.kbos.get(name, '')))
return |
Move to the position of self.SearchVar
def relocate(self):
"""Move to the position of self.SearchVar"""
name = self.SearchVar.get()
if self.kbos.has_key(name):
kbo = self.kbos[name]
assert isinstance(kbo, orbfit.Orbfit)
this_time = Time(self.date.get(), scal... |
Zoom in
def zoom(self, event=None, scale=2.0):
"""Zoom in"""
# compute the x,y of the center of the screen
sx1 = (self.cx1 + self.cx2) / 2.0
sy1 = (self.cy1 + self.cy2) / 2.0
if not event is None:
logging.debug("EVENT: {},{}".format(event.x, event.y))
s... |
Plot a circle of size at this x,y location
def create_point(self, xcen, ycen, size=10, color='red', fill=None):
"""Plot a circle of size at this x,y location"""
if fill is None:
fill = color
(x, y) = self.p2c((xcen, ycen))
x1 = x - size
x2 = x + size
y1 = y... |
set the color of the currently selected pointing to 'blue
def current_pointing(self, index):
"""set the color of the currently selected pointing to 'blue'"""
if self.current is not None:
for item in self.pointings[self.current]['items']:
self.itemconfigure(item, outline="bla... |
Delete the currently active pointing
def delete_pointing(self, event):
"""Delete the currently active pointing"""
if self.current is None:
return
for item in self.pointings[self.current]['items']:
self.delete(item)
self.delete(self.pointings[self.current]['label... |
Load some pointings
def load_pointings(self, filename=None):
"""Load some pointings"""
filename = ( filename is None and tkFileDialog.askopenfilename() or filename)
if filename is None:
return
f = storage.open_vos_or_local(filename)
lines = f.readlines()
f... |
Plot the sky coverage of pointing at event.x,event.y on the canvas.
def create_pointing(self, event, label_text=None):
"""Plot the sky coverage of pointing at event.x,event.y on the canvas.
"""
x = self.canvasx(event.x)
y = self.canvasy(event.y)
(ra, dec) = self.c2p((x, y))
... |
Plot pointings on canavs
def plot_pointings(self, pointings=None):
"""Plot pointings on canavs"""
if pointings is None:
pointings = self.pointings
i = 0
for pointing in pointings:
items = []
i = i + 1
label = {}
label['text']... |
Let the label of the current pointing to the value in the plabel box
def set_pointing_label(self):
"""Let the label of the current pointing to the value in the plabel box"""
current = self.current
pointing = self.pointings[current]
self.delete_pointing(None)
pointing["label"]['... |
Grab nearest pointing to event.x,event.y and with cursor
def move_pointing(self, event):
"""Grab nearest pointing to event.x,event.y and with cursor"""
(ra, dec) = self.c2p((self.canvasx(event.x),
self.canvasy(event.y)))
closest = None
this_pointing = None... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.