<commit_before>"""
Downloads rise/set tables from the United States Naval Observatory.
"""


from __future__ import print_function
import datetime
import math
import os
import random
import time as time_module

import vesper.util.usno_table_utils as utils


_TABLES_DIR_PATH = r'C:\Users\Harold\Desktop\NFC\Data\USNO Tables Test'

_YEAR_RANGE = (1990, 2030)
_AA_TABLE_INTERVAL = 10

_SPECIFIC_LOCATIONS = (
    (42.45, -76.5, -4, 'Ithaca, NY'),
    (46.70, -114.0, -6, 'MPG Ranch')
)
_NUM_SPECIFIC_LOCATION_DATES = 300

_NUM_RANDOM_RS_TABLES = 10 # 1000
_NUM_RANDOM_AA_TABLES = 10 # 1000
_RANDOM_LAT_RANGE = (-80, 80)

_DRY_RUN = False

_START_TIME = datetime.datetime(2016, 2, 20, 19, 42)

_PAUSE_DURATION = 10
"""Duration of pause that precedes each file download, in seconds."""


def _main():
    
    if not _DRY_RUN:
        _wait_until_time(_START_TIME)
        
    # _download_specific_location_tables()
    _download_random_tables()
    
    
def _wait_until_time(dt):
    while datetime.datetime.now() < dt:
        time_module.sleep(5)
        
    
def _download_specific_location_tables():
    for data in _generate_specific_locations_rs_table_data():
        _download_table(*data)<commit_msg>Began adding command line arguments to ephemerides scripts.<commit_after>"""
Downloads rise/set tables from the United States Naval Observatory.
"""


from __future__ import print_function
import argparse
import datetime
import math
import os
import random
import time as time_module

import vesper.util.usno_table_utils as utils


_TABLES_DIR_PATH = r'C:\Users\Harold\Desktop\NFC\Data\USNO Tables Test'

_YEAR_RANGE = (1990, 2030)
_AA_TABLE_INTERVAL = 10

_SPECIFIC_LOCATIONS = (
    (42.45, -76.5, -4, 'Ithaca, NY'),
    (46.70, -114.0, -6, 'MPG Ranch')
)
_NUM_SPECIFIC_LOCATION_DATES = 300

_NUM_RANDOM_RS_TABLES = 10 # 1000
_NUM_RANDOM_AA_TABLES = 10 # 1000
_RANDOM_LAT_RANGE = (-80, 80)

_DRY_RUN = True

_START_TIME = datetime.datetime(2016, 2, 20, 19, 42)

_PAUSE_DURATION = 10
"""Duration of pause that precedes each file download, in seconds."""


def _main():
    
    args = _parse_args()
    
    if not _DRY_RUN:
        _wait_until_time(_START_TIME)
        
    # _download_specific_location_tables()
    _download_random_tables()
    
    
def _parse_args():
    
    parser = argparse.ArgumentParser(
        description='''
            This script downloads rise/set and altitude/azimuth tables
            from the United States Naval Observatory (USNO).''')
    
    date_format = 'YYYY-MM-DD'
    
    parser.add_argument(
        '--tables-dir_path', default=None,
        help='the directory to which to download tables.')
    
    parser.add_argument(
        '--dry-run', action='store_true', default=False,
        help=(
            'run but do not actually download tables. Write table '
            'files but store the date and time of writing in each '
            'file rather than a USNO table.'))
    
    parser.add_argument(
        '--start-time', default=None, metavar='YYYY-MM-DD HH:MM',
        help=(
            'the time at which to begin downloading tables. If no '
            'time is specified, downloading begins immediately.'))
    
    parser.add_argument(
        '--pause-duration', type=int, default=None,
        help=(
            'the duration in seconds of the pause between consecutive '
            'table downloads'))
    
    args = parser.parse_args()
    
    return args


def _wait_until_time(dt):
    while datetime.datetime.now() < dt:
        time_module.sleep(5)
        
    
def _download_specific_location_tables():
    for data in _generate_specific_locations_rs_table_data():
        _download_table(*data)
{'fraction_non_alphanumeric': 0.09517353579175705, 'fraction_numerical': 0.03253796095444685, 'mean_word_length': 3.0538461538461537, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4600501', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1203, 'n_words': 318}