Skip to content

Commit

Permalink
Merge pull request #2 from unaschneck/pep8
Browse files Browse the repository at this point in the history
PEP 8 Deprecation Warnings
  • Loading branch information
unaschneck authored Nov 26, 2024
2 parents a70ad9f + a43f7ec commit a154581
Show file tree
Hide file tree
Showing 23 changed files with 1,128 additions and 921 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/web_scrap_dynamic_csv_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Web Scrap for New Changes - coradr_jpl_options.csv
working-directory: pydar
run: |
python updateCsvCORADARJPLOptions.py
python updateCsvCORADRJPLOptions.py
- name: Web Scrap for New Changes - feature_name_details.csv
working-directory: pydar
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
exclude: .*\.(TAB|csv)$

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-toml
- id: check-yaml
Expand Down
150 changes: 79 additions & 71 deletions README.md

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions add_new_features.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
## Developer Note: Update Pydar's backend when new features are updated
## New officially named features: https://planetarynames.wr.usgs.gov/#nomenclature-news

# Standard Library Imports
import os

# Related Third Party Imports
import pandas as pd

# Internal Local Imports
import pydar

if __name__ == "__main__":
os.system('python pydar/updateCsvCORADARJPLOptions.py')
os.system('python pydar/updateCsvCORADRJPLOptions.py')
os.system('python pydar/updateCsvSwathCoverage.py')
os.system('python pydar/updateCsvFeatureNameDetails.py')

Expand All @@ -18,8 +24,10 @@
features_in_csv = list(features_df["Feature Name"])

# list of all features that exist (with both latitude/longitude values)
retrieved_features = pydar.retrieveFeaturesFromLatitudeLongitudeRange(
min_latitude=-90, max_latitude=90, min_longitude=0, max_longitude=360)
retrieved_features = pydar.features_from_latlon_range(min_latitude=-90,
max_latitude=90,
min_longitude=0,
max_longitude=360)

# check if all features in CSV have both latitude/longitude values
if not features_in_csv == retrieved_features:
Expand Down
118 changes: 57 additions & 61 deletions example_pydar_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,89 +4,85 @@
# VERSION 1:
## Get swatch coverage based on latitude/longitude, Time, or Feature
feature_name = "Ontario Lacus"
flyby_ids_name = pydar.retrieveIDSByFeatureName(feature_name=feature_name)
print("Flyby IDS based on Feature Name '{0}' = {1}".format(
feature_name.title(), flyby_ids_name))
flyby_ids_name = pydar.ids_from_feature_name(feature_name=feature_name)
print(
f"Flyby IDS based on Feature Name '{feature_name.title()}' = {flyby_ids_name}"
)

flyby_ids_with_segments = pydar.retrieveIDSByLatitudeLongitude(
latitude=-80, longitude=170)
print("\nFlyby IDS based on Latitude/Longitude = {0}".format(
flyby_ids_with_segments))
flyby_ids_with_segments = pydar.ids_from_latlon(latitude=-80,
longitude=170)
print(
f"\nFlyby IDS based on Latitude/Longitude = {flyby_ids_with_segments}")

flyby_ids_range = pydar.retrieveIDSByLatitudeLongitudeRange(
min_latitude=-82,
max_latitude=-72,
min_longitude=183,
max_longitude=185)
print("\nFlyby IDS based on Latitude/Longitude Range = {0}".format(
flyby_ids_range))
flyby_ids_range = pydar.ids_from_latlon_range(min_latitude=-82,
max_latitude=-72,
min_longitude=183,
max_longitude=185)
print(f"\nFlyby IDS based on Latitude/Longitude Range = {flyby_ids_range}")

feature_names_list = pydar.retrieveFeaturesFromLatitudeLongitude(
latitude=-72, longitude=183)
feature_names_list = pydar.features_from_latlon(latitude=-72,
longitude=183)
print(
"\nFeature Names Found at -72 latitude and 183 longitude = {0}".format(
feature_names_list))
f"\nFeature Names Found at -72 latitude and 183 longitude = {feature_names_list}"
)

feature_names_list = pydar.retrieveFeaturesFromLatitudeLongitudeRange(
min_latitude=-82,
max_latitude=-72,
min_longitude=183,
max_longitude=190)
print("\nFeature Names Found in Latitude/Longitude Range = {0}".format(
feature_names_list))
feature_names_list = pydar.features_from_latlon_range(min_latitude=-82,
max_latitude=-72,
min_longitude=183,
max_longitude=190)
print(
f"\nFeature Names Found in Latitude/Longitude Range = {feature_names_list}"
)

flyby_ids_time = pydar.retrieveIDSByTime(year=2005, doy=301)
print("\nFlyby IDS based on a specific timestamp = {0}".format(
flyby_ids_time))
flyby_ids_time = pydar.ids_from_time(year=2005, doy=301)
print(f"\nFlyby IDS based on a specific timestamp = {flyby_ids_time}")

flyby_ids_time_range = pydar.retrieveIDSByTimeRange(start_year=2004,
start_doy=299,
start_hour=2,
start_minute=15,
start_second=23,
start_millisecond=987,
end_year=2005,
end_doy=301,
end_hour=2,
end_minute=15,
end_second=23,
end_millisecond=987)
print("\nFlyby IDS based on a range of timestamps = {0}".format(
flyby_ids_time_range))
flyby_ids_time_range = pydar.ids_from_time_range(start_year=2004,
start_doy=299,
start_hour=2,
start_minute=15,
start_second=23,
start_millisecond=987,
end_year=2005,
end_doy=301,
end_hour=2,
end_minute=15,
end_second=23,
end_millisecond=987)
print(
f"\nFlyby IDS based on a range of timestamps = {flyby_ids_time_range}")

# Convert Flby Id into an Observation Number
flyby_id_value = "T65"
observation_num = pydar.convertFlybyIDToObservationNumber(
flyby_id=flyby_id_value)
print("\nFlyby ID '{0}' is observation number = {1}".format(
flyby_id_value, observation_num))
observation_num = pydar.id_to_observation(flyby_id=flyby_id_value)
print(
f"\nFlyby ID '{flyby_id_value}' is observation number = {observation_num}"
)

observation_num = "211"
flyby_id = pydar.convertObservationNumberToFlybyID(
flyby_observation_num=observation_num)
print("\nObservation Number '{0}' is flyby id = {1}".format(
observation_num, flyby_id))
flyby_id = pydar.observation_to_id(flyby_observation_num=observation_num)
print(f"\nObservation Number '{observation_num}' is flyby id = {flyby_id}")

# Extract Flyby Data Files to results/ directory
pydar.extractFlybyDataImages(flyby_id="T65",
flyby_observation_num=None,
resolution='D',
segment_num="S01")
pydar.extract_flyby_images(flyby_id="T65",
flyby_observation_num=None,
resolution='D',
segment_num="S01")

# Display all Images in pydar_results/ directory
pydar.displayImages(image_directory="pydar_results/CORADR_0211_V03_S01")
pydar.display_all_images("pydar_results/CORADR_0211_V03_S01")

# Read AAREADME to console
pydar.returnAAREADMEOptions()
pydar.readAAREADME(
pydar.aareadme_options()
pydar.read_aareadme(
coradr_results_directory="pydar_results/CORADR_0211_V03_S01",
section_to_print="INSTRUMENT_name")

# Read .LBL to console
pydar.returnLBLOptions()
pydar.readLBLREADME(
coradr_results_directory="pydar_results/CORADR_0211_V03_S01/",
section_to_print="LOOK_DIrecTION")
#pydar.lbl_options()
#pydar.read_lbl_readme(
# coradr_results_directory="pydar_results/CORADR_0211_V03_S01/",
# section_to_print="LOOK_DIrecTION")

# VERSION 2: (Upcoming)
#pydar.extractMetadata()
Expand Down
78 changes: 40 additions & 38 deletions pydar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,51 @@
from .pydar_testing import testing
# display_image.py function calls
from .display_image import display_all_images

# error_handling.py function calls for testing
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 extractFlybyDataImages
from .extract_flyby_parameters import getFlybyData
from .extract_flyby_parameters import convertFlybyIDToObservationNumber
from .extract_flyby_parameters import convertObservationNumberToFlybyID
from .extract_flyby_parameters import _retrieve_flyby_data
from .extract_flyby_parameters import _return_segment_options
from .extract_flyby_parameters import extract_flyby_images
from .extract_flyby_parameters import id_to_observation
from .extract_flyby_parameters import observation_to_id

# extract_flyby_parameters.py data
from .extract_flyby_parameters import resolution_types
from .extract_flyby_parameters import datafile_types_columns

# display_image.py function calls
from .display_image import displayImages

# retrieve_supplementary_backplanes.py function calls
from .retrieve_supplementary_backplanes import extractMetadata
from .extract_flyby_parameters import RESOLUTION_TYPES
from .extract_flyby_parameters import DATAFILE_TYPES

# read_readme.py function calls
from .read_readme import returnAAREADMEOptions
from .read_readme import readAAREADME
from .read_readme import returnLBLOptions
from .read_readme import readLBLREADME
from .read_readme import aareadme_options
from .read_readme import read_aareadme
from .read_readme import lbl_options
from .read_readme import read_lbl_readme

# retrieve_ids_by_time_position.py function calls
from .retrieve_ids_by_time_position import retrieveIDSByFeatureName
from .retrieve_ids_by_time_position import retrieveIDSByLatitudeLongitude
from .retrieve_ids_by_time_position import retrieveIDSByLatitudeLongitudeRange
from .retrieve_ids_by_time_position import retrieveIDSByTime
from .retrieve_ids_by_time_position import retrieveIDSByTimeRange
from .retrieve_ids_by_time_position import retrieveFeaturesFromLatitudeLongitude
from .retrieve_ids_by_time_position import retrieveFeaturesFromLatitudeLongitudeRange
from .retrieve_ids_by_time_position import ids_from_feature_name
from .retrieve_ids_by_time_position import ids_from_latlon
from .retrieve_ids_by_time_position import ids_from_latlon_range
from .retrieve_ids_by_time_position import ids_from_time
from .retrieve_ids_by_time_position import ids_from_time_range
from .retrieve_ids_by_time_position import features_from_latlon
from .retrieve_ids_by_time_position import features_from_latlon_range

## 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
#from .sbdr_make_shapefile import sbdrMakeShapeFile
#from .sbdr_make_shapefile import field_options

# error_handling.py function calls for testing
from .error_handling import errorHandlingExtractFlybyDataImages
from .error_handling import errorHandlingConvertFlybyIDToObservationNumber
from .error_handling import errorHandlingConvertObservationNumberToFlybyID
from .error_handling import errorHandlingDisplayImages
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
# retrieve_supplementary_backplanes.py function calls
#from .retrieve_supplementary_backplanes import extractMetadata
43 changes: 29 additions & 14 deletions pydar/display_image.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
## Display PDR images in Matplotlib
# #
# #
# #
# display_image.py displays the PDR images in CORADR files #
# for flyby observations and IDs #
# #
# This includes the functions for: #
# - display_all_images: displays all the images #
# from the flyby results in Matplotlib #
# #
# #
# #
# #
# #

# Built in Python functions
# Standard Library Imports
import logging
import os

# External Python libraries (installed via pip install)
# Related Third Party Imports
import rasterio
import matplotlib.pyplot as plt

# Internal Pydar reference to access functions, global variables, and error handling
# Internal Local Imports
import pydar

########################################################################

## Logging set up for .INFO
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand All @@ -19,19 +34,19 @@


#### DISPLAY ALL PDR IMAGES IN A DIRECTORY #############################
def displayImages(image_directory=None,
fig_title=None,
cmap="gray",
figsize_n=6,
fig_dpi=120):
def display_all_images(image_directory: str = None,
fig_title: str = None,
cmap: str = "gray",
figsize_n: int = 6,
fig_dpi: int = 120) -> None:
# Display all images in the image directory specified
# plt.show() all imgs in a given directory

pydar.errorHandlingDisplayImages(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
Loading

0 comments on commit a154581

Please sign in to comment.