Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintence Request: Don't read settings from shoreline and transect settings files #208

Open
3 tasks
2320sharon opened this issue Dec 15, 2023 · 3 comments
Open
3 tasks
Assignees
Labels
V2 for version 2 of coastseg

Comments

@2320sharon
Copy link
Collaborator

Coastseg should not read settings from the files shoreline_settings.json & transect_settings.json . After testing coastseg with users our team has determined that the best approach is to store all relevant settings in a single file config.json. Saving these settings to different files is an artifact from a time where we wanted to store different settings in different files, however, this makes to more complicated for both developers and users to track settings, so we have decided to abandon this approach.

Tasks

  • modify the load_session_files to not read the shoreline and transect settings from shoreline_settings.json & transect_settings.json

  • don't save the shoreline and transect settings in a separate file

  • remove all code that generates the shoreline and transect settings files

@2320sharon 2320sharon added the V2 for version 2 of coastseg label Dec 15, 2023
@2320sharon 2320sharon self-assigned this Dec 15, 2023
@2320sharon
Copy link
Collaborator Author

  • make tide_correction.py save_transect_settings update the config.json file instead of the transects_settings.json
def save_transect_settings(
    session_path: str,
    reference_elevation: float,
    beach_slope: float,
    filename: str = "transects_settings.json",
) -> None:
    """
    Update and save transect settings with the provided reference elevation and beach slope.

    Parameters:
    -----------
    session_path : str
        Path to the session directory where the transect settings JSON file is located.
    reference_elevation : float
        The reference elevation value to be updated in the transect settings.
    beach_slope : float
        The beach slope value to be updated in the transect settings.
    filename : str, optional
        The name of the JSON file containing the transect settings. Defaults to "transects_settings.json".

    Returns:
    --------
    None

    Notes:
    ------
    The function reads the existing settings file in the session directory (as specified by the
    `filename` parameter), updates the reference elevation and beach slope values, and then
    writes the updated settings back to the same file.

    Raises:
    -------
    FileNotFoundError:
        If the specified settings file does not exist in the given session path.
    """
    transects_settings = file_utilities.read_json_file(
        os.path.join(session_path, filename), raise_error=False
    )
    transects_settings["reference_elevation"] = reference_elevation
    transects_settings["beach_slope"] = beach_slope
    file_utilities.to_file(transects_settings, os.path.join(session_path, filename))

@2320sharon
Copy link
Collaborator Author

After some investigation I've found that the shoreline_settings.json file is being used to store the settings for the extracted shorelines. Its used to store the reference shoreline as a numpy array, the inputs dictionary which contains the details of the ROI the shorelines were extracted from, and the rest of the settings that were used to extract the shorelines.

I suppose its possible to get rid of this file because these details can be created on the fly when the extracted shorelines are loaded onto the map. I'll need to think about this a bit more.

@2320sharon
Copy link
Collaborator Author

I'm going to pause on this idea for now given that with the current design reading from shoreline_settings.json is necessary and re-evaluate this decision after refactoring how extracted shorelines can be loaded and saved

2320sharon added a commit that referenced this issue May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2 for version 2 of coastseg
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant