簡體   English   中英

將 Python 程序中的數據保存到“工作區”中,這樣我就可以 plot 無需再次運行程序

[英]Saving data from Python program into a 'workspace' so I can plot without having to the run the program again

使用 MATLAB,所有數據和變量都被保存到工作區中。 這使得從命令 window 訪問和操作數據以進行簡單繪圖變得非常容易,而無需再次運行主程序。

我知道這可以使用 Spyder 來完成,但是 go 如何保存數據,以便我可以在任何 IDE / 終端中運行更小的輔助繪圖程序。 然后該程序將訪問這些數據,因此每次對繪圖進行小的更改時我都不必運行主程序。

某些文件格式比其他文件格式有什么好處嗎? 即某些文件格式會壓縮數據嗎? 有些允許更快的訪問嗎? 是否有選項可以將數據保存在 Spyder 之外的工作區中?

Most of the data would either be 2D numpy arrays and would be plotted as images, or 1D numpy arrays for line plotting.

您可以為此使用 Google Colab。 它允許您分段 Python 代碼,以便您可以在一個段中運行您的主程序,然后在下一個段中創建繪圖代碼。 運行第一個段后,所有數據都將保存在該點,因此您無需重新運行它。

If you're running this code on your local machine, you can just save the numpy arrays into a numpy file like this: https://numpy.org/doc/1.18/reference/generated/numpy.save.html

然后,當您運行繪圖程序時,您可以從 numpy 文件中讀取。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM