def lunar_phase(self, date=None): # phase is a fraction 0.0 -> 1.0 # radius is visual radius in arcseconds # direction is Waxing or Waning # name is Gibbous or Crescent lunar_names = [['Waxing', 'Crescent'], ['Waxing', 'Gibbous'], ['Waning', 'Gibbous'], ['Waning', 'Crescent']] if date is None: date = datetime.datetime.utcnow() here = ephem.Observer() here.lat = self.lat here.lon = self.lon here.date = date self.moon.compute(here) self.sun.compute(here) # lunar name computation from # https://stackoverflow.com/questions/26702144/human-readable-names-for-phases-of-the-moon-with-pyephem sunlon = ephem.Ecliptic(self.sun).lon moonlon = ephem.Ecliptic(self.moon).lon tau = 2.0 * ephem.pi angle = (moonlon - sunlon) % tau quarter = int(angle * 4.0 // tau) ### return { "phase": self.moon.moon_phase, "radius": self.moon.radius, 'direction': lunar_names[quarter][0], 'name': lunar_names[quarter][1], "sunmoon_angle": angle }
def moon_phase(when): tau = 2 * ephem.pi waxing = [ "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0" ] waning = [ "0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M" ] waning.reverse() sun = ephem.Sun() moon = ephem.Moon() names = [ 'Waxing Crescent', 'Waxing Gibbous', 'Waning Gibbous', 'Waning Crescent' ] sun.compute(when) moon.compute(when) sunlon = ephem.Ecliptic(sun).lon moonlon = ephem.Ecliptic(moon).lon angle = (moonlon - sunlon) % tau quarter = int(angle * 4.0 // tau) if quarter <= 1: letter = waxing[int(moon.moon_phase * 14)] else: letter = waning[int(moon.moon_phase * 14)] return (moon.moon_phase * 100, names[quarter], letter)
def _run(self, simData, cols_present=False): if cols_present: # Column already present in data; assume it is correct and does not need recalculating. return simData for i in np.arange(simData.size): if self.degrees: coord = ephem.Equatorial(np.radians(simData[self.raCol][i]), np.radians(simData[self.decCol][i]), epoch=2000) else: coord = ephem.Equatorial(simData[self.raCol][i], simData[self.decCol][i], epoch=2000) ecl = ephem.Ecliptic(coord) simData['eclipLat'][i] = ecl.lat if self.subtractSunLon: djd = mjd2djd(simData[self.mjdCol][i]) sun = ephem.Sun(djd) sunEcl = ephem.Ecliptic(sun) lon = wrapRA(ecl.lon - sunEcl.lon) simData['eclipLon'][i] = lon else: simData['eclipLon'][i] = ecl.lon if self.degrees: simData['eclipLon'] = np.degrees(simData['eclipLon']) simData['eclipLat'] = np.degrees(simData['eclipLat']) return simData
def add_EP(): ec = ephem.Ecliptic(0, 90. / degrad, epoch=2000) eq = ephem.Equatorial(ec, epoch=2000) add_point(float(eq.ra), float(eq.dec), flipRA=1, color='b', label="NEP/SEP", symb='s') ec = ephem.Ecliptic(0, -90. / degrad, epoch=2000) eq = ephem.Equatorial(ec, epoch=2000) add_point(float(eq.ra), float(eq.dec), flipRA=1, color='b', symb='s')
def helio_lat_lng(ra=0, dec=0, jd=0, fits=None): import ephem import cPickle as pickle #hjd, hra, hdec = np.loadtxt('/Users/brammer/WFC3/Backgrounds/Synphot/sun_coords.dat', unpack=True) fp = open('%s/sun_coords.pkl' % (datapath()), 'rb') hjd = pickle.load(fp) hra = pickle.load(fp) hdec = pickle.load(fp) fp.close() ra_sun = np.interp(jd, hjd, hra) dec_sun = np.interp(jd, hjd, hdec) if fits is not None: head = pyfits.getheader(fits, ext=0) ra, dec, jd = head['RA_TARG'], head['DEC_TARG'], head['EXPSTART'] #return dec-sun_dec, ra-sun_ra #ra, dec = 34.440618, -5.1721396 eq = icrs(ra=ra, dec=dec, unit=(u.deg, u.deg)) try: eq.ra.format = eq.ra.to_string eq.dec.format = eq.dec.to_string except: pass equat = ephem.Equatorial(str(eq.ra.format(sep=':', unit=u.hour)), str(eq.dec.format(sep=':', unit=u.deg)), epoch=ephem.J2000) eclip_obs = ephem.Ecliptic(equat) eq = icrs(ra=ra_sun, dec=dec_sun, unit=(u.deg, u.deg)) try: eq.ra.format = eq.ra.to_string eq.dec.format = eq.dec.to_string except: pass equat = ephem.Equatorial(str(eq.ra.format(sep=':', unit=u.hour)), str(eq.dec.format(sep=':', unit=u.deg)), epoch=ephem.J2000) eclip_sun = ephem.Ecliptic(equat) #dlon = (eclip_obs.lon-eclip_sun.lon)/np.pi*180 #print np.array([eclip_obs.lat, eclip_obs.lon, eclip_sun.lat, eclip_sun.lon])/np.pi*180 dlon = ((eclip_obs.lon - eclip_sun.lon) / np.pi * 180 + 180) % 360 - 180 return (eclip_obs.lat - eclip_sun.lat) / np.pi * 180, dlon
def SolarLongitube(JD): date = ephem.Date(JD - 2415020) s = ephem.Sun(date) # date应为UT时间 sa = ephem.Equatorial(s.ra, s.dec, epoch=date) se = ephem.Ecliptic(sa) L = se.lon / ephem.degree / 180 * math.pi return L
def SignCalculatiton(year, month, day, hour, minute=0, second=0, GMT=8): date = datetime.datetime(year, month, day, hour, minute, second) date -= datetime.timedelta(hours=GMT) Moon.compute(date) longitude = ephem.Ecliptic(Moon, epoch=str(date.year)).lon index = int(longitude//(math.pi/6)) return Constellations[index][1]
def coordinate_transform(self, coordinates: tuple, system_and_date: tuple): """ Transform coordinates from other systems to celestial coordinates Args: coordinates (tuple): system_and_date (tuple): Returns: """ position = np.radians(coordinates) # Convert coordinates from degrees to radians if system_and_date[1] == "Now": epoch = self.current_time() # Get the current time and date as the epoch else: epoch = system_and_date[1] self.observer.date = epoch if system_and_date[0] == "Horizontal": converted_ra, converted_dec = np.degrees(self.observer.radec_of(position[1], position[0])) elif system_and_date[0] == "Galactic": galactic_posit = ephem.Galactic(position[1], position[0], epoch=epoch) converted_ra, converted_dec = np.degrees(galactic_posit.to_radec()) # Convert from Galactic elif system_and_date[0] == "Ecliptic": ecliptic_position = ephem.Ecliptic(position[1], position[0], epoch=epoch) converted_ra, converted_dec = np.degrees(ecliptic_position.to_radec()) # Convert from Ecliptic coordinates else: converted_ra, converted_dec = coordinates return converted_ra, converted_dec # Return the coordinate tuple
def _run(self, simData): for i in np.arange(simData.size): coord = ephem.Equatorial(simData[self.raCol][i], simData[self.decCol][i], epoch=2000) ecl = ephem.Ecliptic(coord) simData['eclipLat'][i] = ecl.lat if self.subtractSunLon: djd = mjd2djd(simData[self.mjdCol][i]) sun = ephem.Sun(djd) sunEcl = ephem.Ecliptic(sun) lon = wrapRA(ecl.lon - sunEcl.lon) simData['eclipLon'][i] = lon else: simData['eclipLon'][i] = ecl.lon return simData
def extract(self): if not self.active: return default ret = default ## do some tests on the data try: if self.ra < 0.0 or self.ra >= 360.0: ret.update({'ra': None}) else: ret.update({'ra': ephem.degrees(str(self.ra))}) except: ret.update({'ra': None}) try: if self.dec < -90.0 or self.dec > 90.0: ret.update({'dec': None}) else: ret.update({'dec': ephem.degrees(str(self.dec))}) except: ret.update({'dec': None}) if ret['dec'] is not None and ret['ra'] is not None: np = ephem.Equatorial(ret['ra'], ret['dec'], epoch='2000') else: return ret g = ephem.Galactic(np) e = ephem.Ecliptic(np) ret = {'galb': rad2deg*float(g.lat), 'gall': rad2deg*float(g.long), \ 'ecb': rad2deg*float(e.lat), 'ecl': rad2deg*float(e.long), \ 'ra': rad2deg*float(np.ra), 'dec': rad2deg*float(np.dec)} return ret
def testcrdsys(self): """Test coordinate conversions for accuracy""" eq_ec_ga = [ [ ('19:59:28.3566','40:44:02.096'), ('317.7054323','59.3254895'), ('76.1898379','5.7554756')], [ ('12:30:49.4233','12:23:28.043'), ('182.0592608','14.4166861'), ('283.7777978','74.4911308')], [ ('13:25:27.6152','-43:01:08.805'), ('217.1433477','-31.3319020'), ('309.5158743','19.4173247')]] for eq,ec,ga in eq_ec_ga: eq_ec = a.coord.convert(eq,'eq','ec') eq_ga = a.coord.convert(eq,'eq','ga') ec_eq = a.coord.convert(ec,'ec','eq') ec_ga = a.coord.convert(ec,'ec','ga') ga_eq = a.coord.convert(ga,'ga','eq') ga_ec = a.coord.convert(ga,'ga','ec') eq_ck = e.Equatorial(eq[0], eq[1], epoch=e.J2000).get() ec_ck = e.Ecliptic(ec[0], ec[1], epoch=e.J2000).get() ga_ck = e.Galactic(ga[0], ga[1], epoch=e.J2000).get() self.assertAlmostEqual(eq_ec[0], ec_ck[0], 4) self.assertAlmostEqual(eq_ec[1], ec_ck[1], 4) self.assertAlmostEqual(eq_ga[0], ga_ck[0], 4) self.assertAlmostEqual(eq_ga[1], ga_ck[1], 4) self.assertAlmostEqual(ec_eq[0], eq_ck[0], 4) self.assertAlmostEqual(ec_eq[1], eq_ck[1], 4) self.assertAlmostEqual(ec_ga[0], ga_ck[0], 4) self.assertAlmostEqual(ec_ga[1], ga_ck[1], 4) self.assertAlmostEqual(ga_eq[0], eq_ck[0], 4) self.assertAlmostEqual(ga_eq[1], eq_ck[1], 4) self.assertAlmostEqual(ga_ec[0], ec_ck[0], 4) self.assertAlmostEqual(ga_ec[1], ec_ck[1], 4)
def tess_table(_tessfn=_tessdata + 'Sullivan+2015.csv'): """Load the Sullivan et al. TESS simulation and add extra columns. """ tess = pd.read_csv(_tessfn, skipinitialspace=True, delimiter=',') colnames = [col.lower() for col in tess.columns] if not 'mstar' in colnames: tess['Mstar'] = tess.Rstar tess.Mstar[(tess.Mstar > 1.5) * (tess.Rstar > 1.5)] = 1.5 if not 'a' in colnames: tess['a'] = ((tess.P / 365.24)**2 * tess.Mstar)**0.333333 if not 'mplanet' in colnames: tess['Mplanet'] = (an.mjup / an.mearth) * (tess.K / 28.43) * ( tess.P / 365.24)**0.3333 * tess.Mstar**0.66667 #tess['Mplanet'] = tess.Rplanet**2.06 if not 'teq' in colnames: tess['Teq'] = 250 * tess['S/SEarth']**0.25 tess['transitdepth'] = ((tess.Rplanet * an.rearth) / (tess.Rstar * an.rsun))**2 tess['b'] = 0.5 tess['T14'] = (tess.P / np.pi) * np.arcsin( (tess.Rstar * an.rsun) / (tess.a * an.AU) * np.sqrt((1 - tess.transitdepth**0.5)**2 - tess.b**2)) coords = [] for pair in zip(tess.RA, tess.Dec): coords.append( ephem.Ecliptic( ephem.Equatorial(obs.hms(pair[0], output_string=True), obs.dms(pair[1], output_string=True)))) tess['ec_lat'] = [coord.lat * 180 / np.pi for coord in coords] tess['ec_lon'] = [coord.lon * 180 / np.pi for coord in coords] return tess
def shift_to_vlsr_frame(self): # From http://web.mit.edu/8.13/www/nsrt_software/documentation/vlsr.pdf ep_target = ephem.Equatorial(self.target) # Sun velocity apex is at 18 hr, 30 deg; convert to x, y, z # geocentric celestial for dot product with source, multiply by speed x0 = 20.0 * math.cos(18.0 * np.pi / 12.0) * math.cos( 30.0 * np.pi / 180.0) y0 = 20.0 * math.sin(18.0 * np.pi / 12.0) * math.cos( 30.0 * np.pi / 180.0) z0 = 20.0 * math.sin(30.0 * np.pi / 180.0) # Make sure we have target angles in radians tg_ra_rad = float(ep_target.ra) tg_dec_rad = float(ep_target.dec) # Calculate sinces, cosines for dot product ctra = math.cos(tg_ra_rad) stra = math.sin(tg_ra_rad) ctdc = math.cos(tg_dec_rad) stdc = math.sin(tg_dec_rad) # Calculate correction due to movement of Sun with respect to LSR # dot product of target & apex vectors vsun = x0 * ctra * ctdc + y0 * stra * ctdc + z0 * stdc # get target in geocentric ecliptic system ecl = ephem.Ecliptic(ep_target) tlon = ecl.lon tlat = ecl.lat # Get sun ecliptic coordinates, in radians sun = ephem.Sun() sun.compute(self.site) se = ephem.Ecliptic(sun) slong = float(se.lon) # Calculate correction due to earth movement relative to the Sun vorb = 30.0 * math.cos(tlat) * math.sin(slong - tlon) # Combine both effects vlsr_kmps = vsun + vorb # in km/s vlsr_corr = 1e3 * vlsr_kmps # in m/s self.vlsr_corr = vlsr_corr # store for this spectrum # Convert and store shift also for frequency self.freq_vlsr_corr = -1 * self.rest_freq * self.vlsr_corr / c
def ecliptic_loc(self): rr = ephem.Equatorial( ephem.hours(self.imagesQuery.field_ra(self.fieldId)), ephem.degrees(self.imagesQuery.field_dec(self.fieldId))) ec = ephem.Ecliptic(rr) retval = (degrees(ec.lat), str(ec.lon) ) # eclat is float (deg), eclon is str in deg return retval
def createEclipticPole(self): b = ephem.Ecliptic("0", "90", epoch="2016") c = ephem.Equatorial(b) r = c.ra d = c.dec rr = float(r) / (2.0 * math.pi) * 24 dd = float(d) * 180. / math.pi return rr, dd
def get_solar_longitude(time=datetime.datetime.utcnow()): obs = ephem.Observer() obs.date = time sun = ephem.Sun() sun.compute(obs) return ephem.Ecliptic(sun).lon * 180.0 / ephem.pi
def ecliptic(self): p = [] for t in range(-180, 180): e = ephem.Equatorial(ephem.Ecliptic(t * pi / 180, 0, epoch=ephem.J2000), epoch=ephem.J2000) p.append((e.ra * 180 / pi, e.dec * 180 / pi)) return p
def planetary_signs(birth, bodies): signs = [] for name, body in bodies: body.compute(birth) degrees, minutes, seconds = str(ephem.Ecliptic(body).lon).split(':') degrees = int(degrees) + int(minutes) / 60 + float(seconds) / (60 * 60) #print(name, Ecliptic(body).lon, degrees) signs.append((name, get_sign(degrees), (degrees))) return signs
def ecliptic(ra, dec): """ecliptic. Args: ra: dec: """ np = ephem.Equatorial(math.radians(ra), math.radians(dec), epoch='2000') e = ephem.Ecliptic(np) return (math.degrees(e.lon), math.degrees(e.lat))
def transform_celestial(coords, systems): lons, lats = np.radians(coords['lon']), np.radians(coords['lat']) out = Table() out['lon'] = np.zeros(len(coords), dtype='float64') out['lat'] = np.zeros(len(coords), dtype='float64') for ii, (lon, lat) in enumerate(zip(lons, lats)): # Create coordinate in input system if systems['in'] == 'fk5': coord = ephem.Equatorial(lon, lat) elif systems['in'] == 'fk4': coord = ephem.Equatorial(lon, lat, epoch=ephem.B1950) elif systems['in'] == 'galactic': coord = ephem.Galactic(lon, lat) elif systems['in'] == 'ecliptic': coord = ephem.Ecliptic(lon, lat) else: raise ValueError() # Convert to appropriate output system # Retrieving output system coordinates is system specific # because the attribute names depend on the system if systems['out'] == 'fk5': coord = ephem.Equatorial(coord, epoch=ephem.J2000) lon, lat = coord.ra, coord.dec elif systems['out'] == 'fk4': coord = ephem.Equatorial(coord, epoch=ephem.B1950) lon, lat = coord.ra, coord.dec elif systems['out'] == 'galactic': coord = ephem.Galactic(coord) lon, lat = coord.lon, coord.lat elif systems['out'] == 'ecliptic': coord = ephem.Ecliptic(coord) lon, lat = coord.lon, coord.lat else: raise ValueError() out[ii]['lon'] = np.degrees(lon) out[ii]['lat'] = np.degrees(lat) return out
def ecliptic_lon(now_time: datetime.datetime) -> float: """ 根据日期计算黄经 now_time -- 日期 Return arguments: float -- 黄经 """ s = ephem.Sun(now_time) equ = ephem.Equatorial(s.ra, s.dec, epoch=now_time) e = ephem.Ecliptic(equ) return e.lon
def plot_ecliptic_plane(handles, labels): ep = [ephem.Ecliptic(str(lon), str(0)) for lon in range(0, 360) ] # this line is fine: need Ecliptic(long, lat) format in creation ecPlane = [ephem.Equatorial(coord) for coord in ep] # so this must be where the issue is. ra_ecPlane = [math.degrees(coord.ra) for coord in ecPlane] dec_ecPlane = [math.degrees(coord.dec) for coord in ecPlane] handles.append(plt.plot(ra_ecPlane, dec_ecPlane, '#E47833')) labels.append('ecliptic') # plt.plot([rr+360 for rr in ra_ecPlane], dec_ecPlane, '#E47833') # echo return handles, labels
def createEclipticPath(self): eline = [] for i in range(361): l = str(0 + i) b = ephem.Ecliptic(l, "0", epoch="2016") c = ephem.Equatorial(b) r = c.ra d = c.dec rr = float(r) / (2.0 * math.pi) * 24 dd = float(d) * 180. / math.pi eline.append([rr, dd]) return eline
def __init__(self, parfile, timfile): # initialize libstempo object t2psr = t2.tempopulsar( parfile, timfile, maxobs=30000, ) # get attributes self.name = t2psr.name self.residuals = np.double(t2psr.residuals()) self.toas = np.double(t2psr.toas() * 86400) self.toaerrs = np.double(t2psr.toaerrs * 1e-6) self.flags = t2psr.flagvals('f') Mmat = np.double(t2psr.designmatrix()) # sort self.isort, self.iisort = utils.argsortTOAs(self.toas, self.flags, which='jitterext', dt=1.0) self.toas = self.toas[self.isort] self.toaerrs = self.toaerrs[self.isort] self.residuals = self.residuals[self.isort] self.flags = self.flags[self.isort] Mmat = Mmat[self.isort, :] u, s, v = np.linalg.svd(Mmat, full_matrices=False) self.Musvd = u self.Mssvd = s # get sky location pars = t2psr.pars() if 'RAJ' not in pars and 'DECJ' not in pars: elong, elat = t2psr['ELONG'].val, t2psr['ELAT'].val ec = ephem.Ecliptic(elong, elat) # check for B name if 'B' in t2psr.name: epoch = '1950' else: epoch = '2000' eq = ephem.Equatorial(ec, epoch=epoch) self.phi = np.double([eq.ra]) self.theta = np.pi / 2 - np.double([eq.dec]) else: self.phi = np.double(t2psr['RAJ'].val) self.theta = np.pi / 2 - np.double(t2psr['DECJ'].val)
def parser(file_name): deb_objects = [] with open(file_name, 'r') as file: while True: line0 = file.readline() if not line0: break line1 = file.readline() line2 = file.readline() if ' DEB' not in line0: continue tle_rec = ephem.readtle(line0, line1, line2) tle_rec.compute() ecliptic_obj_pos1 = ephem.Ecliptic(tle_rec) ecliptic_obj_pos2 = ephem.Ecliptic(tle_rec, epoch=0) name = line0[2:].rstrip() lat1 = ecliptic_obj_pos1.lat lon1 = ecliptic_obj_pos1.lon lat2 = ecliptic_obj_pos2.lat lon2 = ecliptic_obj_pos2.lon alt = tle_rec.elevation / 1000 revs_per_day = tle_rec._n deb_object = DebObject(name, lat1, lon1, lat2, lon2, alt, revs_per_day) deb_objects.append(deb_object.__dict__) write_file(deb_objects)
def ecliptic_lat_span(self, blockID): junk, fieldIds = self.fields_in_block(blockID) ecs = [] for field in fieldIds: rr = ephem.Equatorial(ephem.hours(self.bk.field_ra(field)), ephem.degrees(self.bk.field_dec(field))) ec = ephem.Ecliptic(rr) ecs.append(ec) ecs.sort(key=lambda x: x.__getattribute__('lat')) retval = (degrees(ecs[0].lat), degrees(ecs[-1].lat) ) # eclat is float (deg), min-max return retval
def compute_libration(self): """ Compute topocentric libration angles and the position angle of the moon's rotational axis. :return: - """ # Astrometric libration angles and the selenographic co-longitude of the sun are provided # by PyEphem. self.astrometric_lib_lat = self.moon.libration_lat self.astrometric_lib_long = self.moon.libration_long self.colong = self.moon.colong # Compute topocentric libration values. For algorithmic details, refer to the user's guide. j2000 = ephem.Date(datetime.datetime(2000, 1, 1, 12, 0)) t = (ephem.Date(self.location_time.date) - j2000) / 36525. epsilon = radians(23.439281 - 0.013002575 * t) ma = ephem.Equatorial(self.ra, self.de, epoch=ephem.Date(self.location_time.date)) me = ephem.Ecliptic(ma) cap_i = radians(1.54266) omega = radians(125.044555 - 1934.13626194 * t) lm = radians(218.31664563 + 481267.88119575 * t - 0.00146638 * t**2) i = acos( cos(cap_i) * cos(epsilon) + sin(cap_i) * sin(epsilon) * cos(omega)) omega_prime = atan2(-sin(cap_i) * sin(omega) / sin(i), (cos(cap_i) * sin(epsilon) - sin(cap_i) * cos(epsilon) * cos(omega)) / sin(i)) self.pos_rot_north = atan2( -sin(i) * cos(omega_prime - self.ra), cos(self.de) * cos(i) - sin(self.de) * sin(i) * sin(omega_prime - self.ra)) self.topocentric_lib_lat = asin(-sin(cap_i) * cos(me.lat) * sin(me.lon - omega) - cos(cap_i) * sin(me.lat)) self.topocentric_lib_long = (atan2( cos(cap_i) * cos(me.lat) * sin(me.lon - omega) - sin(cap_i) * sin(me.lat), cos(me.lat) * cos(me.lon - omega)) - lm + omega) % (2. * pi) if self.topocentric_lib_long > 1.: self.topocentric_lib_long -= 2. * pi elif self.topocentric_lib_long < -1.: self.topocentric_lib_long += 2. * pi
def add_fields(): fields_to_plot = ascii.read("fields_to_plot.txt") for i in range(len(fields_to_plot["RA"])): eq = ephem.Equatorial(fields_to_plot["RA"][i] / degrad, fields_to_plot["Dec"][i] / degrad, epoch=2000) ec = ephem.Ecliptic(eq, epoch=2000) if abs(float(ec.lat) * degrad) >= 54: pltcolor = 'g' else: pltcolor = 'r' add_point(fields_to_plot["RA"][i] / degrad, fields_to_plot["Dec"][i] / degrad, color=pltcolor, txtlabel=fields_to_plot["Field"][i])
def block_table_pprint(): """ :return: """ with open('block_table.tex', 'w') as outfile: for name, coords in parameters.BLOCKS.items(): print name, coords ra = ephem.hours(coords['RA']) dec = ephem.degrees(coords['DEC']) eq = ephem.Equatorial(ra, dec) ec = ephem.Ecliptic(eq) outfile.write( "{} & {:2.1f} & {:2.1f} & {:2.1f} & {:2.1f} {} \n".format( name[2:], math.degrees(ephem.degrees(ra)), math.degrees(dec), math.degrees(ec.lat), math.degrees(ec.lon), r"\\")) return
def equ2ecl(al, de, epoch='2000'): g = ephem.Ecliptic(0.0, np.pi / 2.0, epoch=str(epoch)) [al_gp, de_gp] = g.to_radec() g.from_radec(0.0, np.pi / 2.0) l_cp = g.lon.znorm al = np.radians(al) de = np.radians(de) l = l_cp - np.arctan2( np.cos(de) * np.sin(al - al_gp), np.cos(de_gp) * np.sin(de) - np.sin(de_gp) * np.cos(de) * np.cos(al - al_gp)) temp = np.sin(l_cp - l) * (np.sin(de_gp) * np.sin(de) + np.cos(de_gp) * np.cos(de) * np.cos(al - al_gp) ) / (np.cos(de) * np.sin(al - al_gp)) b = np.degrees(np.arctan(temp)) l = np.degrees(l) % 360.0 return [l, b]