sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def change_owner(ctx, owner, uuid): """Changes the ownership of objects""" objects = ctx.obj['objects'] database = ctx.obj['db'] if uuid is True: owner_filter = {'uuid': owner} else: owner_filter = {'name': owner} owner = database.objectmodels['user'].find_one(owner_filter) ...
Changes the ownership of objects
entailment
def notify(self, event): """Notify a user""" self.log('Got a notification event!') self.log(event, pretty=True) self.log(event.__dict__)
Notify a user
entailment
def clientdisconnect(self, event): """Handler to deal with a possibly disconnected remote controlling client :param event: ClientDisconnect Event """ try: if event.clientuuid == self.remote_controller: self.log("Remote controller disconnected!", lvl=c...
Handler to deal with a possibly disconnected remote controlling client :param event: ClientDisconnect Event
entailment
def getlist(self, event): """Processes configuration list requests :param event: """ try: componentlist = model_factory(Schema).find({}) data = [] for comp in componentlist: try: data.append({ ...
Processes configuration list requests :param event:
entailment
def put(self, event): """Store a given configuration""" self.log("Configuration put request ", event.user) try: component = model_factory(Schema).find_one({ 'uuid': event.data['uuid'] }) component.update(event.data) ...
Store a given configuration
entailment
def get(self, event): """Get a stored configuration""" try: comp = event.data['uuid'] except KeyError: comp = None if not comp: self.log('Invalid get request without schema or component', lvl=error) return se...
Get a stored configuration
entailment
def rec(self): """Records a single snapshot""" try: self._snapshot() except Exception as e: self.log("Timer error: ", e, type(e), lvl=error)
Records a single snapshot
entailment
def _toggle_filming(self): """Toggles the camera system recording state""" if self._filming: self.log("Stopping operation") self._filming = False self.timer.stop() else: self.log("Starting operation") self._filming = True s...
Toggles the camera system recording state
entailment
def client_disconnect(self, event): """ A client has disconnected, update possible subscriptions accordingly. :param event: """ self.log("Removing disconnected client from subscriptions", lvl=debug) client_uuid = event.clientuuid self._unsubscribe(client_uuid)
A client has disconnected, update possible subscriptions accordingly. :param event:
entailment
def get(self, event): """Get a specified object""" try: data, schema, user, client = self._get_args(event) except AttributeError: return object_filter = self._get_filter(event) if 'subscribe' in data: do_subscribe = data['subscribe'] is True...
Get a specified object
entailment
def search(self, event): """Search for an object""" try: data, schema, user, client = self._get_args(event) except AttributeError: return # object_filter['$text'] = {'$search': str(data['search'])} if data.get('fulltext', False) is True: obje...
Search for an object
entailment
def objectlist(self, event): """Get a list of objects""" self.log('LEGACY LIST FUNCTION CALLED!', lvl=warn) try: data, schema, user, client = self._get_args(event) except AttributeError: return object_filter = self._get_filter(event) self.log('Ob...
Get a list of objects
entailment
def change(self, event): """Change an existing object""" try: data, schema, user, client = self._get_args(event) except AttributeError: return try: uuid = data['uuid'] change = data['change'] field = change['field'] ...
Change an existing object
entailment
def put(self, event): """Put an object""" try: data, schema, user, client = self._get_args(event) except AttributeError: return try: clientobject = data['obj'] uuid = clientobject['uuid'] except KeyError as e: self.log...
Put an object
entailment
def delete(self, event): """Delete an existing object""" try: data, schema, user, client = self._get_args(event) except AttributeError: return try: uuids = data['uuid'] if not isinstance(uuids, list): uuids = [uuids] ...
Delete an existing object
entailment
def subscribe(self, event): """Subscribe to an object's future changes""" uuids = event.data if not isinstance(uuids, list): uuids = [uuids] subscribed = [] for uuid in uuids: try: self._add_subscription(uuid, event) subsc...
Subscribe to an object's future changes
entailment
def unsubscribe(self, event): """Unsubscribe from an object's future changes""" # TODO: Automatic Unsubscription uuids = event.data if not isinstance(uuids, list): uuids = [uuids] result = [] for uuid in uuids: if uuid in self.subscriptions: ...
Unsubscribe from an object's future changes
entailment
def update_subscriptions(self, event): """OM event handler for to be stored and client shared objectmodels :param event: OMRequest with uuid, schema and object data """ # self.log("Event: '%s'" % event.__dict__) try: self._update_subscribers(event.schema, event.data)...
OM event handler for to be stored and client shared objectmodels :param event: OMRequest with uuid, schema and object data
entailment
def GithubImporter(ctx, repository, all, owner, project, ignore_labels, no_tags, username, password): """Project Importer for Github Repository Issues Argument REPOSITORY must be given as 'username/repository' Owner and project have to be UUIDs """ db = ctx.obj['db'] if project is not None: ...
Project Importer for Github Repository Issues Argument REPOSITORY must be given as 'username/repository' Owner and project have to be UUIDs
entailment
def all_languages(): """Compile a list of all available language translations""" rv = [] for lang in os.listdir(localedir): base = lang.split('_')[0].split('.')[0].split('@')[0] if 2 <= len(base) <= 3 and all(c.islower() for c in base): if base != 'all': rv.appe...
Compile a list of all available language translations
entailment
def language_token_to_name(languages): """Get a descriptive title for all languages""" result = {} with open(os.path.join(localedir, 'languages.json'), 'r') as f: language_lookup = json.load(f) for language in languages: language = language.lower() try: result[lang...
Get a descriptive title for all languages
entailment
def print_messages(domain, msg): """Debugging function to print all message language variants""" domain = Domain(domain) for lang in all_languages(): print(lang, ':', domain.get(lang, msg))
Debugging function to print all message language variants
entailment
def i18n(msg, event=None, lang='en', domain='backend'): """Gettext function wrapper to return a message in a specified language by domain To use internationalization (i18n) on your messages, import it as '_' and use as usual. Do not forget to supply the client's language setting.""" if event is not No...
Gettext function wrapper to return a message in a specified language by domain To use internationalization (i18n) on your messages, import it as '_' and use as usual. Do not forget to supply the client's language setting.
entailment
def std_hash(word, salt): """Generates a cryptographically strong (sha512) hash with this nodes salt added.""" try: password = word.encode('utf-8') except UnicodeDecodeError: password = word word_hash = sha512(password) word_hash.update(salt) hex_hash = word_hash.hexdigest(...
Generates a cryptographically strong (sha512) hash with this nodes salt added.
entailment
def std_human_uid(kind=None): """Return a random generated human-friendly phrase as low-probability unique id""" kind_list = alphabet if kind == 'animal': kind_list = animals elif kind == 'place': kind_list = places name = "{color} {adjective} {kind} of {attribute}".format( ...
Return a random generated human-friendly phrase as low-probability unique id
entailment
def std_table(rows): """Return a formatted table of given rows""" result = "" if len(rows) > 1: headers = rows[0]._fields lens = [] for i in range(len(rows[0])): lens.append(len(max([x[i] for x in rows] + [headers[i]], key=lambda x: len(st...
Return a formatted table of given rows
entailment
def std_salt(length=16, lowercase=True): """Generates a cryptographically sane salt of 'length' (default: 16) alphanumeric characters """ alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" if lowercase is True: alphabet += "abcdefghijklmnopqrstuvwxyz" chars = [] for i in range(lengt...
Generates a cryptographically sane salt of 'length' (default: 16) alphanumeric characters
entailment
def _get_translation(self, lang): """Add a new translation language to the live gettext translator""" try: return self._translations[lang] except KeyError: # The fact that `fallback=True` is not the default is a serious design flaw. rv = self._translations[la...
Add a new translation language to the live gettext translator
entailment
def handler(*names, **kwargs): """Creates an Event Handler This decorator can be applied to methods of classes derived from :class:`circuits.core.components.BaseComponent`. It marks the method as a handler for the events passed as arguments to the ``@handler`` decorator. The events are specified by...
Creates an Event Handler This decorator can be applied to methods of classes derived from :class:`circuits.core.components.BaseComponent`. It marks the method as a handler for the events passed as arguments to the ``@handler`` decorator. The events are specified by their name. The decorated method...
entailment
def log(self, *args, **kwargs): """Log a statement from this component""" func = inspect.currentframe().f_back.f_code # Dump the message + the name of this function to the log. if 'exc' in kwargs and kwargs['exc'] is True: exc_type, exc_obj, exc_tb = exc_info() ...
Log a statement from this component
entailment
def register(self, *args): """Register a configurable component in the configuration schema store""" super(ConfigurableMeta, self).register(*args) from hfos.database import configschemastore # self.log('ADDING SCHEMA:') # pprint(self.configschema) configschemasto...
Register a configurable component in the configuration schema store
entailment
def unregister(self): """Removes the unique name from the systems unique name list""" self.names.remove(self.uniquename) super(ConfigurableMeta, self).unregister()
Removes the unique name from the systems unique name list
entailment
def _read_config(self): """Read this component's configuration from the database""" try: self.config = self.componentmodel.find_one( {'name': self.uniquename}) except ServerSelectionTimeoutError: # pragma: no cover self.log("No database access! Check if ...
Read this component's configuration from the database
entailment
def _write_config(self): """Write this component's configuration back to the database""" if not self.config: self.log("Unable to write non existing configuration", lvl=error) return self.config.save() self.log("Configuration stored.")
Write this component's configuration back to the database
entailment
def _set_config(self, config=None): """Set this component's initial configuration""" if not config: config = {} try: # pprint(self.configschema) self.config = self.componentmodel(config) # self.log("Config schema:", lvl=critical) # ppr...
Set this component's initial configuration
entailment
def reload_configuration(self, event): """Event triggered configuration reload""" if event.target == self.uniquename: self.log('Reloading configuration') self._read_config()
Event triggered configuration reload
entailment
def _augment_info(info): """Fill out the template information""" info['description_header'] = "=" * len(info['description']) info['component_name'] = info['plugin_name'].capitalize() info['year'] = time.localtime().tm_year info['license_longtext'] = '' info['keyword_list'] = u"" for keywor...
Fill out the template information
entailment
def _construct_module(info, target): """Build a module from templates and user supplied information""" for path in paths: real_path = os.path.abspath(os.path.join(target, path.format(**info))) log("Making directory '%s'" % real_path) os.makedirs(real_path) # pprint(info) for it...
Build a module from templates and user supplied information
entailment
def _ask_questionnaire(): """Asks questions to fill out a HFOS plugin template""" answers = {} print(info_header) pprint(questions.items()) for question, default in questions.items(): response = _ask(question, default, str(type(default)), show_hint=True) if type(default) == unicode...
Asks questions to fill out a HFOS plugin template
entailment
def create_module(clear_target, target): """Creates a new template HFOS plugin module""" if os.path.exists(target): if clear_target: shutil.rmtree(target) else: log("Target exists! Use --clear to delete it first.", emitter='MANAGE') sys.exit(2...
Creates a new template HFOS plugin module
entailment
def lookup_field(key, lookup_type=None, placeholder=None, html_class="div", select_type="strapselect", mapping="uuid"): """Generates a lookup field for form definitions""" if lookup_type is None: lookup_type = key if placeholder is None: placeholder = "Select a " + lookup_...
Generates a lookup field for form definitions
entailment
def fieldset(title, items, options=None): """A field set with a title and sub items""" result = { 'title': title, 'type': 'fieldset', 'items': items } if options is not None: result.update(options) return result
A field set with a title and sub items
entailment
def section(rows, columns, items, label=None): """A section consisting of rows and columns""" # TODO: Integrate label sections = [] column_class = "section-column col-sm-%i" % (12 / columns) for vertical in range(columns): column_items = [] for horizontal in range(rows): ...
A section consisting of rows and columns
entailment
def emptyArray(key, add_label=None): """An array that starts empty""" result = { 'key': key, 'startEmpty': True } if add_label is not None: result['add'] = add_label result['style'] = {'add': 'btn-success'} return result
An array that starts empty
entailment
def tabset(titles, contents): """A tabbed container widget""" tabs = [] for no, title in enumerate(titles): tab = { 'title': title, } content = contents[no] if isinstance(content, list): tab['items'] = content else: tab['items'] = ...
A tabbed container widget
entailment
def country_field(key='country'): """Provides a select box for country selection""" country_list = list(countries) title_map = [] for item in country_list: title_map.append({'value': item.alpha_3, 'name': item.name}) widget = { 'key': key, 'type': 'uiselect', 'title...
Provides a select box for country selection
entailment
def area_field(key='area'): """Provides a select box for country selection""" area_list = list(subdivisions) title_map = [] for item in area_list: title_map.append({'value': item.code, 'name': item.name}) widget = { 'key': key, 'type': 'uiselect', 'titleMap': title_...
Provides a select box for country selection
entailment
def timed_connectivity_check(self, event): """Tests internet connectivity in regular intervals and updates the nodestate accordingly""" self.status = self._can_connect() self.log('Timed connectivity check:', self.status, lvl=verbose) if self.status: if not self.old_status: ...
Tests internet connectivity in regular intervals and updates the nodestate accordingly
entailment
def _can_connect(self): """Tries to connect to the configured host:port and returns True if the connection was established""" self.log('Trying to reach configured connectivity check endpoint', lvl=verbose) try: socket.setdefaulttimeout(self.config.timeout) socket.socket(...
Tries to connect to the configured host:port and returns True if the connection was established
entailment
def referenceframe(self, event): """Handles navigational reference frame updates. These are necessary to assign geo coordinates to alerts and other misc things. :param event with incoming referenceframe message """ self.log("Got a reference frame update! ", event, lvl=v...
Handles navigational reference frame updates. These are necessary to assign geo coordinates to alerts and other misc things. :param event with incoming referenceframe message
entailment
def activityrequest(self, event): """ActivityMonitor event handler for incoming events :param event with incoming ActivityMonitor message """ # self.log("Event: '%s'" % event.__dict__) try: action = event.action data = event.data self.log("A...
ActivityMonitor event handler for incoming events :param event with incoming ActivityMonitor message
entailment
def modify(ctx, schema, uuid, object_filter, field, value): """Modify field values of objects""" database = ctx.obj['db'] model = database.objectmodels[schema] obj = None if uuid: obj = model.find_one({'uuid': uuid}) elif object_filter: obj = model.find_one(literal_eval(object_...
Modify field values of objects
entailment
def view(ctx, schema, uuid, object_filter): """Show stored objects""" database = ctx.obj['db'] if schema is None: log('No schema given. Read the help', lvl=warn) return model = database.objectmodels[schema] if uuid: obj = model.find({'uuid': uuid}) elif object_filter:...
Show stored objects
entailment
def delete(ctx, schema, uuid, object_filter, yes): """Delete stored objects (CAUTION!)""" database = ctx.obj['db'] if schema is None: log('No schema given. Read the help', lvl=warn) return model = database.objectmodels[schema] if uuid: count = model.count({'uuid': uuid}) ...
Delete stored objects (CAUTION!)
entailment
def validate(ctx, schema, all_schemata): """Validates all objects or all objects of a given schema.""" database = ctx.obj['db'] if schema is None: if all_schemata is False: log('No schema given. Read the help', lvl=warn) return else: schemata = database....
Validates all objects or all objects of a given schema.
entailment
def find_field(ctx, search, by_type, obj): """Find fields in registered data models.""" # TODO: Fix this to work recursively on all possible subschemes if search is not None: search = search else: search = _ask("Enter search term") database = ctx.obj['db'] def find(search_sche...
Find fields in registered data models.
entailment
def Distance(lat1, lon1, lat2, lon2): """Get distance between pairs of lat-lon points""" az12, az21, dist = wgs84_geod.inv(lon1, lat1, lon2, lat2) return az21, dist
Get distance between pairs of lat-lon points
entailment
def client_details(self, *args): """Display known details about a given client""" self.log(_('Client details:', lang='de')) client = self._clients[args[0]] self.log('UUID:', client.uuid, 'IP:', client.ip, 'Name:', client.name, 'User:', self._users[client.useruuid], pre...
Display known details about a given client
entailment
def client_list(self, *args): """Display a list of connected clients""" if len(self._clients) == 0: self.log('No clients connected') else: self.log(self._clients, pretty=True)
Display a list of connected clients
entailment
def users_list(self, *args): """Display a list of connected users""" if len(self._users) == 0: self.log('No users connected') else: self.log(self._users, pretty=True)
Display a list of connected users
entailment
def sourcess_list(self, *args): """Display a list of all registered events""" from pprint import pprint sources = {} sources.update(self.authorized_events) sources.update(self.anonymous_events) for source in sources: pprint(source)
Display a list of all registered events
entailment
def events_list(self, *args): """Display a list of all registered events""" def merge(a, b, path=None): "merges b into a" if path is None: path = [] for key in b: if key in a: if isinstance(a[key], dict) and isinstance(b[key], dict...
Display a list of all registered events
entailment
def who(self, *args): """Display a table of connected users and clients""" if len(self._users) == 0: self.log('No users connected') if len(self._clients) == 0: self.log('No clients connected') return Row = namedtuple("Row", ['User', 'Clien...
Display a table of connected users and clients
entailment
def disconnect(self, sock): """Handles socket disconnections""" self.log("Disconnect ", sock, lvl=debug) try: if sock in self._sockets: self.log("Getting socket", lvl=debug) sockobj = self._sockets[sock] self.log("Getting clientuuid",...
Handles socket disconnections
entailment
def _logoutclient(self, useruuid, clientuuid): """Log out a client and possibly associated user""" self.log("Cleaning up client of logged in user.", lvl=debug) try: self._users[useruuid].clients.remove(clientuuid) if len(self._users[useruuid].clients) == 0: ...
Log out a client and possibly associated user
entailment
def connect(self, *args): """Registers new sockets and their clients and allocates uuids""" self.log("Connect ", args, lvl=verbose) try: sock = args[0] ip = args[1] if sock not in self._sockets: self.log("New client connected:", ip, lvl=debu...
Registers new sockets and their clients and allocates uuids
entailment
def send(self, event): """Sends a packet to an already known user or one of his clients by UUID""" try: jsonpacket = json.dumps(event.packet, cls=ComplexEncoder) if event.sendtype == "user": # TODO: I think, caching a user name <-> uuid table would ...
Sends a packet to an already known user or one of his clients by UUID
entailment
def broadcast(self, event): """Broadcasts an event either to all users or clients, depending on event flag""" try: if event.broadcasttype == "users": if len(self._users) > 0: self.log("Broadcasting to all users:", event...
Broadcasts an event either to all users or clients, depending on event flag
entailment
def _checkPermissions(self, user, event): """Checks if the user has in any role that allows to fire the event.""" for role in user.account.roles: if role in event.roles: self.log('Access granted', lvl=verbose) return True self.log('Access denied', lv...
Checks if the user has in any role that allows to fire the event.
entailment
def _handleAuthorizedEvents(self, component, action, data, user, client): """Isolated communication link for authorized events.""" try: if component == "debugger": self.log(component, action, data, user, client, lvl=info) if not user and component in self.author...
Isolated communication link for authorized events.
entailment
def _handleAnonymousEvents(self, component, action, data, client): """Handler for anonymous (public) events""" try: event = self.anonymous_events[component][action]['event'] self.log("Firing anonymous event: ", component, action, str(data)[:20], lvl=network)...
Handler for anonymous (public) events
entailment
def _handleAuthenticationEvents(self, requestdata, requestaction, clientuuid, sock): """Handler for authentication events""" # TODO: Move this stuff over to ./auth.py if requestaction in ("login", "autologin"): try: self.log("Login...
Handler for authentication events
entailment
def _reset_flood_offenders(self, *args): """Resets the list of flood offenders on event trigger""" offenders = [] # self.log('Resetting flood offenders') for offender, offence_time in self._flooding.items(): if time() - offence_time < 10: self.log('Removed o...
Resets the list of flood offenders on event trigger
entailment
def _check_flood_protection(self, component, action, clientuuid): """Checks if any clients have been flooding the node""" if clientuuid not in self._flood_counter: self._flood_counter[clientuuid] = 0 self._flood_counter[clientuuid] += 1 if self._flood_counter[clientuuid] >...
Checks if any clients have been flooding the node
entailment
def read(self, *args): """Handles raw client requests and distributes them to the appropriate components""" self.log("Beginning new transaction: ", args, lvl=network) try: sock, msg = args[0], args[1] user = password = client = clientuuid = useruuid = requestdata...
Handles raw client requests and distributes them to the appropriate components
entailment
def authentication(self, event): """Links the client to the granted account and profile, then notifies the client""" try: self.log("Authorization has been granted by DB check:", event.username, lvl=debug) account, profile, clientconfig = event.userd...
Links the client to the granted account and profile, then notifies the client
entailment
def selectlanguage(self, event): """Store client's selection of a new translation""" self.log('Language selection event:', event.client, pretty=True) if event.data not in all_languages(): self.log('Unavailable language selected:', event.data, lvl=warn) language = None ...
Store client's selection of a new translation
entailment
def getlanguages(self, event): """Compile and return a human readable list of registered translations""" self.log('Client requests all languages.', lvl=verbose) result = { 'component': 'hfos.ui.clientmanager', 'action': 'getlanguages', 'data': language_token_...
Compile and return a human readable list of registered translations
entailment
def ping(self, event): """Perform a ping to measure client <-> node latency""" self.log('Client ping received:', event.data, lvl=verbose) response = { 'component': 'hfos.ui.clientmanager', 'action': 'pong', 'data': [event.data, time() * 1000] } ...
Perform a ping to measure client <-> node latency
entailment
def convert(self, lat, lon, source, dest, height=0, datetime=None, precision=1e-10, ssheight=50*6371): """Converts between geodetic, modified apex, quasi-dipole and MLT. Parameters ========== lat : array_like Latitude lon : array_like Long...
Converts between geodetic, modified apex, quasi-dipole and MLT. Parameters ========== lat : array_like Latitude lon : array_like Longitude/MLT source : {'geo', 'apex', 'qd', 'mlt'} Input coordinate system dest : {'geo', 'apex', 'qd', '...
entailment
def geo2apex(self, glat, glon, height): """Converts geodetic to modified apex coordinates. Parameters ========== glat : array_like Geodetic latitude glon : array_like Geodetic longitude height : array_like Altitude in km Retur...
Converts geodetic to modified apex coordinates. Parameters ========== glat : array_like Geodetic latitude glon : array_like Geodetic longitude height : array_like Altitude in km Returns ======= alat : ndarray or float ...
entailment
def apex2geo(self, alat, alon, height, precision=1e-10): """Converts modified apex to geodetic coordinates. Parameters ========== alat : array_like Modified apex latitude alon : array_like Modified apex longitude height : array_like Al...
Converts modified apex to geodetic coordinates. Parameters ========== alat : array_like Modified apex latitude alon : array_like Modified apex longitude height : array_like Altitude in km precision : float, optional Precisi...
entailment
def geo2qd(self, glat, glon, height): """Converts geodetic to quasi-dipole coordinates. Parameters ========== glat : array_like Geodetic latitude glon : array_like Geodetic longitude height : array_like Altitude in km Returns ...
Converts geodetic to quasi-dipole coordinates. Parameters ========== glat : array_like Geodetic latitude glon : array_like Geodetic longitude height : array_like Altitude in km Returns ======= qlat : ndarray or float ...
entailment
def qd2geo(self, qlat, qlon, height, precision=1e-10): """Converts quasi-dipole to geodetic coordinates. Parameters ========== qlat : array_like Quasi-dipole latitude qlon : array_like Quasi-dipole longitude height : array_like Altitud...
Converts quasi-dipole to geodetic coordinates. Parameters ========== qlat : array_like Quasi-dipole latitude qlon : array_like Quasi-dipole longitude height : array_like Altitude in km precision : float, optional Precision ...
entailment
def _apex2qd_nonvectorized(self, alat, alon, height): """Convert from apex to quasi-dipole (not-vectorised) Parameters ----------- alat : (float) Apex latitude in degrees alon : (float) Apex longitude in degrees height : (float) Height...
Convert from apex to quasi-dipole (not-vectorised) Parameters ----------- alat : (float) Apex latitude in degrees alon : (float) Apex longitude in degrees height : (float) Height in km Returns --------- qlat : (float) ...
entailment
def apex2qd(self, alat, alon, height): """Converts modified apex to quasi-dipole coordinates. Parameters ========== alat : array_like Modified apex latitude alon : array_like Modified apex longitude height : array_like Altitude in km ...
Converts modified apex to quasi-dipole coordinates. Parameters ========== alat : array_like Modified apex latitude alon : array_like Modified apex longitude height : array_like Altitude in km Returns ======= qlat : nda...
entailment
def qd2apex(self, qlat, qlon, height): """Converts quasi-dipole to modified apex coordinates. Parameters ========== qlat : array_like Quasi-dipole latitude qlon : array_like Quasi-dipole longitude height : array_like Altitude in km ...
Converts quasi-dipole to modified apex coordinates. Parameters ========== qlat : array_like Quasi-dipole latitude qlon : array_like Quasi-dipole longitude height : array_like Altitude in km Returns ======= alat : ndarr...
entailment
def mlon2mlt(self, mlon, datetime, ssheight=50*6371): """Computes the magnetic local time at the specified magnetic longitude and UT. Parameters ========== mlon : array_like Magnetic longitude (apex and quasi-dipole longitude are always equal) da...
Computes the magnetic local time at the specified magnetic longitude and UT. Parameters ========== mlon : array_like Magnetic longitude (apex and quasi-dipole longitude are always equal) datetime : :class:`datetime.datetime` Date and time ...
entailment
def mlt2mlon(self, mlt, datetime, ssheight=50*6371): """Computes the magnetic longitude at the specified magnetic local time and UT. Parameters ========== mlt : array_like Magnetic local time datetime : :class:`datetime.datetime` Date and time ...
Computes the magnetic longitude at the specified magnetic local time and UT. Parameters ========== mlt : array_like Magnetic local time datetime : :class:`datetime.datetime` Date and time ssheight : float, optional Altitude in km to us...
entailment
def map_to_height(self, glat, glon, height, newheight, conjugate=False, precision=1e-10): """Performs mapping of points along the magnetic field to the closest or conjugate hemisphere. Parameters ========== glat : array_like Geodetic latitude ...
Performs mapping of points along the magnetic field to the closest or conjugate hemisphere. Parameters ========== glat : array_like Geodetic latitude glon : array_like Geodetic longitude height : array_like Source altitude in km ...
entailment
def map_E_to_height(self, alat, alon, height, newheight, E): """Performs mapping of electric field along the magnetic field. It is assumed that the electric field is perpendicular to B. Parameters ========== alat : (N,) array_like or float Modified apex latitude ...
Performs mapping of electric field along the magnetic field. It is assumed that the electric field is perpendicular to B. Parameters ========== alat : (N,) array_like or float Modified apex latitude alon : (N,) array_like or float Modified apex longitude...
entailment
def map_V_to_height(self, alat, alon, height, newheight, V): """Performs mapping of electric drift velocity along the magnetic field. It is assumed that the electric field is perpendicular to B. Parameters ========== alat : (N,) array_like or float Modified apex lat...
Performs mapping of electric drift velocity along the magnetic field. It is assumed that the electric field is perpendicular to B. Parameters ========== alat : (N,) array_like or float Modified apex latitude alon : (N,) array_like or float Modified apex ...
entailment
def basevectors_qd(self, lat, lon, height, coords='geo', precision=1e-10): """Returns quasi-dipole base vectors f1 and f2 at the specified coordinates. The vectors are described by Richmond [1995] [2]_ and Emmert et al. [2010] [3]_. The vector components are geodetic east and n...
Returns quasi-dipole base vectors f1 and f2 at the specified coordinates. The vectors are described by Richmond [1995] [2]_ and Emmert et al. [2010] [3]_. The vector components are geodetic east and north. Parameters ========== lat : (N,) array_like or float ...
entailment
def basevectors_apex(self, lat, lon, height, coords='geo', precision=1e-10): """Returns base vectors in quasi-dipole and apex coordinates. The vectors are described by Richmond [1995] [4]_ and Emmert et al. [2010] [5]_. The vector components are geodetic east, north, and up (only east ...
Returns base vectors in quasi-dipole and apex coordinates. The vectors are described by Richmond [1995] [4]_ and Emmert et al. [2010] [5]_. The vector components are geodetic east, north, and up (only east and north for `f1` and `f2`). Parameters ========== lat, lon : ...
entailment
def get_apex(self, lat, height=None): """ Calculate apex height Parameters ----------- lat : (float) Latitude in degrees height : (float or NoneType) Height above the surface of the earth in km or NoneType to use reference height (default=None...
Calculate apex height Parameters ----------- lat : (float) Latitude in degrees height : (float or NoneType) Height above the surface of the earth in km or NoneType to use reference height (default=None) Returns ---------- apex...
entailment
def set_epoch(self, year): """Updates the epoch for all subsequent conversions. Parameters ========== year : float Decimal year """ fa.loadapxsh(self.datafile, np.float(year)) self.year = year
Updates the epoch for all subsequent conversions. Parameters ========== year : float Decimal year
entailment
def basic_parser(patterns, with_name=None): """ Basic ordered parser. """ def parse(line): output = None highest_order = 0 highest_pattern_name = None for pattern in patterns: results = pattern.findall(line) if results and any(results): ...
Basic ordered parser.
entailment
def alt_parser(patterns): """ This parser is able to handle multiple different patterns finding stuff in text-- while removing matches that overlap. """ from reparse.util import remove_lower_overlapping get_first = lambda items: [i[0] for i in items] get_second = lambda items: [i[1] for i in...
This parser is able to handle multiple different patterns finding stuff in text-- while removing matches that overlap.
entailment
def build_tree_parser(patterns): """ This parser_type simply outputs an array of [(tree, regex)] for use in another language. """ def output(): for pattern in patterns: yield (pattern.build_full_tree(), pattern.regex) return list(output())
This parser_type simply outputs an array of [(tree, regex)] for use in another language.
entailment
def parser(parser_type=basic_parser, functions=None, patterns=None, expressions=None, patterns_yaml_path=None, expressions_yaml_path=None): """ A Reparse parser description. Simply provide the functions, patterns, & expressions to build. If you are using YAML for expressions + patterns, y...
A Reparse parser description. Simply provide the functions, patterns, & expressions to build. If you are using YAML for expressions + patterns, you can use ``expressions_yaml_path`` & ``patterns_yaml_path`` for convenience. The default parser_type is the basic ordered parser.
entailment