Beispiel #1
0
from .collection import OrbitalElementSet

from os.path import exists as opexists
from os.path import join as opjoin
from os.path import isabs
from os import makedirs
import glob
from tarfile import is_tarfile
from tarfile import open as taropen
import os
from settings import Config
import shutil
from os.path import basename

PROJECT_DIR = Config.get_project_dir()
CONFIG = Config.get_params()
_ex_folder = CONFIG['extract_dir']
EXTRACT_PATH = _ex_folder if isabs(_ex_folder) else opjoin(PROJECT_DIR, _ex_folder)

BUCKET = CONFIG['s3']['bucket']
_s3_folder = CONFIG['s3files_dir']
S3_FILES_DIR = _s3_folder if isabs(_s3_folder) else opjoin(PROJECT_DIR, _s3_folder)


class FilepathException(Exception):
    pass


class FilepathInvalidException(Exception):
    pass
Beispiel #2
0
from math import radians

import pytest
from datamining import OrbitalElementSet
from datamining import OrbitalElementSetCollection
from datamining.orbitalelements.collection import AEIValueError
from os.path import join as opjoin
from settings import Config

PROJECT_DIR = Config.get_project_dir()
PARAMS = Config.get_params()
A1_AEI_FILE_LEN = 46


def test_orbital_elements():
    filepath = opjoin(PROJECT_DIR, PARAMS['integrator']['dir'], 'A1.aei')
    collection = OrbitalElementSetCollection(filepath)
    assert len(collection.orbital_elements) == A1_AEI_FILE_LEN
    assert len(collection) == A1_AEI_FILE_LEN
    orbitalelements = collection.orbital_elements[0]

    assert orbitalelements == collection[0]
    assert orbitalelements.time == 0.0000000
    assert orbitalelements.p_longitude == radians(1.541309E+02)
    assert orbitalelements.mean_anomaly == radians(3.172742E+02)
    assert orbitalelements.semi_axis == 2.76503
    assert orbitalelements.eccentricity == 0.077237
    assert orbitalelements.inclination == radians(int(10.6047))
    assert orbitalelements.node == radians(int(80.4757))

Beispiel #3
0
from os.path import join as opjoin
from shutil import copyfile
import os
from settings import Config

PROJECT_DIR = Config.get_project_dir()
INTEGRATOR_PATH = opjoin(PROJECT_DIR, Config.get_params()['integrator']['dir'])
PARAMS = Config.get_params()


def test_set_time_interval():
    from integrator import set_time_interval

    def _copyfile(name: str):
        path = opjoin(INTEGRATOR_PATH, name)
        target = opjoin(INTEGRATOR_PATH, name + '.backup')
        copyfile(path, target)
        return path

    param_in_filepath = _copyfile(PARAMS.INTEGRATOR_PARAM_FILENAME)

    set_time_interval(1, 2)

    startday_assert_flag = False
    stopday_assert_flag = False
    with open(param_in_filepath) as f:
        for line in f:
            startday_assert_flag = startday_assert_flag or (' start time (days)= 1' in line)
            stopday_assert_flag = stopday_assert_flag or (' stop time (days) = 2' in line)

    assert startday_assert_flag
Beispiel #4
0
import redis

from sqlalchemy import create_engine, Integer, Column
from sqlalchemy.ext.declarative import as_declarative
from sqlalchemy.orm import Session
from sqlalchemy.orm import sessionmaker
from sqlalchemy.sql import ClauseElement
from alembic.config import Config as AlembicConfig
import os
from settings import Config
from sqlalchemy import event
from sqlalchemy.engine import Engine
import time
import logging

CONFIG = Config.get_params()
_HOST = CONFIG['postgres']['host']
_USER = CONFIG['postgres']['user']
_PASSWORD = CONFIG['postgres']['password']
_DB = CONFIG['postgres']['db']

if CONFIG['debug']:
    logging.basicConfig()
    logger = logging.getLogger("myapp.sqltime")
    logger.setLevel(logging.DEBUG)

    @event.listens_for(Engine, "before_cursor_execute")
    def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
        conn.info.setdefault('query_start_time', []).append(time.time())
        logger.debug("Start Query: %s", statement % parameters)