Skip to content

Commit

Permalink
Reorganize types.py files
Browse files Browse the repository at this point in the history
  • Loading branch information
garlic-os committed Aug 7, 2024
1 parent dc3d289 commit 5c83003
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 33 deletions.
2 changes: 1 addition & 1 deletion test/test_checkArgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest

from RAiDER.checkArgs import checkArgs, get_raster_ext, makeDelayFileNames
from RAiDER.cli.args import AOIGroup, DateGroup, HeightGroupUnparsed, LOSGroup, RunConfig, RuntimeGroup, TimeGroup
from RAiDER.cli.types import AOIGroup, DateGroup, HeightGroupUnparsed, LOSGroup, RunConfig, RuntimeGroup, TimeGroup
from RAiDER.llreader import BoundingBox, RasterRDR, StationFile
from RAiDER.losreader import Zenith
from RAiDER.models.gmao import GMAO
Expand Down
2 changes: 1 addition & 1 deletion test/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from test import TEST_DIR

from RAiDER.cli.args import DateGroupUnparsed, LOSGroupUnparsed, TimeGroup
from RAiDER.cli.types import DateGroupUnparsed, LOSGroupUnparsed, TimeGroup
from RAiDER.cli.validators import (
getBufferedExtent, isOutside, isInside,
coerce_into_date,
Expand Down
28 changes: 28 additions & 0 deletions tools/RAiDER/aria/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import argparse
from pathlib import Path
from typing import Optional

from RAiDER.types import TimeInterpolationMethod


class CalcDelaysArgsUnparsed(argparse.Namespace):
bucket: Optional[str]
bucket_prefix: Optional[str]
input_bucket_prefix: Optional[str]
file: Optional[Path]
weather_model: str
api_uid: Optional[str]
api_key: Optional[str]
interpolate_time: TimeInterpolationMethod
output_directory: Path

class CalcDelaysArgs(argparse.Namespace):
bucket: Optional[str]
bucket_prefix: Optional[str]
input_bucket_prefix: Optional[str]
file: Path
weather_model: str
api_uid: Optional[str]
api_key: Optional[str]
interpolate_time: TimeInterpolationMethod
output_directory: Path
2 changes: 1 addition & 1 deletion tools/RAiDER/checkArgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pandas as pd
import rasterio.drivers as rd

from RAiDER.cli.args import RunConfig
from RAiDER.cli.types import RunConfig
from RAiDER.llreader import BoundingBox, StationFile
from RAiDER.logger import logger
from RAiDER.losreader import LOS, Zenith
Expand Down
5 changes: 3 additions & 2 deletions tools/RAiDER/cli/raider.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
from textwrap import dedent
from typing import Any, Optional, cast

from RAiDER.aria.types import CalcDelaysArgsUnparsed
from RAiDER.gnss.types import RAiDERCombineArgs
import numpy as np
import xarray as xr
import yaml

import RAiDER.aria.calcGUNW
import RAiDER.aria.prepFromGUNW
from RAiDER import aws
from RAiDER.cli.args import (
from RAiDER.cli.types import (
AOIGroup,
AOIGroupUnparsed,
DateGroupUnparsed,
Expand All @@ -39,7 +41,6 @@
get_s1_azimuth_time_grid,
get_times_for_azimuth_interpolation,
)
from RAiDER.types import CalcDelaysArgs, CalcDelaysArgsUnparsed
from RAiDER.utilFcns import get_dt


Expand Down
5 changes: 3 additions & 2 deletions tools/RAiDER/cli/args.py → tools/RAiDER/cli/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def __init__(
)
else:
sentinel_datetime = dt.datetime.combine(dt.date(1900, 1, 1), self.time)
end_time = sentinel_datetime + dt.timedelta(seconds=TimeGroup._DEFAULT_ACQUISITION_WINDOW_SEC)
self.end_time = end_time.time()
new_end_time = sentinel_datetime + dt.timedelta(seconds=TimeGroup._DEFAULT_ACQUISITION_WINDOW_SEC)
self.end_time = new_end_time.time()
if self.end_time < self.time:
raise ValueError(
'Acquisition start time must be before end time. '
Expand All @@ -95,6 +95,7 @@ def __init__(

@staticmethod
def coerce_into_time(val: Union[int, str]) -> dt.time:
val = str(val)
all_formats = map(''.join, itertools.product(TimeGroup.TIME_FORMATS, TimeGroup.TIMEZONE_FORMATS))
for tf in all_formats:
try:
Expand Down
2 changes: 1 addition & 1 deletion tools/RAiDER/cli/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
else:
Self = Any

from RAiDER.cli.args import (
from RAiDER.cli.types import (
AOIGroupUnparsed,
DateGroup,
DateGroupUnparsed,
Expand Down
13 changes: 13 additions & 0 deletions tools/RAiDER/gnss/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import argparse
from pathlib import Path
from typing import Optional


class RAiDERCombineArgs(argparse.Namespace):
raider_file: Path
raider_folder: Path
gnss_folder: Path
gnss_file: Optional[Path]
raider_column_name: str
out_name: str
local_time: Optional[str]
26 changes: 1 addition & 25 deletions tools/RAiDER/types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,10 @@
"""Types specific to RAiDER."""

import argparse
from pathlib import Path
from typing import Literal, Optional, Union
from typing import Literal, Union

from pyproj import CRS


LookDir = Literal['right', 'left']
TimeInterpolationMethod = Literal['none', 'center_time', 'azimuth_time_grid']
CRSLike = Union[CRS, str, int]

class CalcDelaysArgsUnparsed(argparse.Namespace):
bucket: Optional[str]
bucket_prefix: Optional[str]
input_bucket_prefix: Optional[str]
file: Optional[Path]
weather_model: str
api_uid: Optional[str]
api_key: Optional[str]
interpolate_time: TimeInterpolationMethod
output_directory: Path

class CalcDelaysArgs(argparse.Namespace):
bucket: Optional[str]
bucket_prefix: Optional[str]
input_bucket_prefix: Optional[str]
file: Path
weather_model: str
api_uid: Optional[str]
api_key: Optional[str]
interpolate_time: TimeInterpolationMethod
output_directory: Path

0 comments on commit 5c83003

Please sign in to comment.