Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
- autopep8
- Fix comment typo
- Use consistent notation for intervals everywhere, e.g., [0, 360]
  • Loading branch information
garlic-os committed Jun 8, 2024
1 parent 223d862 commit b407817
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 92 deletions.
53 changes: 28 additions & 25 deletions test/test_gnss.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
from RAiDER.models.customExceptions import NoStationDataFoundError
from RAiDER.gnss.downloadGNSSDelays import (
get_stats_by_llh, get_station_list, download_tropo_delays,
filterToBBox,
)
from RAiDER.gnss.processDelayFiles import (
addDateTimeToFiles,
getDateTime,
concatDelayFiles
)
import datetime
import os
import pytest
Expand All @@ -8,18 +18,6 @@
SCENARIO2_DIR = os.path.join(TEST_DIR, "scenario_2")


from RAiDER.gnss.processDelayFiles import (
addDateTimeToFiles,
getDateTime,
concatDelayFiles
)
from RAiDER.gnss.downloadGNSSDelays import (
get_stats_by_llh, get_station_list, download_tropo_delays,
filterToBBox,
)
from RAiDER.models.customExceptions import NoStationDataFoundError


def file_len(fname):
with open(fname) as f:
for i, l in enumerate(f):
Expand Down Expand Up @@ -107,26 +105,28 @@ def test_concatDelayFiles(tmp_path, temp_file):
)
assert file_len(out_name) == file_length


def test_get_stats_by_llh2():
stations = get_stats_by_llh(llhBox=[10,18,360-93,360-88])
stations = get_stats_by_llh(llhBox=[10, 18, 360-93, 360-88])
assert isinstance(stations, pd.DataFrame)


def test_get_stats_by_llh3():
with pytest.raises(ValueError):
get_stats_by_llh(llhBox=[10,18,-93,-88])

get_stats_by_llh(llhBox=[10, 18, -93, -88])


def test_get_station_list():
stations, output_file = get_station_list(stationFile=os.path.join(SCENARIO2_DIR, 'stations.csv'), writeStationFile=False)
assert isinstance(stations,list)
assert isinstance(output_file,pd.DataFrame)
stations, output_file = get_station_list(stationFile=os.path.join(
SCENARIO2_DIR, 'stations.csv'), writeStationFile=False)
assert isinstance(stations, list)
assert isinstance(output_file, pd.DataFrame)


def test_download_tropo_delays1():
with pytest.raises(NotImplementedError):
download_tropo_delays(stats=['GUAT', 'SLAC', 'CRSE'], years=[2022], gps_repo='dummy_repo')
download_tropo_delays(stats=['GUAT', 'SLAC', 'CRSE'], years=[
2022], gps_repo='dummy_repo')


def test_download_tropo_delays2():
Expand All @@ -135,7 +135,8 @@ def test_download_tropo_delays2():


def test_download_tropo_delays2(tmp_path):
stations, output_file = get_station_list(stationFile=os.path.join(SCENARIO2_DIR, 'stations.csv'))
stations, output_file = get_station_list(
stationFile=os.path.join(SCENARIO2_DIR, 'stations.csv'))

# spot check a couple of stations
assert 'CAPE' in stations
Expand All @@ -148,15 +149,17 @@ def test_download_tropo_delays2(tmp_path):


def test_filterByBBox1():
_, station_data = get_station_list(stationFile=os.path.join(SCENARIO2_DIR, 'stations.csv'), writeStationFile=False)
_, station_data = get_station_list(stationFile=os.path.join(
SCENARIO2_DIR, 'stations.csv'), writeStationFile=False)
with pytest.raises(ValueError):
filterToBBox(station_data, llhBox=[34,38,-120,-115])
filterToBBox(station_data, llhBox=[34, 38, -120, -115])


def test_filterByBBox2():
_, station_data = get_station_list(stationFile=os.path.join(SCENARIO2_DIR, 'stations.csv'), writeStationFile=False)
new_data = filterToBBox(station_data, llhBox=[34,38,240,245])
for stat in ['CAPE','MHMS','NVCO']:
_, station_data = get_station_list(stationFile=os.path.join(
SCENARIO2_DIR, 'stations.csv'), writeStationFile=False)
new_data = filterToBBox(station_data, llhBox=[34, 38, 240, 245])
for stat in ['CAPE', 'MHMS', 'NVCO']:
assert stat not in new_data['ID'].to_list()
for stat in ['FGNW', 'JPLT', 'NVTP', 'WLHG', 'WORG']:
assert stat in new_data['ID'].to_list()
27 changes: 16 additions & 11 deletions tools/RAiDER/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,42 @@

import RAiDER.cli.conf as conf


def main():
parser = argparse.ArgumentParser(
prefix_chars='+',
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument(
'++process', choices=['calcDelays', 'downloadGNSS', 'calcDelaysGUNW'],
default='calcDelays',
help='Select the entrypoint to use'
'++process',
choices=['calcDelays', 'downloadGNSS', 'calcDelaysGUNW'],
default='calcDelays',
help='Select the entrypoint to use'
)
parser.add_argument(
'++logger_path',
required = False,
default = None,
'++logger_path',
required=False,
default=None,
help='Set the path to write the log files',
)

args, unknowns = parser.parse_known_args()

# Needed for a global logging path
conf.setLoggerPath(args.logger_path)
sys.argv = [args.process, *unknowns]

sys.argv = [args.process, *unknowns]

try:
# python >=3.10 interface
(process_entry_point,) = entry_points(group='console_scripts', name=f'{args.process}.py')
(process_entry_point,) = entry_points(
group='console_scripts', name=f'{args.process}.py')
except TypeError:
# python 3.8 and 3.9 interface
scripts = entry_points()['console_scripts']
process_entry_point = [ep for ep in scripts if ep.name == f'{args.process}.py'][0]
process_entry_point = [
ep for ep in scripts if ep.name == f'{args.process}.py'
][0]

process_entry_point.load()()

Expand Down
Loading

0 comments on commit b407817

Please sign in to comment.