generate one orbfit ephemeris

    **Key Arguments:**
        - ``cmd`` -- the command to execute [cmd, object]

    **Return:**
        - ``results`` -- the single ephemeris results
196168
def _generate_one_ephemeris(
        cmd):
    

    global cmdList
    cmd = cmdList[cmd]

    results = []
    for c in cmd:
        p = Popen(c[0], stdout=PIPE, stderr=PIPE, shell=True)
        stdout, stderr = p.communicate()

        if len(stderr) and len(stderr.split()) != 15:
            print stderr, len(stderr.split())
            return None
        elif "!!WARNING! WARNING! WARNING! WARNING!!" in stdout:
            print "%(stdout)s was not found in astorb.dat" % locals()
            return None

        # SPLIT RESULTS INTO LIST OF DICTIONARIES
        r = stdout.strip().split("\n")
        keys = r[0].strip().split(',')
        lines = r[1:]
        for l in lines:
            # CREATE DICTIONARY FROM KEYS AND VALUES
            values = l.strip().split(',')
            for k, v in zip(keys, values):
                v = v.strip().replace("/", "")
                try:
                    v = float(v)
                except:
                    pass
            result = dict(zip(keys, values))
            result["object_name"] = c[1]
            results.append(result)
    return results
1370692
def rungtd1d(time: Union[datetime, str, np.ndarray],
             altkm: np.ndarray,
             glat: float, glon: float) -> xarray.Dataset:
    
    time = todt64(time)
    # %% get solar parameters for date
    f107Ap = gi.getApF107(time, smoothdays=81)
    f107a = f107Ap['f107s'].item()
    f107 = f107Ap['f107'].item()
    Ap = f107Ap['Ap'].item()
# %% dimensions
    altkm = np.atleast_1d(altkm)
    assert altkm.ndim == 1
    assert isinstance(glon, (int, float))
    assert isinstance(glat, (int, float))
    assert isinstance(time, np.datetime64) or (time.size == 1 and isinstance(
        time[0], np.datetime64)), 'if you have multiple times, for loop over them'

# don't check ap, too complicated
    assert isinstance(MASS, (float, int))
    assert len(TSELECOPS) == 25
# %%
    gtd7.tselec(TSELECOPS)  # like the msis_driver example

    iyd, utsec, stl = datetime2gtd(time, glon)
    altkm = np.atleast_1d(altkm)

    gtd7.meters(1)  # makes output in m^-3 and kg/m^-3
# %%
    if isinstance(Ap, (float, int)):
        Ap = [Ap]*7  # even if SW(9) == 1 due to f2py needs for array

    dens = np.empty((altkm.size, len(species)))
    temp = np.empty((altkm.size, len(ttypes)))
    for i, a in enumerate(altkm):
        dens[i, :], temp[i, :] = gtd7.gtd7(iyd, utsec, a, glat, glon, stl, f107a, f107, Ap, MASS)

    dsf = {k: (('time', 'alt_km', 'lat', 'lon'), v[None, :, None, None]) for (k, v) in zip(species, dens.T)}
    dsf.update({'Tn':  (('time', 'alt_km', 'lat', 'lon'), temp[:, 1][None, :, None, None]),
                'Texo': (('time', 'alt_km', 'lat', 'lon'), temp[:, 0][None, :, None, None])})

    atmos = xarray.Dataset(dsf,
                           coords={'time': time.astype(datetime), 'alt_km': altkm, 'lat': [glat], 'lon': [glon], },
                           attrs={'Ap': Ap, 'f107': f107, 'f107a': f107a,
                                  'species': species})

    return atmos
827737
def allskyfinder(self, figsize=(14, 7), **kwargs):
        '''
        
        '''

        plt.figure(figsize=figsize)
        scatter = self.plot(**kwargs)
        plt.xlabel(r'Right Ascension ($^\circ$)'); plt.ylabel(r'Declination ($^\circ$)')
        #plt.title('{} in {:.1f}'.format(self.name, epoch))
        plt.xlim(0, 360)
        plt.ylim(-90,90)
        return scatter
591907
def runCommandReturnOutput(cmd):
    
    splits = shlex.split(cmd)
    proc = subprocess.Popen(
        splits, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    stdout, stderr = proc.communicate()
    if proc.returncode != 0:
        raise subprocess.CalledProcessError(stdout, stderr)
    return stdout, stderr
1327954
def cmd(commands, opts={})
      results = {}
      threads = clouds.collect do |name, c|
        Thread.new{ results[ name ] = c.cmd(commands, opts) }
      end
      threads.each{ |aThread| aThread.join }
      results
    end
246870
def lunarEclipseGlobal(jd, backward):
    

    sweList = swisseph.lun_eclipse_when(jd, backward=backward)
    return {
        'maximum': sweList[1][0],
        'partial_begin': sweList[1][2],
        'partial_end': sweList[1][3],
        'totality_begin': sweList[1][4],
        'totality_end': sweList[1][5],
        'penumbral_begin': sweList[1][6],
        'penumbral_end': sweList[1][7],
    }
23085
def nextSolarReturn(chart, date):
    
    sun = chart.getObject(const.SUN)
    srDate = ephem.nextSolarReturn(date, sun.lon)
    return _computeChart(chart, srDate)
555331
def run_commands(self, commands):
        """"""
        if "eos" in self.profile:
            return list(self.parent.cli(commands).values())[0]
        else:
            raise AttributeError("MockedDriver instance has not attribute '_rpc'")
355493
def cmd(self, fun, arg=None, pub_data=None, kwarg=None, print_event=True, full_return=False):
        '''
        
        '''
        return super(WheelClient, self).cmd(fun,
                                            arg,
                                            pub_data,
                                            kwarg,
                                            print_event,
                                            full_return)
1086797
def rungtd1d(time: datetime,
             altkm: np.ndarray,
             glat: float, glon: float, *,
             f107a: float = None, f107: float = None, Ap: int = None) -> xarray.Dataset:
    
    time = todatetime(time)
    # %% get solar parameters for date
    if f107a and f107a and Ap:
        pass
    else:
        f107Ap = gi.getApF107(time, smoothdays=81)
        f107a = f107Ap['f107s'].item()
        f107 = f107Ap['f107'].item()
        Ap = f107Ap['Ap'].item()
# %% dimensions
    altkm = np.atleast_1d(altkm)
    assert altkm.ndim == 1
    assert isinstance(glon, (int, float))
    assert isinstance(glat, (int, float))

# %%
    iyd = time.strftime('%y%j')
    altkm = np.atleast_1d(altkm)
# %%
    dens = np.empty((altkm.size, len(species)))
    temp = np.empty((altkm.size, len(ttypes)))
    for i, a in enumerate(altkm):
        cmd = [str(EXE),
               iyd, str(time.hour), str(time.minute), str(time.second),
               str(glat), str(glon),
               str(f107a), str(f107), str(Ap), str(a)]

        ret = subprocess.check_output(cmd,
                                      universal_newlines=True,
                                      stderr=subprocess.DEVNULL)
        f = io.StringIO(ret)
        dens[i, :] = np.genfromtxt(f, max_rows=1)
        temp[i, :] = np.genfromtxt(f, max_rows=1)

    dsf = {k: (('time', 'alt_km', 'lat', 'lon'), v[None, :, None, None]) for (k, v) in zip(species, dens.T)}
    dsf.update({'Tn':  (('time', 'alt_km', 'lat', 'lon'), temp[:, 1][None, :, None, None]),
                'Texo': (('time', 'alt_km', 'lat', 'lon'), temp[:, 0][None, :, None, None])})

    atmos = xarray.Dataset(dsf,
                           coords={'time': [time], 'alt_km': altkm, 'lat': [glat], 'lon': [glon], },
                           attrs={'Ap': Ap, 'f107': f107, 'f107a': f107a,
                                  'species': species})

    return atmos
111780
def singleFactor(factors, chart, factor, obj, aspect=None):
    "
    
    objID = obj if type(obj) == str else obj.id
    res = {
        'factor': factor,
        'objID': objID,
        'aspect': aspect
    }
    
    # For signs (obj as string) return sign element
    if type(obj) == str:
        res['element'] = props.sign.element[obj]
        
    # For Sun return sign and sunseason element
    elif objID == const.SUN:
        sunseason = props.sign.sunseason[obj.sign]
        res['sign'] = obj.sign
        res['sunseason'] = sunseason
        res['element'] = props.base.sunseasonElement[sunseason]
        
    # For Moon return phase and phase element
    elif objID == const.MOON:
        phase = chart.getMoonPhase()
        res['phase'] = phase
        res['element'] = props.base.moonphaseElement[phase]
        
    # For regular planets return element or sign/sign element
    # if there's an aspect involved
    elif objID in const.LIST_SEVEN_PLANETS:
        if aspect:
            res['sign'] = obj.sign
            res['element'] = props.sign.element[obj.sign]
        else:
            res['element'] = obj.element()
            
    try:
        # If there's element, insert into list
        res['element']
        factors.append(res)
    except KeyError:
        pass
    
    return res
285440
def do_objs(kbos):
    """"""

    import orbfit, ephem, math
    import re
    re_string=w.FilterVar.get()
    vlist=[]
    for name in kbos:
        if not re.search(re_string,name):
            continue
        vlist.append(name)
        if type(kbos[name])==type(ephem.EllipticalBody()):
	    kbos[name].compute(w.date.get())
	    ra=kbos[name].ra
	    dec=kbos[name].dec
	    a=math.radians(10.0/3600.0)
	    b=a
	    ang=0.0
	    color='blue'
            yoffset=+10
	    xoffset=+10
        else:
            yoffset=-10
            xoffset=-10
            file=kbos[name]
	    jdate=ephem.julian_date(w.date.get())
	    obs=568
 	    try:
	        position=orbfit.predict(file,jdate,obs)
	    except:
		continue
	    ra=math.radians(position[0])
	    dec=math.radians(position[1])
	    a=math.radians(position[2]/3600.0)
	    b=math.radians(position[3]/3600.0)
	    ang=math.radians(position[4])
	    if ( a> math.radians(1.0) ):
	        color='green'
            else:
	        color='black'
	if w.show_ellipse.get()==1 :
            if ( a < math.radians(5.0) ): 
	        w.create_ellipse(ra,dec,a,b,ang)
        if ( a < math.radians(1.0) ): 
            w.create_point(ra,dec,size=2,color=color)
	if w.show_labels.get()==1:
	    w.label(ra,dec,name,offset=[xoffset,yoffset])
    vlist.sort()
    for v in vlist:
        w.objList.insert(END,v)
    w.plot_pointings()
59820
def cmd(send, msg, _):
    
    try:
        req = get('http://thefuckingweather.com/April/%s' % msg, timeout=5)
        doc = fromstring(req.text)
        elem = doc.find('.//h1')
    except ReadTimeout:
        elem = None
    if elem is None:
        send('NO FSCKING RESULTS.')
    else:
        send(elem.text)
576095
def _get_cmd(cmd):
    
    check_cmd = "RunTHetA.py"
    try:
        local_cmd = subprocess.check_output(["which", check_cmd]).strip()
    except subprocess.CalledProcessError:
        return None
    return [sys.executable, "%s/%s" % (os.path.dirname(os.path.realpath(local_cmd)), cmd)]
557068
def nextSunrise(date, pos):
    
    jd = eph.nextSunrise(date.jd, pos.lat, pos.lon)
    return Datetime.fromJD(jd, date.utcoffset)
1255463
def runcommand(cosmology='WMAP5'):
    

    # Return the WMAP5 cosmology concentration predicted for
    # z=0 range of masses
    Mi = [1e8, 1e9, 1e10]
    zi = 0
    print("Concentrations for haloes of mass %s at z=%s" % (Mi, zi))
    output = commah.run(cosmology=cosmology, zi=zi, Mi=Mi)

    print(output['c'].flatten())

    # Return the WMAP5 cosmology concentration predicted for
    # z=0 range of masses AND cosmological parameters
    Mi = [1e8, 1e9, 1e10]
    zi = 0
    print("Concentrations for haloes of mass %s at z=%s" % (Mi, zi))
    output, cosmo = commah.run(cosmology=cosmology, zi=zi, Mi=Mi,
                               retcosmo=True)

    print(output['c'].flatten())
    print(cosmo)

    # Return the WMAP5 cosmology concentration predicted for MW
    # mass (2e12 Msol) across redshift
    Mi = 2e12
    z = [0, 0.5, 1, 1.5, 2, 2.5]
    output = commah.run(cosmology=cosmology, zi=0, Mi=Mi, z=z)
    for zval in z:
        print("M(z=0)=%s has c(z=%s)=%s"
              % (Mi, zval, output[output['z'] == zval]['c'].flatten()))

    # Return the WMAP5 cosmology concentration predicted for MW
    # mass (2e12 Msol) across redshift
    Mi = 2e12
    zi = [0, 0.5, 1, 1.5, 2, 2.5]
    output = commah.run(cosmology=cosmology, zi=zi, Mi=Mi)
    for zval in zi:
        print("M(z=%s)=%s has concentration %s"
              % (zval, Mi, output[(output['zi'] == zval) &
                                  (output['z'] == zval)]['c'].flatten()))

    # Return the WMAP5 cosmology concentration and
    # rarity of high-z cluster
    Mi = 2e14
    zi = 6
    output = commah.run(cosmology=cosmology, zi=zi, Mi=Mi)
    print("Concentrations for haloes of mass %s at z=%s" % (Mi, zi))
    print(output['c'].flatten())
    print("Mass variance sigma of haloes of mass %s at z=%s" % (Mi, zi))
    print(output['sig'].flatten())
    print("Fluctuation for haloes of mass %s at z=%s" % (Mi, zi))
    print(output['nu'].flatten())

    # Return the WMAP5 cosmology accretion rate prediction
    # for haloes at range of redshift and mass
    Mi = [1e8, 1e9, 1e10]
    zi = [0]
    z = [0, 0.5, 1, 1.5, 2, 2.5]
    output = commah.run(cosmology=cosmology, zi=zi, Mi=Mi, z=z)
    for Mval in Mi:
        print("dM/dt for halo of mass %s at z=%s across redshift %s is: "
              % (Mval, zi, z))
        print(output[output['Mi'] == Mval]['dMdt'].flatten())

    # Return the WMAP5 cosmology Halo Mass History for haloes with M(z=0) = 1e8
    M = [1e8]
    z = [0, 0.5, 1, 1.5, 2, 2.5]
    print("Halo Mass History for z=0 mass of %s across z=%s" % (M, z))
    output = commah.run(cosmology=cosmology, zi=0, Mi=M, z=z)
    print(output['Mz'].flatten())

    # Return the WMAP5 cosmology formation redshifts for haloes at
    # range of redshift and mass
    M = [1e8, 1e9, 1e10]
    z = [0]
    print("Formation Redshifts for haloes of mass %s at z=%s" % (M, z))
    output = commah.run(cosmology=cosmology, zi=0, Mi=M, z=z)
    for Mval in M:
        print(output[output['Mi'] == Mval]['zf'].flatten())

    return("Done")
914430
def solarReturn(self, year):
        
        sun = self.getObject(const.SUN)
        date = Datetime('{0}/01/01'.format(year),
                        '00:00',
                        self.date.utcoffset)
        srDate = ephem.nextSolarReturn(date, sun.lon)
        return Chart(srDate, self.pos, hsys=self.hsys)