Skip to content

Commit

Permalink
#197 save config_gdf as crs 4326 + zenodo issue
Browse files Browse the repository at this point in the history
  • Loading branch information
2320sharon committed Oct 27, 2023
1 parent ceb379a commit c60349a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/coastseg/extract_shorelines_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self, extracted_shoreline_traitlet):
options=[],
layout=ipywidgets.Layout(padding="0px", margin="0px"),
)
self.ROI_list_widget = ipywidgets.dropdown(
self.ROI_list_widget = ipywidgets.Dropdown(
description="Available ROIs",
options=[],
layout=ipywidgets.Layout(padding="0px", margin="0px"),
Expand Down
27 changes: 16 additions & 11 deletions src/coastseg/zoo_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ def get_files_to_download(
filenames = [filenames]
url_dict = {}
for filename in filenames:
response = next((f for f in available_files if f["filename"] == filename), None)
response = next((f for f in available_files if f["key"] == filename), None)
if response is None:
raise ValueError(f"Cannot find {filename} at {model_id}")
link = response["links"]["download"]
link = response["links"]["self"]
file_path = os.path.join(model_path, filename)
url_dict[file_path] = link
return url_dict
Expand Down Expand Up @@ -867,8 +867,15 @@ def postprocess_data(
# Copy over the config_gdf.geojson file
config_gdf_path = os.path.join(roi_directory, "config_gdf.geojson")
if os.path.exists(config_gdf_path):
shutil.copy(
config_gdf_path, os.path.join(session_path, "config_gdf.geojson")
# Read in the GeoJSON file using geopandas
gdf = gpd.read_file(config_gdf_path)

# Project the GeoDataFrame to EPSG:4326
gdf_4326 = gdf.to_crs("EPSG:4326")

# Save the projected GeoDataFrame to a new GeoJSON file
gdf_4326.to_file(
os.path.join(session_path, "config_gdf.geojson"), driver="GeoJSON"
)
model_settings_path = os.path.join(session_path, "model_settings.json")
file_utilities.write_to_json(model_settings_path, preprocessed_data)
Expand Down Expand Up @@ -1311,7 +1318,7 @@ def download_best(
download_dict = {}
# download best_model.txt and read the name of the best model
best_model_json = next(
(f for f in available_files if f["filename"] == "BEST_MODEL.txt"), None
(f for f in available_files if f["key"] == "BEST_MODEL.txt"), None
)
if best_model_json is None:
raise ValueError(f"Cannot find BEST_MODEL.txt in {model_id}")
Expand All @@ -1321,7 +1328,7 @@ def download_best(
# if best BEST_MODEL.txt file not exist then download it
if not os.path.isfile(BEST_MODEL_txt_path):
common.download_url(
best_model_json["links"]["download"],
best_model_json["links"]["self"],
BEST_MODEL_txt_path,
"Downloading best_model.txt",
)
Expand Down Expand Up @@ -1375,10 +1382,8 @@ def download_ensemble(
"""
download_dict = {}
# get json and models
all_models_reponses = [
f for f in available_files if f["filename"].endswith(".h5")
]
all_model_names = [f["filename"] for f in all_models_reponses]
all_models_reponses = [f for f in available_files if f["key"].endswith(".h5")]
all_model_names = [f["key"] for f in all_models_reponses]
json_file_names = [
model_name.replace("_fullmodel.h5", ".json")
for model_name in all_model_names
Expand Down Expand Up @@ -1406,7 +1411,7 @@ def download_ensemble(
logger.info(f"all_json_reponses : {all_json_reponses }")
for response in all_models_reponses + all_json_reponses:
# get the link of the best model
link = response["links"]["download"]
link = response["links"]["self"]
filename = response["key"]
filepath = os.path.join(model_path, filename)
download_dict[filepath] = link
Expand Down

0 comments on commit c60349a

Please sign in to comment.