idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
33,800 | def create_station ( name , latlonalt , parent_frame = WGS84 , orientation = 'N' , mask = None ) : if isinstance ( orientation , str ) : orient = { 'N' : np . pi , 'S' : 0. , 'E' : np . pi / 2. , 'W' : 3 * np . pi / 2. } heading = orient [ orientation ] else : heading = orientation latlonalt = list ( latlonalt ) latlon... | Create a ground station instance |
33,801 | def visibility ( cls , orb , ** kwargs ) : from . . orbits . listeners import stations_listeners , Listener listeners = kwargs . setdefault ( 'listeners' , [ ] ) events = kwargs . pop ( 'events' , None ) event_classes = tuple ( ) if events : if isinstance ( events , Listener ) : listeners . append ( events ) elif isins... | Visibility from a topocentric frame |
33,802 | def _to_parent_frame ( self , * args , ** kwargs ) : lat , lon , _ = self . latlonalt m = rot3 ( - lon ) @ rot2 ( lat - np . pi / 2. ) @ rot3 ( self . heading ) offset = np . zeros ( 6 ) offset [ : 3 ] = self . coordinates return self . _convert ( m , m ) , offset | Conversion from Topocentric Frame to parent frame |
33,803 | def _geodetic_to_cartesian ( cls , lat , lon , alt ) : C = Earth . r / np . sqrt ( 1 - ( Earth . e * np . sin ( lat ) ) ** 2 ) S = Earth . r * ( 1 - Earth . e ** 2 ) / np . sqrt ( 1 - ( Earth . e * np . sin ( lat ) ) ** 2 ) r_d = ( C + alt ) * np . cos ( lat ) r_k = ( S + alt ) * np . sin ( lat ) norm = np . sqrt ( r_d... | Conversion from latitude longitude and altitude coordinates to cartesian with respect to an ellipsoid |
33,804 | def get_mask ( cls , azim ) : if cls . mask is None : raise ValueError ( "No mask defined for the station {}" . format ( cls . name ) ) azim %= 2 * np . pi if azim in cls . mask [ 0 , : ] : return cls . mask [ 1 , np . where ( azim == cls . mask [ 0 , : ] ) [ 0 ] [ 0 ] ] for next_i , mask_azim in enumerate ( cls . mask... | Linear interpolation between two points of the mask |
33,805 | def get_body ( name ) : try : body , propag = _bodies [ name . lower ( ) ] body . propagate = propag . propagate except KeyError as e : raise UnknownBodyError ( e . args [ 0 ] ) return body | Retrieve a given body orbits and parameters |
33,806 | def propagate ( cls , date ) : date = date . change_scale ( 'TDB' ) t_tdb = date . julian_century def cos ( angle ) : return np . cos ( np . radians ( angle ) ) def sin ( angle ) : return np . sin ( np . radians ( angle ) ) lambda_el = 218.32 + 481267.8813 * t_tdb + 6.29 * sin ( 134.9 + 477198.85 * t_tdb ) - 1.27 * sin... | Compute the Moon position at a given date |
33,807 | def propagate ( cls , date ) : date = date . change_scale ( 'UT1' ) t_ut1 = date . julian_century lambda_M = 280.460 + 36000.771 * t_ut1 M = np . radians ( 357.5291092 + 35999.05034 * t_ut1 ) lambda_el = np . radians ( lambda_M + 1.914666471 * np . sin ( M ) + 0.019994643 * np . sin ( 2 * M ) ) r = 1.000140612 - 0.0167... | Compute the position of the sun at a given date |
33,808 | def iter ( self , ** kwargs ) : if 'dates' not in kwargs : start = kwargs . setdefault ( 'start' , self . orbit . date ) stop = kwargs . get ( 'stop' ) step = kwargs . setdefault ( 'step' , getattr ( self , 'step' , None ) ) if 'stop' is None : raise ValueError ( "The end of the propagation should be defined" ) start =... | Compute a range of orbits between two dates |
33,809 | def get_orbit ( name , date ) : if name not in [ x . name for x in Bsp ( ) . top . list ] : raise UnknownBodyError ( name ) for a , b in Bsp ( ) . top . steps ( name ) : if b . name not in _propagator_cache : propagator = type ( "%sBspPropagator" % b . name , ( GenericBspPropagator , ) , { 'src' : a , 'dst' : b } ) cen... | Retrieve the orbit of a solar system object |
33,810 | def create_frames ( until = None ) : now = Date . now ( ) if until : get_orbit ( until , now ) else : for body in list_bodies ( ) : get_orbit ( body . name , now ) | Create frames available in the JPL files |
33,811 | def get_body ( name ) : body = Pck ( ) [ name ] body . propagate = lambda date : get_orbit ( name , date ) return body | Retrieve the Body structure of a JPL . bsp file object |
33,812 | def open ( self ) : segments = [ ] files = config . get ( 'env' , 'jpl' , fallback = [ ] ) if not files : raise JplConfigError ( "No JPL file defined" ) for filepath in files : filepath = Path ( filepath ) if filepath . suffix . lower ( ) != ".bsp" : continue segments . extend ( SPK . open ( str ( filepath ) ) . segmen... | Open the files |
33,813 | def get ( self , center , target , date ) : if ( center . index , target . index ) in self . segments : pos , vel = self . segments [ center . index , target . index ] . compute_and_differentiate ( date . jd ) sign = 1 else : pos , vel = self . segments [ target . index , center . index ] . compute_and_differentiate ( ... | Retrieve the position and velocity of a target with respect to a center |
33,814 | def get_propagator ( name ) : from . sgp4 import Sgp4 from . sgp4beta import Sgp4Beta scope = locals ( ) . copy ( ) scope . update ( globals ( ) ) if name not in scope : raise UnknownPropagatorError ( name ) return scope [ name ] | Retrieve a named propagator |
33,815 | def stations_listeners ( stations ) : stations = stations if isinstance ( stations , ( list , tuple ) ) else [ stations ] listeners = [ ] for sta in stations : listeners . append ( StationSignalListener ( sta ) ) listeners . append ( StationMaxListener ( sta ) ) if sta . mask is not None : listeners . append ( StationM... | Function for creating listeners for a a list of station |
33,816 | def _bisect ( self , begin , end , listener ) : step = ( end . date - begin . date ) / 2 while abs ( step ) >= self . _eps_bisect : date = begin . date + step if self . SPEAKER_MODE == "global" : orb = self . propagate ( date ) else : orb = begin . propagate ( date ) if listener ( begin ) * listener ( orb ) > 0 : begin... | This method search for the zero - crossing of the watched parameter |
33,817 | def check ( self , orb ) : return self . prev is not None and np . sign ( self ( orb ) ) != np . sign ( self ( self . prev ) ) | Method that check whether or not the listener is triggered |
33,818 | def _m_to_e ( cls , e , M ) : k1 = 3 * np . pi + 2 k2 = np . pi - 1 k3 = 6 * np . pi - 1 A = 3 * k2 ** 2 / k1 B = k3 ** 2 / ( 6 * k1 ) m1 = float ( M ) if abs ( m1 ) < 1 / 6 : E = m1 + e * ( 6 * m1 ) ** ( 1 / 3 ) - m1 elif m1 < 0 : w = np . pi + m1 E = m1 + e * ( A * w / ( B - w ) - np . pi - m1 ) else : w = np . pi - ... | Conversion from Mean Anomaly to Eccentric anomaly |
33,819 | def _cartesian_to_spherical ( cls , coord , center ) : x , y , z , vx , vy , vz = coord r = np . linalg . norm ( coord [ : 3 ] ) phi = arcsin ( z / r ) theta = arctan2 ( y , x ) r_dot = ( x * vx + y * vy + z * vz ) / r phi_dot = ( vz * ( x ** 2 + y ** 2 ) - z * ( x * vx + y * vy ) ) / ( r ** 2 * sqrt ( x ** 2 + y ** 2 ... | Cartesian to Spherical conversion |
33,820 | def _spherical_to_cartesian ( cls , coord , center ) : r , theta , phi , r_dot , theta_dot , phi_dot = coord x = r * cos ( phi ) * cos ( theta ) y = r * cos ( phi ) * sin ( theta ) z = r * sin ( phi ) vx = r_dot * x / r - y * theta_dot - z * phi_dot * cos ( theta ) vy = r_dot * y / r + x * theta_dot - z * phi_dot * sin... | Spherical to cartesian conversion |
33,821 | def interpolate ( self , date , method = None , order = None ) : if not self . start <= date <= self . stop : raise ValueError ( "Date '%s' not in range" % date ) prev_idx = 0 ephem = self while True : idx = len ( ephem ) if idx == 1 : break k = idx // 2 if date > ephem [ k ] . date : prev_idx += k ephem = ephem [ k : ... | Interpolate data at a given date |
33,822 | def iter ( self , * , dates = None , start = None , stop = None , step = None , strict = True , ** kwargs ) : listeners = kwargs . get ( 'listeners' , [ ] ) if dates : for date in dates : orb = self . propagate ( date ) for listen_orb in self . listen ( orb , listeners ) : yield listen_orb yield orb else : real_start =... | Ephemeris generator based on the data of this one but with different dates |
33,823 | def ephem ( self , * args , ** kwargs ) : return self . __class__ ( self . ephemeris ( * args , ** kwargs ) ) | Create an Ephem object which is a subset of this one |
33,824 | def copy ( self , * , form = None , frame = None ) : new = self . ephem ( ) if frame : new . frame = frame if form : new . form = form return new | Create a deep copy of the ephemeris and allow frame and form changing |
33,825 | def loads ( text ) : if text . startswith ( "CCSDS_OEM_VERS" ) : func = _read_oem elif text . startswith ( "CCSDS_OPM_VERS" ) : func = _read_opm else : raise ValueError ( "Unknown CCSDS type" ) return func ( text ) | Read CCSDS from a string and provide the beyond class corresponding ; Orbit or list of Orbit if it s an OPM Ephem if it s an OEM . |
33,826 | def dumps ( data , ** kwargs ) : if isinstance ( data , Ephem ) or ( isinstance ( data , Iterable ) and all ( isinstance ( x , Ephem ) for x in data ) ) : content = _dump_oem ( data , ** kwargs ) elif isinstance ( data , Orbit ) : content = _dump_opm ( data , ** kwargs ) else : raise TypeError ( "Unknown object type" )... | Create a string CCSDS representation of the object |
33,827 | def _float ( value ) : if "[" in value : value , sep , unit = value . partition ( "[" ) unit = sep + unit if unit in ( "[km]" , "[km/s]" ) : multiplier = 1000 elif unit == "[s]" : multiplier = 1 else : raise ValueError ( "Unknown unit for this field" , unit ) else : multiplier = 1000 return float ( value ) * multiplier | Conversion of state vector field with automatic unit handling |
33,828 | def _tab ( element ) : elements = { 'x' : 'tab5.2a.txt' , 'y' : 'tab5.2b.txt' , 's' : 'tab5.2d.txt' } if element . lower ( ) not in elements . keys ( ) : raise ValueError ( 'Unknown element \'%s\'' % element ) filepath = Path ( __file__ ) . parent / "data" / elements [ element . lower ( ) ] total = [ ] with filepath . ... | Extraction and caching of IAU2000 nutation coefficients |
33,829 | def _earth_orientation ( date ) : ttt = date . change_scale ( 'TT' ) . julian_century s_prime = - 0.000047 * ttt return date . eop . x / 3600. , date . eop . y / 3600. , s_prime / 3600 | Earth orientation parameters in degrees |
33,830 | def earth_orientation ( date ) : x_p , y_p , s_prime = np . deg2rad ( _earth_orientation ( date ) ) return rot3 ( - s_prime ) @ rot2 ( x_p ) @ rot1 ( y_p ) | Earth orientation as a rotating matrix |
33,831 | def _xys ( date ) : X , Y , s_xy2 = _xysxy2 ( date ) dX , dY = date . eop . dx / 1000. , date . eop . dy / 1000. X = np . radians ( ( X + dX ) / 3600. ) Y = np . radians ( ( Y + dY ) / 3600. ) s = np . radians ( s_xy2 / 3600. ) - ( X * Y / 2 ) return X , Y , s | Get The X Y and s coordinates |
33,832 | def orbit ( self , orbit ) : self . _orbit = orbit tle = Tle . from_orbit ( orbit ) lines = tle . text . splitlines ( ) if len ( lines ) == 3 : _ , line1 , line2 = lines else : line1 , line2 = lines self . tle = twoline2rv ( line1 , line2 , wgs72 ) | Initialize the propagator |
33,833 | def propagate ( self , date ) : if type ( date ) is timedelta : date = self . orbit . date + date _date = [ float ( x ) for x in "{:%Y %m %d %H %M %S.%f}" . format ( date ) . split ( ) ] p , v = self . tle . propagate ( * _date ) result = [ x * 1000 for x in p + v ] return self . orbit . __class__ ( date , result , 'ca... | Propagate the initialized orbit |
33,834 | def to_tnw ( orbit ) : pos , vel = _split ( orbit ) t = vel / norm ( vel ) w = np . cross ( pos , vel ) / ( norm ( pos ) * norm ( vel ) ) n = np . cross ( w , t ) return np . array ( [ t , n , w ] ) | In the TNW Local Orbital Reference Frame x is oriented along the velocity vector z along the angular momentum and y complete the frame . |
33,835 | def to_qsw ( orbit ) : pos , vel = _split ( orbit ) q = pos / norm ( pos ) w = np . cross ( pos , vel ) / ( norm ( pos ) * norm ( vel ) ) s = np . cross ( w , q ) return np . array ( [ q , s , w ] ) | In the QSW Local Orbital Reference Frame x is oriented along the position vector z along the angular momentum and y complete the frame . |
33,836 | def _float ( text ) : text = text . strip ( ) if text [ 0 ] in ( '-' , '+' ) : text = "%s.%s" % ( text [ 0 ] , text [ 1 : ] ) else : text = "+.%s" % text if "+" in text [ 1 : ] or "-" in text [ 1 : ] : value , exp_sign , expo = text . rpartition ( '+' ) if '+' in text [ 1 : ] else text . rpartition ( '-' ) v = float ( ... | Fonction to convert the decimal point assumed format of TLE to actual float |
33,837 | def _unfloat ( flt , precision = 5 ) : if flt == 0. : return "{}-0" . format ( "0" * precision ) num , _ , exp = "{:.{}e}" . format ( flt , precision - 1 ) . partition ( 'e' ) exp = int ( exp ) num = num . replace ( '.' , '' ) return "%s%d" % ( num , exp + 1 ) | Function to convert float to decimal point assumed format |
33,838 | def _check_validity ( cls , text ) : if not text [ 0 ] . lstrip ( ) . startswith ( '1 ' ) or not text [ 1 ] . lstrip ( ) . startswith ( '2 ' ) : raise ValueError ( "Line number check failed" ) for line in text : line = line . strip ( ) if str ( cls . _checksum ( line ) ) != line [ - 1 ] : raise ValueError ( "Checksum v... | Check the validity of a TLE |
33,839 | def _checksum ( cls , line ) : tr_table = str . maketrans ( { c : None for c in ascii_uppercase + "+ ." } ) no_letters = line [ : 68 ] . translate ( tr_table ) . replace ( "-" , "1" ) return sum ( [ int ( l ) for l in no_letters ] ) % 10 | Compute the checksum of a full line |
33,840 | def orbit ( self ) : data = { 'bstar' : self . bstar , 'ndot' : self . ndot , 'ndotdot' : self . ndotdot , 'tle' : self . text } return Orbit ( self . epoch , self . to_list ( ) , "TLE" , "TEME" , 'Sgp4' , ** data ) | Convert TLE to Orbit object in order to make computations on it |
33,841 | def from_string ( cls , text , comments = "#" , error = "warn" ) : cache = [ ] for line in text . splitlines ( ) : if not line . strip ( ) or line . startswith ( comments ) : continue if line . startswith ( '1 ' ) : cache . append ( line ) elif line . startswith ( '2 ' ) : cache . append ( line ) try : yield cls ( "\n"... | Generator of TLEs from a string |
33,842 | def orbit2frame ( name , ref_orbit , orientation = None , center = None , bypass = False ) : if orientation is None : orientation = ref_orbit . frame . orientation elif orientation . upper ( ) in ( "RSW" , "LVLH" ) : orientation = "QSW" elif orientation . upper ( ) not in ( "QSW" , "TNW" ) : raise ValueError ( "Unknown... | Create a frame based on a Orbit or Ephem object . |
33,843 | def transform ( self , new_frame ) : steps = self . __class__ . steps ( new_frame ) orbit = self . orbit for _from , _to in steps : from_obj = _from ( self . date , orbit ) direct = "_to_%s" % _to if hasattr ( from_obj , direct ) : rotation , offset = getattr ( from_obj , direct ) ( ) else : to_obj = _to ( self . date ... | Change the frame of the orbit |
33,844 | def _scale_tdb_minus_tt ( self , mjd , eop ) : jd = mjd + Date . JD_MJD jj = Date . _julian_century ( jd ) m = radians ( 357.5277233 + 35999.05034 * jj ) delta_lambda = radians ( 246.11 + 0.90251792 * ( jd - 2451545. ) ) return 0.001657 * sin ( m ) + 0.000022 * sin ( delta_lambda ) | Definition of the Barycentric Dynamic Time scale relatively to Terrestrial Time |
33,845 | def offset ( self , mjd , new_scale , eop ) : delta = 0 for one , two in self . steps ( new_scale ) : one = one . name . lower ( ) two = two . name . lower ( ) oper = "_scale_{}_minus_{}" . format ( two , one ) roper = "_scale_{}_minus_{}" . format ( one , two ) if hasattr ( self , oper ) : delta += getattr ( self , op... | Compute the offset necessary in order to convert from one time - scale to another |
33,846 | def datetime ( self ) : if 'dt_scale' not in self . _cache . keys ( ) : self . _cache [ 'dt_scale' ] = self . _datetime - timedelta ( seconds = self . _offset ) return self . _cache [ 'dt_scale' ] | Conversion of the Date object into a datetime . datetime |
33,847 | def strptime ( cls , data , format , scale = DEFAULT_SCALE ) : return cls ( datetime . strptime ( data , format ) , scale = scale ) | Convert a string representation of a date to a Date object |
33,848 | def range ( cls , start = None , stop = None , step = None , inclusive = False ) : def sign ( x ) : return ( - 1 , 1 ) [ x >= 0 ] if not step : raise ValueError ( "Null step" ) if isinstance ( stop , timedelta ) : stop = start + stop if sign ( ( stop - start ) . total_seconds ( ) ) != sign ( step . total_seconds ( ) ) ... | Generator of a date range |
33,849 | def _newton ( self , orb , step ) : date = orb . date + step new_body = zeros ( 6 ) new_body [ : 3 ] = orb [ 3 : ] for body in self . bodies : orb_body = body . propagate ( date ) orb_body . frame = orb . frame diff = orb_body [ : 3 ] - orb [ : 3 ] norm = sqrt ( sum ( diff ** 2 ) ) ** 3 new_body [ 3 : ] += G * body . m... | Newton s Law of Universal Gravitation |
33,850 | def _make_step ( self , orb , step ) : method = self . BUTCHER [ self . method ] a , b , c = method [ 'a' ] , method [ 'b' ] , method [ 'c' ] y_n = orb . copy ( ) ks = [ self . _newton ( y_n , timedelta ( 0 ) ) ] for a , c in zip ( a [ 1 : ] , c [ 1 : ] ) : k_plus1 = self . _newton ( y_n + a @ ks * step . total_seconds... | Compute the next step with the selected method |
33,851 | def _soi ( self , orb ) : for body in self . alt : soi = self . SOI [ body . name ] sph = orb . copy ( frame = soi . frame , form = 'spherical' ) if sph . r < soi . radius : active = body break else : active = self . central return active | Evaluate the need for SOI transition by comparing the radial distance between the considered body and the spacecraft |
33,852 | def _change_soi ( self , body ) : if body == self . central : self . bodies = [ self . central ] self . step = self . central_step self . active = self . central . name self . frame = self . central . name else : soi = self . SOI [ body . name ] self . bodies = [ body ] self . step = self . alt_step self . active = bod... | Modify the inner parameters of the Kepler propagator in order to place the spacecraft in the right Sphere of Influence |
33,853 | def register ( name = EopDb . DEFAULT_DBNAME ) : if isinstance ( name , str ) : def wrapper ( klass ) : EopDb . register ( klass , name ) return klass return wrapper else : klass = name EopDb . register ( klass ) return klass | Decorator for registering an Eop Database |
33,854 | def get_last_next ( self , date ) : past , future = ( None , None ) , ( None , None ) for mjd , value in reversed ( self . data ) : if mjd <= date : past = ( mjd , value ) break future = ( mjd , value ) return past , future | Provide the last and next leap - second events relative to a date |
33,855 | def db ( cls , dbname = None ) : cls . _load_entry_points ( ) dbname = dbname or config . get ( 'eop' , 'dbname' , fallback = cls . DEFAULT_DBNAME ) if dbname not in cls . _dbs . keys ( ) : raise EopError ( "Unknown database '%s'" % dbname ) if isclass ( cls . _dbs [ dbname ] ) : try : cls . _dbs [ dbname ] = cls . _db... | Retrieve the database |
33,856 | def get ( cls , mjd : float , dbname : str = None ) -> Eop : try : value = cls . db ( dbname ) [ mjd ] except ( EopError , KeyError ) as e : if isinstance ( e , KeyError ) : msg = "Missing EOP data for mjd = '%s'" % e else : msg = str ( e ) if cls . policy ( ) == cls . WARN : log . warning ( msg ) elif cls . policy ( )... | Retrieve Earth Orientation Parameters and timescales differences for a given date |
33,857 | def register ( cls , klass , name = DEFAULT_DBNAME ) : if name in cls . _dbs : msg = "'{}' is already registered for an Eop database. Skipping" . format ( name ) log . warning ( msg ) else : cls . _dbs [ name ] = klass | Register an Eop Database |
33,858 | def _tab ( max_i = None ) : filepath = Path ( __file__ ) . parent / "data" / "tab5.1.txt" result = [ ] with filepath . open ( ) as fhd : i = 0 for line in fhd . read ( ) . splitlines ( ) : if line . startswith ( "#" ) or not line . strip ( ) : continue fields = line . split ( ) result . append ( ( [ int ( x ) for x in ... | Extraction and caching of IAU1980 nutation coefficients |
33,859 | def _precesion ( date ) : t = date . change_scale ( 'TT' ) . julian_century zeta = ( 2306.2181 * t + 0.30188 * t ** 2 + 0.017998 * t ** 3 ) / 3600. theta = ( 2004.3109 * t - 0.42665 * t ** 2 - 0.041833 * t ** 3 ) / 3600. z = ( 2306.2181 * t + 1.09468 * t ** 2 + 0.018203 * t ** 3 ) / 3600. return zeta , theta , z | Precession in degrees |
33,860 | def precesion ( date ) : zeta , theta , z = np . deg2rad ( _precesion ( date ) ) return rot3 ( zeta ) @ rot2 ( - theta ) @ rot3 ( z ) | Precession as a rotation matrix |
33,861 | def _nutation ( date , eop_correction = True , terms = 106 ) : ttt = date . change_scale ( 'TT' ) . julian_century r = 360. epsilon_bar = 84381.448 - 46.8150 * ttt - 5.9e-4 * ttt ** 2 + 1.813e-3 * ttt ** 3 epsilon_bar /= 3600. m_m = 134.96298139 + ( 1325 * r + 198.8673981 ) * ttt + 0.0086972 * ttt ** 2 + 1.78e-5 * ttt ... | Model 1980 of nutation as described in Vallado p . 224 |
33,862 | def nutation ( date , eop_correction = True , terms = 106 ) : epsilon_bar , delta_psi , delta_eps = np . deg2rad ( _nutation ( date , eop_correction , terms ) ) epsilon = epsilon_bar + delta_eps return rot1 ( - epsilon_bar ) @ rot3 ( delta_psi ) @ rot1 ( epsilon ) | Nutation as a rotation matrix |
33,863 | def equinox ( date , eop_correction = True , terms = 106 , kinematic = True ) : epsilon_bar , delta_psi , delta_eps = _nutation ( date , eop_correction , terms ) equin = delta_psi * 3600. * np . cos ( np . deg2rad ( epsilon_bar ) ) if date . d >= 50506 and kinematic : ttt = date . change_scale ( 'TT' ) . julian_century... | Equinox equation in degrees |
33,864 | def _sideral ( date , longitude = 0. , model = 'mean' , eop_correction = True , terms = 106 ) : t = date . change_scale ( 'UT1' ) . julian_century theta = 67310.54841 + ( 876600 * 3600 + 8640184.812866 ) * t + 0.093104 * t ** 2 - 6.2e-6 * t ** 3 theta /= 240. if model == 'apparent' : theta += equinox ( date , eop_corre... | Get the sideral time at a defined date |
33,865 | def sideral ( date , longitude = 0. , model = 'mean' , eop_correction = True , terms = 106 ) : theta = _sideral ( date , longitude , model , eop_correction , terms ) return rot3 ( np . deg2rad ( - theta ) ) | Sideral time as a rotation matrix |
33,866 | def dv ( self , orb ) : orb = orb . copy ( form = "cartesian" ) if self . frame == "QSW" : mat = to_qsw ( orb ) . T elif self . frame == "TNW" : mat = to_tnw ( orb ) . T else : mat = np . identity ( 3 ) return mat @ self . _dv | Computation of the velocity increment in the reference frame of the orbit |
33,867 | def copy ( self , * , frame = None , form = None ) : new_compl = { } for k , v in self . complements . items ( ) : new_compl [ k ] = v . copy ( ) if hasattr ( v , 'copy' ) else v new_obj = self . __class__ ( self . date , self . base . copy ( ) , self . form , self . frame , self . propagator . copy ( ) if self . propa... | Provide a new instance of the same point in space - time |
33,868 | def propagate ( self , date ) : if self . propagator . orbit is not self : self . propagator . orbit = self return self . propagator . propagate ( date ) | Propagate the orbit to a new date |
33,869 | def ephemeris ( self , ** kwargs ) : for orb in self . iter ( inclusive = True , ** kwargs ) : yield orb | Generator giving the propagation of the orbit at different dates |
33,870 | def period ( self ) : return timedelta ( seconds = 2 * np . pi * np . sqrt ( self . kep . a ** 3 / self . mu ) ) | Period of the orbit as a timedelta |
33,871 | def va ( self ) : return np . sqrt ( self . mu * ( 2 / ( self . ra ) - 1 / self . kep . a ) ) | Velocity at apocenter |
33,872 | def vp ( self ) : return np . sqrt ( self . mu * ( 2 / ( self . rp ) - 1 / self . kep . a ) ) | Velocity at pericenter |
33,873 | def path ( self , goal ) : if goal == self . name : return [ self ] if goal not in self . routes : raise ValueError ( "Unknown '{0}'" . format ( goal ) ) obj = self path = [ obj ] while True : obj = obj . routes [ goal ] . direction path . append ( obj ) if obj . name == goal : break return path | Get the shortest way between two nodes of the graph |
33,874 | def steps ( self , goal ) : path = self . path ( goal ) for i in range ( len ( path ) - 1 ) : yield path [ i ] , path [ i + 1 ] | Get the list of individual relations leading to the targeted node |
33,875 | def build_if_needed ( db ) : if len ( db . engine . table_names ( ) ) == 0 : from my_site . models . tables . user import User db . create_all ( ) | Little helper method for making tables in SQL - Alchemy with SQLite |
33,876 | def deunicode ( item ) : if item is None : return None if isinstance ( item , str ) : return item if isinstance ( item , six . text_type ) : return item . encode ( 'utf-8' ) if isinstance ( item , dict ) : return { deunicode ( key ) : deunicode ( value ) for ( key , value ) in item . items ( ) } if isinstance ( item , ... | Convert unicode objects to str |
33,877 | def assert_true ( expr , msg_fmt = "{msg}" ) : if not expr : msg = "{!r} is not truthy" . format ( expr ) fail ( msg_fmt . format ( msg = msg , expr = expr ) ) | Fail the test unless the expression is truthy . |
33,878 | def assert_false ( expr , msg_fmt = "{msg}" ) : if expr : msg = "{!r} is not falsy" . format ( expr ) fail ( msg_fmt . format ( msg = msg , expr = expr ) ) | Fail the test unless the expression is falsy . |
33,879 | def assert_boolean_true ( expr , msg_fmt = "{msg}" ) : if expr is not True : msg = "{!r} is not True" . format ( expr ) fail ( msg_fmt . format ( msg = msg , expr = expr ) ) | Fail the test unless the expression is the constant True . |
33,880 | def assert_boolean_false ( expr , msg_fmt = "{msg}" ) : if expr is not False : msg = "{!r} is not False" . format ( expr ) fail ( msg_fmt . format ( msg = msg , expr = expr ) ) | Fail the test unless the expression is the constant False . |
33,881 | def assert_is_none ( expr , msg_fmt = "{msg}" ) : if expr is not None : msg = "{!r} is not None" . format ( expr ) fail ( msg_fmt . format ( msg = msg , expr = expr ) ) | Fail if the expression is not None . |
33,882 | def assert_is_not_none ( expr , msg_fmt = "{msg}" ) : if expr is None : msg = "expression is None" fail ( msg_fmt . format ( msg = msg , expr = expr ) ) | Fail if the expression is None . |
33,883 | def assert_equal ( first , second , msg_fmt = "{msg}" ) : if isinstance ( first , dict ) and isinstance ( second , dict ) : assert_dict_equal ( first , second , msg_fmt ) elif not first == second : msg = "{!r} != {!r}" . format ( first , second ) fail ( msg_fmt . format ( msg = msg , first = first , second = second ) ) | Fail unless first equals second as determined by the == operator . |
33,884 | def assert_not_equal ( first , second , msg_fmt = "{msg}" ) : if first == second : msg = "{!r} == {!r}" . format ( first , second ) fail ( msg_fmt . format ( msg = msg , first = first , second = second ) ) | Fail if first equals second as determined by the == operator . |
33,885 | def assert_almost_equal ( first , second , msg_fmt = "{msg}" , places = None , delta = None ) : if delta is not None and places is not None : raise TypeError ( "'places' and 'delta' are mutually exclusive" ) if delta is not None : if delta <= 0 : raise ValueError ( "delta must be larger than 0" ) diff = abs ( second - ... | Fail if first and second are not equal after rounding . |
33,886 | def assert_dict_equal ( first , second , key_msg_fmt = "{msg}" , value_msg_fmt = "{msg}" ) : first_keys = set ( first . keys ( ) ) second_keys = set ( second . keys ( ) ) missing_keys = list ( first_keys - second_keys ) extra_keys = list ( second_keys - first_keys ) if missing_keys or extra_keys : if missing_keys : if ... | Fail unless first dictionary equals second . |
33,887 | def assert_less ( first , second , msg_fmt = "{msg}" ) : if not first < second : msg = "{!r} is not less than {!r}" . format ( first , second ) fail ( msg_fmt . format ( msg = msg , first = first , second = second ) ) | Fail if first is not less than second . |
33,888 | def assert_less_equal ( first , second , msg_fmt = "{msg}" ) : if not first <= second : msg = "{!r} is not less than or equal to {!r}" . format ( first , second ) fail ( msg_fmt . format ( msg = msg , first = first , second = second ) ) | Fail if first is not less than or equal to second . |
33,889 | def assert_greater ( first , second , msg_fmt = "{msg}" ) : if not first > second : msg = "{!r} is not greater than {!r}" . format ( first , second ) fail ( msg_fmt . format ( msg = msg , first = first , second = second ) ) | Fail if first is not greater than second . |
33,890 | def assert_greater_equal ( first , second , msg_fmt = "{msg}" ) : if not first >= second : msg = "{!r} is not greater than or equal to {!r}" . format ( first , second ) fail ( msg_fmt . format ( msg = msg , first = first , second = second ) ) | Fail if first is not greater than or equal to second . |
33,891 | def assert_regex ( text , regex , msg_fmt = "{msg}" ) : compiled = re . compile ( regex ) if not compiled . search ( text ) : msg = "{!r} does not match {!r}" . format ( text , compiled . pattern ) fail ( msg_fmt . format ( msg = msg , text = text , pattern = compiled . pattern ) ) | Fail if text does not match the regular expression . |
33,892 | def assert_is ( first , second , msg_fmt = "{msg}" ) : if first is not second : msg = "{!r} is not {!r}" . format ( first , second ) fail ( msg_fmt . format ( msg = msg , first = first , second = second ) ) | Fail if first and second do not refer to the same object . |
33,893 | def assert_is_not ( first , second , msg_fmt = "{msg}" ) : if first is second : msg = "both arguments refer to {!r}" . format ( first ) fail ( msg_fmt . format ( msg = msg , first = first , second = second ) ) | Fail if first and second refer to the same object . |
33,894 | def assert_in ( first , second , msg_fmt = "{msg}" ) : if first not in second : msg = "{!r} not in {!r}" . format ( first , second ) fail ( msg_fmt . format ( msg = msg , first = first , second = second ) ) | Fail if first is not in collection second . |
33,895 | def assert_not_in ( first , second , msg_fmt = "{msg}" ) : if first in second : msg = "{!r} is in {!r}" . format ( first , second ) fail ( msg_fmt . format ( msg = msg , first = first , second = second ) ) | Fail if first is in a collection second . |
33,896 | def assert_count_equal ( sequence1 , sequence2 , msg_fmt = "{msg}" ) : def compare ( ) : missing1 = list ( sequence2 ) missing2 = [ ] for item in sequence1 : try : missing1 . remove ( item ) except ValueError : missing2 . append ( item ) return missing1 , missing2 def build_message ( ) : msg = "" if missing_from_1 : ms... | Compare the items of two sequences ignoring order . |
33,897 | def assert_is_instance ( obj , cls , msg_fmt = "{msg}" ) : if not isinstance ( obj , cls ) : msg = "{!r} is an instance of {!r}, expected {!r}" . format ( obj , obj . __class__ , cls ) types = cls if isinstance ( cls , tuple ) else ( cls , ) fail ( msg_fmt . format ( msg = msg , obj = obj , types = types ) ) | Fail if an object is not an instance of a class or tuple of classes . |
33,898 | def assert_has_attr ( obj , attribute , msg_fmt = "{msg}" ) : if not hasattr ( obj , attribute ) : msg = "{!r} does not have attribute '{}'" . format ( obj , attribute ) fail ( msg_fmt . format ( msg = msg , obj = obj , attribute = attribute ) ) | Fail is an object does not have an attribute . |
33,899 | def assert_datetime_about_now ( actual , msg_fmt = "{msg}" ) : now = datetime . now ( ) if actual is None : msg = "None is not a valid date/time" fail ( msg_fmt . format ( msg = msg , actual = actual , now = now ) ) lower_bound = now - timedelta ( seconds = _EPSILON_SECONDS ) upper_bound = now + timedelta ( seconds = _... | Fail if a datetime object is not within 5 seconds of the local time . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.