Skip to content

Commit

Permalink
Fixed circular importing between llreader and utilFncs
Browse files Browse the repository at this point in the history
  • Loading branch information
royagrace committed Oct 3, 2024
1 parent 1b8efe6 commit 89888a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
9 changes: 6 additions & 3 deletions tools/RAiDER/llreader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# noqa: D100
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Author: Jeremy Maurer, Raymond Hogenson & David Bekaert
Expand All @@ -23,7 +24,6 @@

from RAiDER.logger import logger
from RAiDER.types import BB, RIO
from RAiDER.utilFcns import rio_open, rio_stats


class AOI:
Expand Down Expand Up @@ -265,6 +265,7 @@ def __init__(self, lat_file, lon_file=None, hgt_file=None, dem_file=None, conven

def readLL(self) -> tuple[np.ndarray, Optional[np.ndarray]]:
# allow for 2-band lat/lon raster
from RAiDER.utilFcns import rio_open
lats, _ = rio_open(Path(self._latfile))

if self._lonfile is None:
Expand All @@ -275,6 +276,7 @@ def readLL(self) -> tuple[np.ndarray, Optional[np.ndarray]]:

def readZ(self) -> np.ndarray:
"""Read the heights from the raster file, or download a DEM if not present."""
from RAiDER.utilFcns import rio_open
if self._hgtfile is not None and os.path.exists(self._hgtfile):
logger.info('Using existing heights at: %s', self._hgtfile)
hgts, _ = rio_open(self._hgtfile)
Expand Down Expand Up @@ -320,7 +322,7 @@ class GeocodedFile(AOI):
def __init__(self, path: Path, is_dem=False, cube_spacing_in_m: Optional[float]=None) -> None:
super().__init__(cube_spacing_in_m)

from RAiDER.utilFcns import rio_extents, rio_profile
from RAiDER.utilFcns import rio_extents, rio_profile, rio_stats

self._filename = path
self.p = rio_profile(path)
Expand Down Expand Up @@ -361,6 +363,7 @@ class Geocube(AOI):
"""Pull lat/lon/height from a georeferenced data cube."""

def __init__(self, path_cube, cube_spacing_in_m: Optional[float]=None) -> None:
from RAiDER.utilFcns import rio_stats
super().__init__(cube_spacing_in_m)
self.path = path_cube
self._type = 'Geocube'
Expand Down Expand Up @@ -392,7 +395,7 @@ def bounds_from_latlon_rasters(lat_filestr: str, lon_filestr: str) -> tuple[BB.S
Parse lat/lon/height inputs and return
the appropriate outputs.
"""
from RAiDER.utilFcns import get_file_and_band
from RAiDER.utilFcns import get_file_and_band, rio_stats

latinfo = get_file_and_band(lat_filestr)
loninfo = get_file_and_band(lon_filestr)
Expand Down
12 changes: 10 additions & 2 deletions tools/RAiDER/utilFcns.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pathlib
import re
from pathlib import Path
from typing import Any, Optional, Tuple, Union, List
from typing import Any, List, Optional, Tuple, Union

import numpy as np
import rasterio
Expand All @@ -16,14 +16,22 @@
import RAiDER
from RAiDER.constants import (
R_EARTH_MAX_WGS84 as Rmax,
)
from RAiDER.constants import (
R_EARTH_MIN_WGS84 as Rmin,
)
from RAiDER.constants import (
_THRESHOLD_SECONDS,
)
from RAiDER.constants import (
_g0 as g0,
)
from RAiDER.constants import (
_g1 as G1,
)
from RAiDER.llreader import AOI
from RAiDER.logger import logger
from RAiDER.types import BB, RIO, CRSLike
from llreader import AOI


# Optional imports
Expand Down

0 comments on commit 89888a6

Please sign in to comment.