Load some pointings
195476
def load_pointings(self, filename=None):
        """"""

        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.close()
        points = []
        if lines[0][0:5] == "<?xml":
            # ## assume astrores format
            # ## with <DATA at start of 'data' segment
            for i in range(len(lines)):
                if lines[i][0:5] == '<DATA':
                    break
            for j in range(i + 5, len(lines)):
                if lines[j][0:2] == "]]":
                    break
                vs = lines[j].split('|')
                points.append(vs)
        elif lines[0][0:5] == 'index':
            # ## Palomar Format
            # ## OK.. ID/NAME/RA /DEC format
            v = lines[0].split()
            if len(v) == 2 :
                date = v[1]
                self.date.set(v[1])
                self.reset()
            for line in lines:
                if line[0] == '!' or line[0:5] == 'index':
                    # index is a header line for Palomar
                    continue
                d = line.split()
                if len(d) < 9:
                    sys.stderr.write("Don't understand pointing format\n%s\n" % line)
                    continue
                ras = "%s:%s:%s" % (d[2], d[3], d[4])
                decs = "%s:%s:%s" % (d[5], d[6], d[7])
                points.append((d[1].strip(), ras, decs))
        elif lines[0][0:5] == "#SSIM":
            # ## Survey Simulator format
            for line in lines[1:]:
                d = line.split()
                points.append((d[8], d[2], d[3]))
        else:
            # ## try name/ ra /dec / epoch
            for line in lines:
                d = line.split()
                if len(d) == 5:  # brave assumption time!
                    # self.pointing_format = 'Subaru'  # unfortunately this doesn't seem to do anything, & breaks save
                    pointing_name = d[0].split('=')[0]
                    # oh grief these are sexagecimal with no separators. WHY
                    ra = d[1].split('=')[1]
                    dec = d[2].split('=')[1]
                    if len(ra.split('.')[0]) == 5:  # LACK OF SEPARATORS ARGH
                        ra = '0' + ra
                    if len(dec.split('.')[0]) == 5:
                        dec = '0' + dec
                    ra = "{}:{}:{}".format(ra[0:2], ra[2:4], ra[4:])
                    dec = "{}:{}:{}".format(dec[0:2], dec[2:4], dec[4:])
                    points.append((pointing_name, ra, dec))
                elif len(d) == 4:
                    f = d[1].count(":")
                    if ( f > 0 ):
                        points.append((d[0], d[1], d[2]))
                    else:
                        points.append(('', math.radians(float(d[1])), math.radians(float(d[2]))))
                elif len(d) == 8:
                    line = "%s %s:%s:%s %s:%s:%s %s" % (d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7] )
                    d = line.split()
                    # this one seems unfinished...no append
                else:
                    sys.stderr.write("Don't understand pointing format\n%s\n" % ( line))
                    continue

        self.plot_points_list(points)
        return
1177674
def getTriples(pointing):
    """"""

    sql="SELECT id FROM triples t join triple_members m ON t.id=m.triple"
    sql+=" join bucket.exposure e on e.expnum=m.expnum "
    sql+=" WHERE pointing=%s  group by id  order by e.expnum  "
    cfeps.execute(sql, ( pointing, ) )
    return(cfeps.fetchall())
1204769
function loadTimbits(callback) {

  var folder = path.join(config.home, "/timbits");
  var files = filteredFiles(folder, /\.(coffee|js)$/);
  var pending = files.length;
  
  files.forEach(function(file) {
    var name = file.substring(0, file.lastIndexOf("."));
    timbits.add(name, require(path.join(folder, file)), function() {
      pending--;
      if (pending === 0) callback();
    });
  });
}
1180864
def read_point_prop(self, device_name, point):
        
        with open("%s.bin" % device_name, "rb") as file:
            return pickle.load(file)["points"][point]
1231653
def save_pointings(self):
        """"""
        i = 0
        if self.pointing_format.get() in ['GEMINI ET', 'CFHT ET', 'CFHT API']:
            logging.info('Beginning table pointing save.')
            for pointing in self.pointings:
                name = pointing["label"]["text"]
                camera = pointing["camera"]
                ccds = numpy.radians(camera.geometry)
                polygons = []
                for ccd in ccds:
                    polygon = Polygon.Polygon(((ccd[0], ccd[1]),
                                               (ccd[0], ccd[3]),
                                               (ccd[2], ccd[3]),
                                               (ccd[2], ccd[1]),
                                               (ccd[0], ccd[1])))
                    polygons.append(polygon)
                et = EphemTarget(name, ephem_format=self.pointing_format.get())
                # determine the mean motion of target KBOs in this field.
                field_kbos = []
                center_ra = 0
                center_dec = 0

                pointing_date = mpc.Time(self.date.get(), scale='utc')
                start_date = mpc.Time(self.date.get(), scale='utc') - TimeDelta(8.1*units.day)
                end_date = start_date + TimeDelta(17*units.day)
                time_step = TimeDelta(3.0*units.hour)

                # Compute the mean position of KBOs in the field on current date.
                for kbo_name, kbo in self.kbos.items():
                    if kbo_name in Neptune or kbo_name in tracking_termination:
                        print 'skipping', kbo_name
                        continue
                    kbo.predict(pointing_date)
                    ra = kbo.coordinate.ra
                    dec = kbo.coordinate.dec
                    if kbo_name in name:
                        print "{} matches pointing {} by name, adding to field.".format(kbo_name, name)
                        field_kbos.append(kbo)
                        center_ra += ra.radian
                        center_dec += dec.radian
                    else:
                        for polygon in polygons:
                            if polygon.isInside(ra.radian, dec.radian):
                                print "{} inside pointing {} polygon, adding to field.".format(kbo_name, name)
                                field_kbos.append(kbo)
                                center_ra += ra.radian
                                center_dec += dec.radian

                # logging.critical("KBOs in field {0}: {1}".format(name, ', '.join([n.name for n in field_kbos])))

                today = start_date
                while today < end_date:
                    today += time_step
                    mean_motion = (0, 0)
                    max_mag = 0.0
                    if len(field_kbos) > 0:
                        current_ra = 0
                        current_dec = 0
                        for kbo in field_kbos:
                            kbo.predict(today)
                            max_mag = max(max_mag, kbo.mag)
                            current_ra += kbo.coordinate.ra.radian
                            current_dec += kbo.coordinate.dec.radian
                        mean_motion = ((current_ra - center_ra) / len(field_kbos),
                                       (current_dec - center_dec) / len(field_kbos))
                    ra = pointing['camera'].coordinate.ra.radian + mean_motion[0]
                    dec = pointing['camera'].coordinate.dec.radian + mean_motion[1]
                    cc = SkyCoord(ra=ra,
                                  dec=dec,
                                  unit=(units.radian, units.radian),
                                  obstime=today)
                    dt = pointing_date - today
                    cc.dra = (mean_motion[0] * units.radian / dt.to(units.hour)).to(units.arcsec/units.hour).value*math.cos(dec)
                    cc.ddec = (mean_motion[1] * units.radian / dt.to(units.hour)).to(units.arcsec/units.hour).value
                    cc.mag = max_mag
                    et.append(cc)

                et.save()
            return

        f = tkFileDialog.asksaveasfile()
        if self.pointing_format.get() == 'Subaru':
            for pointing in self.pointings:
                (sra, sdec) = str(pointing["camera"]).split()
                ra = sra.replace(":", "")
                dec = sdec.replace(":", "")
                name = pointing["label"]["text"]
                f.write("""{}=OBJECT="{}" RA={} DEC={} EQUINOX=2000.0 INSROT_PA=90\n""".format(name,
                                                                                               name,
                                                                                               ra,
                                                                                               dec))
            return
        if self.pointing_format.get() == 'CFHT PH':
            f.write("""<?xml version = "1.0"?>
<!DOCTYPE ASTRO SYSTEM "http://vizier.u-strasbg.fr/xml/astrores.dtd">
<ASTRO ID="v0.8" xmlns:ASTRO="http://vizier.u-strasbg.fr/doc/astrores.htx">
<TABLE ID="Table">
<NAME>Fixed Targets</NAME>
<TITLE>Fixed Targets for CFHT QSO</TITLE>
<!-- Definition of each field -->
<FIELD name="NAME" datatype="A" width="20">
   <DESCRIPTION>Name of target</DESCRIPTION>
</FIELD>
<FIELD name="RA" ref="" datatype="A" width="11" unit="&quot;h:m:s&quot;">
   <DESCRIPTION>Right ascension of target</DESCRIPTION>
</FIELD>     
<FIELD name="DEC" ref="" datatype="A" width="11" unit="&quot;d:m:s&quot;">
   <DESCRIPTION>Declination of target</DESCRIPTION>
</FIELD>     
<FIELD name="EPOCH" datatype="F" width="6">
    <DESCRIPTION>Epoch of coordinates</DESCRIPTION>
</FIELD>     
<FIELD name="POINT" datatype="A" width="5">
<DESCRIPTION>Pointing name</DESCRIPTION>
</FIELD>     
<!-- Data table --> 
<DATA><CSV headlines="4" colsep="|"><![CDATA[
NAME                |RA         |DEC        |EPOCH |POINT|
                    |hh:mm:ss.ss|+dd:mm:ss.s|      |     |
12345678901234567890|12345678901|12345678901|123456|12345|
--------------------|-----------|-----------|------|-----|\n""")
        if self.pointing_format.get() == 'Palomar':
            f.write("index\n")
        for pointing in self.pointings:
            i = i + 1
            name = pointing["label"]["text"]
            (sra, sdec) = str(pointing["camera"]).split()
            ra = sra.split(":")
            dec = sdec.split(":")
            dec[0] = str(int(dec[0]))
            if int(dec[0]) >= 0:
                dec[0] = '+' + dec[0]
            if self.pointing_format.get() == 'Palomar':
                f.write("%5d %16s %2s %2s %4s %3s %2s %4s 2000\n" % (i, name,
                                                                     ra[0].zfill(2),
                                                                     ra[1].zfill(2),
                                                                     ra[2].zfill(2),
                                                                     dec[0].zfill(3),
                                                                     dec[1].zfill(2),
                                                                     dec[2].zfill(2)))
            elif self.pointing_format.get() == 'CFHT PH':
                # f.write("%f %f\n" % (pointing["camera"].ra,pointing["camera"].dec))
                f.write("%-20s|%11s|%11s|%6.1f|%-5d|\n" % (name, sra, sdec, 2000.0, 1))
            elif self.pointing_format.get() == 'KPNO/CTIO':
                str1 = sra.replace(":", " ")
                str2 = sdec.replace(":", " ")
                f.write("%16s %16s %16s 2000\n" % ( name, str1, str2))
            elif self.pointing_format.get() == 'SSim':
                ra = []
                dec = []
                for ccd in pointing["camera"].geometry:
                    ra.append(ccd[0])
                    ra.append(ccd[2])
                    dec.append(ccd[1])
                    dec.append(ccd[3])

                dra = math.degrees(math.fabs(max(ra) - min(ra)))
                ddec = math.degrees(math.fabs(max(dec) - min(dec)))
                f.write("%f %f %16s %16s DATE 1.00 1.00 500 FILE\n" % (dra, ddec, sra, sdec ))
        if self.pointing_format.get() == 'CFHT PH':
            f.write("""]]</CSV></DATA>
</TABLE>
</ASTRO>
""")
        f.close()
481125
def loadtoc(self):
        """"""
        self.toc = self.TOCTMPLT()
        self.lib.seek(self.pkgstart+self.tocpos)
        tocstr = self.lib.read(self.toclen)
        self.toc.frombinary(tocstr)
877817
def load_shortcuts(self):
        """"""
        shortcuts = []
        for context, name, keystr in iter_shortcuts():
            shortcut = Shortcut(context, name, keystr)
            shortcuts.append(shortcut)
        shortcuts = sorted(shortcuts, key=lambda x: x.context+x.name)
        # Store the original order of shortcuts
        for i, shortcut in enumerate(shortcuts):
            shortcut.index = i
        self.source_model.shortcuts = shortcuts
        self.source_model.scores = [0]*len(shortcuts)
        self.source_model.rich_text = [s.name for s in shortcuts]
        self.source_model.reset()
        self.adjust_cells()
        self.sortByColumn(CONTEXT, Qt.AscendingOrder)
776566
def touch(args):
    
    p = OptionParser(touch.__doc__)
    opts, args = p.parse_args(args)
    fp = sys.stdin

    for link_name in fp:
        link_name = link_name.strip()
        if not op.islink(link_name):
            continue
        if not op.exists(link_name):
            continue

        source = get_abs_path(link_name)
        lnsf(source, link_name)
346024
function() {
			var that = this,
				add = function(target, events, capture) {
					events.split(' ').forEach(function(type) {
						target.addEventListener(type, that, capture);
					});
				};
			add(document, 'DOMContentLoaded');
			add(document, 'click mousedown mouseup', true);
			add(window, 'load hashchange');
			if (!gui.hosted) {
				add(window, 'resize orientationchange');
			}
			if (!(window.chrome && chrome.app && chrome.runtime)) {
				add(window, 'unload');
			}
			
			/*
			if (document.readyState === "complete") { // TODO: IE cornercase?
				if (!this._loaded) {
					this._ondom();
					this._onload();
				}
			}
			*/
		}
90290
def register_commands(self):
        
        for command in self._entry_points[self.COMMANDS_ENTRY_POINT].values():
            command.load()
777118
function(point, eventName, options){
		if (point){
			var targetElement = elementFromPoint(point, this.focusWindow);
			syn.trigger(targetElement, eventName, options);
		}
	}
1169261
def mouse_event_callback(self, window, xpos, ypos):
        
        # screen coordinates relative to the top-left corner
        self.example.mouse_position_event(xpos, ypos)
1130194
protected function preload()
    {
        $this->point( Point::POINT_PRELOAD );
        $this->point( Point::POINT_MULTIPLE_PRELOAD, true );
        $this->finish(POINT::POINT_MULTIPLE_PRELOAD); // Needs!
        $this->point( Point::POINT_CALIBRATE );
    }
49712
def attach(self, gui):
        """"""
        super(CorrelogramView, self).attach(gui)
        self.actions.add(self.toggle_normalization, shortcut='n')
        self.actions.separator()
        self.actions.add(self.set_bin, alias='cb')
        self.actions.add(self.set_window, alias='cw')
350231
def _load_commands(root):
    """"""
    def proto_text(t):
        if t.tag == 'name':
            return '{name}'
        elif t.tag == 'ptype':
            return '{type}'
        out = []
        if t.text:
            out.append(_escape_tpl_str(t.text))
        for x in t:
            out.append(proto_text(x))
            if x.tail:
                out.append(_escape_tpl_str(x.tail))
        return ''.join(out)
    out = collections.OrderedDict()
    for elem in root.findall('commands/command'):
        type_elem = elem.find('proto/ptype')
        name = elem.get('name') or elem.find('proto/name').text
        type = type_elem.text if type_elem is not None else None
        proto_template = proto_text(elem.find('proto'))
        params = [_load_param(x) for x in elem.findall('param')]
        comment = elem.get('comment')
        out[name] = Command(name, type, proto_template, params, comment)
    return out
1357532
def click(self, x, y):
        '''
        
        '''
        self.shell('input', 'tap', str(x), str(y))
1389
function pointAt(node){
      var parent = node.parentNode;
      var next = node.nextSibling;
      return function(newnode) {
        parent.insertBefore(newnode, next);
      };
    }