Skip to content

Commit

Permalink
Fix bug with plotting time axis for fitters.
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-hellerstein committed Mar 26, 2024
1 parent 8427c13 commit 1f181c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
10 changes: 0 additions & 10 deletions examples/Controlling-Glucose-Metabolis-in-Yeast.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1383,16 +1383,6 @@
"**In conclusion,** this was an eye-opening and very interesting class that is unlike anything I've taken before. I sincerely apologize for not being able to attend class in-person during some of the final weeks and for getting HW2 in late; I have had a lot of family issues happening this quarter and I had to fly home for the weekend HW2 was due when I missed your email. It's just been a stressful quarter with 4 classes and starting/trying to perform well in my new lab. I found this class to be very valuable and it has motivated me to take some classes in systems biology and more classes in biomodeling/biostatistics/computational biology. I hope there comes a time when I can apply this to my own research during graduate school, especially now that I've got a great pipeline to design & test simple controls. Thank you so much, Professor Hellerstein, I hope to see you around. Best of luck with your research & other classes!"
]
},
{
"cell_type": "markdown",
"id": "bf9d5e39-4e93-4cfb-ba13-476d0d084b35",
"metadata": {
"id": "3001497a-1a07-47c5-9a0a-c6ad0da88035"
},
"source": [
"P.S. I restarted my kernel on JupyterHub & ran all cells and verified that each one worked before submission per your advice from HW1. Please let me know if there is anything that doesn't work for you."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
14 changes: 7 additions & 7 deletions src/controlSBML/control_sbml.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def __init__(self, model_reference:str,
fitter_method:Optional[str]=OPTION_DCT[cn.O_FITTER_METHOD],
setpoint:Optional[float]=OPTION_DCT[cn.O_SETPOINT],
sign:Optional[int]=OPTION_DCT[cn.O_SIGN],
times:Optional[np.ndarray[float]]=OPTION_DCT[cn.O_TIMES],
times:Optional[np.ndarray[float]]=None,
save_path:Optional[str]=SAVE_PATH,
**kwargs):
"""
Expand Down Expand Up @@ -437,7 +437,7 @@ def _initializeStaircaseOptions(self, initial_value=None, final_value=None, num_

############ PLOTTERS ##############
def plotModel(self,
times:Optional[np.ndarray[float]]=OPTION_DCT[cn.O_TIMES],
times:Optional[np.ndarray[float]]=None,
selections:Optional[List[str]]=OPTION_DCT[cn.O_SELECTIONS],
**kwargs)->ModelResult:
"""
Expand Down Expand Up @@ -473,7 +473,7 @@ def plotStaircaseResponse(self,
initial_value:Optional[float]=OPTION_DCT[cn.O_INITIAL_VALUE],
final_value:Optional[float]=OPTION_DCT[cn.O_FINAL_VALUE],
num_step:Optional[int]=OPTION_DCT[cn.O_NUM_STEP],
times:Optional[np.ndarray]=OPTION_DCT[cn.O_TIMES],
times:Optional[np.ndarray]=None,
**kwargs)->StaircaseResponseResult:
"""
Simulates the staircase response and plots it.
Expand Down Expand Up @@ -514,7 +514,7 @@ def plotTransferFunctionFit(self,
final_value:Optional[float]=None,
num_step:Optional[int]=OPTION_DCT[cn.O_NUM_STEP],
fitter_method:Optional[str]=OPTION_DCT[cn.O_FITTER_METHOD],
times:Optional[np.ndarray]=OPTION_DCT[cn.O_TIMES],
times:Optional[np.ndarray]=None,
**kwargs)->TransferFunctionFitResult:
"""
Simulates the staircase response and plots it. Sets the fitter result.
Expand Down Expand Up @@ -585,7 +585,7 @@ def _plotClosedLoop(self,
setpoint:Optional[float]=OPTION_DCT[cn.O_SETPOINT],
sign:Optional[float]=OPTION_DCT[cn.O_SIGN],
selections:Optional[List[str]]=OPTION_DCT[cn.O_SELECTIONS],
times:Optional[np.ndarray]=OPTION_DCT[cn.O_TIMES],
times:Optional[np.ndarray]=None,
**kwargs):
"""
Plots the closed loop response. Control parameters not explicity specified are None.
Expand Down Expand Up @@ -628,7 +628,7 @@ def plotGridDesign(self,
grid:Grid,
setpoint:Optional[float]=OPTION_DCT[cn.O_SETPOINT],
sign:Optional[float]=OPTION_DCT[cn.O_SIGN],
times:Optional[np.ndarray]=OPTION_DCT[cn.O_TIMES],
times:Optional[np.ndarray]=None,
num_process:Optional[int]=OPTION_DCT[cn.O_NUM_PROCESS],
num_restart:Optional[int]=OPTION_DCT[cn.O_NUM_RESTART],
selections:Optional[List[str]]=OPTION_DCT[cn.O_SELECTIONS],
Expand Down Expand Up @@ -713,7 +713,7 @@ def plotDesign(self,
kF_spec:bool=OPTION_DCT[cn.O_KF_SPEC],
setpoint:Optional[float]=OPTION_DCT[cn.O_SETPOINT],
sign:Optional[float]=OPTION_DCT[cn.O_SIGN],
times:Optional[np.ndarray]=OPTION_DCT[cn.O_TIMES],
times:Optional[np.ndarray]=None,
num_process:Optional[int]=OPTION_DCT[cn.O_NUM_PROCESS],
num_restart:Optional[int]=OPTION_DCT[cn.O_NUM_RESTART],
selections:Optional[List[str]]=OPTION_DCT[cn.O_SELECTIONS],
Expand Down
3 changes: 2 additions & 1 deletion src/controlSBML/siso_transfer_function_fitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def __init__(self, timeseries:Timeseries, num_zero:Optional[int]=0, num_pole:Opt
self.out_std = np.std(self.out_arr)
self.max_out_value = np.max(self.out_arr)
self.dt = np.round(np.mean(np.diff(timeseries.index)))/cn.MS_IN_SEC
self.times = np.array([self.dt*n for n in range(len(timeseries.index))]) # Must be evenly spaced
start_time = timeseries.index[0]/cn.MS_IN_SEC
self.times = start_time + np.array([self.dt*n for n in range(len(timeseries.index))]) # Must be evenly spaced
self.times = np.reshape(self.times, (len(self.times),))
self.length = len(self.times)
self.num_zero:int = num_zero # type: ignore
Expand Down

0 comments on commit 1f181c4

Please sign in to comment.