コード例 #1
0
    def __init__(self, rest=AuthenticatingRestProxy(RestRequests())):
        """Initialize the Projects API client.

        Args:
            rest (RestProxy): a RestProxy that makes calls to the ADAM API.
        """
        self._rest = rest
コード例 #2
0
def propagate_states(state_vectors, epoch_time, end_time):
    """Propagate states from one time to another

    Assume state epoch is the same as integration start time

    Args:
        sate_vectors (list of lists) - list of lists with 6 elements 
                                        [rx, ry, rz, vx, vy, vz]  [km, km/s]
        epoch_time (datetime.datetime) - epoch of state (UTC datetime)
        end_time (datetime.datetime) - time at which to end the simulation
                                        (UTC datetime)

    Returns:
        end_state_vectors (list of lists) - states at end of integration
                                            [rx, ry, rz, vx, vy, vz]  [km, km/s]
    """

    # Convert times to strings
    epoch_time_str = batch_time_string_from_datetime(epoch_time)
    start_time_str = epoch_time_str
    end_time_str = batch_time_string_from_datetime(end_time)
    print("Propagating %i states to propagate from %s to %s" %
          (len(state_vectors), start_time_str, end_time_str))

    url = "https://pro-equinox-162418.appspot.com/_ah/api/adam/v1"
    rest = RestRequests(url)
    batches_module = Batches(rest)

    # Create batches from statevectors
    batches = []
    propagation_params = PropagationParams({
        'start_time':
        start_time_str,
        'end_time':
        end_time_str,
        'project_uuid':
        'ffffffff-ffff-ffff-ffff-ffffffffffff'
    })
    for state_vector in state_vectors:
        opm_params = OpmParams({
            'epoch': start_time_str,
            'state_vector': state_vector
        })
        batches.append(Batch(propagation_params, opm_params))

    # submit batches and wait till they finish running
    BatchRunManager(batches_module, batches).run()

    # Get final states
    end_state_vectors = []
    for batch in batches:
        end_state_vectors.append(batch.get_results().get_end_state_vector())

    return end_state_vectors
コード例 #3
0
def propagate_states(state_vectors, epoch_time, end_time):
    """Propagate states from one time to another

    Assume state epoch is the same as integration start time

    Args:
        sate_vectors (list of lists) - list of lists with 6 elements 
                                        [rx, ry, rz, vx, vy, vz]  [km, km/s]
        epoch_time (datetime.datetime) - epoch of state (UTC datetime)
        end_time (datetime.datetime) - time at which to end the simulation
                                        (UTC datetime)

    Returns:
        end_state_vectors (list of lists) - states at end of integration
                                            [rx, ry, rz, vx, vy, vz]  [km, km/s]
    """

    # Convert times to strings
    epoch_time_str = batch_time_string_from_datetime(epoch_time)
    start_time_str = epoch_time_str
    end_time_str = batch_time_string_from_datetime(end_time)
    print("Propagating %i states to propagate from %s to %s" %
          (len(state_vectors), start_time_str, end_time_str))

    # Create batches from statevectors
    batches = []
    url = "https://pro-equinox-162418.appspot.com/_ah/api/adam/v1"
    rest = RestRequests(url)
    for state_vector in state_vectors:
        batch = Batch(rest)
        batch.set_state_vector(epoch_time_str, state_vector)
        batch.set_start_time(start_time_str)
        batch.set_end_time(end_time_str)
        batch.set_project('ffffffff-ffff-ffff-ffff-ffffffffffff')
        batches.append(batch)

    # submit batches and wait till they finish running
    submit_batches(batches)

    # Get final states
    end_state_vectors = []
    for batch in batches:
        end_state_vectors.append(batch.get_end_state_vector())

    return end_state_vectors
コード例 #4
0
 def __init__(self, rest=AuthenticatingRestProxy(RestRequests())):
     self._rest = rest
コード例 #5
0
from adam import Batch
from adam import Batches
from adam import BatchRunManager
from adam import PropagationParams
from adam import OpmParams
from adam import ConfigManager
from adam import Projects
from adam import RestRequests
from adam import AuthenticatingRestProxy
import time
import os

# Reads your config from a file in current directory. For instructions on setting this up, see config_demo notebook.
config = ConfigManager(os.getcwd() + '/config.json').get_config()
auth_rest = AuthenticatingRestProxy(RestRequests(config.get_url()), config.get_token())

# Example inputs

# 6x1 state vector (position [km], velocity [km/s])
state_vec = [130347560.13690618,
             -74407287.6018632,
             -35247598.541470632,
             23.935241263310683,
             27.146279819258538,
             10.346605942591514]

# Lower triangular covariance matrix (21 elements in a list)
covariance = [3.331349476038534e-04, + \
              4.618927349220216e-04, 6.782421679971363e-04, + \
             -3.070007847730449e-04, -4.221234189514228e-04, 3.231931992380369e-04, + \
             -3.349365033922630e-07, -4.686084221046758e-07, 2.484949578400095e-07, 4.296022805587290e-10, + \
コード例 #6
0
from adam import Batch
from adam import Batches
from adam import BatchRunManager
from adam import PropagationParams
from adam import OpmParams
from adam import Projects
from adam import RestRequests
from adam import AuthorizingRestProxy
import time
import os

url = "https://pro-equinox-162418.appspot.com/_ah/api/adam/v1"
# Reads your token from a file in current directory. For instructions on getting a token, see auth_demo notebook.
token = open(os.getcwd() + '/token.txt').read()
auth_rest = AuthorizingRestProxy(RestRequests(url), token)

# Example inputs

# 6x1 state vector (position [km], velocity [km/s])
state_vec = [
    130347560.13690618, -74407287.6018632, -35247598.541470632,
    23.935241263310683, 27.146279819258538, 10.346605942591514
]

# Lower triangular covariance matrix (21 elements in a list)
covariance = [3.331349476038534e-04, + \
              4.618927349220216e-04, 6.782421679971363e-04, + \
             -3.070007847730449e-04, -4.221234189514228e-04, 3.231931992380369e-04, + \
             -3.349365033922630e-07, -4.686084221046758e-07, 2.484949578400095e-07, 4.296022805587290e-10, + \
             -2.211832501084875e-07, -2.864186892102733e-07, 1.798098699846038e-07, 2.608899201686016e-10, 1.767514756338532e-10, + \
             -3.041346050686871e-07, -4.989496988610662e-07, 3.540310904497689e-07, 1.869263192954590e-10, 1.008862586240695e-10, 6.224444338635500e-10]
コード例 #7
0
from adam import Batch
from adam import Batches
from adam import BatchRunManager
from adam import PropagationParams
from adam import OpmParams
from adam import ConfigManager
from adam import Projects
from adam import RestRequests
from adam import AuthenticatingRestProxy
import time
import os

# ConfigManager loads the config set up via adamctl.
# See the README at https://github.com/B612-Asteroid-Institute/adam_home/blob/master/README.md
config = ConfigManager().get_config()
auth_rest = AuthenticatingRestProxy(RestRequests(config['url']),
                                    config['token'])

# Example inputs

# 6x1 state vector (position [km], velocity [km/s])
state_vec = [
    130347560.13690618, -74407287.6018632, -35247598.541470632,
    23.935241263310683, 27.146279819258538, 10.346605942591514
]

# Lower triangular covariance matrix (21 elements in a list)
covariance = [3.331349476038534e-04, + \
              4.618927349220216e-04, 6.782421679971363e-04, + \
             -3.070007847730449e-04, -4.221234189514228e-04, 3.231931992380369e-04, + \
             -3.349365033922630e-07, -4.686084221046758e-07, 2.484949578400095e-07, 4.296022805587290e-10, + \
コード例 #8
0
from adam import Batch
from adam import Batches
from adam import BatchRunManager
from adam import PropagationParams
from adam import OpmParams
from adam import ConfigManager
from adam import Projects
from adam import RestRequests
from adam import AuthenticatingRestProxy
import time
import os

# ConfigManager loads the config set up via adamctl.
# See the README at https://github.com/B612-Asteroid-Institute/adam_home/blob/master/README.md
config = ConfigManager().get_config()
auth_rest = AuthenticatingRestProxy(RestRequests())

# Example inputs

# 6x1 state vector (position [km], velocity [km/s])
state_vec = [
    130347560.13690618, -74407287.6018632, -35247598.541470632,
    23.935241263310683, 27.146279819258538, 10.346605942591514
]

# Lower triangular covariance matrix (21 elements in a list)
covariance = [3.331349476038534e-04, + \
              4.618927349220216e-04, 6.782421679971363e-04, + \
             -3.070007847730449e-04, -4.221234189514228e-04, 3.231931992380369e-04, + \
             -3.349365033922630e-07, -4.686084221046758e-07, 2.484949578400095e-07, 4.296022805587290e-10, + \
             -2.211832501084875e-07, -2.864186892102733e-07, 1.798098699846038e-07, 2.608899201686016e-10, 1.767514756338532e-10, + \
コード例 #9
0
from adam import Auth
from adam import Batch
from adam import Projects
from adam import RestRequests
from adam import AuthorizingRestProxy
import time
import os

# Authorize user TODO: move this somewhere else
# This should really be done under the hood and not exposed to the client
url = "https://pro-equinox-162418.appspot.com/_ah/api/adam/v1"
rest = RestRequests(url)
auth = Auth(rest)
tokenFile = os.getcwd() + '/token.txt'
# Opening with "a+" instead of "r" creates the file if it doesn't exist.
with open(tokenFile, "a+") as f:
    f.seek(0)
    token = f.readline().replace('\n', '')

try:
    if not auth.authorize(token):
        if auth.initial_authorization():
            with open(tokenFile, "w") as f:
                f.write(auth.get_token())
except RuntimeError as e:
    print('Encountered server error while attempting to authorize: ' + str(e))

if auth.get_token() == "":
    print('Could not authorize user.')
else:
    print('Welcome, ' + auth.get_user())