![]() ![]() To run the script from the command line, type:įile "topo_profiler.py", line 20 %matplotlib inline Open a new Bash window and navigate (using cd, ls and pwd) to the directory that contains your topo_profiler.py file. These are line numbers from the Jupyter notebook and are also commented out. You should also see some lines that look like this: # In. ![]() These are comments and the Python interpreter will not read them. If you exported the file through the Jupyter notebook menu, any Markdown (text) cells should be prefixed with a #. Most code-friendly text editors will color the text in the file according to the language they are written in! Then open the file topo_profiler.py in your chosen text editor. Call your file topo_profiler.py and make sure that the file is in the same directory that contains the folder data where the file topo.asc is. py file using whichever method is easier. ![]() Go ahead and convert your Jupyter notebook into a. Copy the script and paste it into a simple text file (using a text editor like TextWrangler or Notepad++) and save the file with a.We can convert this code into a command-line Python script in two different ways: You should copy the code from the Jupyter notebook you were working in before to a new notebook to make sure nothing sneaks into the script: Let’s look back at the script we wrote earlier that plots the West-to-East topographic profiles across our data. We will first run this script locally (in your own computer) before moving it to, the CSDMS HPCC, and running it on a remote server with the commands you learned during the Bash lessons. However, you should quickly move your prototype code into stand-alone scripts that are platform independent and better suited for version control.īefore we dive further into Python, we are going to convert the scripts we wrote in the first lesson into stand-alone Python scripts that can run from the command line. The Jupyter notebooks are valuable in the early stages of your code development workflow, where you gradually build your program by tinkering with the code and exploring the data. py that are run from the command line or within an IDE (Integrated Development Environment) such as Spyder. Stand-alone Python programs are text files with the extension. The Jupyter notebooks, however, can only run inside their specific graphical environment. ![]() We started out using the Jupyter (iPython) notebooks in these lessons because they are a friendly environment to try out individual commands and write short scripts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |