Skip to content

Commit

Permalink
backend function names for error_handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cyschneck committed Nov 12, 2024
1 parent d0549cd commit a2639ad
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 111 deletions.
23 changes: 12 additions & 11 deletions pydar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
from .display_image import display_all_images

# error_handling.py function calls for testing
from .error_handling import errorHandlingDisplayAllImages
from .error_handling import errorHandlingExtractFlybyImages
from .error_handling import errorHandlingConvertFlybyIDToObservationNumber
from .error_handling import errorHandlingConvertObservationNumberToFlybyID
from .error_handling import errorHandlingREADME
from .error_handling import errorHandlingRetrieveIDSByFeature
from .error_handling import errorHandlingRetrieveIDSByLatitudeLongitude
from .error_handling import errorHandlingRetrieveIDSByLatitudeLongitudeRange
from .error_handling import errorHandlingRetrieveIDSByTime
from .error_handling import errorHandlingRetrieveIDSByTimeRange
from .error_handling import errorHandlingSbdrMakeShapeFile
from .error_handling import _error_handling_extract_flyby_images
from .error_handling import _error_handling_display_all_images
from .error_handling import _error_handling_convert_id_to_observation_num
from .error_handling import _error_handling_convert_observation_num_to_id
from .error_handling import _error_handling_readme_options
from .error_handling import _error_handling_id_from_feature_name
from .error_handling import _error_handling_id_from_lat_lon
from .error_handling import _error_handling_id_from_lat_lon_range
from .error_handling import _error_handling_id_from_time
from .error_handling import _error_handling_id_from_time_range

# extract_flyby_parameters.py function calls
from .extract_flyby_parameters import _retrieve_flyby_data
Expand Down Expand Up @@ -41,6 +40,8 @@

## Version 2:

# from .error_handling import _error_handling_sbdr_make_shapefile

# sbdr_make_shapefile.py function calls
#from .sbdr_make_shapefile import sbdrMakeShapeFile
#from .sbdr_make_shapefile import field_options
Expand Down
10 changes: 5 additions & 5 deletions pydar/display_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def display_all_images(image_directory: str = None,
# Display all images in the image directory specified
# plt.show() all imgs in a given directory

pydar.errorHandlingDisplayAllImages(image_directory=image_directory,
fig_title=fig_title,
cmap=cmap,
figsize_n=figsize_n,
fig_dpi=fig_dpi)
pydar._error_handling_display_all_images(image_directory=image_directory,
fig_title=fig_title,
cmap=cmap,
figsize_n=figsize_n,
fig_dpi=fig_dpi)

# Display all IMG files in directory
for filename in os.listdir(image_directory):
Expand Down
120 changes: 60 additions & 60 deletions pydar/error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
import pydar


def errorHandlingExtractFlybyImages(flyby_observation_num=None,
flyby_id=None,
segment_num=None,
additional_data_types_to_download=[],
resolution=None,
top_x_resolutions=None):
def _error_handling_extract_flyby_images(flyby_observation_num=None,
flyby_id=None,
segment_num=None,
additional_data_types_to_download=[],
resolution=None,
top_x_resolutions=None):
# Error Handling for extract_flyby_parameters variables: extract_flyby_images()
available_flyby_id, available_observation_numbers = pydar._retrieve_flyby_data(
)
Expand Down Expand Up @@ -125,7 +125,7 @@ def errorHandlingExtractFlybyImages(flyby_observation_num=None,
)


def errorHandlingConvertFlybyIDToObservationNumber(flyby_id=None):
def _error_handling_convert_id_to_observation_num(flyby_id=None):
# Error Handling for Converting a Flyby ID into an Observation Number: id_to_observation()
if flyby_id is None:
raise ValueError("[flyby_id]: A valid flyby_id string is required")
Expand All @@ -151,7 +151,7 @@ def errorHandlingConvertFlybyIDToObservationNumber(flyby_id=None):
)


def errorHandlingConvertObservationNumberToFlybyID(flyby_observation_num=None):
def _error_handling_convert_observation_num_to_id(flyby_observation_num=None):
# Error Handling for Converting an Observation Number to a Flyby ID: observation_to_id()
if flyby_observation_num is None:
raise ValueError(
Expand Down Expand Up @@ -181,11 +181,11 @@ def errorHandlingConvertObservationNumberToFlybyID(flyby_observation_num=None):
)


def errorHandlingDisplayAllImages(image_directory=None,
fig_title=None,
cmap=None,
figsize_n=None,
fig_dpi=None):
def _error_handling_display_all_images(image_directory=None,
fig_title=None,
cmap=None,
figsize_n=None,
fig_dpi=None):
# Error Handling for Displaying Images from an Image Directory: display_all_images()
if image_directory == None:
raise ValueError("[image_directory]: image_directory is required")
Expand Down Expand Up @@ -222,9 +222,9 @@ def errorHandlingDisplayAllImages(image_directory=None,
)


def errorHandlingREADME(coradr_results_directory=None,
section_to_print=None,
print_to_console=True):
def _error_handling_readme_options(coradr_results_directory=None,
section_to_print=None,
print_to_console=True):
# Error Handling for README options: read_readme
if coradr_results_directory is None:
raise ValueError(
Expand All @@ -246,7 +246,7 @@ def errorHandlingREADME(coradr_results_directory=None,
)


def errorHandlingRetrieveIDSByFeature(feature_name=None):
def _error_handling_id_from_feature_name(feature_name=None):
# Error Handling for retrieving the IDs for a specific feature name: retrieveIDSByFeature()
if feature_name is None:
raise ValueError("[feature_name]: feature_name is required")
Expand All @@ -257,7 +257,7 @@ def errorHandlingRetrieveIDSByFeature(feature_name=None):
)


def errorHandlingRetrieveIDSByLatitudeLongitude(latitude=None, longitude=None):
def _error_handling_id_from_lat_lon(latitude=None, longitude=None):
# Error Handling for retrieving IDs based on latitude and longitude

if latitude is None:
Expand Down Expand Up @@ -286,10 +286,10 @@ def errorHandlingRetrieveIDSByLatitudeLongitude(latitude=None, longitude=None):
)


def errorHandlingRetrieveIDSByLatitudeLongitudeRange(min_latitude=None,
max_latitude=None,
min_longitude=None,
max_longitude=None):
def _error_handling_id_from_lat_lon_range(min_latitude=None,
max_latitude=None,
min_longitude=None,
max_longitude=None):
# Error Handling for retrieving IDs based on a range of latitude and longitudes
if min_latitude is None:
raise ValueError("[min_latitude]: min_latitude is required")
Expand Down Expand Up @@ -352,12 +352,12 @@ def errorHandlingRetrieveIDSByLatitudeLongitudeRange(min_latitude=None,
"[longitude]: max_longitude must be greater than min_longtiude")


def errorHandlingRetrieveIDSByTime(year=None,
doy=None,
hour=None,
minute=None,
second=None,
millisecond=None):
def _error_handling_id_from_time(year=None,
doy=None,
hour=None,
minute=None,
second=None,
millisecond=None):
# Error handling for retrieving IDs based on a specific time
if year is None:
raise ValueError("[year]: year is required")
Expand Down Expand Up @@ -411,18 +411,18 @@ def errorHandlingRetrieveIDSByTime(year=None,
"[millisecond]: second must be a positive value from 0 to 999")


def errorHandlingRetrieveIDSByTimeRange(start_year=None,
start_doy=None,
start_hour=None,
start_minute=None,
start_second=None,
start_millisecond=None,
end_year=None,
end_doy=None,
end_hour=None,
end_minute=None,
end_second=None,
end_millisecond=None):
def _error_handling_id_from_time_range(start_year=None,
start_doy=None,
start_hour=None,
start_minute=None,
start_second=None,
start_millisecond=None,
end_year=None,
end_doy=None,
end_hour=None,
end_minute=None,
end_second=None,
end_millisecond=None):
# Error handling for retrieving IDs based on a range of times
if start_year is None:
raise ValueError("[start_year]: start_year is required")
Expand All @@ -434,18 +434,18 @@ def errorHandlingRetrieveIDSByTimeRange(start_year=None,
if end_doy is None:
raise ValueError("[end_doy]: end_doy is required")

errorHandlingRetrieveIDSByTime(year=start_year,
doy=start_doy,
hour=start_hour,
minute=start_minute,
second=start_second,
millisecond=start_millisecond)
errorHandlingRetrieveIDSByTime(year=end_year,
doy=end_doy,
hour=end_hour,
minute=end_minute,
second=end_second,
millisecond=end_millisecond)
_error_handling_id_from_time(year=start_year,
doy=start_doy,
hour=start_hour,
minute=start_minute,
second=start_second,
millisecond=start_millisecond)
_error_handling_id_from_time(year=end_year,
doy=end_doy,
hour=end_hour,
minute=end_minute,
second=end_second,
millisecond=end_millisecond)

if start_year > end_year:
raise ValueError(
Expand Down Expand Up @@ -486,14 +486,14 @@ def errorHandlingRetrieveIDSByTimeRange(start_year=None,
)


def errorHandlingSbdrMakeShapeFile(filename=None,
fields=[],
write_files=False,
saronly=0,
usepassive=False,
ind=None,
file_out=None,
lon360=False):
def _error_handling_sbdr_make_shapefile(filename=None,
fields=[],
write_files=False,
saronly=0,
usepassive=False,
ind=None,
file_out=None,
lon360=False):
# Error handling for using SBDR to make a shapefile
if type(filename) != str:
raise ValueError(
Expand Down
6 changes: 3 additions & 3 deletions pydar/extract_flyby_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _retrieve_flyby_data() -> (list, str):

def id_to_observation(flyby_id: str = None) -> str:
# convert Flyby ID to Observation Number to find data files
pydar.errorHandlingConvertFlybyIDToObservationNumber(flyby_id=flyby_id)
pydar._error_handling_convert_id_to_observation_num(flyby_id=flyby_id)

flyby_csv_file = os.path.join(
os.path.dirname(__file__), 'data',
Expand All @@ -71,7 +71,7 @@ def observation_to_id(flyby_observation_num: str = None) -> str:
while len(flyby_observation_num) < 4:
flyby_observation_num = "0" + flyby_observation_num # set all radar take numbers to be four digits long: 229 -> 0229

pydar.errorHandlingConvertObservationNumberToFlybyID(
pydar._error_handling_convert_observation_num_to_id(
flyby_observation_num=flyby_observation_num)

flyby_csv_file = os.path.join(
Expand Down Expand Up @@ -296,7 +296,7 @@ def extract_flyby_images(flyby_observation_num: str = None,
resolution = None # set default resolution to None if selecting the top x resolutions

# Error handling:
pydar.errorHandlingExtractFlybyImages(
pydar._error_handling_extract_flyby_images(
flyby_observation_num=flyby_observation_num,
flyby_id=flyby_id,
segment_num=segment_num,
Expand Down
4 changes: 2 additions & 2 deletions pydar/read_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def read_aareadme(coradr_results_directory: str = None,
section_to_print: str = None,
print_to_console: bool = True) -> None:
# Print AAREADME to console
pydar.errorHandlingREADME(
pydar._error_handling_readme_options(
coradr_results_directory=coradr_results_directory,
section_to_print=section_to_print,
print_to_console=print_to_console)
Expand Down Expand Up @@ -192,7 +192,7 @@ def read_lbl_readme(coradr_results_directory: str = None,
if section_to_print == "DESCRIPTION" or section_to_print == "IMAGE" or section_to_print == "DATA_SET_MAP_PROJECTION":
section_to_print = f"^{section_to_print}" # sets the user's option to include the easy to miss ^

pydar.errorHandlingREADME(
pydar._error_handling_readme_options(
coradr_results_directory=coradr_results_directory,
section_to_print=section_to_print,
print_to_console=print_to_console)
Expand Down
42 changes: 20 additions & 22 deletions pydar/retrieve_ids_by_time_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _retrieve_latlon_with_feature_names_from_csv() -> dict:
def ids_from_feature_name(feature_name: str = None) -> dict:
# Retrieve a dictionary of flyby IDs and associated segment numbers
# Returns a Dictionary of Flyby IDs and a list of their segment numbers
pydar.errorHandlingRetrieveIDSByFeature(feature_name=feature_name)
pydar._error_handling_id_from_feature_name(feature_name=feature_name)

feature_name_csv_dict = _retrieve_latlon_with_feature_names_from_csv()
feature_name = feature_name.title(
Expand Down Expand Up @@ -85,8 +85,8 @@ def ids_from_latlon(latitude: (int, float) = None,
longitude: (int, float) = None) -> dict:
# Retrieve all FLyby Ids at a specific latitude/longitude
# Returns a Dictionary of Flyby IDs and a list of their segment numbers
pydar.errorHandlingRetrieveIDSByLatitudeLongitude(latitude=latitude,
longitude=longitude)
pydar._error_handling_id_from_lat_lon(latitude=latitude,
longitude=longitude)

# Runs range check, but the range is 0 for an exact spot
flyby_ids = ids_from_latlon_range(min_latitude=latitude,
Expand All @@ -103,11 +103,10 @@ def ids_from_latlon_range(min_latitude: (int, float) = None,
max_longitude: (int, float) = None):
# Retrieve all Flyby Ids that cover a specific latitude/longitude or within a range of latitude/longitudes
# Returns a Dictionary of Flyby IDs and a list of their segment numbers
pydar.errorHandlingRetrieveIDSByLatitudeLongitudeRange(
min_latitude=min_latitude,
max_latitude=max_latitude,
min_longitude=min_longitude,
max_longitude=max_longitude)
pydar._error_handling_id_from_lat_lon_range(min_latitude=min_latitude,
max_latitude=max_latitude,
min_longitude=min_longitude,
max_longitude=max_longitude)

swath_csv_file = os.path.join(
os.path.dirname(__file__), 'data',
Expand Down Expand Up @@ -153,12 +152,12 @@ def ids_from_time(year: int = None,
millisecond: int = None) -> dict:
# Retrieve Flyby IDs based on a single Timestamp of YYYY-DOYThh:mm:ss.sss
# Returns a Dictionary of Flyby IDs and a list of their segment numbers
pydar.errorHandlingRetrieveIDSByTime(year=year,
doy=doy,
hour=hour,
minute=minute,
second=second,
millisecond=millisecond)
pydar._error_handling_id_from_time(year=year,
doy=doy,
hour=hour,
minute=minute,
second=second,
millisecond=millisecond)

swath_csv_file = os.path.join(
os.path.dirname(__file__), 'data',
Expand Down Expand Up @@ -199,7 +198,7 @@ def ids_from_time_range(start_year: int = None,
# Retrieve Flyby IDs based on a range of Timestamps YYYY-DOYThh:mm:ss.sss
# Returns a Dictionary of Flyby IDs and a list of their segment numbers

pydar.errorHandlingRetrieveIDSByTimeRange(
pydar._error_handling_id_from_time_range(
start_year=start_year,
start_doy=start_doy,
start_hour=start_hour,
Expand Down Expand Up @@ -323,8 +322,8 @@ def features_from_latlon(latitude: (int, float) = None,
longitude: (int, float) = None) -> list:
# Retrieve all Feature Names that at a specific latitude/longitude
# Returns a list of feature names
pydar.errorHandlingRetrieveIDSByLatitudeLongitude(latitude=latitude,
longitude=longitude)
pydar._error_handling_id_from_lat_lon(latitude=latitude,
longitude=longitude)

# Runs range check, but the range is 0 for an exact spot
feature_names_list = features_from_latlon_range(min_latitude=latitude,
Expand All @@ -341,11 +340,10 @@ def features_from_latlon_range(min_latitude: (int, float) = None,
max_longitude: (int, float) = None) -> list:
# Retrieve all Feature Names that are within a range of latitude/longitude
# Returns a list of feature names
pydar.errorHandlingRetrieveIDSByLatitudeLongitudeRange(
min_latitude=min_latitude,
max_latitude=max_latitude,
min_longitude=min_longitude,
max_longitude=max_longitude)
pydar._error_handling_id_from_lat_lon_range(min_latitude=min_latitude,
max_latitude=max_latitude,
min_longitude=min_longitude,
max_longitude=max_longitude)

feature_name_csv_dict = _retrieve_latlon_with_feature_names_from_csv()
feature_names_list = []
Expand Down
Loading

0 comments on commit a2639ad

Please sign in to comment.