예제 #1
0
def main():
    """Run the main script."""
    parser, inspect_parser, query_parser = make_parser()
    args = parser.parse_args()

    # Extract data from the data files into structured Python objects.
    database = NEODatabase(load_neos(args.neofile),
                           load_approaches(args.cadfile))

    # Run the chosen subcommand.
    try:
        if args.cmd == 'inspect':
            inspect(database,
                    pdes=args.pdes,
                    name=args.name,
                    verbose=args.verbose)
        elif args.cmd == 'query':
            query(database, args)
        elif args.cmd == 'interactive':
            NEOShell(database,
                     inspect_parser,
                     query_parser,
                     aggressive=args.aggressive).cmdloop()
    except UnboundLocalError:
        print("Supplied bad name or designation. Please check your inputs.")
def build_results(n):
    neos = tuple(load_neos(TEST_NEO_FILE))
    approaches = tuple(load_approaches(TEST_CAD_FILE))

    # Only needed to link together these objects.
    NEODatabase(neos, approaches)

    return approaches[:n]
예제 #3
0
    def setUp(self):
        self.neo_data_file = f'{PROJECT_ROOT}/data/neo_data.csv'

        self.db = NEODatabase(filename=self.neo_data_file)
        self.db.load_data()

        self.start_date = '2020-01-01'
        self.end_date = '2020-01-10'
예제 #4
0
def build_results(n):
    neos = load_neos(TEST_NEO_FILE)
    approaches = load_approaches(TEST_CAD_FILE)

    # Only needed to link together these objects.
    db = NEODatabase(neos, approaches)

    return db.get_approaches_list()[:n]
예제 #5
0
파일: main.py 프로젝트: richdon/projects
def main():
    """Run the main script."""
    parser, inspect_parser, query_parser = make_parser()
    args = parser.parse_args()

    # Extract data from the data files into structured Python objects.
    database = NEODatabase(load_neos(args.neofile), load_approaches(args.cadfile))

    # Run the chosen subcommand.
    if args.cmd == 'inspect':
        inspect(database, pdes=args.pdes, name=args.name, verbose=args.verbose)
    elif args.cmd == 'query':
        query(database, args)
    elif args.cmd == 'interactive':
        NEOShell(database, inspect_parser, query_parser, aggressive=args.aggressive).cmdloop()
예제 #6
0
 def setUpClass(cls):
     cls.neos = load_neos(TEST_NEO_FILE)
     cls.approaches = load_approaches(TEST_CAD_FILE)
     cls.db = NEODatabase(cls.neos, cls.approaches)
예제 #7
0
                        'distance:[>=|=|<=]:float.'
                        'Input as: [option:operation:value] '
                        'e.g. diameter:>=:0.042')

    args = parser.parse_args()
    var_args = vars(args)

    # Load Data
    if args.filename:
        filename = args.filename
    else:
        filename = f'{PROJECT_ROOT}/data/neo_data.csv'

    #print("data address",filename)

    db = NEODatabase(filename=filename)

    try:
        db.load_data()
    except FileNotFoundError as e:
        print(
            f'File {var_args.get("filename")} not found, please try another file name.'
        )
        sys.exit()
    except Exception as e:
        print(Exception)
        sys.exit()

    # Build Query
    query_selectors = Query(**var_args).build_query()
    #print("Query selectors",query_selectors)
from database import NEODatabase
from writer import NEOWriter
import pathlib
from search import *
# Testing purpose file

PROJECT_ROOT = pathlib.Path(__file__).parent.absolute()
input_filename = f'{PROJECT_ROOT}/data/neo_data.csv'
output_filename = f'{PROJECT_ROOT}/data/neo_data_out.csv'

# First step, load database
db = NEODatabase(input_filename)
db.load_data()

# getting the NEOs with 8 orbits
# obj = []
# for key in db.NEOList:
#     print(db[key])
# if len(db.NEOList[key].orbits) == 8:
#     obj.append(db.NEOList[key])

# "distance:>:74768000"
query_selectors = Query(**{
    "output": "csv_file",
    "start_date": "2020-01-01",
    "end_date": "2020-01-10",
    # "date": "2020-01-02",
    "number": 10,
    "filter": ["is_hazardous:=:False"]
}).build_query()
예제 #9
0
def main():
    """Run the main script."""
    args = get_feed()

    # Extract data from the data files into structured Python objects.
    database = NEODatabase(load_neos(args))
예제 #10
0
from extract import load_neos, load_approaches
from database import NEODatabase
from filters import valid_attribute, limit
import operator
import math
import datetime
import operator

neos = load_neos('./tests/test-neos-2020.csv')
cads = load_approaches('./tests/test-cad-2020.json')

neo_database = NEODatabase(neos, cads)

result = neo_database.get_neo_by_designation('1865')

#print(result)

#print(get_attribute(an_approach, operator.eq, value, attribute))

#print(neo_1036.approaches)

#print(neo_database.get_neo_by_name('Ganymed'))
예제 #11
0
This module exports two functions: `write_to_csv` and `write_to_json`, each of
which accept an `results` stream of close approaches and a path to which to
write the data.

These functions are invoked by the main module with the output of the `limit`
function and the filename supplied by the user at the command line. The file's
extension determines which of these functions is used.

You'll edit this file in Part 4.
"""
import csv
import json
from filters import limit
from database import NEODatabase

db = NEODatabase()
cas = db._approaches


def write_to_csv(results=limit(cas), filename='data/neos_write.csv'):
    """Write an iterable of `CloseApproach` objects to a CSV file.

    The precise output specification is in `README.md`. Roughly, each output
    row corresponds to the information in a single close approach from the
    `results` stream and its associated near-Earth object.

    :param results: An iterable of `CloseApproach` objects.
    :param filename: A Path-like object pointing to where the data should be
    saved.
    """
    fieldnames = ('datetime_utc', 'distance_au', 'velocity_km_s',