Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Updated Python
Browse files Browse the repository at this point in the history
Automatically call bin2xr when reading in a parameter file and BIN_OUT exists. Added a readbin boolean argument to turn this off if necessary (default is True)
  • Loading branch information
daminton committed Nov 2, 2021
1 parent 1ef9812 commit 744949f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
from datetime import date
import xarray as xr
import numpy as np
import os

class Simulation:
"""
This is a class that define the basic Swift/Swifter/Swiftest simulation object
"""
def __init__(self, codename="Swiftest", param_file=""):
def __init__(self, codename="Swiftest", param_file="", readbin=True):
self.ds = xr.Dataset()
self.param = {
'! VERSION': f"Swiftest parameter input",
Expand Down Expand Up @@ -55,6 +56,11 @@ def __init__(self, codename="Swiftest", param_file=""):
self.codename = codename
if param_file != "" :
self.read_param(param_file, codename)
if readbin:
if os.path.exists(self.param['BIN_OUT']):
self.bin2xr()
else:
print(f"BIN_OUT file {self.param['BIN_OUT']} not found.")
return


Expand Down

0 comments on commit 744949f

Please sign in to comment.