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

Fix indentation #285

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ MusicBox: A MUSICA model for boxes and columns.
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.14008358.svg)](https://doi.org/10.5281/zenodo.14008358)


Copyright (C) 2020 National Center for Atmospheric Research
Copyright (C) 2020 National Science Foundation - National Center for Atmospheric Research

# Installation
```
Expand Down
120 changes: 60 additions & 60 deletions src/acom_music_box/connections/electron_configuration_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,73 +10,41 @@ class ElectronConfiguraitonReader:
""" Reads configuration information from the electron applicant to create a box model simulation.
"""

def __init__(self):
self.box_model_options = None
self.species_list = None
self.reaction_list = None
self.initial_conditions = None
self.evolving_conditions = None
def __init__(self):
self.box_model_options = None
self.species_list = None
self.reaction_list = None
self.initial_conditions = None
self.evolving_conditions = None

def read_electron_configuration(self):
with open(self.electron_configuration_file_path, 'r') as file:
for line in file:
element, configuration = line.strip().split(' ')
self.electron_configuration[element] = configuration
def read_electron_configuration(self):
with open(self.electron_configuration_file_path, 'r') as file:
for line in file:
element, configuration = line.strip().split(' ')
self.electron_configuration[element] = configuration

def get_electron_configuration(self, element):
return self.electron_configuration[element]
def get_electron_configuration(self, element):
return self.electron_configuration[element]

def readFromUIJson(self, path_to_json):
"""
Reads and parses a JSON file from the MusicBox Interactive UI to set up the box model simulation.
def readFromUIJson(self, path_to_json):
"""
Reads and parses a JSON file from the MusicBox Interactive UI to set up the box model simulation.

This function takes the path to a JSON file, reads the file, and parses the JSON
to set up the box model simulation.
This function takes the path to a JSON file, reads the file, and parses the JSON
to set up the box model simulation.

Args:
path_to_json (str): The path to the JSON file from the UI.
Args:
path_to_json (str): The path to the JSON file from the UI.

Returns:
None
Returns:
None

Raises:
ValueError: If the JSON file cannot be read or parsed.
"""
Raises:
ValueError: If the JSON file cannot be read or parsed.
"""

with open(path_to_json, 'r') as json_file:
data = json.load(json_file)

# Set box model options
self.box_model_options = BoxModelOptions.from_UI_JSON(data)

# Set species list
self.species_list = SpeciesList.from_UI_JSON(data)

# Set reaction list
self.reaction_list = ReactionList.from_UI_JSON(
data, self.species_list)

# Set initial conditions
self.initial_conditions = Conditions.from_UI_JSON(
data, self.species_list, self.reaction_list)

# Set evolving conditions
self.evolving_conditions = EvolvingConditions.from_UI_JSON(
data, self.species_list, self.reaction_list)

def readFromUIJsonString(self, data):
"""
Reads and parses a JSON string from the MusicBox Interactive UI to set up the box model simulation.

Args:
json_string (str): The JSON string from the UI.

Returns:
None

Raises:
ValueError: If the JSON string cannot be parsed.
"""
with open(path_to_json, 'r') as json_file:
data = json.load(json_file)

# Set box model options
self.box_model_options = BoxModelOptions.from_UI_JSON(data)
Expand All @@ -85,7 +53,8 @@ def readFromUIJsonString(self, data):
self.species_list = SpeciesList.from_UI_JSON(data)

# Set reaction list
self.reaction_list = ReactionList.from_UI_JSON(data, self.species_list)
self.reaction_list = ReactionList.from_UI_JSON(
data, self.species_list)

# Set initial conditions
self.initial_conditions = Conditions.from_UI_JSON(
Expand All @@ -94,3 +63,34 @@ def readFromUIJsonString(self, data):
# Set evolving conditions
self.evolving_conditions = EvolvingConditions.from_UI_JSON(
data, self.species_list, self.reaction_list)

def readFromUIJsonString(self, data):
"""
Reads and parses a JSON string from the MusicBox Interactive UI to set up the box model simulation.

Args:
json_string (str): The JSON string from the UI.

Returns:
None

Raises:
ValueError: If the JSON string cannot be parsed.
"""

# Set box model options
self.box_model_options = BoxModelOptions.from_UI_JSON(data)

# Set species list
self.species_list = SpeciesList.from_UI_JSON(data)

# Set reaction list
self.reaction_list = ReactionList.from_UI_JSON(data, self.species_list)

# Set initial conditions
self.initial_conditions = Conditions.from_UI_JSON(
data, self.species_list, self.reaction_list)

# Set evolving conditions
self.evolving_conditions = EvolvingConditions.from_UI_JSON(
data, self.species_list, self.reaction_list)
2 changes: 1 addition & 1 deletion src/acom_music_box/tools/waccmToMusicBox.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and convert to initial conditions for MusicBox (case TS1).
#
# Author: Carl Drews
# Copyright 2024 by Atomospheric Chemistry Observations & Modeling (UCAR/ACOM)
# Copyright 2024 by Atmospheric Chemistry Observations & Modeling (UCAR/ACOM)

# import os
import argparse
Expand Down